babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334
  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/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending to DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending to SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending to SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending to SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending to SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending to SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /** Defines that alpha blending equation a SUM */
  651. static readonly ALPHA_EQUATION_ADD: number;
  652. /** Defines that alpha blending equation a SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  654. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  656. /** Defines that alpha blending equation a MAX operation */
  657. static readonly ALPHA_EQUATION_MAX: number;
  658. /** Defines that alpha blending equation a MIN operation */
  659. static readonly ALPHA_EQUATION_MIN: number;
  660. /**
  661. * Defines that alpha blending equation a DARKEN operation:
  662. * It takes the min of the src and sums the alpha channels.
  663. */
  664. static readonly ALPHA_EQUATION_DARKEN: number;
  665. /** Defines that the ressource is not delayed*/
  666. static readonly DELAYLOADSTATE_NONE: number;
  667. /** Defines that the ressource was successfully delay loaded */
  668. static readonly DELAYLOADSTATE_LOADED: number;
  669. /** Defines that the ressource is currently delay loading */
  670. static readonly DELAYLOADSTATE_LOADING: number;
  671. /** Defines that the ressource is delayed and has not started loading */
  672. static readonly DELAYLOADSTATE_NOTLOADED: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  674. static readonly NEVER: number;
  675. /** 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 */
  676. static readonly ALWAYS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  678. static readonly LESS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  680. static readonly EQUAL: number;
  681. /** 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 */
  682. static readonly LEQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  684. static readonly GREATER: number;
  685. /** 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 */
  686. static readonly GEQUAL: number;
  687. /** 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 */
  688. static readonly NOTEQUAL: number;
  689. /** Passed to stencilOperation to specify that stencil value must be kept */
  690. static readonly KEEP: number;
  691. /** Passed to stencilOperation to specify that stencil value must be replaced */
  692. static readonly REPLACE: number;
  693. /** Passed to stencilOperation to specify that stencil value must be incremented */
  694. static readonly INCR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be decremented */
  696. static readonly DECR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be inverted */
  698. static readonly INVERT: number;
  699. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  700. static readonly INCR_WRAP: number;
  701. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  702. static readonly DECR_WRAP: number;
  703. /** Texture is not repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  705. /** Texture is repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  707. /** Texture is repeating and mirrored */
  708. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  709. /** ALPHA */
  710. static readonly TEXTUREFORMAT_ALPHA: number;
  711. /** LUMINANCE */
  712. static readonly TEXTUREFORMAT_LUMINANCE: number;
  713. /** LUMINANCE_ALPHA */
  714. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  715. /** RGB */
  716. static readonly TEXTUREFORMAT_RGB: number;
  717. /** RGBA */
  718. static readonly TEXTUREFORMAT_RGBA: number;
  719. /** RED */
  720. static readonly TEXTUREFORMAT_RED: number;
  721. /** RED (2nd reference) */
  722. static readonly TEXTUREFORMAT_R: number;
  723. /** RG */
  724. static readonly TEXTUREFORMAT_RG: number;
  725. /** RED_INTEGER */
  726. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  727. /** RED_INTEGER (2nd reference) */
  728. static readonly TEXTUREFORMAT_R_INTEGER: number;
  729. /** RG_INTEGER */
  730. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  731. /** RGB_INTEGER */
  732. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  733. /** RGBA_INTEGER */
  734. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  735. /** UNSIGNED_BYTE */
  736. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  737. /** UNSIGNED_BYTE (2nd reference) */
  738. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  739. /** FLOAT */
  740. static readonly TEXTURETYPE_FLOAT: number;
  741. /** HALF_FLOAT */
  742. static readonly TEXTURETYPE_HALF_FLOAT: number;
  743. /** BYTE */
  744. static readonly TEXTURETYPE_BYTE: number;
  745. /** SHORT */
  746. static readonly TEXTURETYPE_SHORT: number;
  747. /** UNSIGNED_SHORT */
  748. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  749. /** INT */
  750. static readonly TEXTURETYPE_INT: number;
  751. /** UNSIGNED_INT */
  752. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  753. /** UNSIGNED_SHORT_4_4_4_4 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  755. /** UNSIGNED_SHORT_5_5_5_1 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  757. /** UNSIGNED_SHORT_5_6_5 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  759. /** UNSIGNED_INT_2_10_10_10_REV */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  761. /** UNSIGNED_INT_24_8 */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  763. /** UNSIGNED_INT_10F_11F_11F_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  765. /** UNSIGNED_INT_5_9_9_9_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  767. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  768. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  769. /** nearest is mag = nearest and min = nearest and mip = linear */
  770. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** Trilinear is mag = linear and min = linear and mip = linear */
  774. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  775. /** nearest is mag = nearest and min = nearest and mip = linear */
  776. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  777. /** Bilinear is mag = linear and min = linear and mip = nearest */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  781. /** mag = nearest and min = nearest and mip = nearest */
  782. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = nearest */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = linear */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  787. /** mag = nearest and min = linear and mip = none */
  788. static readonly TEXTURE_NEAREST_LINEAR: number;
  789. /** mag = nearest and min = nearest and mip = none */
  790. static readonly TEXTURE_NEAREST_NEAREST: number;
  791. /** mag = linear and min = nearest and mip = nearest */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  793. /** mag = linear and min = nearest and mip = linear */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  795. /** mag = linear and min = linear and mip = none */
  796. static readonly TEXTURE_LINEAR_LINEAR: number;
  797. /** mag = linear and min = nearest and mip = none */
  798. static readonly TEXTURE_LINEAR_NEAREST: number;
  799. /** Explicit coordinates mode */
  800. static readonly TEXTURE_EXPLICIT_MODE: number;
  801. /** Spherical coordinates mode */
  802. static readonly TEXTURE_SPHERICAL_MODE: number;
  803. /** Planar coordinates mode */
  804. static readonly TEXTURE_PLANAR_MODE: number;
  805. /** Cubic coordinates mode */
  806. static readonly TEXTURE_CUBIC_MODE: number;
  807. /** Projection coordinates mode */
  808. static readonly TEXTURE_PROJECTION_MODE: number;
  809. /** Skybox coordinates mode */
  810. static readonly TEXTURE_SKYBOX_MODE: number;
  811. /** Inverse Cubic coordinates mode */
  812. static readonly TEXTURE_INVCUBIC_MODE: number;
  813. /** Equirectangular coordinates mode */
  814. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed Mirrored coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  819. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  820. static readonly SCALEMODE_FLOOR: number;
  821. /** Defines that texture rescaling will look for the nearest power of 2 size */
  822. static readonly SCALEMODE_NEAREST: number;
  823. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  824. static readonly SCALEMODE_CEILING: number;
  825. /**
  826. * The dirty texture flag value
  827. */
  828. static readonly MATERIAL_TextureDirtyFlag: number;
  829. /**
  830. * The dirty light flag value
  831. */
  832. static readonly MATERIAL_LightDirtyFlag: number;
  833. /**
  834. * The dirty fresnel flag value
  835. */
  836. static readonly MATERIAL_FresnelDirtyFlag: number;
  837. /**
  838. * The dirty attribute flag value
  839. */
  840. static readonly MATERIAL_AttributesDirtyFlag: number;
  841. /**
  842. * The dirty misc flag value
  843. */
  844. static readonly MATERIAL_MiscDirtyFlag: number;
  845. /**
  846. * The all dirty flag value
  847. */
  848. static readonly MATERIAL_AllDirtyFlag: number;
  849. /**
  850. * Returns the triangle fill mode
  851. */
  852. static readonly MATERIAL_TriangleFillMode: number;
  853. /**
  854. * Returns the wireframe mode
  855. */
  856. static readonly MATERIAL_WireFrameFillMode: number;
  857. /**
  858. * Returns the point fill mode
  859. */
  860. static readonly MATERIAL_PointFillMode: number;
  861. /**
  862. * Returns the point list draw mode
  863. */
  864. static readonly MATERIAL_PointListDrawMode: number;
  865. /**
  866. * Returns the line list draw mode
  867. */
  868. static readonly MATERIAL_LineListDrawMode: number;
  869. /**
  870. * Returns the line loop draw mode
  871. */
  872. static readonly MATERIAL_LineLoopDrawMode: number;
  873. /**
  874. * Returns the line strip draw mode
  875. */
  876. static readonly MATERIAL_LineStripDrawMode: number;
  877. /**
  878. * Returns the triangle strip draw mode
  879. */
  880. static readonly MATERIAL_TriangleStripDrawMode: number;
  881. /**
  882. * Returns the triangle fan draw mode
  883. */
  884. static readonly MATERIAL_TriangleFanDrawMode: number;
  885. /**
  886. * Stores the clock-wise side orientation
  887. */
  888. static readonly MATERIAL_ClockWiseSideOrientation: number;
  889. /**
  890. * Stores the counter clock-wise side orientation
  891. */
  892. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  893. /**
  894. * Nothing
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_NothingTrigger: number;
  898. /**
  899. * On pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPickTrigger: number;
  903. /**
  904. * On left pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnLeftPickTrigger: number;
  908. /**
  909. * On right pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnRightPickTrigger: number;
  913. /**
  914. * On center pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnCenterPickTrigger: number;
  918. /**
  919. * On pick down
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnPickDownTrigger: number;
  923. /**
  924. * On double pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnDoublePickTrigger: number;
  928. /**
  929. * On pick up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnPickUpTrigger: number;
  933. /**
  934. * On pick out.
  935. * This trigger will only be raised if you also declared a OnPickDown
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnPickOutTrigger: number;
  939. /**
  940. * On long press
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnLongPressTrigger: number;
  944. /**
  945. * On pointer over
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOverTrigger: number;
  949. /**
  950. * On pointer out
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOutTrigger: number;
  954. /**
  955. * On every frame
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnEveryFrameTrigger: number;
  959. /**
  960. * On intersection enter
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionEnterTrigger: number;
  964. /**
  965. * On intersection exit
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionExitTrigger: number;
  969. /**
  970. * On key down
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyDownTrigger: number;
  974. /**
  975. * On key up
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyUpTrigger: number;
  979. /**
  980. * Billboard mode will only apply to Y axis
  981. */
  982. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  983. /**
  984. * Billboard mode will apply to all axes
  985. */
  986. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  987. /**
  988. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  989. */
  990. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  991. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  992. * Test order :
  993. * Is the bounding sphere outside the frustum ?
  994. * If not, are the bounding box vertices outside the frustum ?
  995. * It not, then the cullable object is in the frustum.
  996. */
  997. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  998. /** Culling strategy : Bounding Sphere Only.
  999. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1000. * It's also less accurate than the standard because some not visible objects can still be selected.
  1001. * Test : is the bounding sphere outside the frustum ?
  1002. * If not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1005. /** Culling strategy : Optimistic Inclusion.
  1006. * This in an inclusion test first, then the standard exclusion test.
  1007. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1008. * 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.
  1009. * Anyway, it's as accurate as the standard strategy.
  1010. * Test :
  1011. * Is the cullable object bounding sphere center in the frustum ?
  1012. * If not, apply the default culling strategy.
  1013. */
  1014. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1015. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1016. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1017. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1018. * 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.
  1019. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1020. * Test :
  1021. * Is the cullable object bounding sphere center in the frustum ?
  1022. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1023. */
  1024. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1025. /**
  1026. * No logging while loading
  1027. */
  1028. static readonly SCENELOADER_NO_LOGGING: number;
  1029. /**
  1030. * Minimal logging while loading
  1031. */
  1032. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1033. /**
  1034. * Summary logging while loading
  1035. */
  1036. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1037. /**
  1038. * Detailled logging while loading
  1039. */
  1040. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1041. }
  1042. }
  1043. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1044. import { Nullable } from "babylonjs/types";
  1045. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1046. /**
  1047. * This represents the required contract to create a new type of texture loader.
  1048. */
  1049. export interface IInternalTextureLoader {
  1050. /**
  1051. * Defines wether the loader supports cascade loading the different faces.
  1052. */
  1053. supportCascades: boolean;
  1054. /**
  1055. * This returns if the loader support the current file information.
  1056. * @param extension defines the file extension of the file being loaded
  1057. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1058. * @param fallback defines the fallback internal texture if any
  1059. * @param isBase64 defines whether the texture is encoded as a base64
  1060. * @param isBuffer defines whether the texture data are stored as a buffer
  1061. * @returns true if the loader can load the specified file
  1062. */
  1063. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1064. /**
  1065. * Transform the url before loading if required.
  1066. * @param rootUrl the url of the texture
  1067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1068. * @returns the transformed texture
  1069. */
  1070. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1071. /**
  1072. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the fallback texture
  1076. */
  1077. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1078. /**
  1079. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param createPolynomials will be true if polynomials have been requested
  1083. * @param onLoad defines the callback to trigger once the texture is ready
  1084. * @param onError defines the callback to trigger in case of error
  1085. */
  1086. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1087. /**
  1088. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1089. * @param data contains the texture data
  1090. * @param texture defines the BabylonJS internal texture
  1091. * @param callback defines the method to call once ready to upload
  1092. */
  1093. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1094. }
  1095. }
  1096. declare module "babylonjs/Engines/IPipelineContext" {
  1097. /**
  1098. * Class used to store and describe the pipeline context associated with an effect
  1099. */
  1100. export interface IPipelineContext {
  1101. /**
  1102. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1103. */
  1104. isAsync: boolean;
  1105. /**
  1106. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1107. */
  1108. isReady: boolean;
  1109. /** @hidden */
  1110. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1111. }
  1112. }
  1113. declare module "babylonjs/Meshes/dataBuffer" {
  1114. /**
  1115. * Class used to store gfx data (like WebGLBuffer)
  1116. */
  1117. export class DataBuffer {
  1118. /**
  1119. * Gets or sets the number of objects referencing this buffer
  1120. */
  1121. references: number;
  1122. /** Gets or sets the size of the underlying buffer */
  1123. capacity: number;
  1124. /**
  1125. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1126. */
  1127. is32Bits: boolean;
  1128. /**
  1129. * Gets the underlying buffer
  1130. */
  1131. readonly underlyingResource: any;
  1132. }
  1133. }
  1134. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1135. /** @hidden */
  1136. export interface IShaderProcessor {
  1137. attributeProcessor?: (attribute: string) => string;
  1138. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1139. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1140. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1141. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1142. lineProcessor?: (line: string, isFragment: boolean) => string;
  1143. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1144. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. }
  1146. }
  1147. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1148. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1149. /** @hidden */
  1150. export interface ProcessingOptions {
  1151. defines: string[];
  1152. indexParameters: any;
  1153. isFragment: boolean;
  1154. shouldUseHighPrecisionShader: boolean;
  1155. supportsUniformBuffers: boolean;
  1156. shadersRepository: string;
  1157. includesShadersStore: {
  1158. [key: string]: string;
  1159. };
  1160. processor?: IShaderProcessor;
  1161. version: string;
  1162. platformName: string;
  1163. lookForClosingBracketForUniformBuffer?: boolean;
  1164. }
  1165. }
  1166. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1167. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1168. /** @hidden */
  1169. export class ShaderCodeNode {
  1170. line: string;
  1171. children: ShaderCodeNode[];
  1172. additionalDefineKey?: string;
  1173. additionalDefineValue?: string;
  1174. isValid(preprocessors: {
  1175. [key: string]: string;
  1176. }): boolean;
  1177. process(preprocessors: {
  1178. [key: string]: string;
  1179. }, options: ProcessingOptions): string;
  1180. }
  1181. }
  1182. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1183. /** @hidden */
  1184. export class ShaderCodeCursor {
  1185. private _lines;
  1186. lineIndex: number;
  1187. readonly currentLine: string;
  1188. readonly canRead: boolean;
  1189. lines: string[];
  1190. }
  1191. }
  1192. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1193. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1194. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1195. /** @hidden */
  1196. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1197. process(preprocessors: {
  1198. [key: string]: string;
  1199. }, options: ProcessingOptions): string;
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1203. /** @hidden */
  1204. export class ShaderDefineExpression {
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1213. /** @hidden */
  1214. export class ShaderCodeTestNode extends ShaderCodeNode {
  1215. testExpression: ShaderDefineExpression;
  1216. isValid(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1225. define: string;
  1226. not: boolean;
  1227. constructor(define: string, not?: boolean);
  1228. isTrue(preprocessors: {
  1229. [key: string]: string;
  1230. }): boolean;
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1237. leftOperand: ShaderDefineExpression;
  1238. rightOperand: ShaderDefineExpression;
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1245. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1246. /** @hidden */
  1247. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1248. leftOperand: ShaderDefineExpression;
  1249. rightOperand: ShaderDefineExpression;
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1259. define: string;
  1260. operand: string;
  1261. testValue: string;
  1262. constructor(define: string, operand: string, testValue: string);
  1263. isTrue(preprocessors: {
  1264. [key: string]: string;
  1265. }): boolean;
  1266. }
  1267. }
  1268. declare module "babylonjs/Offline/IOfflineProvider" {
  1269. /**
  1270. * Class used to enable access to offline support
  1271. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1272. */
  1273. export interface IOfflineProvider {
  1274. /**
  1275. * Gets a boolean indicating if scene must be saved in the database
  1276. */
  1277. enableSceneOffline: boolean;
  1278. /**
  1279. * Gets a boolean indicating if textures must be saved in the database
  1280. */
  1281. enableTexturesOffline: boolean;
  1282. /**
  1283. * Open the offline support and make it available
  1284. * @param successCallback defines the callback to call on success
  1285. * @param errorCallback defines the callback to call on error
  1286. */
  1287. open(successCallback: () => void, errorCallback: () => void): void;
  1288. /**
  1289. * Loads an image from the offline support
  1290. * @param url defines the url to load from
  1291. * @param image defines the target DOM image
  1292. */
  1293. loadImage(url: string, image: HTMLImageElement): void;
  1294. /**
  1295. * Loads a file from offline support
  1296. * @param url defines the URL to load from
  1297. * @param sceneLoaded defines a callback to call on success
  1298. * @param progressCallBack defines a callback to call when progress changed
  1299. * @param errorCallback defines a callback to call on error
  1300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1301. */
  1302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/filesInputStore" {
  1306. /**
  1307. * Class used to help managing file picking and drag'n'drop
  1308. * File Storage
  1309. */
  1310. export class FilesInputStore {
  1311. /**
  1312. * List of files ready to be loaded
  1313. */
  1314. static FilesToLoad: {
  1315. [key: string]: File;
  1316. };
  1317. }
  1318. }
  1319. declare module "babylonjs/Misc/retryStrategy" {
  1320. import { WebRequest } from "babylonjs/Misc/webRequest";
  1321. /**
  1322. * Class used to define a retry strategy when error happens while loading assets
  1323. */
  1324. export class RetryStrategy {
  1325. /**
  1326. * Function used to defines an exponential back off strategy
  1327. * @param maxRetries defines the maximum number of retries (3 by default)
  1328. * @param baseInterval defines the interval between retries
  1329. * @returns the strategy function to use
  1330. */
  1331. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1332. }
  1333. }
  1334. declare module "babylonjs/Misc/baseError" {
  1335. /**
  1336. * @ignore
  1337. * Application error to support additional information when loading a file
  1338. */
  1339. export abstract class BaseError extends Error {
  1340. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1341. }
  1342. }
  1343. declare module "babylonjs/Misc/fileTools" {
  1344. import { WebRequest } from "babylonjs/Misc/webRequest";
  1345. import { Nullable } from "babylonjs/types";
  1346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1347. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1348. import { BaseError } from "babylonjs/Misc/baseError";
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1467. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1468. /** @hidden */
  1469. export class ShaderProcessor {
  1470. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1471. private static _ProcessPrecision;
  1472. private static _ExtractOperation;
  1473. private static _BuildSubExpression;
  1474. private static _BuildExpression;
  1475. private static _MoveCursorWithinIf;
  1476. private static _MoveCursor;
  1477. private static _EvaluatePreProcessors;
  1478. private static _PreparePreProcessors;
  1479. private static _ProcessShaderConversion;
  1480. private static _ProcessIncludes;
  1481. }
  1482. }
  1483. declare module "babylonjs/Maths/math.like" {
  1484. import { float, int, DeepImmutable } from "babylonjs/types";
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IColor4Like {
  1489. r: float;
  1490. g: float;
  1491. b: float;
  1492. a: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IColor3Like {
  1498. r: float;
  1499. g: float;
  1500. b: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector4Like {
  1506. x: float;
  1507. y: float;
  1508. z: float;
  1509. w: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IVector3Like {
  1515. x: float;
  1516. y: float;
  1517. z: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector2Like {
  1523. x: float;
  1524. y: float;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IMatrixLike {
  1530. toArray(): DeepImmutable<Float32Array>;
  1531. updateFlag: int;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IViewportLike {
  1537. x: float;
  1538. y: float;
  1539. width: float;
  1540. height: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IPlaneLike {
  1546. normal: IVector3Like;
  1547. d: float;
  1548. normalize(): void;
  1549. }
  1550. }
  1551. declare module "babylonjs/Materials/iEffectFallbacks" {
  1552. import { Effect } from "babylonjs/Materials/effect";
  1553. /**
  1554. * Interface used to define common properties for effect fallbacks
  1555. */
  1556. export interface IEffectFallbacks {
  1557. /**
  1558. * Removes the defines that should be removed when falling back.
  1559. * @param currentDefines defines the current define statements for the shader.
  1560. * @param effect defines the current effect we try to compile
  1561. * @returns The resulting defines with defines of the current rank removed.
  1562. */
  1563. reduce(currentDefines: string, effect: Effect): string;
  1564. /**
  1565. * Removes the fallback from the bound mesh.
  1566. */
  1567. unBindMesh(): void;
  1568. /**
  1569. * Checks to see if more fallbacks are still availible.
  1570. */
  1571. hasMoreFallbacks: boolean;
  1572. }
  1573. }
  1574. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1575. /**
  1576. * Class used to evalaute queries containing `and` and `or` operators
  1577. */
  1578. export class AndOrNotEvaluator {
  1579. /**
  1580. * Evaluate a query
  1581. * @param query defines the query to evaluate
  1582. * @param evaluateCallback defines the callback used to filter result
  1583. * @returns true if the query matches
  1584. */
  1585. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1586. private static _HandleParenthesisContent;
  1587. private static _SimplifyNegation;
  1588. }
  1589. }
  1590. declare module "babylonjs/Misc/tags" {
  1591. /**
  1592. * Class used to store custom tags
  1593. */
  1594. export class Tags {
  1595. /**
  1596. * Adds support for tags on the given object
  1597. * @param obj defines the object to use
  1598. */
  1599. static EnableFor(obj: any): void;
  1600. /**
  1601. * Removes tags support
  1602. * @param obj defines the object to use
  1603. */
  1604. static DisableFor(obj: any): void;
  1605. /**
  1606. * Gets a boolean indicating if the given object has tags
  1607. * @param obj defines the object to use
  1608. * @returns a boolean
  1609. */
  1610. static HasTags(obj: any): boolean;
  1611. /**
  1612. * Gets the tags available on a given object
  1613. * @param obj defines the object to use
  1614. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1615. * @returns the tags
  1616. */
  1617. static GetTags(obj: any, asString?: boolean): any;
  1618. /**
  1619. * Adds tags to an object
  1620. * @param obj defines the object to use
  1621. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1622. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1623. */
  1624. static AddTagsTo(obj: any, tagsString: string): void;
  1625. /**
  1626. * @hidden
  1627. */
  1628. static _AddTagTo(obj: any, tag: string): void;
  1629. /**
  1630. * Removes specific tags from a specific object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tags to remove
  1633. */
  1634. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1635. /**
  1636. * @hidden
  1637. */
  1638. static _RemoveTagFrom(obj: any, tag: string): void;
  1639. /**
  1640. * Defines if tags hosted on an object match a given query
  1641. * @param obj defines the object to use
  1642. * @param tagsQuery defines the tag query
  1643. * @returns a boolean
  1644. */
  1645. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1646. }
  1647. }
  1648. declare module "babylonjs/Maths/math.scalar" {
  1649. /**
  1650. * Scalar computation library
  1651. */
  1652. export class Scalar {
  1653. /**
  1654. * Two pi constants convenient for computation.
  1655. */
  1656. static TwoPi: number;
  1657. /**
  1658. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1659. * @param a number
  1660. * @param b number
  1661. * @param epsilon (default = 1.401298E-45)
  1662. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. */
  1664. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1665. /**
  1666. * Returns a string : the upper case translation of the number i to hexadecimal.
  1667. * @param i number
  1668. * @returns the upper case translation of the number i to hexadecimal.
  1669. */
  1670. static ToHex(i: number): string;
  1671. /**
  1672. * Returns -1 if value is negative and +1 is value is positive.
  1673. * @param value the value
  1674. * @returns the value itself if it's equal to zero.
  1675. */
  1676. static Sign(value: number): number;
  1677. /**
  1678. * Returns the value itself if it's between min and max.
  1679. * Returns min if the value is lower than min.
  1680. * Returns max if the value is greater than max.
  1681. * @param value the value to clmap
  1682. * @param min the min value to clamp to (default: 0)
  1683. * @param max the max value to clamp to (default: 1)
  1684. * @returns the clamped value
  1685. */
  1686. static Clamp(value: number, min?: number, max?: number): number;
  1687. /**
  1688. * the log2 of value.
  1689. * @param value the value to compute log2 of
  1690. * @returns the log2 of value.
  1691. */
  1692. static Log2(value: number): number;
  1693. /**
  1694. * Loops the value, so that it is never larger than length and never smaller than 0.
  1695. *
  1696. * This is similar to the modulo operator but it works with floating point numbers.
  1697. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1698. * With t = 5 and length = 2.5, the result would be 0.0.
  1699. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1700. * @param value the value
  1701. * @param length the length
  1702. * @returns the looped value
  1703. */
  1704. static Repeat(value: number, length: number): number;
  1705. /**
  1706. * Normalize the value between 0.0 and 1.0 using min and max values
  1707. * @param value value to normalize
  1708. * @param min max to normalize between
  1709. * @param max min to normalize between
  1710. * @returns the normalized value
  1711. */
  1712. static Normalize(value: number, min: number, max: number): number;
  1713. /**
  1714. * Denormalize the value from 0.0 and 1.0 using min and max values
  1715. * @param normalized value to denormalize
  1716. * @param min max to denormalize between
  1717. * @param max min to denormalize between
  1718. * @returns the denormalized value
  1719. */
  1720. static Denormalize(normalized: number, min: number, max: number): number;
  1721. /**
  1722. * Calculates the shortest difference between two given angles given in degrees.
  1723. * @param current current angle in degrees
  1724. * @param target target angle in degrees
  1725. * @returns the delta
  1726. */
  1727. static DeltaAngle(current: number, target: number): number;
  1728. /**
  1729. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1730. * @param tx value
  1731. * @param length length
  1732. * @returns The returned value will move back and forth between 0 and length
  1733. */
  1734. static PingPong(tx: number, length: number): number;
  1735. /**
  1736. * Interpolates between min and max with smoothing at the limits.
  1737. *
  1738. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1739. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1740. * @param from from
  1741. * @param to to
  1742. * @param tx value
  1743. * @returns the smooth stepped value
  1744. */
  1745. static SmoothStep(from: number, to: number, tx: number): number;
  1746. /**
  1747. * Moves a value current towards target.
  1748. *
  1749. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1750. * Negative values of maxDelta pushes the value away from target.
  1751. * @param current current value
  1752. * @param target target value
  1753. * @param maxDelta max distance to move
  1754. * @returns resulting value
  1755. */
  1756. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1757. /**
  1758. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1759. *
  1760. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1761. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting angle
  1766. */
  1767. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1770. * @param start start value
  1771. * @param end target value
  1772. * @param amount amount to lerp between
  1773. * @returns the lerped value
  1774. */
  1775. static Lerp(start: number, end: number, amount: number): number;
  1776. /**
  1777. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1778. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static LerpAngle(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1787. * @param a start value
  1788. * @param b target value
  1789. * @param value value between a and b
  1790. * @returns the inverseLerp value
  1791. */
  1792. static InverseLerp(a: number, b: number, value: number): number;
  1793. /**
  1794. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1795. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1796. * @param value1 spline value
  1797. * @param tangent1 spline value
  1798. * @param value2 spline value
  1799. * @param tangent2 spline value
  1800. * @param amount input value
  1801. * @returns hermite result
  1802. */
  1803. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1804. /**
  1805. * Returns a random float number between and min and max values
  1806. * @param min min value of random
  1807. * @param max max value of random
  1808. * @returns random value
  1809. */
  1810. static RandomRange(min: number, max: number): number;
  1811. /**
  1812. * This function returns percentage of a number in a given range.
  1813. *
  1814. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1815. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1816. * @param number to convert to percentage
  1817. * @param min min range
  1818. * @param max max range
  1819. * @returns the percentage
  1820. */
  1821. static RangeToPercent(number: number, min: number, max: number): number;
  1822. /**
  1823. * This function returns number that corresponds to the percentage in a given range.
  1824. *
  1825. * PercentToRange(0.34,0,100) will return 34.
  1826. * @param percent to convert to number
  1827. * @param min min range
  1828. * @param max max range
  1829. * @returns the number
  1830. */
  1831. static PercentToRange(percent: number, min: number, max: number): number;
  1832. /**
  1833. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1834. * @param angle The angle to normalize in radian.
  1835. * @return The converted angle.
  1836. */
  1837. static NormalizeRadians(angle: number): number;
  1838. }
  1839. }
  1840. declare module "babylonjs/Maths/math.constants" {
  1841. /**
  1842. * Constant used to convert a value to gamma space
  1843. * @ignorenaming
  1844. */
  1845. export const ToGammaSpace: number;
  1846. /**
  1847. * Constant used to convert a value to linear space
  1848. * @ignorenaming
  1849. */
  1850. export const ToLinearSpace = 2.2;
  1851. /**
  1852. * Constant used to define the minimal number value in Babylon.js
  1853. * @ignorenaming
  1854. */
  1855. let Epsilon: number;
  1856. export { Epsilon };
  1857. }
  1858. declare module "babylonjs/Maths/math.viewport" {
  1859. /**
  1860. * Class used to represent a viewport on screen
  1861. */
  1862. export class Viewport {
  1863. /** viewport left coordinate */
  1864. x: number;
  1865. /** viewport top coordinate */
  1866. y: number;
  1867. /**viewport width */
  1868. width: number;
  1869. /** viewport height */
  1870. height: number;
  1871. /**
  1872. * Creates a Viewport object located at (x, y) and sized (width, height)
  1873. * @param x defines viewport left coordinate
  1874. * @param y defines viewport top coordinate
  1875. * @param width defines the viewport width
  1876. * @param height defines the viewport height
  1877. */
  1878. constructor(
  1879. /** viewport left coordinate */
  1880. x: number,
  1881. /** viewport top coordinate */
  1882. y: number,
  1883. /**viewport width */
  1884. width: number,
  1885. /** viewport height */
  1886. height: number);
  1887. /**
  1888. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @returns a new Viewport
  1892. */
  1893. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1894. /**
  1895. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1896. * @param renderWidth defines the rendering width
  1897. * @param renderHeight defines the rendering height
  1898. * @param ref defines the target viewport
  1899. * @returns the current viewport
  1900. */
  1901. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1902. /**
  1903. * Returns a new Viewport copied from the current one
  1904. * @returns a new Viewport
  1905. */
  1906. clone(): Viewport;
  1907. }
  1908. }
  1909. declare module "babylonjs/Misc/arrayTools" {
  1910. /**
  1911. * Class containing a set of static utilities functions for arrays.
  1912. */
  1913. export class ArrayTools {
  1914. /**
  1915. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1916. * @param size the number of element to construct and put in the array
  1917. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1918. * @returns a new array filled with new objects
  1919. */
  1920. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1921. }
  1922. }
  1923. declare module "babylonjs/Maths/math.vector" {
  1924. import { Viewport } from "babylonjs/Maths/math.viewport";
  1925. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1926. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1927. /**
  1928. * Class representing a vector containing 2 coordinates
  1929. */
  1930. export class Vector2 {
  1931. /** defines the first coordinate */
  1932. x: number;
  1933. /** defines the second coordinate */
  1934. y: number;
  1935. /**
  1936. * Creates a new Vector2 from the given x and y coordinates
  1937. * @param x defines the first coordinate
  1938. * @param y defines the second coordinate
  1939. */
  1940. constructor(
  1941. /** defines the first coordinate */
  1942. x?: number,
  1943. /** defines the second coordinate */
  1944. y?: number);
  1945. /**
  1946. * Gets a string with the Vector2 coordinates
  1947. * @returns a string with the Vector2 coordinates
  1948. */
  1949. toString(): string;
  1950. /**
  1951. * Gets class name
  1952. * @returns the string "Vector2"
  1953. */
  1954. getClassName(): string;
  1955. /**
  1956. * Gets current vector hash code
  1957. * @returns the Vector2 hash code as a number
  1958. */
  1959. getHashCode(): number;
  1960. /**
  1961. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1962. * @param array defines the source array
  1963. * @param index defines the offset in source array
  1964. * @returns the current Vector2
  1965. */
  1966. toArray(array: FloatArray, index?: number): Vector2;
  1967. /**
  1968. * Copy the current vector to an array
  1969. * @returns a new array with 2 elements: the Vector2 coordinates.
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1974. * @param source defines the source Vector2
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. copyFromFloats(x: number, y: number): Vector2;
  1985. /**
  1986. * Sets the Vector2 coordinates with the given floats
  1987. * @param x defines the first coordinate
  1988. * @param y defines the second coordinate
  1989. * @returns the current updated Vector2
  1990. */
  1991. set(x: number, y: number): Vector2;
  1992. /**
  1993. * Add another vector with the current one
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1996. */
  1997. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2013. * @param otherVector defines the other vector
  2014. * @returns a new Vector2
  2015. */
  2016. addVector3(otherVector: Vector3): Vector2;
  2017. /**
  2018. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. subtract(otherVector: Vector2): Vector2;
  2023. /**
  2024. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2032. * @param otherVector defines the other vector
  2033. * @returns the current updated Vector2
  2034. */
  2035. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2036. /**
  2037. * Multiplies in place the current Vector2 coordinates by the given ones
  2038. * @param otherVector defines the other vector
  2039. * @returns the current updated Vector2
  2040. */
  2041. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2048. /**
  2049. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2057. * @param x defines the first coordinate
  2058. * @param y defines the second coordinate
  2059. * @returns a new Vector2
  2060. */
  2061. multiplyByFloats(x: number, y: number): Vector2;
  2062. /**
  2063. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2064. * @param otherVector defines the other vector
  2065. * @returns a new Vector2
  2066. */
  2067. divide(otherVector: Vector2): Vector2;
  2068. /**
  2069. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2070. * @param otherVector defines the other vector
  2071. * @param result defines the target vector
  2072. * @returns the unmodified current Vector2
  2073. */
  2074. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2075. /**
  2076. * Divides the current Vector2 coordinates by the given ones
  2077. * @param otherVector defines the other vector
  2078. * @returns the current updated Vector2
  2079. */
  2080. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2081. /**
  2082. * Gets a new Vector2 with current Vector2 negated coordinates
  2083. * @returns a new Vector2
  2084. */
  2085. negate(): Vector2;
  2086. /**
  2087. * Multiply the Vector2 coordinates by scale
  2088. * @param scale defines the scaling factor
  2089. * @returns the current updated Vector2
  2090. */
  2091. scaleInPlace(scale: number): Vector2;
  2092. /**
  2093. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2094. * @param scale defines the scaling factor
  2095. * @returns a new Vector2
  2096. */
  2097. scale(scale: number): Vector2;
  2098. /**
  2099. * Scale the current Vector2 values by a factor to a given Vector2
  2100. * @param scale defines the scale factor
  2101. * @param result defines the Vector2 object where to store the result
  2102. * @returns the unmodified current Vector2
  2103. */
  2104. scaleToRef(scale: number, result: Vector2): Vector2;
  2105. /**
  2106. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2107. * @param scale defines the scale factor
  2108. * @param result defines the Vector2 object where to store the result
  2109. * @returns the unmodified current Vector2
  2110. */
  2111. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2112. /**
  2113. * Gets a boolean if two vectors are equals
  2114. * @param otherVector defines the other vector
  2115. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2116. */
  2117. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2118. /**
  2119. * Gets a boolean if two vectors are equals (using an epsilon value)
  2120. * @param otherVector defines the other vector
  2121. * @param epsilon defines the minimal distance to consider equality
  2122. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2123. */
  2124. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2125. /**
  2126. * Gets a new Vector2 from current Vector2 floored values
  2127. * @returns a new Vector2
  2128. */
  2129. floor(): Vector2;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. fract(): Vector2;
  2135. /**
  2136. * Gets the length of the vector
  2137. * @returns the vector length (float)
  2138. */
  2139. length(): number;
  2140. /**
  2141. * Gets the vector squared length
  2142. * @returns the vector squared length (float)
  2143. */
  2144. lengthSquared(): number;
  2145. /**
  2146. * Normalize the vector
  2147. * @returns the current updated Vector2
  2148. */
  2149. normalize(): Vector2;
  2150. /**
  2151. * Gets a new Vector2 copied from the Vector2
  2152. * @returns a new Vector2
  2153. */
  2154. clone(): Vector2;
  2155. /**
  2156. * Gets a new Vector2(0, 0)
  2157. * @returns a new Vector2
  2158. */
  2159. static Zero(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(1, 1)
  2162. * @returns a new Vector2
  2163. */
  2164. static One(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 set from the given index element of the given array
  2167. * @param array defines the data source
  2168. * @param offset defines the offset in the data source
  2169. * @returns a new Vector2
  2170. */
  2171. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2172. /**
  2173. * Sets "result" from the given index element of the given array
  2174. * @param array defines the data source
  2175. * @param offset defines the offset in the data source
  2176. * @param result defines the target vector
  2177. */
  2178. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2179. /**
  2180. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2181. * @param value1 defines 1st point of control
  2182. * @param value2 defines 2nd point of control
  2183. * @param value3 defines 3rd point of control
  2184. * @param value4 defines 4th point of control
  2185. * @param amount defines the interpolation factor
  2186. * @returns a new Vector2
  2187. */
  2188. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2189. /**
  2190. * 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".
  2191. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2192. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2193. * @param value defines the value to clamp
  2194. * @param min defines the lower limit
  2195. * @param max defines the upper limit
  2196. * @returns a new Vector2
  2197. */
  2198. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2199. /**
  2200. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2201. * @param value1 defines the 1st control point
  2202. * @param tangent1 defines the outgoing tangent
  2203. * @param value2 defines the 2nd control point
  2204. * @param tangent2 defines the incoming tangent
  2205. * @param amount defines the interpolation factor
  2206. * @returns a new Vector2
  2207. */
  2208. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2209. /**
  2210. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2211. * @param start defines the start vector
  2212. * @param end defines the end vector
  2213. * @param amount defines the interpolation factor
  2214. * @returns a new Vector2
  2215. */
  2216. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2217. /**
  2218. * Gets the dot product of the vector "left" and the vector "right"
  2219. * @param left defines first vector
  2220. * @param right defines second vector
  2221. * @returns the dot product (float)
  2222. */
  2223. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2224. /**
  2225. * Returns a new Vector2 equal to the normalized given vector
  2226. * @param vector defines the vector to normalize
  2227. * @returns a new Vector2
  2228. */
  2229. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2232. * @param left defines 1st vector
  2233. * @param right defines 2nd vector
  2234. * @returns a new Vector2
  2235. */
  2236. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2237. /**
  2238. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2239. * @param left defines 1st vector
  2240. * @param right defines 2nd vector
  2241. * @returns a new Vector2
  2242. */
  2243. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2244. /**
  2245. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2246. * @param vector defines the vector to transform
  2247. * @param transformation defines the matrix to apply
  2248. * @returns a new Vector2
  2249. */
  2250. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2251. /**
  2252. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2253. * @param vector defines the vector to transform
  2254. * @param transformation defines the matrix to apply
  2255. * @param result defines the target vector
  2256. */
  2257. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2258. /**
  2259. * Determines if a given vector is included in a triangle
  2260. * @param p defines the vector to test
  2261. * @param p0 defines 1st triangle point
  2262. * @param p1 defines 2nd triangle point
  2263. * @param p2 defines 3rd triangle point
  2264. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2265. */
  2266. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2267. /**
  2268. * Gets the distance between the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns the distance between vectors
  2272. */
  2273. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2274. /**
  2275. * Returns the squared distance between the vectors "value1" and "value2"
  2276. * @param value1 defines first vector
  2277. * @param value2 defines second vector
  2278. * @returns the squared distance between vectors
  2279. */
  2280. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2281. /**
  2282. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2283. * @param value1 defines first vector
  2284. * @param value2 defines second vector
  2285. * @returns a new Vector2
  2286. */
  2287. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2288. /**
  2289. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2290. * @param p defines the middle point
  2291. * @param segA defines one point of the segment
  2292. * @param segB defines the other point of the segment
  2293. * @returns the shortest distance
  2294. */
  2295. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2296. }
  2297. /**
  2298. * Classed used to store (x,y,z) vector representation
  2299. * A Vector3 is the main object used in 3D geometry
  2300. * It can represent etiher the coordinates of a point the space, either a direction
  2301. * Reminder: js uses a left handed forward facing system
  2302. */
  2303. export class Vector3 {
  2304. /**
  2305. * Defines the first coordinates (on X axis)
  2306. */
  2307. x: number;
  2308. /**
  2309. * Defines the second coordinates (on Y axis)
  2310. */
  2311. y: number;
  2312. /**
  2313. * Defines the third coordinates (on Z axis)
  2314. */
  2315. z: number;
  2316. private static _UpReadOnly;
  2317. private static _ZeroReadOnly;
  2318. /**
  2319. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2320. * @param x defines the first coordinates (on X axis)
  2321. * @param y defines the second coordinates (on Y axis)
  2322. * @param z defines the third coordinates (on Z axis)
  2323. */
  2324. constructor(
  2325. /**
  2326. * Defines the first coordinates (on X axis)
  2327. */
  2328. x?: number,
  2329. /**
  2330. * Defines the second coordinates (on Y axis)
  2331. */
  2332. y?: number,
  2333. /**
  2334. * Defines the third coordinates (on Z axis)
  2335. */
  2336. z?: number);
  2337. /**
  2338. * Creates a string representation of the Vector3
  2339. * @returns a string with the Vector3 coordinates.
  2340. */
  2341. toString(): string;
  2342. /**
  2343. * Gets the class name
  2344. * @returns the string "Vector3"
  2345. */
  2346. getClassName(): string;
  2347. /**
  2348. * Creates the Vector3 hash code
  2349. * @returns a number which tends to be unique between Vector3 instances
  2350. */
  2351. getHashCode(): number;
  2352. /**
  2353. * Creates an array containing three elements : the coordinates of the Vector3
  2354. * @returns a new array of numbers
  2355. */
  2356. asArray(): number[];
  2357. /**
  2358. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2359. * @param array defines the destination array
  2360. * @param index defines the offset in the destination array
  2361. * @returns the current Vector3
  2362. */
  2363. toArray(array: FloatArray, index?: number): Vector3;
  2364. /**
  2365. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2366. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2367. */
  2368. toQuaternion(): Quaternion;
  2369. /**
  2370. * Adds the given vector to the current Vector3
  2371. * @param otherVector defines the second operand
  2372. * @returns the current updated Vector3
  2373. */
  2374. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the given coordinates to the current Vector3
  2377. * @param x defines the x coordinate of the operand
  2378. * @param y defines the y coordinate of the operand
  2379. * @param z defines the z coordinate of the operand
  2380. * @returns the current updated Vector3
  2381. */
  2382. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2383. /**
  2384. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2385. * @param otherVector defines the second operand
  2386. * @returns the resulting Vector3
  2387. */
  2388. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2389. /**
  2390. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2391. * @param otherVector defines the second operand
  2392. * @param result defines the Vector3 object where to store the result
  2393. * @returns the current Vector3
  2394. */
  2395. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2396. /**
  2397. * Subtract the given vector from the current Vector3
  2398. * @param otherVector defines the second operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2402. /**
  2403. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2417. * @param x defines the x coordinate of the operand
  2418. * @param y defines the y coordinate of the operand
  2419. * @param z defines the z coordinate of the operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2423. /**
  2424. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2425. * @param x defines the x coordinate of the operand
  2426. * @param y defines the y coordinate of the operand
  2427. * @param z defines the z coordinate of the operand
  2428. * @param result defines the Vector3 object where to store the result
  2429. * @returns the current Vector3
  2430. */
  2431. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2432. /**
  2433. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2434. * @returns a new Vector3
  2435. */
  2436. negate(): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. readonly isNonUniform: boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * This function is deprecated. Use FromArray instead
  2701. * @param array defines the source array
  2702. * @param offset defines the offset in the source array
  2703. * @returns the new Vector3
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * This function is deprecated. Use FromArrayToRef instead.
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @param result defines the Vector3 where to store the result
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Multiplies the current Vector4 coordinates by scale (float).
  3160. * @param scale the number to scale with
  3161. * @returns the updated Vector4.
  3162. */
  3163. scaleInPlace(scale: number): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3166. * @param scale the number to scale with
  3167. * @returns a new vector with the result
  3168. */
  3169. scale(scale: number): Vector4;
  3170. /**
  3171. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3172. * @param scale the number to scale with
  3173. * @param result a vector to store the result in
  3174. * @returns the current Vector4.
  3175. */
  3176. scaleToRef(scale: number, result: Vector4): Vector4;
  3177. /**
  3178. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3179. * @param scale defines the scale factor
  3180. * @param result defines the Vector4 object where to store the result
  3181. * @returns the unmodified current Vector4
  3182. */
  3183. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3184. /**
  3185. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3186. * @param otherVector the vector to compare against
  3187. * @returns true if they are equal
  3188. */
  3189. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3190. /**
  3191. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3192. * @param otherVector vector to compare against
  3193. * @param epsilon (Default: very small number)
  3194. * @returns true if they are equal
  3195. */
  3196. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3197. /**
  3198. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3199. * @param x x value to compare against
  3200. * @param y y value to compare against
  3201. * @param z z value to compare against
  3202. * @param w w value to compare against
  3203. * @returns true if equal
  3204. */
  3205. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3206. /**
  3207. * Multiplies in place the current Vector4 by the given one.
  3208. * @param otherVector vector to multiple with
  3209. * @returns the updated Vector4.
  3210. */
  3211. multiplyInPlace(otherVector: Vector4): Vector4;
  3212. /**
  3213. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3214. * @param otherVector vector to multiple with
  3215. * @returns resulting new vector
  3216. */
  3217. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3218. /**
  3219. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3220. * @param otherVector vector to multiple with
  3221. * @param result vector to store the result
  3222. * @returns the current Vector4.
  3223. */
  3224. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3227. * @param x x value multiply with
  3228. * @param y y value multiply with
  3229. * @param z z value multiply with
  3230. * @param w w value multiply with
  3231. * @returns resulting new vector
  3232. */
  3233. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3234. /**
  3235. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3236. * @param otherVector vector to devide with
  3237. * @returns resulting new vector
  3238. */
  3239. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3240. /**
  3241. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3242. * @param otherVector vector to devide with
  3243. * @param result vector to store the result
  3244. * @returns the current Vector4.
  3245. */
  3246. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3247. /**
  3248. * Divides the current Vector3 coordinates by the given ones.
  3249. * @param otherVector vector to devide with
  3250. * @returns the updated Vector3.
  3251. */
  3252. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3255. * @param other defines the second operand
  3256. * @returns the current updated Vector4
  3257. */
  3258. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3261. * @param other defines the second operand
  3262. * @returns the current updated Vector4
  3263. */
  3264. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3265. /**
  3266. * Gets a new Vector4 from current Vector4 floored values
  3267. * @returns a new Vector4
  3268. */
  3269. floor(): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector3 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. fract(): Vector4;
  3275. /**
  3276. * Returns the Vector4 length (float).
  3277. * @returns the length
  3278. */
  3279. length(): number;
  3280. /**
  3281. * Returns the Vector4 squared length (float).
  3282. * @returns the length squared
  3283. */
  3284. lengthSquared(): number;
  3285. /**
  3286. * Normalizes in place the Vector4.
  3287. * @returns the updated Vector4.
  3288. */
  3289. normalize(): Vector4;
  3290. /**
  3291. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3292. * @returns this converted to a new vector3
  3293. */
  3294. toVector3(): Vector3;
  3295. /**
  3296. * Returns a new Vector4 copied from the current one.
  3297. * @returns the new cloned vector
  3298. */
  3299. clone(): Vector4;
  3300. /**
  3301. * Updates the current Vector4 with the given one coordinates.
  3302. * @param source the source vector to copy from
  3303. * @returns the updated Vector4.
  3304. */
  3305. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Updates the current Vector4 coordinates with the given floats.
  3308. * @param x float to copy from
  3309. * @param y float to copy from
  3310. * @param z float to copy from
  3311. * @param w float to copy from
  3312. * @returns the updated Vector4.
  3313. */
  3314. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3315. /**
  3316. * Updates the current Vector4 coordinates with the given floats.
  3317. * @param x float to set from
  3318. * @param y float to set from
  3319. * @param z float to set from
  3320. * @param w float to set from
  3321. * @returns the updated Vector4.
  3322. */
  3323. set(x: number, y: number, z: number, w: number): Vector4;
  3324. /**
  3325. * Copies the given float to the current Vector3 coordinates
  3326. * @param v defines the x, y, z and w coordinates of the operand
  3327. * @returns the current updated Vector3
  3328. */
  3329. setAll(v: number): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set from the starting index of the given array.
  3332. * @param array the array to pull values from
  3333. * @param offset the offset into the array to start at
  3334. * @returns the new vector
  3335. */
  3336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3337. /**
  3338. * Updates the given vector "result" from the starting index of the given array.
  3339. * @param array the array to pull values from
  3340. * @param offset the offset into the array to start at
  3341. * @param result the vector to store the result in
  3342. */
  3343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3344. /**
  3345. * Updates the given vector "result" from the starting index of the given Float32Array.
  3346. * @param array the array to pull values from
  3347. * @param offset the offset into the array to start at
  3348. * @param result the vector to store the result in
  3349. */
  3350. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3351. /**
  3352. * Updates the given vector "result" coordinates from the given floats.
  3353. * @param x float to set from
  3354. * @param y float to set from
  3355. * @param z float to set from
  3356. * @param w float to set from
  3357. * @param result the vector to the floats in
  3358. */
  3359. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3360. /**
  3361. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3362. * @returns the new vector
  3363. */
  3364. static Zero(): Vector4;
  3365. /**
  3366. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3367. * @returns the new vector
  3368. */
  3369. static One(): Vector4;
  3370. /**
  3371. * Returns a new normalized Vector4 from the given one.
  3372. * @param vector the vector to normalize
  3373. * @returns the vector
  3374. */
  3375. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3376. /**
  3377. * Updates the given vector "result" from the normalization of the given one.
  3378. * @param vector the vector to normalize
  3379. * @param result the vector to store the result in
  3380. */
  3381. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3382. /**
  3383. * Returns a vector with the minimum values from the left and right vectors
  3384. * @param left left vector to minimize
  3385. * @param right right vector to minimize
  3386. * @returns a new vector with the minimum of the left and right vector values
  3387. */
  3388. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Returns a vector with the maximum values from the left and right vectors
  3391. * @param left left vector to maximize
  3392. * @param right right vector to maximize
  3393. * @returns a new vector with the maximum of the left and right vector values
  3394. */
  3395. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Returns the distance (float) between the vectors "value1" and "value2".
  3398. * @param value1 value to calulate the distance between
  3399. * @param value2 value to calulate the distance between
  3400. * @return the distance between the two vectors
  3401. */
  3402. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3403. /**
  3404. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3405. * @param value1 value to calulate the distance between
  3406. * @param value2 value to calulate the distance between
  3407. * @return the distance between the two vectors squared
  3408. */
  3409. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3410. /**
  3411. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3412. * @param value1 value to calulate the center between
  3413. * @param value2 value to calulate the center between
  3414. * @return the center between the two vectors
  3415. */
  3416. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3419. * This methods computes transformed normalized direction vectors only.
  3420. * @param vector the vector to transform
  3421. * @param transformation the transformation matrix to apply
  3422. * @returns the new vector
  3423. */
  3424. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3425. /**
  3426. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @param result the vector to store the result in
  3431. */
  3432. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param x value to transform
  3437. * @param y value to transform
  3438. * @param z value to transform
  3439. * @param w value to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the results in
  3442. */
  3443. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Creates a new Vector4 from a Vector3
  3446. * @param source defines the source data
  3447. * @param w defines the 4th component (default is 0)
  3448. * @returns a new Vector4
  3449. */
  3450. static FromVector3(source: Vector3, w?: number): Vector4;
  3451. }
  3452. /**
  3453. * Class used to store quaternion data
  3454. * @see https://en.wikipedia.org/wiki/Quaternion
  3455. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3456. */
  3457. export class Quaternion {
  3458. /** defines the first component (0 by default) */
  3459. x: number;
  3460. /** defines the second component (0 by default) */
  3461. y: number;
  3462. /** defines the third component (0 by default) */
  3463. z: number;
  3464. /** defines the fourth component (1.0 by default) */
  3465. w: number;
  3466. /**
  3467. * Creates a new Quaternion from the given floats
  3468. * @param x defines the first component (0 by default)
  3469. * @param y defines the second component (0 by default)
  3470. * @param z defines the third component (0 by default)
  3471. * @param w defines the fourth component (1.0 by default)
  3472. */
  3473. constructor(
  3474. /** defines the first component (0 by default) */
  3475. x?: number,
  3476. /** defines the second component (0 by default) */
  3477. y?: number,
  3478. /** defines the third component (0 by default) */
  3479. z?: number,
  3480. /** defines the fourth component (1.0 by default) */
  3481. w?: number);
  3482. /**
  3483. * Gets a string representation for the current quaternion
  3484. * @returns a string with the Quaternion coordinates
  3485. */
  3486. toString(): string;
  3487. /**
  3488. * Gets the class name of the quaternion
  3489. * @returns the string "Quaternion"
  3490. */
  3491. getClassName(): string;
  3492. /**
  3493. * Gets a hash code for this quaternion
  3494. * @returns the quaternion hash code
  3495. */
  3496. getHashCode(): number;
  3497. /**
  3498. * Copy the quaternion to an array
  3499. * @returns a new array populated with 4 elements from the quaternion coordinates
  3500. */
  3501. asArray(): number[];
  3502. /**
  3503. * Check if two quaternions are equals
  3504. * @param otherQuaternion defines the second operand
  3505. * @return true if the current quaternion and the given one coordinates are strictly equals
  3506. */
  3507. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3508. /**
  3509. * Clone the current quaternion
  3510. * @returns a new quaternion copied from the current one
  3511. */
  3512. clone(): Quaternion;
  3513. /**
  3514. * Copy a quaternion to the current one
  3515. * @param other defines the other quaternion
  3516. * @returns the updated current quaternion
  3517. */
  3518. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3519. /**
  3520. * Updates the current quaternion with the given float coordinates
  3521. * @param x defines the x coordinate
  3522. * @param y defines the y coordinate
  3523. * @param z defines the z coordinate
  3524. * @param w defines the w coordinate
  3525. * @returns the updated current quaternion
  3526. */
  3527. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3528. /**
  3529. * Updates the current quaternion from the given float coordinates
  3530. * @param x defines the x coordinate
  3531. * @param y defines the y coordinate
  3532. * @param z defines the z coordinate
  3533. * @param w defines the w coordinate
  3534. * @returns the updated current quaternion
  3535. */
  3536. set(x: number, y: number, z: number, w: number): Quaternion;
  3537. /**
  3538. * Adds two quaternions
  3539. * @param other defines the second operand
  3540. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3541. */
  3542. add(other: DeepImmutable<Quaternion>): Quaternion;
  3543. /**
  3544. * Add a quaternion to the current one
  3545. * @param other defines the quaternion to add
  3546. * @returns the current quaternion
  3547. */
  3548. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3549. /**
  3550. * Subtract two quaternions
  3551. * @param other defines the second operand
  3552. * @returns a new quaternion as the subtraction result of the given one from the current one
  3553. */
  3554. subtract(other: Quaternion): Quaternion;
  3555. /**
  3556. * Multiplies the current quaternion by a scale factor
  3557. * @param value defines the scale factor
  3558. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3559. */
  3560. scale(value: number): Quaternion;
  3561. /**
  3562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3563. * @param scale defines the scale factor
  3564. * @param result defines the Quaternion object where to store the result
  3565. * @returns the unmodified current quaternion
  3566. */
  3567. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3568. /**
  3569. * Multiplies in place the current quaternion by a scale factor
  3570. * @param value defines the scale factor
  3571. * @returns the current modified quaternion
  3572. */
  3573. scaleInPlace(value: number): Quaternion;
  3574. /**
  3575. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3576. * @param scale defines the scale factor
  3577. * @param result defines the Quaternion object where to store the result
  3578. * @returns the unmodified current quaternion
  3579. */
  3580. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3581. /**
  3582. * Multiplies two quaternions
  3583. * @param q1 defines the second operand
  3584. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3585. */
  3586. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3589. * @param q1 defines the second operand
  3590. * @param result defines the target quaternion
  3591. * @returns the current quaternion
  3592. */
  3593. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3594. /**
  3595. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3596. * @param q1 defines the second operand
  3597. * @returns the currentupdated quaternion
  3598. */
  3599. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3602. * @param ref defines the target quaternion
  3603. * @returns the current quaternion
  3604. */
  3605. conjugateToRef(ref: Quaternion): Quaternion;
  3606. /**
  3607. * Conjugates in place (1-q) the current quaternion
  3608. * @returns the current updated quaternion
  3609. */
  3610. conjugateInPlace(): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns a new quaternion
  3614. */
  3615. conjugate(): Quaternion;
  3616. /**
  3617. * Gets length of current quaternion
  3618. * @returns the quaternion length (float)
  3619. */
  3620. length(): number;
  3621. /**
  3622. * Normalize in place the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. normalize(): Quaternion;
  3626. /**
  3627. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3628. * @param order is a reserved parameter and is ignore for now
  3629. * @returns a new Vector3 containing the Euler angles
  3630. */
  3631. toEulerAngles(order?: string): Vector3;
  3632. /**
  3633. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3634. * @param result defines the vector which will be filled with the Euler angles
  3635. * @param order is a reserved parameter and is ignore for now
  3636. * @returns the current unchanged quaternion
  3637. */
  3638. toEulerAnglesToRef(result: Vector3): Quaternion;
  3639. /**
  3640. * Updates the given rotation matrix with the current quaternion values
  3641. * @param result defines the target matrix
  3642. * @returns the current unchanged quaternion
  3643. */
  3644. toRotationMatrix(result: Matrix): Quaternion;
  3645. /**
  3646. * Updates the current quaternion from the given rotation matrix values
  3647. * @param matrix defines the source matrix
  3648. * @returns the current updated quaternion
  3649. */
  3650. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3651. /**
  3652. * Creates a new quaternion from a rotation matrix
  3653. * @param matrix defines the source matrix
  3654. * @returns a new quaternion created from the given rotation matrix values
  3655. */
  3656. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3657. /**
  3658. * Updates the given quaternion with the given rotation matrix values
  3659. * @param matrix defines the source matrix
  3660. * @param result defines the target quaternion
  3661. */
  3662. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3663. /**
  3664. * Returns the dot product (float) between the quaternions "left" and "right"
  3665. * @param left defines the left operand
  3666. * @param right defines the right operand
  3667. * @returns the dot product
  3668. */
  3669. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3670. /**
  3671. * Checks if the two quaternions are close to each other
  3672. * @param quat0 defines the first quaternion to check
  3673. * @param quat1 defines the second quaternion to check
  3674. * @returns true if the two quaternions are close to each other
  3675. */
  3676. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3677. /**
  3678. * Creates an empty quaternion
  3679. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3680. */
  3681. static Zero(): Quaternion;
  3682. /**
  3683. * Inverse a given quaternion
  3684. * @param q defines the source quaternion
  3685. * @returns a new quaternion as the inverted current quaternion
  3686. */
  3687. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3688. /**
  3689. * Inverse a given quaternion
  3690. * @param q defines the source quaternion
  3691. * @param result the quaternion the result will be stored in
  3692. * @returns the result quaternion
  3693. */
  3694. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3695. /**
  3696. * Creates an identity quaternion
  3697. * @returns the identity quaternion
  3698. */
  3699. static Identity(): Quaternion;
  3700. /**
  3701. * Gets a boolean indicating if the given quaternion is identity
  3702. * @param quaternion defines the quaternion to check
  3703. * @returns true if the quaternion is identity
  3704. */
  3705. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3706. /**
  3707. * Creates a quaternion from a rotation around an axis
  3708. * @param axis defines the axis to use
  3709. * @param angle defines the angle to use
  3710. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3711. */
  3712. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3713. /**
  3714. * Creates a rotation around an axis and stores it into the given quaternion
  3715. * @param axis defines the axis to use
  3716. * @param angle defines the angle to use
  3717. * @param result defines the target quaternion
  3718. * @returns the target quaternion
  3719. */
  3720. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3721. /**
  3722. * Creates a new quaternion from data stored into an array
  3723. * @param array defines the data source
  3724. * @param offset defines the offset in the source array where the data starts
  3725. * @returns a new quaternion
  3726. */
  3727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3728. /**
  3729. * Create a quaternion from Euler rotation angles
  3730. * @param x Pitch
  3731. * @param y Yaw
  3732. * @param z Roll
  3733. * @returns the new Quaternion
  3734. */
  3735. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3736. /**
  3737. * Updates a quaternion from Euler rotation angles
  3738. * @param x Pitch
  3739. * @param y Yaw
  3740. * @param z Roll
  3741. * @param result the quaternion to store the result
  3742. * @returns the updated quaternion
  3743. */
  3744. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3745. /**
  3746. * Create a quaternion from Euler rotation vector
  3747. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3748. * @returns the new Quaternion
  3749. */
  3750. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3751. /**
  3752. * Updates a quaternion from Euler rotation vector
  3753. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3754. * @param result the quaternion to store the result
  3755. * @returns the updated quaternion
  3756. */
  3757. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3758. /**
  3759. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3760. * @param yaw defines the rotation around Y axis
  3761. * @param pitch defines the rotation around X axis
  3762. * @param roll defines the rotation around Z axis
  3763. * @returns the new quaternion
  3764. */
  3765. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3766. /**
  3767. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3768. * @param yaw defines the rotation around Y axis
  3769. * @param pitch defines the rotation around X axis
  3770. * @param roll defines the rotation around Z axis
  3771. * @param result defines the target quaternion
  3772. */
  3773. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3774. /**
  3775. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3776. * @param alpha defines the rotation around first axis
  3777. * @param beta defines the rotation around second axis
  3778. * @param gamma defines the rotation around third axis
  3779. * @returns the new quaternion
  3780. */
  3781. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3782. /**
  3783. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3784. * @param alpha defines the rotation around first axis
  3785. * @param beta defines the rotation around second axis
  3786. * @param gamma defines the rotation around third axis
  3787. * @param result defines the target quaternion
  3788. */
  3789. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3790. /**
  3791. * 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)
  3792. * @param axis1 defines the first axis
  3793. * @param axis2 defines the second axis
  3794. * @param axis3 defines the third axis
  3795. * @returns the new quaternion
  3796. */
  3797. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3798. /**
  3799. * 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
  3800. * @param axis1 defines the first axis
  3801. * @param axis2 defines the second axis
  3802. * @param axis3 defines the third axis
  3803. * @param ref defines the target quaternion
  3804. */
  3805. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3806. /**
  3807. * Interpolates between two quaternions
  3808. * @param left defines first quaternion
  3809. * @param right defines second quaternion
  3810. * @param amount defines the gradient to use
  3811. * @returns the new interpolated quaternion
  3812. */
  3813. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3814. /**
  3815. * Interpolates between two quaternions and stores it into a target quaternion
  3816. * @param left defines first quaternion
  3817. * @param right defines second quaternion
  3818. * @param amount defines the gradient to use
  3819. * @param result defines the target quaternion
  3820. */
  3821. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3822. /**
  3823. * Interpolate between two quaternions using Hermite interpolation
  3824. * @param value1 defines first quaternion
  3825. * @param tangent1 defines the incoming tangent
  3826. * @param value2 defines second quaternion
  3827. * @param tangent2 defines the outgoing tangent
  3828. * @param amount defines the target quaternion
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. }
  3833. /**
  3834. * Class used to store matrix data (4x4)
  3835. */
  3836. export class Matrix {
  3837. private static _updateFlagSeed;
  3838. private static _identityReadOnly;
  3839. private _isIdentity;
  3840. private _isIdentityDirty;
  3841. private _isIdentity3x2;
  3842. private _isIdentity3x2Dirty;
  3843. /**
  3844. * Gets the update flag of the matrix which is an unique number for the matrix.
  3845. * It will be incremented every time the matrix data change.
  3846. * You can use it to speed the comparison between two versions of the same matrix.
  3847. */
  3848. updateFlag: number;
  3849. private readonly _m;
  3850. /**
  3851. * Gets the internal data of the matrix
  3852. */
  3853. readonly m: DeepImmutable<Float32Array>;
  3854. /** @hidden */
  3855. _markAsUpdated(): void;
  3856. /** @hidden */
  3857. private _updateIdentityStatus;
  3858. /**
  3859. * Creates an empty matrix (filled with zeros)
  3860. */
  3861. constructor();
  3862. /**
  3863. * Check if the current matrix is identity
  3864. * @returns true is the matrix is the identity matrix
  3865. */
  3866. isIdentity(): boolean;
  3867. /**
  3868. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentityAs3x2(): boolean;
  3872. /**
  3873. * Gets the determinant of the matrix
  3874. * @returns the matrix determinant
  3875. */
  3876. determinant(): number;
  3877. /**
  3878. * Returns the matrix as a Float32Array
  3879. * @returns the matrix underlying array
  3880. */
  3881. toArray(): DeepImmutable<Float32Array>;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array.
  3885. */
  3886. asArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Inverts the current matrix in place
  3889. * @returns the current inverted matrix
  3890. */
  3891. invert(): Matrix;
  3892. /**
  3893. * Sets all the matrix elements to zero
  3894. * @returns the current matrix
  3895. */
  3896. reset(): Matrix;
  3897. /**
  3898. * Adds the current matrix with a second one
  3899. * @param other defines the matrix to add
  3900. * @returns a new matrix as the addition of the current matrix and the given one
  3901. */
  3902. add(other: DeepImmutable<Matrix>): Matrix;
  3903. /**
  3904. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3905. * @param other defines the matrix to add
  3906. * @param result defines the target matrix
  3907. * @returns the current matrix
  3908. */
  3909. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3910. /**
  3911. * Adds in place the given matrix to the current matrix
  3912. * @param other defines the second operand
  3913. * @returns the current updated matrix
  3914. */
  3915. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3916. /**
  3917. * Sets the given matrix to the current inverted Matrix
  3918. * @param other defines the target matrix
  3919. * @returns the unmodified current matrix
  3920. */
  3921. invertToRef(other: Matrix): Matrix;
  3922. /**
  3923. * add a value at the specified position in the current Matrix
  3924. * @param index the index of the value within the matrix. between 0 and 15.
  3925. * @param value the value to be added
  3926. * @returns the current updated matrix
  3927. */
  3928. addAtIndex(index: number, value: number): Matrix;
  3929. /**
  3930. * mutiply the specified position in the current Matrix by a value
  3931. * @param index the index of the value within the matrix. between 0 and 15.
  3932. * @param value the value to be added
  3933. * @returns the current updated matrix
  3934. */
  3935. multiplyAtIndex(index: number, value: number): Matrix;
  3936. /**
  3937. * Inserts the translation vector (using 3 floats) in the current matrix
  3938. * @param x defines the 1st component of the translation
  3939. * @param y defines the 2nd component of the translation
  3940. * @param z defines the 3rd component of the translation
  3941. * @returns the current updated matrix
  3942. */
  3943. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3944. /**
  3945. * Adds the translation vector (using 3 floats) in the current matrix
  3946. * @param x defines the 1st component of the translation
  3947. * @param y defines the 2nd component of the translation
  3948. * @param z defines the 3rd component of the translation
  3949. * @returns the current updated matrix
  3950. */
  3951. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3952. /**
  3953. * Inserts the translation vector in the current matrix
  3954. * @param vector3 defines the translation to insert
  3955. * @returns the current updated matrix
  3956. */
  3957. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3958. /**
  3959. * Gets the translation value of the current matrix
  3960. * @returns a new Vector3 as the extracted translation from the matrix
  3961. */
  3962. getTranslation(): Vector3;
  3963. /**
  3964. * Fill a Vector3 with the extracted translation from the matrix
  3965. * @param result defines the Vector3 where to store the translation
  3966. * @returns the current matrix
  3967. */
  3968. getTranslationToRef(result: Vector3): Matrix;
  3969. /**
  3970. * Remove rotation and scaling part from the matrix
  3971. * @returns the updated matrix
  3972. */
  3973. removeRotationAndScaling(): Matrix;
  3974. /**
  3975. * Multiply two matrices
  3976. * @param other defines the second operand
  3977. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3978. */
  3979. multiply(other: DeepImmutable<Matrix>): Matrix;
  3980. /**
  3981. * Copy the current matrix from the given one
  3982. * @param other defines the source matrix
  3983. * @returns the current updated matrix
  3984. */
  3985. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3986. /**
  3987. * Populates the given array from the starting index with the current matrix values
  3988. * @param array defines the target array
  3989. * @param offset defines the offset in the target array where to start storing values
  3990. * @returns the current matrix
  3991. */
  3992. copyToArray(array: Float32Array, offset?: number): Matrix;
  3993. /**
  3994. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3995. * @param other defines the second operand
  3996. * @param result defines the matrix where to store the multiplication
  3997. * @returns the current matrix
  3998. */
  3999. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4000. /**
  4001. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4002. * @param other defines the second operand
  4003. * @param result defines the array where to store the multiplication
  4004. * @param offset defines the offset in the target array where to start storing values
  4005. * @returns the current matrix
  4006. */
  4007. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4008. /**
  4009. * Check equality between this matrix and a second one
  4010. * @param value defines the second matrix to compare
  4011. * @returns true is the current matrix and the given one values are strictly equal
  4012. */
  4013. equals(value: DeepImmutable<Matrix>): boolean;
  4014. /**
  4015. * Clone the current matrix
  4016. * @returns a new matrix from the current matrix
  4017. */
  4018. clone(): Matrix;
  4019. /**
  4020. * Returns the name of the current matrix class
  4021. * @returns the string "Matrix"
  4022. */
  4023. getClassName(): string;
  4024. /**
  4025. * Gets the hash code of the current matrix
  4026. * @returns the hash code
  4027. */
  4028. getHashCode(): number;
  4029. /**
  4030. * Decomposes the current Matrix into a translation, rotation and scaling components
  4031. * @param scale defines the scale vector3 given as a reference to update
  4032. * @param rotation defines the rotation quaternion given as a reference to update
  4033. * @param translation defines the translation vector3 given as a reference to update
  4034. * @returns true if operation was successful
  4035. */
  4036. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4037. /**
  4038. * Gets specific row of the matrix
  4039. * @param index defines the number of the row to get
  4040. * @returns the index-th row of the current matrix as a new Vector4
  4041. */
  4042. getRow(index: number): Nullable<Vector4>;
  4043. /**
  4044. * Sets the index-th row of the current matrix to the vector4 values
  4045. * @param index defines the number of the row to set
  4046. * @param row defines the target vector4
  4047. * @returns the updated current matrix
  4048. */
  4049. setRow(index: number, row: Vector4): Matrix;
  4050. /**
  4051. * Compute the transpose of the matrix
  4052. * @returns the new transposed matrix
  4053. */
  4054. transpose(): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix and store it in a given matrix
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. transposeToRef(result: Matrix): Matrix;
  4061. /**
  4062. * Sets the index-th row of the current matrix with the given 4 x float values
  4063. * @param index defines the row index
  4064. * @param x defines the x component to set
  4065. * @param y defines the y component to set
  4066. * @param z defines the z component to set
  4067. * @param w defines the w component to set
  4068. * @returns the updated current matrix
  4069. */
  4070. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4071. /**
  4072. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4073. * @param scale defines the scale factor
  4074. * @returns a new matrix
  4075. */
  4076. scale(scale: number): Matrix;
  4077. /**
  4078. * Scale the current matrix values by a factor to a given result matrix
  4079. * @param scale defines the scale factor
  4080. * @param result defines the matrix to store the result
  4081. * @returns the current matrix
  4082. */
  4083. scaleToRef(scale: number, result: Matrix): Matrix;
  4084. /**
  4085. * Scale the current matrix values by a factor and add the result to a given matrix
  4086. * @param scale defines the scale factor
  4087. * @param result defines the Matrix to store the result
  4088. * @returns the current matrix
  4089. */
  4090. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4091. /**
  4092. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4093. * @param ref matrix to store the result
  4094. */
  4095. toNormalMatrix(ref: Matrix): void;
  4096. /**
  4097. * Gets only rotation part of the current matrix
  4098. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4099. */
  4100. getRotationMatrix(): Matrix;
  4101. /**
  4102. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4103. * @param result defines the target matrix to store data to
  4104. * @returns the current matrix
  4105. */
  4106. getRotationMatrixToRef(result: Matrix): Matrix;
  4107. /**
  4108. * Toggles model matrix from being right handed to left handed in place and vice versa
  4109. */
  4110. toggleModelMatrixHandInPlace(): void;
  4111. /**
  4112. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4113. */
  4114. toggleProjectionMatrixHandInPlace(): void;
  4115. /**
  4116. * Creates a matrix from an array
  4117. * @param array defines the source array
  4118. * @param offset defines an offset in the source array
  4119. * @returns a new Matrix set from the starting index of the given array
  4120. */
  4121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4122. /**
  4123. * Copy the content of an array into a given matrix
  4124. * @param array defines the source array
  4125. * @param offset defines an offset in the source array
  4126. * @param result defines the target matrix
  4127. */
  4128. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4129. /**
  4130. * Stores an array into a matrix after having multiplied each component by a given factor
  4131. * @param array defines the source array
  4132. * @param offset defines the offset in the source array
  4133. * @param scale defines the scaling factor
  4134. * @param result defines the target matrix
  4135. */
  4136. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4137. /**
  4138. * Gets an identity matrix that must not be updated
  4139. */
  4140. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4141. /**
  4142. * Stores a list of values (16) inside a given matrix
  4143. * @param initialM11 defines 1st value of 1st row
  4144. * @param initialM12 defines 2nd value of 1st row
  4145. * @param initialM13 defines 3rd value of 1st row
  4146. * @param initialM14 defines 4th value of 1st row
  4147. * @param initialM21 defines 1st value of 2nd row
  4148. * @param initialM22 defines 2nd value of 2nd row
  4149. * @param initialM23 defines 3rd value of 2nd row
  4150. * @param initialM24 defines 4th value of 2nd row
  4151. * @param initialM31 defines 1st value of 3rd row
  4152. * @param initialM32 defines 2nd value of 3rd row
  4153. * @param initialM33 defines 3rd value of 3rd row
  4154. * @param initialM34 defines 4th value of 3rd row
  4155. * @param initialM41 defines 1st value of 4th row
  4156. * @param initialM42 defines 2nd value of 4th row
  4157. * @param initialM43 defines 3rd value of 4th row
  4158. * @param initialM44 defines 4th value of 4th row
  4159. * @param result defines the target matrix
  4160. */
  4161. 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;
  4162. /**
  4163. * Creates new matrix from a list of values (16)
  4164. * @param initialM11 defines 1st value of 1st row
  4165. * @param initialM12 defines 2nd value of 1st row
  4166. * @param initialM13 defines 3rd value of 1st row
  4167. * @param initialM14 defines 4th value of 1st row
  4168. * @param initialM21 defines 1st value of 2nd row
  4169. * @param initialM22 defines 2nd value of 2nd row
  4170. * @param initialM23 defines 3rd value of 2nd row
  4171. * @param initialM24 defines 4th value of 2nd row
  4172. * @param initialM31 defines 1st value of 3rd row
  4173. * @param initialM32 defines 2nd value of 3rd row
  4174. * @param initialM33 defines 3rd value of 3rd row
  4175. * @param initialM34 defines 4th value of 3rd row
  4176. * @param initialM41 defines 1st value of 4th row
  4177. * @param initialM42 defines 2nd value of 4th row
  4178. * @param initialM43 defines 3rd value of 4th row
  4179. * @param initialM44 defines 4th value of 4th row
  4180. * @returns the new matrix
  4181. */
  4182. 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;
  4183. /**
  4184. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4185. * @param scale defines the scale vector3
  4186. * @param rotation defines the rotation quaternion
  4187. * @param translation defines the translation vector3
  4188. * @returns a new matrix
  4189. */
  4190. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4193. * @param scale defines the scale vector3
  4194. * @param rotation defines the rotation quaternion
  4195. * @param translation defines the translation vector3
  4196. * @param result defines the target matrix
  4197. */
  4198. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4199. /**
  4200. * Creates a new identity matrix
  4201. * @returns a new identity matrix
  4202. */
  4203. static Identity(): Matrix;
  4204. /**
  4205. * Creates a new identity matrix and stores the result in a given matrix
  4206. * @param result defines the target matrix
  4207. */
  4208. static IdentityToRef(result: Matrix): void;
  4209. /**
  4210. * Creates a new zero matrix
  4211. * @returns a new zero matrix
  4212. */
  4213. static Zero(): Matrix;
  4214. /**
  4215. * Creates a new rotation matrix for "angle" radians around the X axis
  4216. * @param angle defines the angle (in radians) to use
  4217. * @return the new matrix
  4218. */
  4219. static RotationX(angle: number): Matrix;
  4220. /**
  4221. * Creates a new matrix as the invert of a given matrix
  4222. * @param source defines the source matrix
  4223. * @returns the new matrix
  4224. */
  4225. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4226. /**
  4227. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4228. * @param angle defines the angle (in radians) to use
  4229. * @param result defines the target matrix
  4230. */
  4231. static RotationXToRef(angle: number, result: Matrix): void;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the Y axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationY(angle: number): Matrix;
  4238. /**
  4239. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4240. * @param angle defines the angle (in radians) to use
  4241. * @param result defines the target matrix
  4242. */
  4243. static RotationYToRef(angle: number, result: Matrix): void;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the Z axis
  4246. * @param angle defines the angle (in radians) to use
  4247. * @return the new matrix
  4248. */
  4249. static RotationZ(angle: number): Matrix;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4252. * @param angle defines the angle (in radians) to use
  4253. * @param result defines the target matrix
  4254. */
  4255. static RotationZToRef(angle: number, result: Matrix): void;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the given axis
  4258. * @param axis defines the axis to use
  4259. * @param angle defines the angle (in radians) to use
  4260. * @return the new matrix
  4261. */
  4262. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4263. /**
  4264. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4265. * @param axis defines the axis to use
  4266. * @param angle defines the angle (in radians) to use
  4267. * @param result defines the target matrix
  4268. */
  4269. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4270. /**
  4271. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4272. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4273. * @param from defines the vector to align
  4274. * @param to defines the vector to align to
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4278. /**
  4279. * Creates a rotation matrix
  4280. * @param yaw defines the yaw angle in radians (Y axis)
  4281. * @param pitch defines the pitch angle in radians (X axis)
  4282. * @param roll defines the roll angle in radians (X axis)
  4283. * @returns the new rotation matrix
  4284. */
  4285. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4286. /**
  4287. * Creates a rotation matrix and stores it in a given matrix
  4288. * @param yaw defines the yaw angle in radians (Y axis)
  4289. * @param pitch defines the pitch angle in radians (X axis)
  4290. * @param roll defines the roll angle in radians (X axis)
  4291. * @param result defines the target matrix
  4292. */
  4293. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4294. /**
  4295. * Creates a scaling matrix
  4296. * @param x defines the scale factor on X axis
  4297. * @param y defines the scale factor on Y axis
  4298. * @param z defines the scale factor on Z axis
  4299. * @returns the new matrix
  4300. */
  4301. static Scaling(x: number, y: number, z: number): Matrix;
  4302. /**
  4303. * Creates a scaling matrix and stores it in a given matrix
  4304. * @param x defines the scale factor on X axis
  4305. * @param y defines the scale factor on Y axis
  4306. * @param z defines the scale factor on Z axis
  4307. * @param result defines the target matrix
  4308. */
  4309. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4310. /**
  4311. * Creates a translation matrix
  4312. * @param x defines the translation on X axis
  4313. * @param y defines the translation on Y axis
  4314. * @param z defines the translationon Z axis
  4315. * @returns the new matrix
  4316. */
  4317. static Translation(x: number, y: number, z: number): Matrix;
  4318. /**
  4319. * Creates a translation matrix and stores it in a given matrix
  4320. * @param x defines the translation on X axis
  4321. * @param y defines the translation on Y axis
  4322. * @param z defines the translationon Z axis
  4323. * @param result defines the target matrix
  4324. */
  4325. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4326. /**
  4327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4328. * @param startValue defines the start value
  4329. * @param endValue defines the end value
  4330. * @param gradient defines the gradient factor
  4331. * @returns the new matrix
  4332. */
  4333. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4334. /**
  4335. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4336. * @param startValue defines the start value
  4337. * @param endValue defines the end value
  4338. * @param gradient defines the gradient factor
  4339. * @param result defines the Matrix object where to store data
  4340. */
  4341. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4342. /**
  4343. * Builds a new matrix whose values are computed by:
  4344. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4345. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4346. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4347. * @param startValue defines the first matrix
  4348. * @param endValue defines the second matrix
  4349. * @param gradient defines the gradient between the two matrices
  4350. * @returns the new matrix
  4351. */
  4352. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4353. /**
  4354. * Update a matrix to values which are computed by:
  4355. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4356. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4357. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4358. * @param startValue defines the first matrix
  4359. * @param endValue defines the second matrix
  4360. * @param gradient defines the gradient between the two matrices
  4361. * @param result defines the target matrix
  4362. */
  4363. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * 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"
  4366. * This function works in left handed mode
  4367. * @param eye defines the final position of the entity
  4368. * @param target defines where the entity should look at
  4369. * @param up defines the up vector for the entity
  4370. * @returns the new matrix
  4371. */
  4372. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4373. /**
  4374. * 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".
  4375. * This function works in left handed mode
  4376. * @param eye defines the final position of the entity
  4377. * @param target defines where the entity should look at
  4378. * @param up defines the up vector for the entity
  4379. * @param result defines the target matrix
  4380. */
  4381. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in right handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in right handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * Create a left-handed orthographic projection matrix
  4402. * @param width defines the viewport width
  4403. * @param height defines the viewport height
  4404. * @param znear defines the near clip plane
  4405. * @param zfar defines the far clip plane
  4406. * @returns a new matrix as a left-handed orthographic projection matrix
  4407. */
  4408. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4409. /**
  4410. * Store a left-handed orthographic projection to a given matrix
  4411. * @param width defines the viewport width
  4412. * @param height defines the viewport height
  4413. * @param znear defines the near clip plane
  4414. * @param zfar defines the far clip plane
  4415. * @param result defines the target matrix
  4416. */
  4417. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param left defines the viewport left coordinate
  4421. * @param right defines the viewport right coordinate
  4422. * @param bottom defines the viewport bottom coordinate
  4423. * @param top defines the viewport top coordinate
  4424. * @param znear defines the near clip plane
  4425. * @param zfar defines the far clip plane
  4426. * @returns a new matrix as a left-handed orthographic projection matrix
  4427. */
  4428. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4429. /**
  4430. * Stores a left-handed orthographic projection into a given matrix
  4431. * @param left defines the viewport left coordinate
  4432. * @param right defines the viewport right coordinate
  4433. * @param bottom defines the viewport bottom coordinate
  4434. * @param top defines the viewport top coordinate
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Creates a right-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a right-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a right-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a left-handed perspective projection matrix
  4464. * @param width defines the viewport width
  4465. * @param height defines the viewport height
  4466. * @param znear defines the near clip plane
  4467. * @param zfar defines the far clip plane
  4468. * @returns a new matrix as a left-handed perspective projection matrix
  4469. */
  4470. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4471. /**
  4472. * Creates a left-handed perspective projection matrix
  4473. * @param fov defines the horizontal field of view
  4474. * @param aspect defines the aspect ratio
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed perspective projection matrix
  4478. */
  4479. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed perspective projection into a given matrix
  4482. * @param fov defines the horizontal field of view
  4483. * @param aspect defines the aspect ratio
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4488. */
  4489. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4490. /**
  4491. * Creates a right-handed perspective projection matrix
  4492. * @param fov defines the horizontal field of view
  4493. * @param aspect defines the aspect ratio
  4494. * @param znear defines the near clip plane
  4495. * @param zfar defines the far clip plane
  4496. * @returns a new matrix as a right-handed perspective projection matrix
  4497. */
  4498. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4499. /**
  4500. * Stores a right-handed perspective projection into a given matrix
  4501. * @param fov defines the horizontal field of view
  4502. * @param aspect defines the aspect ratio
  4503. * @param znear defines the near clip plane
  4504. * @param zfar defines the far clip plane
  4505. * @param result defines the target matrix
  4506. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4507. */
  4508. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4509. /**
  4510. * Stores a perspective projection for WebVR info a given matrix
  4511. * @param fov defines the field of view
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4516. */
  4517. static PerspectiveFovWebVRToRef(fov: {
  4518. upDegrees: number;
  4519. downDegrees: number;
  4520. leftDegrees: number;
  4521. rightDegrees: number;
  4522. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4523. /**
  4524. * Computes a complete transformation matrix
  4525. * @param viewport defines the viewport to use
  4526. * @param world defines the world matrix
  4527. * @param view defines the view matrix
  4528. * @param projection defines the projection matrix
  4529. * @param zmin defines the near clip plane
  4530. * @param zmax defines the far clip plane
  4531. * @returns the transformation matrix
  4532. */
  4533. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4534. /**
  4535. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4536. * @param matrix defines the matrix to use
  4537. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4538. */
  4539. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4540. /**
  4541. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4542. * @param matrix defines the matrix to use
  4543. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4544. */
  4545. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4546. /**
  4547. * Compute the transpose of a given matrix
  4548. * @param matrix defines the matrix to transpose
  4549. * @returns the new matrix
  4550. */
  4551. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4552. /**
  4553. * Compute the transpose of a matrix and store it in a target matrix
  4554. * @param matrix defines the matrix to transpose
  4555. * @param result defines the target matrix
  4556. */
  4557. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4558. /**
  4559. * Computes a reflection matrix from a plane
  4560. * @param plane defines the reflection plane
  4561. * @returns a new matrix
  4562. */
  4563. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4564. /**
  4565. * Computes a reflection matrix from a plane
  4566. * @param plane defines the reflection plane
  4567. * @param result defines the target matrix
  4568. */
  4569. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4570. /**
  4571. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4572. * @param xaxis defines the value of the 1st axis
  4573. * @param yaxis defines the value of the 2nd axis
  4574. * @param zaxis defines the value of the 3rd axis
  4575. * @param result defines the target matrix
  4576. */
  4577. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4578. /**
  4579. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4580. * @param quat defines the quaternion to use
  4581. * @param result defines the target matrix
  4582. */
  4583. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4584. }
  4585. /**
  4586. * @hidden
  4587. */
  4588. export class TmpVectors {
  4589. static Vector2: Vector2[];
  4590. static Vector3: Vector3[];
  4591. static Vector4: Vector4[];
  4592. static Quaternion: Quaternion[];
  4593. static Matrix: Matrix[];
  4594. }
  4595. }
  4596. declare module "babylonjs/Maths/math.path" {
  4597. import { DeepImmutable, Nullable } from "babylonjs/types";
  4598. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4599. /**
  4600. * Defines potential orientation for back face culling
  4601. */
  4602. export enum Orientation {
  4603. /**
  4604. * Clockwise
  4605. */
  4606. CW = 0,
  4607. /** Counter clockwise */
  4608. CCW = 1
  4609. }
  4610. /** Class used to represent a Bezier curve */
  4611. export class BezierCurve {
  4612. /**
  4613. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4614. * @param t defines the time
  4615. * @param x1 defines the left coordinate on X axis
  4616. * @param y1 defines the left coordinate on Y axis
  4617. * @param x2 defines the right coordinate on X axis
  4618. * @param y2 defines the right coordinate on Y axis
  4619. * @returns the interpolated value
  4620. */
  4621. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4622. }
  4623. /**
  4624. * Defines angle representation
  4625. */
  4626. export class Angle {
  4627. private _radians;
  4628. /**
  4629. * Creates an Angle object of "radians" radians (float).
  4630. * @param radians the angle in radians
  4631. */
  4632. constructor(radians: number);
  4633. /**
  4634. * Get value in degrees
  4635. * @returns the Angle value in degrees (float)
  4636. */
  4637. degrees(): number;
  4638. /**
  4639. * Get value in radians
  4640. * @returns the Angle value in radians (float)
  4641. */
  4642. radians(): number;
  4643. /**
  4644. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4645. * @param a defines first vector
  4646. * @param b defines second vector
  4647. * @returns a new Angle
  4648. */
  4649. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4650. /**
  4651. * Gets a new Angle object from the given float in radians
  4652. * @param radians defines the angle value in radians
  4653. * @returns a new Angle
  4654. */
  4655. static FromRadians(radians: number): Angle;
  4656. /**
  4657. * Gets a new Angle object from the given float in degrees
  4658. * @param degrees defines the angle value in degrees
  4659. * @returns a new Angle
  4660. */
  4661. static FromDegrees(degrees: number): Angle;
  4662. }
  4663. /**
  4664. * This represents an arc in a 2d space.
  4665. */
  4666. export class Arc2 {
  4667. /** Defines the start point of the arc */
  4668. startPoint: Vector2;
  4669. /** Defines the mid point of the arc */
  4670. midPoint: Vector2;
  4671. /** Defines the end point of the arc */
  4672. endPoint: Vector2;
  4673. /**
  4674. * Defines the center point of the arc.
  4675. */
  4676. centerPoint: Vector2;
  4677. /**
  4678. * Defines the radius of the arc.
  4679. */
  4680. radius: number;
  4681. /**
  4682. * Defines the angle of the arc (from mid point to end point).
  4683. */
  4684. angle: Angle;
  4685. /**
  4686. * Defines the start angle of the arc (from start point to middle point).
  4687. */
  4688. startAngle: Angle;
  4689. /**
  4690. * Defines the orientation of the arc (clock wise/counter clock wise).
  4691. */
  4692. orientation: Orientation;
  4693. /**
  4694. * Creates an Arc object from the three given points : start, middle and end.
  4695. * @param startPoint Defines the start point of the arc
  4696. * @param midPoint Defines the midlle point of the arc
  4697. * @param endPoint Defines the end point of the arc
  4698. */
  4699. constructor(
  4700. /** Defines the start point of the arc */
  4701. startPoint: Vector2,
  4702. /** Defines the mid point of the arc */
  4703. midPoint: Vector2,
  4704. /** Defines the end point of the arc */
  4705. endPoint: Vector2);
  4706. }
  4707. /**
  4708. * Represents a 2D path made up of multiple 2D points
  4709. */
  4710. export class Path2 {
  4711. private _points;
  4712. private _length;
  4713. /**
  4714. * If the path start and end point are the same
  4715. */
  4716. closed: boolean;
  4717. /**
  4718. * Creates a Path2 object from the starting 2D coordinates x and y.
  4719. * @param x the starting points x value
  4720. * @param y the starting points y value
  4721. */
  4722. constructor(x: number, y: number);
  4723. /**
  4724. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4725. * @param x the added points x value
  4726. * @param y the added points y value
  4727. * @returns the updated Path2.
  4728. */
  4729. addLineTo(x: number, y: number): Path2;
  4730. /**
  4731. * 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.
  4732. * @param midX middle point x value
  4733. * @param midY middle point y value
  4734. * @param endX end point x value
  4735. * @param endY end point y value
  4736. * @param numberOfSegments (default: 36)
  4737. * @returns the updated Path2.
  4738. */
  4739. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4740. /**
  4741. * Closes the Path2.
  4742. * @returns the Path2.
  4743. */
  4744. close(): Path2;
  4745. /**
  4746. * Gets the sum of the distance between each sequential point in the path
  4747. * @returns the Path2 total length (float).
  4748. */
  4749. length(): number;
  4750. /**
  4751. * Gets the points which construct the path
  4752. * @returns the Path2 internal array of points.
  4753. */
  4754. getPoints(): Vector2[];
  4755. /**
  4756. * Retreives the point at the distance aways from the starting point
  4757. * @param normalizedLengthPosition the length along the path to retreive the point from
  4758. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4759. */
  4760. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4761. /**
  4762. * Creates a new path starting from an x and y position
  4763. * @param x starting x value
  4764. * @param y starting y value
  4765. * @returns a new Path2 starting at the coordinates (x, y).
  4766. */
  4767. static StartingAt(x: number, y: number): Path2;
  4768. }
  4769. /**
  4770. * Represents a 3D path made up of multiple 3D points
  4771. */
  4772. export class Path3D {
  4773. /**
  4774. * an array of Vector3, the curve axis of the Path3D
  4775. */
  4776. path: Vector3[];
  4777. private _curve;
  4778. private _distances;
  4779. private _tangents;
  4780. private _normals;
  4781. private _binormals;
  4782. private _raw;
  4783. /**
  4784. * new Path3D(path, normal, raw)
  4785. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4786. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4787. * @param path an array of Vector3, the curve axis of the Path3D
  4788. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4789. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4790. */
  4791. constructor(
  4792. /**
  4793. * an array of Vector3, the curve axis of the Path3D
  4794. */
  4795. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4796. /**
  4797. * Returns the Path3D array of successive Vector3 designing its curve.
  4798. * @returns the Path3D array of successive Vector3 designing its curve.
  4799. */
  4800. getCurve(): Vector3[];
  4801. /**
  4802. * Returns an array populated with tangent vectors on each Path3D curve point.
  4803. * @returns an array populated with tangent vectors on each Path3D curve point.
  4804. */
  4805. getTangents(): Vector3[];
  4806. /**
  4807. * Returns an array populated with normal vectors on each Path3D curve point.
  4808. * @returns an array populated with normal vectors on each Path3D curve point.
  4809. */
  4810. getNormals(): Vector3[];
  4811. /**
  4812. * Returns an array populated with binormal vectors on each Path3D curve point.
  4813. * @returns an array populated with binormal vectors on each Path3D curve point.
  4814. */
  4815. getBinormals(): Vector3[];
  4816. /**
  4817. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4818. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4819. */
  4820. getDistances(): number[];
  4821. /**
  4822. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4823. * @param path path which all values are copied into the curves points
  4824. * @param firstNormal which should be projected onto the curve
  4825. * @returns the same object updated.
  4826. */
  4827. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4828. private _compute;
  4829. private _getFirstNonNullVector;
  4830. private _getLastNonNullVector;
  4831. private _normalVector;
  4832. }
  4833. /**
  4834. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4835. * A Curve3 is designed from a series of successive Vector3.
  4836. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4837. */
  4838. export class Curve3 {
  4839. private _points;
  4840. private _length;
  4841. /**
  4842. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4843. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4844. * @param v1 (Vector3) the control point
  4845. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4846. * @param nbPoints (integer) the wanted number of points in the curve
  4847. * @returns the created Curve3
  4848. */
  4849. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4850. /**
  4851. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4852. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4853. * @param v1 (Vector3) the first control point
  4854. * @param v2 (Vector3) the second control point
  4855. * @param v3 (Vector3) the end point of the Cubic Bezier
  4856. * @param nbPoints (integer) the wanted number of points in the curve
  4857. * @returns the created Curve3
  4858. */
  4859. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4860. /**
  4861. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4862. * @param p1 (Vector3) the origin point of the Hermite Spline
  4863. * @param t1 (Vector3) the tangent vector at the origin point
  4864. * @param p2 (Vector3) the end point of the Hermite Spline
  4865. * @param t2 (Vector3) the tangent vector at the end point
  4866. * @param nbPoints (integer) the wanted number of points in the curve
  4867. * @returns the created Curve3
  4868. */
  4869. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4870. /**
  4871. * Returns a Curve3 object along a CatmullRom Spline curve :
  4872. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4873. * @param nbPoints (integer) the wanted number of points between each curve control points
  4874. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4875. * @returns the created Curve3
  4876. */
  4877. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4878. /**
  4879. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4880. * A Curve3 is designed from a series of successive Vector3.
  4881. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4882. * @param points points which make up the curve
  4883. */
  4884. constructor(points: Vector3[]);
  4885. /**
  4886. * @returns the Curve3 stored array of successive Vector3
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the curve.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4895. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4896. * curveA and curveB keep unchanged.
  4897. * @param curve the curve to continue from this curve
  4898. * @returns the newly constructed curve
  4899. */
  4900. continue(curve: DeepImmutable<Curve3>): Curve3;
  4901. private _computeLength;
  4902. }
  4903. }
  4904. declare module "babylonjs/Animations/easing" {
  4905. /**
  4906. * This represents the main contract an easing function should follow.
  4907. * Easing functions are used throughout the animation system.
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export interface IEasingFunction {
  4911. /**
  4912. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4913. * of the easing function.
  4914. * The link below provides some of the most common examples of easing functions.
  4915. * @see https://easings.net/
  4916. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4917. * @returns the corresponding value on the curve defined by the easing function
  4918. */
  4919. ease(gradient: number): number;
  4920. }
  4921. /**
  4922. * Base class used for every default easing function.
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. export class EasingFunction implements IEasingFunction {
  4926. /**
  4927. * Interpolation follows the mathematical formula associated with the easing function.
  4928. */
  4929. static readonly EASINGMODE_EASEIN: number;
  4930. /**
  4931. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4932. */
  4933. static readonly EASINGMODE_EASEOUT: number;
  4934. /**
  4935. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4936. */
  4937. static readonly EASINGMODE_EASEINOUT: number;
  4938. private _easingMode;
  4939. /**
  4940. * Sets the easing mode of the current function.
  4941. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4942. */
  4943. setEasingMode(easingMode: number): void;
  4944. /**
  4945. * Gets the current easing mode.
  4946. * @returns the easing mode
  4947. */
  4948. getEasingMode(): number;
  4949. /**
  4950. * @hidden
  4951. */
  4952. easeInCore(gradient: number): number;
  4953. /**
  4954. * Given an input gradient between 0 and 1, this returns the corresponding value
  4955. * of the easing function.
  4956. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4957. * @returns the corresponding value on the curve defined by the easing function
  4958. */
  4959. ease(gradient: number): number;
  4960. }
  4961. /**
  4962. * Easing function with a circle shape (see link below).
  4963. * @see https://easings.net/#easeInCirc
  4964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4965. */
  4966. export class CircleEase extends EasingFunction implements IEasingFunction {
  4967. /** @hidden */
  4968. easeInCore(gradient: number): number;
  4969. }
  4970. /**
  4971. * Easing function with a ease back shape (see link below).
  4972. * @see https://easings.net/#easeInBack
  4973. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4974. */
  4975. export class BackEase extends EasingFunction implements IEasingFunction {
  4976. /** Defines the amplitude of the function */
  4977. amplitude: number;
  4978. /**
  4979. * Instantiates a back ease easing
  4980. * @see https://easings.net/#easeInBack
  4981. * @param amplitude Defines the amplitude of the function
  4982. */
  4983. constructor(
  4984. /** Defines the amplitude of the function */
  4985. amplitude?: number);
  4986. /** @hidden */
  4987. easeInCore(gradient: number): number;
  4988. }
  4989. /**
  4990. * Easing function with a bouncing shape (see link below).
  4991. * @see https://easings.net/#easeInBounce
  4992. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4993. */
  4994. export class BounceEase extends EasingFunction implements IEasingFunction {
  4995. /** Defines the number of bounces */
  4996. bounces: number;
  4997. /** Defines the amplitude of the bounce */
  4998. bounciness: number;
  4999. /**
  5000. * Instantiates a bounce easing
  5001. * @see https://easings.net/#easeInBounce
  5002. * @param bounces Defines the number of bounces
  5003. * @param bounciness Defines the amplitude of the bounce
  5004. */
  5005. constructor(
  5006. /** Defines the number of bounces */
  5007. bounces?: number,
  5008. /** Defines the amplitude of the bounce */
  5009. bounciness?: number);
  5010. /** @hidden */
  5011. easeInCore(gradient: number): number;
  5012. }
  5013. /**
  5014. * Easing function with a power of 3 shape (see link below).
  5015. * @see https://easings.net/#easeInCubic
  5016. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5017. */
  5018. export class CubicEase extends EasingFunction implements IEasingFunction {
  5019. /** @hidden */
  5020. easeInCore(gradient: number): number;
  5021. }
  5022. /**
  5023. * Easing function with an elastic shape (see link below).
  5024. * @see https://easings.net/#easeInElastic
  5025. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5026. */
  5027. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5028. /** Defines the number of oscillations*/
  5029. oscillations: number;
  5030. /** Defines the amplitude of the oscillations*/
  5031. springiness: number;
  5032. /**
  5033. * Instantiates an elastic easing function
  5034. * @see https://easings.net/#easeInElastic
  5035. * @param oscillations Defines the number of oscillations
  5036. * @param springiness Defines the amplitude of the oscillations
  5037. */
  5038. constructor(
  5039. /** Defines the number of oscillations*/
  5040. oscillations?: number,
  5041. /** Defines the amplitude of the oscillations*/
  5042. springiness?: number);
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with an exponential shape (see link below).
  5048. * @see https://easings.net/#easeInExpo
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5052. /** Defines the exponent of the function */
  5053. exponent: number;
  5054. /**
  5055. * Instantiates an exponential easing function
  5056. * @see https://easings.net/#easeInExpo
  5057. * @param exponent Defines the exponent of the function
  5058. */
  5059. constructor(
  5060. /** Defines the exponent of the function */
  5061. exponent?: number);
  5062. /** @hidden */
  5063. easeInCore(gradient: number): number;
  5064. }
  5065. /**
  5066. * Easing function with a power shape (see link below).
  5067. * @see https://easings.net/#easeInQuad
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export class PowerEase extends EasingFunction implements IEasingFunction {
  5071. /** Defines the power of the function */
  5072. power: number;
  5073. /**
  5074. * Instantiates an power base easing function
  5075. * @see https://easings.net/#easeInQuad
  5076. * @param power Defines the power of the function
  5077. */
  5078. constructor(
  5079. /** Defines the power of the function */
  5080. power?: number);
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a power of 2 shape (see link below).
  5086. * @see https://easings.net/#easeInQuad
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5090. /** @hidden */
  5091. easeInCore(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a power of 4 shape (see link below).
  5095. * @see https://easings.net/#easeInQuart
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a power of 5 shape (see link below).
  5104. * @see https://easings.net/#easeInQuint
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5108. /** @hidden */
  5109. easeInCore(gradient: number): number;
  5110. }
  5111. /**
  5112. * Easing function with a sin shape (see link below).
  5113. * @see https://easings.net/#easeInSine
  5114. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5115. */
  5116. export class SineEase extends EasingFunction implements IEasingFunction {
  5117. /** @hidden */
  5118. easeInCore(gradient: number): number;
  5119. }
  5120. /**
  5121. * Easing function with a bezier shape (see link below).
  5122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5123. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5124. */
  5125. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5126. /** Defines the x component of the start tangent in the bezier curve */
  5127. x1: number;
  5128. /** Defines the y component of the start tangent in the bezier curve */
  5129. y1: number;
  5130. /** Defines the x component of the end tangent in the bezier curve */
  5131. x2: number;
  5132. /** Defines the y component of the end tangent in the bezier curve */
  5133. y2: number;
  5134. /**
  5135. * Instantiates a bezier function
  5136. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5137. * @param x1 Defines the x component of the start tangent in the bezier curve
  5138. * @param y1 Defines the y component of the start tangent in the bezier curve
  5139. * @param x2 Defines the x component of the end tangent in the bezier curve
  5140. * @param y2 Defines the y component of the end tangent in the bezier curve
  5141. */
  5142. constructor(
  5143. /** Defines the x component of the start tangent in the bezier curve */
  5144. x1?: number,
  5145. /** Defines the y component of the start tangent in the bezier curve */
  5146. y1?: number,
  5147. /** Defines the x component of the end tangent in the bezier curve */
  5148. x2?: number,
  5149. /** Defines the y component of the end tangent in the bezier curve */
  5150. y2?: number);
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. }
  5155. declare module "babylonjs/Maths/math.color" {
  5156. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5157. /**
  5158. * Class used to hold a RBG color
  5159. */
  5160. export class Color3 {
  5161. /**
  5162. * Defines the red component (between 0 and 1, default is 0)
  5163. */
  5164. r: number;
  5165. /**
  5166. * Defines the green component (between 0 and 1, default is 0)
  5167. */
  5168. g: number;
  5169. /**
  5170. * Defines the blue component (between 0 and 1, default is 0)
  5171. */
  5172. b: number;
  5173. /**
  5174. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5175. * @param r defines the red component (between 0 and 1, default is 0)
  5176. * @param g defines the green component (between 0 and 1, default is 0)
  5177. * @param b defines the blue component (between 0 and 1, default is 0)
  5178. */
  5179. constructor(
  5180. /**
  5181. * Defines the red component (between 0 and 1, default is 0)
  5182. */
  5183. r?: number,
  5184. /**
  5185. * Defines the green component (between 0 and 1, default is 0)
  5186. */
  5187. g?: number,
  5188. /**
  5189. * Defines the blue component (between 0 and 1, default is 0)
  5190. */
  5191. b?: number);
  5192. /**
  5193. * Creates a string with the Color3 current values
  5194. * @returns the string representation of the Color3 object
  5195. */
  5196. toString(): string;
  5197. /**
  5198. * Returns the string "Color3"
  5199. * @returns "Color3"
  5200. */
  5201. getClassName(): string;
  5202. /**
  5203. * Compute the Color3 hash code
  5204. * @returns an unique number that can be used to hash Color3 objects
  5205. */
  5206. getHashCode(): number;
  5207. /**
  5208. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5209. * @param array defines the array where to store the r,g,b components
  5210. * @param index defines an optional index in the target array to define where to start storing values
  5211. * @returns the current Color3 object
  5212. */
  5213. toArray(array: FloatArray, index?: number): Color3;
  5214. /**
  5215. * Returns a new Color4 object from the current Color3 and the given alpha
  5216. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5217. * @returns a new Color4 object
  5218. */
  5219. toColor4(alpha?: number): Color4;
  5220. /**
  5221. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5222. * @returns the new array
  5223. */
  5224. asArray(): number[];
  5225. /**
  5226. * Returns the luminance value
  5227. * @returns a float value
  5228. */
  5229. toLuminance(): number;
  5230. /**
  5231. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5232. * @param otherColor defines the second operand
  5233. * @returns the new Color3 object
  5234. */
  5235. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5236. /**
  5237. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5238. * @param otherColor defines the second operand
  5239. * @param result defines the Color3 object where to store the result
  5240. * @returns the current Color3
  5241. */
  5242. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5243. /**
  5244. * Determines equality between Color3 objects
  5245. * @param otherColor defines the second operand
  5246. * @returns true if the rgb values are equal to the given ones
  5247. */
  5248. equals(otherColor: DeepImmutable<Color3>): boolean;
  5249. /**
  5250. * Determines equality between the current Color3 object and a set of r,b,g values
  5251. * @param r defines the red component to check
  5252. * @param g defines the green component to check
  5253. * @param b defines the blue component to check
  5254. * @returns true if the rgb values are equal to the given ones
  5255. */
  5256. equalsFloats(r: number, g: number, b: number): boolean;
  5257. /**
  5258. * Multiplies in place each rgb value by scale
  5259. * @param scale defines the scaling factor
  5260. * @returns the updated Color3
  5261. */
  5262. scale(scale: number): Color3;
  5263. /**
  5264. * Multiplies the rgb values by scale and stores the result into "result"
  5265. * @param scale defines the scaling factor
  5266. * @param result defines the Color3 object where to store the result
  5267. * @returns the unmodified current Color3
  5268. */
  5269. scaleToRef(scale: number, result: Color3): Color3;
  5270. /**
  5271. * Scale the current Color3 values by a factor and add the result to a given Color3
  5272. * @param scale defines the scale factor
  5273. * @param result defines color to store the result into
  5274. * @returns the unmodified current Color3
  5275. */
  5276. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5277. /**
  5278. * Clamps the rgb values by the min and max values and stores the result into "result"
  5279. * @param min defines minimum clamping value (default is 0)
  5280. * @param max defines maximum clamping value (default is 1)
  5281. * @param result defines color to store the result into
  5282. * @returns the original Color3
  5283. */
  5284. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5285. /**
  5286. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5287. * @param otherColor defines the second operand
  5288. * @returns the new Color3
  5289. */
  5290. add(otherColor: DeepImmutable<Color3>): Color3;
  5291. /**
  5292. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5293. * @param otherColor defines the second operand
  5294. * @param result defines Color3 object to store the result into
  5295. * @returns the unmodified current Color3
  5296. */
  5297. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5298. /**
  5299. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5300. * @param otherColor defines the second operand
  5301. * @returns the new Color3
  5302. */
  5303. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5304. /**
  5305. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5306. * @param otherColor defines the second operand
  5307. * @param result defines Color3 object to store the result into
  5308. * @returns the unmodified current Color3
  5309. */
  5310. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5311. /**
  5312. * Copy the current object
  5313. * @returns a new Color3 copied the current one
  5314. */
  5315. clone(): Color3;
  5316. /**
  5317. * Copies the rgb values from the source in the current Color3
  5318. * @param source defines the source Color3 object
  5319. * @returns the updated Color3 object
  5320. */
  5321. copyFrom(source: DeepImmutable<Color3>): Color3;
  5322. /**
  5323. * Updates the Color3 rgb values from the given floats
  5324. * @param r defines the red component to read from
  5325. * @param g defines the green component to read from
  5326. * @param b defines the blue component to read from
  5327. * @returns the current Color3 object
  5328. */
  5329. copyFromFloats(r: number, g: number, b: number): Color3;
  5330. /**
  5331. * Updates the Color3 rgb values from the given floats
  5332. * @param r defines the red component to read from
  5333. * @param g defines the green component to read from
  5334. * @param b defines the blue component to read from
  5335. * @returns the current Color3 object
  5336. */
  5337. set(r: number, g: number, b: number): Color3;
  5338. /**
  5339. * Compute the Color3 hexadecimal code as a string
  5340. * @returns a string containing the hexadecimal representation of the Color3 object
  5341. */
  5342. toHexString(): string;
  5343. /**
  5344. * Computes a new Color3 converted from the current one to linear space
  5345. * @returns a new Color3 object
  5346. */
  5347. toLinearSpace(): Color3;
  5348. /**
  5349. * Converts current color in rgb space to HSV values
  5350. * @returns a new color3 representing the HSV values
  5351. */
  5352. toHSV(): Color3;
  5353. /**
  5354. * Converts current color in rgb space to HSV values
  5355. * @param result defines the Color3 where to store the HSV values
  5356. */
  5357. toHSVToRef(result: Color3): void;
  5358. /**
  5359. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5360. * @param convertedColor defines the Color3 object where to store the linear space version
  5361. * @returns the unmodified Color3
  5362. */
  5363. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5364. /**
  5365. * Computes a new Color3 converted from the current one to gamma space
  5366. * @returns a new Color3 object
  5367. */
  5368. toGammaSpace(): Color3;
  5369. /**
  5370. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5371. * @param convertedColor defines the Color3 object where to store the gamma space version
  5372. * @returns the unmodified Color3
  5373. */
  5374. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5375. private static _BlackReadOnly;
  5376. /**
  5377. * Convert Hue, saturation and value to a Color3 (RGB)
  5378. * @param hue defines the hue
  5379. * @param saturation defines the saturation
  5380. * @param value defines the value
  5381. * @param result defines the Color3 where to store the RGB values
  5382. */
  5383. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5384. /**
  5385. * Creates a new Color3 from the string containing valid hexadecimal values
  5386. * @param hex defines a string containing valid hexadecimal values
  5387. * @returns a new Color3 object
  5388. */
  5389. static FromHexString(hex: string): Color3;
  5390. /**
  5391. * Creates a new Color3 from the starting index of the given array
  5392. * @param array defines the source array
  5393. * @param offset defines an offset in the source array
  5394. * @returns a new Color3 object
  5395. */
  5396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5397. /**
  5398. * Creates a new Color3 from integer values (< 256)
  5399. * @param r defines the red component to read from (value between 0 and 255)
  5400. * @param g defines the green component to read from (value between 0 and 255)
  5401. * @param b defines the blue component to read from (value between 0 and 255)
  5402. * @returns a new Color3 object
  5403. */
  5404. static FromInts(r: number, g: number, b: number): Color3;
  5405. /**
  5406. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5407. * @param start defines the start Color3 value
  5408. * @param end defines the end Color3 value
  5409. * @param amount defines the gradient value between start and end
  5410. * @returns a new Color3 object
  5411. */
  5412. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5413. /**
  5414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5415. * @param left defines the start value
  5416. * @param right defines the end value
  5417. * @param amount defines the gradient factor
  5418. * @param result defines the Color3 object where to store the result
  5419. */
  5420. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5421. /**
  5422. * Returns a Color3 value containing a red color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Red(): Color3;
  5426. /**
  5427. * Returns a Color3 value containing a green color
  5428. * @returns a new Color3 object
  5429. */
  5430. static Green(): Color3;
  5431. /**
  5432. * Returns a Color3 value containing a blue color
  5433. * @returns a new Color3 object
  5434. */
  5435. static Blue(): Color3;
  5436. /**
  5437. * Returns a Color3 value containing a black color
  5438. * @returns a new Color3 object
  5439. */
  5440. static Black(): Color3;
  5441. /**
  5442. * Gets a Color3 value containing a black color that must not be updated
  5443. */
  5444. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5445. /**
  5446. * Returns a Color3 value containing a white color
  5447. * @returns a new Color3 object
  5448. */
  5449. static White(): Color3;
  5450. /**
  5451. * Returns a Color3 value containing a purple color
  5452. * @returns a new Color3 object
  5453. */
  5454. static Purple(): Color3;
  5455. /**
  5456. * Returns a Color3 value containing a magenta color
  5457. * @returns a new Color3 object
  5458. */
  5459. static Magenta(): Color3;
  5460. /**
  5461. * Returns a Color3 value containing a yellow color
  5462. * @returns a new Color3 object
  5463. */
  5464. static Yellow(): Color3;
  5465. /**
  5466. * Returns a Color3 value containing a gray color
  5467. * @returns a new Color3 object
  5468. */
  5469. static Gray(): Color3;
  5470. /**
  5471. * Returns a Color3 value containing a teal color
  5472. * @returns a new Color3 object
  5473. */
  5474. static Teal(): Color3;
  5475. /**
  5476. * Returns a Color3 value containing a random color
  5477. * @returns a new Color3 object
  5478. */
  5479. static Random(): Color3;
  5480. }
  5481. /**
  5482. * Class used to hold a RBGA color
  5483. */
  5484. export class Color4 {
  5485. /**
  5486. * Defines the red component (between 0 and 1, default is 0)
  5487. */
  5488. r: number;
  5489. /**
  5490. * Defines the green component (between 0 and 1, default is 0)
  5491. */
  5492. g: number;
  5493. /**
  5494. * Defines the blue component (between 0 and 1, default is 0)
  5495. */
  5496. b: number;
  5497. /**
  5498. * Defines the alpha component (between 0 and 1, default is 1)
  5499. */
  5500. a: number;
  5501. /**
  5502. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5503. * @param r defines the red component (between 0 and 1, default is 0)
  5504. * @param g defines the green component (between 0 and 1, default is 0)
  5505. * @param b defines the blue component (between 0 and 1, default is 0)
  5506. * @param a defines the alpha component (between 0 and 1, default is 1)
  5507. */
  5508. constructor(
  5509. /**
  5510. * Defines the red component (between 0 and 1, default is 0)
  5511. */
  5512. r?: number,
  5513. /**
  5514. * Defines the green component (between 0 and 1, default is 0)
  5515. */
  5516. g?: number,
  5517. /**
  5518. * Defines the blue component (between 0 and 1, default is 0)
  5519. */
  5520. b?: number,
  5521. /**
  5522. * Defines the alpha component (between 0 and 1, default is 1)
  5523. */
  5524. a?: number);
  5525. /**
  5526. * Adds in place the given Color4 values to the current Color4 object
  5527. * @param right defines the second operand
  5528. * @returns the current updated Color4 object
  5529. */
  5530. addInPlace(right: DeepImmutable<Color4>): Color4;
  5531. /**
  5532. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5533. * @returns the new array
  5534. */
  5535. asArray(): number[];
  5536. /**
  5537. * Stores from the starting index in the given array the Color4 successive values
  5538. * @param array defines the array where to store the r,g,b components
  5539. * @param index defines an optional index in the target array to define where to start storing values
  5540. * @returns the current Color4 object
  5541. */
  5542. toArray(array: number[], index?: number): Color4;
  5543. /**
  5544. * Determines equality between Color4 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgba values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color4>): boolean;
  5549. /**
  5550. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5551. * @param right defines the second operand
  5552. * @returns a new Color4 object
  5553. */
  5554. add(right: DeepImmutable<Color4>): Color4;
  5555. /**
  5556. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5557. * @param right defines the second operand
  5558. * @returns a new Color4 object
  5559. */
  5560. subtract(right: DeepImmutable<Color4>): Color4;
  5561. /**
  5562. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5563. * @param right defines the second operand
  5564. * @param result defines the Color4 object where to store the result
  5565. * @returns the current Color4 object
  5566. */
  5567. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5568. /**
  5569. * Creates a new Color4 with the current Color4 values multiplied by scale
  5570. * @param scale defines the scaling factor to apply
  5571. * @returns a new Color4 object
  5572. */
  5573. scale(scale: number): Color4;
  5574. /**
  5575. * Multiplies the current Color4 values by scale and stores the result in "result"
  5576. * @param scale defines the scaling factor to apply
  5577. * @param result defines the Color4 object where to store the result
  5578. * @returns the current unmodified Color4
  5579. */
  5580. scaleToRef(scale: number, result: Color4): Color4;
  5581. /**
  5582. * Scale the current Color4 values by a factor and add the result to a given Color4
  5583. * @param scale defines the scale factor
  5584. * @param result defines the Color4 object where to store the result
  5585. * @returns the unmodified current Color4
  5586. */
  5587. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5588. /**
  5589. * Clamps the rgb values by the min and max values and stores the result into "result"
  5590. * @param min defines minimum clamping value (default is 0)
  5591. * @param max defines maximum clamping value (default is 1)
  5592. * @param result defines color to store the result into.
  5593. * @returns the cuurent Color4
  5594. */
  5595. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5596. /**
  5597. * Multipy an Color4 value by another and return a new Color4 object
  5598. * @param color defines the Color4 value to multiply by
  5599. * @returns a new Color4 object
  5600. */
  5601. multiply(color: Color4): Color4;
  5602. /**
  5603. * Multipy a Color4 value by another and push the result in a reference value
  5604. * @param color defines the Color4 value to multiply by
  5605. * @param result defines the Color4 to fill the result in
  5606. * @returns the result Color4
  5607. */
  5608. multiplyToRef(color: Color4, result: Color4): Color4;
  5609. /**
  5610. * Creates a string with the Color4 current values
  5611. * @returns the string representation of the Color4 object
  5612. */
  5613. toString(): string;
  5614. /**
  5615. * Returns the string "Color4"
  5616. * @returns "Color4"
  5617. */
  5618. getClassName(): string;
  5619. /**
  5620. * Compute the Color4 hash code
  5621. * @returns an unique number that can be used to hash Color4 objects
  5622. */
  5623. getHashCode(): number;
  5624. /**
  5625. * Creates a new Color4 copied from the current one
  5626. * @returns a new Color4 object
  5627. */
  5628. clone(): Color4;
  5629. /**
  5630. * Copies the given Color4 values into the current one
  5631. * @param source defines the source Color4 object
  5632. * @returns the current updated Color4 object
  5633. */
  5634. copyFrom(source: Color4): Color4;
  5635. /**
  5636. * Copies the given float values into the current one
  5637. * @param r defines the red component to read from
  5638. * @param g defines the green component to read from
  5639. * @param b defines the blue component to read from
  5640. * @param a defines the alpha component to read from
  5641. * @returns the current updated Color4 object
  5642. */
  5643. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5644. /**
  5645. * Copies the given float values into the current one
  5646. * @param r defines the red component to read from
  5647. * @param g defines the green component to read from
  5648. * @param b defines the blue component to read from
  5649. * @param a defines the alpha component to read from
  5650. * @returns the current updated Color4 object
  5651. */
  5652. set(r: number, g: number, b: number, a: number): Color4;
  5653. /**
  5654. * Compute the Color4 hexadecimal code as a string
  5655. * @returns a string containing the hexadecimal representation of the Color4 object
  5656. */
  5657. toHexString(): string;
  5658. /**
  5659. * Computes a new Color4 converted from the current one to linear space
  5660. * @returns a new Color4 object
  5661. */
  5662. toLinearSpace(): Color4;
  5663. /**
  5664. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5665. * @param convertedColor defines the Color4 object where to store the linear space version
  5666. * @returns the unmodified Color4
  5667. */
  5668. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5669. /**
  5670. * Computes a new Color4 converted from the current one to gamma space
  5671. * @returns a new Color4 object
  5672. */
  5673. toGammaSpace(): Color4;
  5674. /**
  5675. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5676. * @param convertedColor defines the Color4 object where to store the gamma space version
  5677. * @returns the unmodified Color4
  5678. */
  5679. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5680. /**
  5681. * Creates a new Color4 from the string containing valid hexadecimal values
  5682. * @param hex defines a string containing valid hexadecimal values
  5683. * @returns a new Color4 object
  5684. */
  5685. static FromHexString(hex: string): Color4;
  5686. /**
  5687. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5688. * @param left defines the start value
  5689. * @param right defines the end value
  5690. * @param amount defines the gradient factor
  5691. * @returns a new Color4 object
  5692. */
  5693. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5694. /**
  5695. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color4 object where to store data
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5702. /**
  5703. * Creates a new Color4 from a Color3 and an alpha value
  5704. * @param color3 defines the source Color3 to read from
  5705. * @param alpha defines the alpha component (1.0 by default)
  5706. * @returns a new Color4 object
  5707. */
  5708. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5709. /**
  5710. * Creates a new Color4 from the starting index element of the given array
  5711. * @param array defines the source array to read from
  5712. * @param offset defines the offset in the source array
  5713. * @returns a new Color4 object
  5714. */
  5715. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5716. /**
  5717. * Creates a new Color3 from integer values (< 256)
  5718. * @param r defines the red component to read from (value between 0 and 255)
  5719. * @param g defines the green component to read from (value between 0 and 255)
  5720. * @param b defines the blue component to read from (value between 0 and 255)
  5721. * @param a defines the alpha component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5725. /**
  5726. * Check the content of a given array and convert it to an array containing RGBA data
  5727. * If the original array was already containing count * 4 values then it is returned directly
  5728. * @param colors defines the array to check
  5729. * @param count defines the number of RGBA data to expect
  5730. * @returns an array containing count * 4 values (RGBA)
  5731. */
  5732. static CheckColors4(colors: number[], count: number): number[];
  5733. }
  5734. /**
  5735. * @hidden
  5736. */
  5737. export class TmpColors {
  5738. static Color3: Color3[];
  5739. static Color4: Color4[];
  5740. }
  5741. }
  5742. declare module "babylonjs/Animations/animationKey" {
  5743. /**
  5744. * Defines an interface which represents an animation key frame
  5745. */
  5746. export interface IAnimationKey {
  5747. /**
  5748. * Frame of the key frame
  5749. */
  5750. frame: number;
  5751. /**
  5752. * Value at the specifies key frame
  5753. */
  5754. value: any;
  5755. /**
  5756. * The input tangent for the cubic hermite spline
  5757. */
  5758. inTangent?: any;
  5759. /**
  5760. * The output tangent for the cubic hermite spline
  5761. */
  5762. outTangent?: any;
  5763. /**
  5764. * The animation interpolation type
  5765. */
  5766. interpolation?: AnimationKeyInterpolation;
  5767. }
  5768. /**
  5769. * Enum for the animation key frame interpolation type
  5770. */
  5771. export enum AnimationKeyInterpolation {
  5772. /**
  5773. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5774. */
  5775. STEP = 1
  5776. }
  5777. }
  5778. declare module "babylonjs/Animations/animationRange" {
  5779. /**
  5780. * Represents the range of an animation
  5781. */
  5782. export class AnimationRange {
  5783. /**The name of the animation range**/
  5784. name: string;
  5785. /**The starting frame of the animation */
  5786. from: number;
  5787. /**The ending frame of the animation*/
  5788. to: number;
  5789. /**
  5790. * Initializes the range of an animation
  5791. * @param name The name of the animation range
  5792. * @param from The starting frame of the animation
  5793. * @param to The ending frame of the animation
  5794. */
  5795. constructor(
  5796. /**The name of the animation range**/
  5797. name: string,
  5798. /**The starting frame of the animation */
  5799. from: number,
  5800. /**The ending frame of the animation*/
  5801. to: number);
  5802. /**
  5803. * Makes a copy of the animation range
  5804. * @returns A copy of the animation range
  5805. */
  5806. clone(): AnimationRange;
  5807. }
  5808. }
  5809. declare module "babylonjs/Animations/animationEvent" {
  5810. /**
  5811. * Composed of a frame, and an action function
  5812. */
  5813. export class AnimationEvent {
  5814. /** The frame for which the event is triggered **/
  5815. frame: number;
  5816. /** The event to perform when triggered **/
  5817. action: (currentFrame: number) => void;
  5818. /** Specifies if the event should be triggered only once**/
  5819. onlyOnce?: boolean | undefined;
  5820. /**
  5821. * Specifies if the animation event is done
  5822. */
  5823. isDone: boolean;
  5824. /**
  5825. * Initializes the animation event
  5826. * @param frame The frame for which the event is triggered
  5827. * @param action The event to perform when triggered
  5828. * @param onlyOnce Specifies if the event should be triggered only once
  5829. */
  5830. constructor(
  5831. /** The frame for which the event is triggered **/
  5832. frame: number,
  5833. /** The event to perform when triggered **/
  5834. action: (currentFrame: number) => void,
  5835. /** Specifies if the event should be triggered only once**/
  5836. onlyOnce?: boolean | undefined);
  5837. /** @hidden */
  5838. _clone(): AnimationEvent;
  5839. }
  5840. }
  5841. declare module "babylonjs/Behaviors/behavior" {
  5842. import { Nullable } from "babylonjs/types";
  5843. /**
  5844. * Interface used to define a behavior
  5845. */
  5846. export interface Behavior<T> {
  5847. /** gets or sets behavior's name */
  5848. name: string;
  5849. /**
  5850. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5851. */
  5852. init(): void;
  5853. /**
  5854. * Called when the behavior is attached to a target
  5855. * @param target defines the target where the behavior is attached to
  5856. */
  5857. attach(target: T): void;
  5858. /**
  5859. * Called when the behavior is detached from its target
  5860. */
  5861. detach(): void;
  5862. }
  5863. /**
  5864. * Interface implemented by classes supporting behaviors
  5865. */
  5866. export interface IBehaviorAware<T> {
  5867. /**
  5868. * Attach a behavior
  5869. * @param behavior defines the behavior to attach
  5870. * @returns the current host
  5871. */
  5872. addBehavior(behavior: Behavior<T>): T;
  5873. /**
  5874. * Remove a behavior from the current object
  5875. * @param behavior defines the behavior to detach
  5876. * @returns the current host
  5877. */
  5878. removeBehavior(behavior: Behavior<T>): T;
  5879. /**
  5880. * Gets a behavior using its name to search
  5881. * @param name defines the name to search
  5882. * @returns the behavior or null if not found
  5883. */
  5884. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5885. }
  5886. }
  5887. declare module "babylonjs/Misc/smartArray" {
  5888. /**
  5889. * Defines an array and its length.
  5890. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5891. */
  5892. export interface ISmartArrayLike<T> {
  5893. /**
  5894. * The data of the array.
  5895. */
  5896. data: Array<T>;
  5897. /**
  5898. * The active length of the array.
  5899. */
  5900. length: number;
  5901. }
  5902. /**
  5903. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5904. */
  5905. export class SmartArray<T> implements ISmartArrayLike<T> {
  5906. /**
  5907. * The full set of data from the array.
  5908. */
  5909. data: Array<T>;
  5910. /**
  5911. * The active length of the array.
  5912. */
  5913. length: number;
  5914. protected _id: number;
  5915. /**
  5916. * Instantiates a Smart Array.
  5917. * @param capacity defines the default capacity of the array.
  5918. */
  5919. constructor(capacity: number);
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * @param value defines the object to push in the array.
  5923. */
  5924. push(value: T): void;
  5925. /**
  5926. * Iterates over the active data and apply the lambda to them.
  5927. * @param func defines the action to apply on each value.
  5928. */
  5929. forEach(func: (content: T) => void): void;
  5930. /**
  5931. * Sorts the full sets of data.
  5932. * @param compareFn defines the comparison function to apply.
  5933. */
  5934. sort(compareFn: (a: T, b: T) => number): void;
  5935. /**
  5936. * Resets the active data to an empty array.
  5937. */
  5938. reset(): void;
  5939. /**
  5940. * Releases all the data from the array as well as the array.
  5941. */
  5942. dispose(): void;
  5943. /**
  5944. * Concats the active data with a given array.
  5945. * @param array defines the data to concatenate with.
  5946. */
  5947. concat(array: any): void;
  5948. /**
  5949. * Returns the position of a value in the active data.
  5950. * @param value defines the value to find the index for
  5951. * @returns the index if found in the active data otherwise -1
  5952. */
  5953. indexOf(value: T): number;
  5954. /**
  5955. * Returns whether an element is part of the active data.
  5956. * @param value defines the value to look for
  5957. * @returns true if found in the active data otherwise false
  5958. */
  5959. contains(value: T): boolean;
  5960. private static _GlobalId;
  5961. }
  5962. /**
  5963. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5964. * The data in this array can only be present once
  5965. */
  5966. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5967. private _duplicateId;
  5968. /**
  5969. * Pushes a value at the end of the active data.
  5970. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5971. * @param value defines the object to push in the array.
  5972. */
  5973. push(value: T): void;
  5974. /**
  5975. * Pushes a value at the end of the active data.
  5976. * If the data is already present, it won t be added again
  5977. * @param value defines the object to push in the array.
  5978. * @returns true if added false if it was already present
  5979. */
  5980. pushNoDuplicate(value: T): boolean;
  5981. /**
  5982. * Resets the active data to an empty array.
  5983. */
  5984. reset(): void;
  5985. /**
  5986. * Concats the active data with a given array.
  5987. * This ensures no dupplicate will be present in the result.
  5988. * @param array defines the data to concatenate with.
  5989. */
  5990. concatWithNoDuplicate(array: any): void;
  5991. }
  5992. }
  5993. declare module "babylonjs/Cameras/cameraInputsManager" {
  5994. import { Nullable } from "babylonjs/types";
  5995. import { Camera } from "babylonjs/Cameras/camera";
  5996. /**
  5997. * @ignore
  5998. * This is a list of all the different input types that are available in the application.
  5999. * Fo instance: ArcRotateCameraGamepadInput...
  6000. */
  6001. export var CameraInputTypes: {};
  6002. /**
  6003. * This is the contract to implement in order to create a new input class.
  6004. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6005. */
  6006. export interface ICameraInput<TCamera extends Camera> {
  6007. /**
  6008. * Defines the camera the input is attached to.
  6009. */
  6010. camera: Nullable<TCamera>;
  6011. /**
  6012. * Gets the class name of the current intput.
  6013. * @returns the class name
  6014. */
  6015. getClassName(): string;
  6016. /**
  6017. * Get the friendly name associated with the input class.
  6018. * @returns the input friendly name
  6019. */
  6020. getSimpleName(): string;
  6021. /**
  6022. * Attach the input controls to a specific dom element to get the input from.
  6023. * @param element Defines the element the controls should be listened from
  6024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6025. */
  6026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6027. /**
  6028. * Detach the current controls from the specified dom element.
  6029. * @param element Defines the element to stop listening the inputs from
  6030. */
  6031. detachControl(element: Nullable<HTMLElement>): void;
  6032. /**
  6033. * Update the current camera state depending on the inputs that have been used this frame.
  6034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6035. */
  6036. checkInputs?: () => void;
  6037. }
  6038. /**
  6039. * Represents a map of input types to input instance or input index to input instance.
  6040. */
  6041. export interface CameraInputsMap<TCamera extends Camera> {
  6042. /**
  6043. * Accessor to the input by input type.
  6044. */
  6045. [name: string]: ICameraInput<TCamera>;
  6046. /**
  6047. * Accessor to the input by input index.
  6048. */
  6049. [idx: number]: ICameraInput<TCamera>;
  6050. }
  6051. /**
  6052. * This represents the input manager used within a camera.
  6053. * It helps dealing with all the different kind of input attached to a camera.
  6054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6055. */
  6056. export class CameraInputsManager<TCamera extends Camera> {
  6057. /**
  6058. * Defines the list of inputs attahed to the camera.
  6059. */
  6060. attached: CameraInputsMap<TCamera>;
  6061. /**
  6062. * Defines the dom element the camera is collecting inputs from.
  6063. * This is null if the controls have not been attached.
  6064. */
  6065. attachedElement: Nullable<HTMLElement>;
  6066. /**
  6067. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6068. */
  6069. noPreventDefault: boolean;
  6070. /**
  6071. * Defined the camera the input manager belongs to.
  6072. */
  6073. camera: TCamera;
  6074. /**
  6075. * Update the current camera state depending on the inputs that have been used this frame.
  6076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6077. */
  6078. checkInputs: () => void;
  6079. /**
  6080. * Instantiate a new Camera Input Manager.
  6081. * @param camera Defines the camera the input manager blongs to
  6082. */
  6083. constructor(camera: TCamera);
  6084. /**
  6085. * Add an input method to a camera
  6086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6087. * @param input camera input method
  6088. */
  6089. add(input: ICameraInput<TCamera>): void;
  6090. /**
  6091. * Remove a specific input method from a camera
  6092. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6093. * @param inputToRemove camera input method
  6094. */
  6095. remove(inputToRemove: ICameraInput<TCamera>): void;
  6096. /**
  6097. * Remove a specific input type from a camera
  6098. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6099. * @param inputType the type of the input to remove
  6100. */
  6101. removeByType(inputType: string): void;
  6102. private _addCheckInputs;
  6103. /**
  6104. * Attach the input controls to the currently attached dom element to listen the events from.
  6105. * @param input Defines the input to attach
  6106. */
  6107. attachInput(input: ICameraInput<TCamera>): void;
  6108. /**
  6109. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6110. * @param element Defines the dom element to collect the events from
  6111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6112. */
  6113. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6114. /**
  6115. * Detach the current manager inputs controls from a specific dom element.
  6116. * @param element Defines the dom element to collect the events from
  6117. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6118. */
  6119. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6120. /**
  6121. * Rebuild the dynamic inputCheck function from the current list of
  6122. * defined inputs in the manager.
  6123. */
  6124. rebuildInputCheck(): void;
  6125. /**
  6126. * Remove all attached input methods from a camera
  6127. */
  6128. clear(): void;
  6129. /**
  6130. * Serialize the current input manager attached to a camera.
  6131. * This ensures than once parsed,
  6132. * the input associated to the camera will be identical to the current ones
  6133. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6134. */
  6135. serialize(serializedCamera: any): void;
  6136. /**
  6137. * Parses an input manager serialized JSON to restore the previous list of inputs
  6138. * and states associated to a camera.
  6139. * @param parsedCamera Defines the JSON to parse
  6140. */
  6141. parse(parsedCamera: any): void;
  6142. }
  6143. }
  6144. declare module "babylonjs/Meshes/buffer" {
  6145. import { Nullable, DataArray } from "babylonjs/types";
  6146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6147. /**
  6148. * Class used to store data that will be store in GPU memory
  6149. */
  6150. export class Buffer {
  6151. private _engine;
  6152. private _buffer;
  6153. /** @hidden */
  6154. _data: Nullable<DataArray>;
  6155. private _updatable;
  6156. private _instanced;
  6157. private _divisor;
  6158. /**
  6159. * Gets the byte stride.
  6160. */
  6161. readonly byteStride: number;
  6162. /**
  6163. * Constructor
  6164. * @param engine the engine
  6165. * @param data the data to use for this buffer
  6166. * @param updatable whether the data is updatable
  6167. * @param stride the stride (optional)
  6168. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6169. * @param instanced whether the buffer is instanced (optional)
  6170. * @param useBytes set to true if the stride in in bytes (optional)
  6171. * @param divisor sets an optional divisor for instances (1 by default)
  6172. */
  6173. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6174. /**
  6175. * Create a new VertexBuffer based on the current buffer
  6176. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6177. * @param offset defines offset in the buffer (0 by default)
  6178. * @param size defines the size in floats of attributes (position is 3 for instance)
  6179. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6180. * @param instanced defines if the vertex buffer contains indexed data
  6181. * @param useBytes defines if the offset and stride are in bytes *
  6182. * @param divisor sets an optional divisor for instances (1 by default)
  6183. * @returns the new vertex buffer
  6184. */
  6185. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6186. /**
  6187. * Gets a boolean indicating if the Buffer is updatable?
  6188. * @returns true if the buffer is updatable
  6189. */
  6190. isUpdatable(): boolean;
  6191. /**
  6192. * Gets current buffer's data
  6193. * @returns a DataArray or null
  6194. */
  6195. getData(): Nullable<DataArray>;
  6196. /**
  6197. * Gets underlying native buffer
  6198. * @returns underlying native buffer
  6199. */
  6200. getBuffer(): Nullable<DataBuffer>;
  6201. /**
  6202. * Gets the stride in float32 units (i.e. byte stride / 4).
  6203. * May not be an integer if the byte stride is not divisible by 4.
  6204. * DEPRECATED. Use byteStride instead.
  6205. * @returns the stride in float32 units
  6206. */
  6207. getStrideSize(): number;
  6208. /**
  6209. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6210. * @param data defines the data to store
  6211. */
  6212. create(data?: Nullable<DataArray>): void;
  6213. /** @hidden */
  6214. _rebuild(): void;
  6215. /**
  6216. * Update current buffer data
  6217. * @param data defines the data to store
  6218. */
  6219. update(data: DataArray): void;
  6220. /**
  6221. * Updates the data directly.
  6222. * @param data the new data
  6223. * @param offset the new offset
  6224. * @param vertexCount the vertex count (optional)
  6225. * @param useBytes set to true if the offset is in bytes
  6226. */
  6227. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6228. /**
  6229. * Release all resources
  6230. */
  6231. dispose(): void;
  6232. }
  6233. /**
  6234. * Specialized buffer used to store vertex data
  6235. */
  6236. export class VertexBuffer {
  6237. /** @hidden */
  6238. _buffer: Buffer;
  6239. private _kind;
  6240. private _size;
  6241. private _ownsBuffer;
  6242. private _instanced;
  6243. private _instanceDivisor;
  6244. /**
  6245. * The byte type.
  6246. */
  6247. static readonly BYTE: number;
  6248. /**
  6249. * The unsigned byte type.
  6250. */
  6251. static readonly UNSIGNED_BYTE: number;
  6252. /**
  6253. * The short type.
  6254. */
  6255. static readonly SHORT: number;
  6256. /**
  6257. * The unsigned short type.
  6258. */
  6259. static readonly UNSIGNED_SHORT: number;
  6260. /**
  6261. * The integer type.
  6262. */
  6263. static readonly INT: number;
  6264. /**
  6265. * The unsigned integer type.
  6266. */
  6267. static readonly UNSIGNED_INT: number;
  6268. /**
  6269. * The float type.
  6270. */
  6271. static readonly FLOAT: number;
  6272. /**
  6273. * Gets or sets the instance divisor when in instanced mode
  6274. */
  6275. instanceDivisor: number;
  6276. /**
  6277. * Gets the byte stride.
  6278. */
  6279. readonly byteStride: number;
  6280. /**
  6281. * Gets the byte offset.
  6282. */
  6283. readonly byteOffset: number;
  6284. /**
  6285. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6286. */
  6287. readonly normalized: boolean;
  6288. /**
  6289. * Gets the data type of each component in the array.
  6290. */
  6291. readonly type: number;
  6292. /**
  6293. * Constructor
  6294. * @param engine the engine
  6295. * @param data the data to use for this vertex buffer
  6296. * @param kind the vertex buffer kind
  6297. * @param updatable whether the data is updatable
  6298. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6299. * @param stride the stride (optional)
  6300. * @param instanced whether the buffer is instanced (optional)
  6301. * @param offset the offset of the data (optional)
  6302. * @param size the number of components (optional)
  6303. * @param type the type of the component (optional)
  6304. * @param normalized whether the data contains normalized data (optional)
  6305. * @param useBytes set to true if stride and offset are in bytes (optional)
  6306. * @param divisor defines the instance divisor to use (1 by default)
  6307. */
  6308. 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, divisor?: number);
  6309. /** @hidden */
  6310. _rebuild(): void;
  6311. /**
  6312. * Returns the kind of the VertexBuffer (string)
  6313. * @returns a string
  6314. */
  6315. getKind(): string;
  6316. /**
  6317. * Gets a boolean indicating if the VertexBuffer is updatable?
  6318. * @returns true if the buffer is updatable
  6319. */
  6320. isUpdatable(): boolean;
  6321. /**
  6322. * Gets current buffer's data
  6323. * @returns a DataArray or null
  6324. */
  6325. getData(): Nullable<DataArray>;
  6326. /**
  6327. * Gets underlying native buffer
  6328. * @returns underlying native buffer
  6329. */
  6330. getBuffer(): Nullable<DataBuffer>;
  6331. /**
  6332. * Gets the stride in float32 units (i.e. byte stride / 4).
  6333. * May not be an integer if the byte stride is not divisible by 4.
  6334. * DEPRECATED. Use byteStride instead.
  6335. * @returns the stride in float32 units
  6336. */
  6337. getStrideSize(): number;
  6338. /**
  6339. * Returns the offset as a multiple of the type byte length.
  6340. * DEPRECATED. Use byteOffset instead.
  6341. * @returns the offset in bytes
  6342. */
  6343. getOffset(): number;
  6344. /**
  6345. * Returns the number of components per vertex attribute (integer)
  6346. * @returns the size in float
  6347. */
  6348. getSize(): number;
  6349. /**
  6350. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6351. * @returns true if this buffer is instanced
  6352. */
  6353. getIsInstanced(): boolean;
  6354. /**
  6355. * Returns the instancing divisor, zero for non-instanced (integer).
  6356. * @returns a number
  6357. */
  6358. getInstanceDivisor(): number;
  6359. /**
  6360. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6361. * @param data defines the data to store
  6362. */
  6363. create(data?: DataArray): void;
  6364. /**
  6365. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6366. * This function will create a new buffer if the current one is not updatable
  6367. * @param data defines the data to store
  6368. */
  6369. update(data: DataArray): void;
  6370. /**
  6371. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6372. * Returns the directly updated WebGLBuffer.
  6373. * @param data the new data
  6374. * @param offset the new offset
  6375. * @param useBytes set to true if the offset is in bytes
  6376. */
  6377. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6378. /**
  6379. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6380. */
  6381. dispose(): void;
  6382. /**
  6383. * Enumerates each value of this vertex buffer as numbers.
  6384. * @param count the number of values to enumerate
  6385. * @param callback the callback function called for each value
  6386. */
  6387. forEach(count: number, callback: (value: number, index: number) => void): void;
  6388. /**
  6389. * Positions
  6390. */
  6391. static readonly PositionKind: string;
  6392. /**
  6393. * Normals
  6394. */
  6395. static readonly NormalKind: string;
  6396. /**
  6397. * Tangents
  6398. */
  6399. static readonly TangentKind: string;
  6400. /**
  6401. * Texture coordinates
  6402. */
  6403. static readonly UVKind: string;
  6404. /**
  6405. * Texture coordinates 2
  6406. */
  6407. static readonly UV2Kind: string;
  6408. /**
  6409. * Texture coordinates 3
  6410. */
  6411. static readonly UV3Kind: string;
  6412. /**
  6413. * Texture coordinates 4
  6414. */
  6415. static readonly UV4Kind: string;
  6416. /**
  6417. * Texture coordinates 5
  6418. */
  6419. static readonly UV5Kind: string;
  6420. /**
  6421. * Texture coordinates 6
  6422. */
  6423. static readonly UV6Kind: string;
  6424. /**
  6425. * Colors
  6426. */
  6427. static readonly ColorKind: string;
  6428. /**
  6429. * Matrix indices (for bones)
  6430. */
  6431. static readonly MatricesIndicesKind: string;
  6432. /**
  6433. * Matrix weights (for bones)
  6434. */
  6435. static readonly MatricesWeightsKind: string;
  6436. /**
  6437. * Additional matrix indices (for bones)
  6438. */
  6439. static readonly MatricesIndicesExtraKind: string;
  6440. /**
  6441. * Additional matrix weights (for bones)
  6442. */
  6443. static readonly MatricesWeightsExtraKind: string;
  6444. /**
  6445. * Deduces the stride given a kind.
  6446. * @param kind The kind string to deduce
  6447. * @returns The deduced stride
  6448. */
  6449. static DeduceStride(kind: string): number;
  6450. /**
  6451. * Gets the byte length of the given type.
  6452. * @param type the type
  6453. * @returns the number of bytes
  6454. */
  6455. static GetTypeByteLength(type: number): number;
  6456. /**
  6457. * Enumerates each value of the given parameters as numbers.
  6458. * @param data the data to enumerate
  6459. * @param byteOffset the byte offset of the data
  6460. * @param byteStride the byte stride of the data
  6461. * @param componentCount the number of components per element
  6462. * @param componentType the type of the component
  6463. * @param count the number of values to enumerate
  6464. * @param normalized whether the data is normalized
  6465. * @param callback the callback function called for each value
  6466. */
  6467. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6468. private static _GetFloatValue;
  6469. }
  6470. }
  6471. declare module "babylonjs/Collisions/intersectionInfo" {
  6472. import { Nullable } from "babylonjs/types";
  6473. /**
  6474. * @hidden
  6475. */
  6476. export class IntersectionInfo {
  6477. bu: Nullable<number>;
  6478. bv: Nullable<number>;
  6479. distance: number;
  6480. faceId: number;
  6481. subMeshId: number;
  6482. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6483. }
  6484. }
  6485. declare module "babylonjs/Maths/math.plane" {
  6486. import { DeepImmutable } from "babylonjs/types";
  6487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6488. /**
  6489. * Represens a plane by the equation ax + by + cz + d = 0
  6490. */
  6491. export class Plane {
  6492. private static _TmpMatrix;
  6493. /**
  6494. * Normal of the plane (a,b,c)
  6495. */
  6496. normal: Vector3;
  6497. /**
  6498. * d component of the plane
  6499. */
  6500. d: number;
  6501. /**
  6502. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6503. * @param a a component of the plane
  6504. * @param b b component of the plane
  6505. * @param c c component of the plane
  6506. * @param d d component of the plane
  6507. */
  6508. constructor(a: number, b: number, c: number, d: number);
  6509. /**
  6510. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6511. */
  6512. asArray(): number[];
  6513. /**
  6514. * @returns a new plane copied from the current Plane.
  6515. */
  6516. clone(): Plane;
  6517. /**
  6518. * @returns the string "Plane".
  6519. */
  6520. getClassName(): string;
  6521. /**
  6522. * @returns the Plane hash code.
  6523. */
  6524. getHashCode(): number;
  6525. /**
  6526. * Normalize the current Plane in place.
  6527. * @returns the updated Plane.
  6528. */
  6529. normalize(): Plane;
  6530. /**
  6531. * Applies a transformation the plane and returns the result
  6532. * @param transformation the transformation matrix to be applied to the plane
  6533. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6534. */
  6535. transform(transformation: DeepImmutable<Matrix>): Plane;
  6536. /**
  6537. * Calcualtte the dot product between the point and the plane normal
  6538. * @param point point to calculate the dot product with
  6539. * @returns the dot product (float) of the point coordinates and the plane normal.
  6540. */
  6541. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6542. /**
  6543. * Updates the current Plane from the plane defined by the three given points.
  6544. * @param point1 one of the points used to contruct the plane
  6545. * @param point2 one of the points used to contruct the plane
  6546. * @param point3 one of the points used to contruct the plane
  6547. * @returns the updated Plane.
  6548. */
  6549. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6550. /**
  6551. * Checks if the plane is facing a given direction
  6552. * @param direction the direction to check if the plane is facing
  6553. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6554. * @returns True is the vector "direction" is the same side than the plane normal.
  6555. */
  6556. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6557. /**
  6558. * Calculates the distance to a point
  6559. * @param point point to calculate distance to
  6560. * @returns the signed distance (float) from the given point to the Plane.
  6561. */
  6562. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6563. /**
  6564. * Creates a plane from an array
  6565. * @param array the array to create a plane from
  6566. * @returns a new Plane from the given array.
  6567. */
  6568. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6569. /**
  6570. * Creates a plane from three points
  6571. * @param point1 point used to create the plane
  6572. * @param point2 point used to create the plane
  6573. * @param point3 point used to create the plane
  6574. * @returns a new Plane defined by the three given points.
  6575. */
  6576. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6577. /**
  6578. * Creates a plane from an origin point and a normal
  6579. * @param origin origin of the plane to be constructed
  6580. * @param normal normal of the plane to be constructed
  6581. * @returns a new Plane the normal vector to this plane at the given origin point.
  6582. * Note : the vector "normal" is updated because normalized.
  6583. */
  6584. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6585. /**
  6586. * Calculates the distance from a plane and a point
  6587. * @param origin origin of the plane to be constructed
  6588. * @param normal normal of the plane to be constructed
  6589. * @param point point to calculate distance to
  6590. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6591. */
  6592. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6593. }
  6594. }
  6595. declare module "babylonjs/Culling/boundingSphere" {
  6596. import { DeepImmutable } from "babylonjs/types";
  6597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6598. import { Plane } from "babylonjs/Maths/math.plane";
  6599. /**
  6600. * Class used to store bounding sphere information
  6601. */
  6602. export class BoundingSphere {
  6603. /**
  6604. * Gets the center of the bounding sphere in local space
  6605. */
  6606. readonly center: Vector3;
  6607. /**
  6608. * Radius of the bounding sphere in local space
  6609. */
  6610. radius: number;
  6611. /**
  6612. * Gets the center of the bounding sphere in world space
  6613. */
  6614. readonly centerWorld: Vector3;
  6615. /**
  6616. * Radius of the bounding sphere in world space
  6617. */
  6618. radiusWorld: number;
  6619. /**
  6620. * Gets the minimum vector in local space
  6621. */
  6622. readonly minimum: Vector3;
  6623. /**
  6624. * Gets the maximum vector in local space
  6625. */
  6626. readonly maximum: Vector3;
  6627. private _worldMatrix;
  6628. private static readonly TmpVector3;
  6629. /**
  6630. * Creates a new bounding sphere
  6631. * @param min defines the minimum vector (in local space)
  6632. * @param max defines the maximum vector (in local space)
  6633. * @param worldMatrix defines the new world matrix
  6634. */
  6635. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6636. /**
  6637. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6638. * @param min defines the new minimum vector (in local space)
  6639. * @param max defines the new maximum vector (in local space)
  6640. * @param worldMatrix defines the new world matrix
  6641. */
  6642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6643. /**
  6644. * Scale the current bounding sphere by applying a scale factor
  6645. * @param factor defines the scale factor to apply
  6646. * @returns the current bounding box
  6647. */
  6648. scale(factor: number): BoundingSphere;
  6649. /**
  6650. * Gets the world matrix of the bounding box
  6651. * @returns a matrix
  6652. */
  6653. getWorldMatrix(): DeepImmutable<Matrix>;
  6654. /** @hidden */
  6655. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6656. /**
  6657. * Tests if the bounding sphere is intersecting the frustum planes
  6658. * @param frustumPlanes defines the frustum planes to test
  6659. * @returns true if there is an intersection
  6660. */
  6661. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6662. /**
  6663. * Tests if the bounding sphere center is in between the frustum planes.
  6664. * Used for optimistic fast inclusion.
  6665. * @param frustumPlanes defines the frustum planes to test
  6666. * @returns true if the sphere center is in between the frustum planes
  6667. */
  6668. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6669. /**
  6670. * Tests if a point is inside the bounding sphere
  6671. * @param point defines the point to test
  6672. * @returns true if the point is inside the bounding sphere
  6673. */
  6674. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6675. /**
  6676. * Checks if two sphere intersct
  6677. * @param sphere0 sphere 0
  6678. * @param sphere1 sphere 1
  6679. * @returns true if the speres intersect
  6680. */
  6681. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6682. }
  6683. }
  6684. declare module "babylonjs/Culling/boundingBox" {
  6685. import { DeepImmutable } from "babylonjs/types";
  6686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6687. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6688. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding box information
  6692. */
  6693. export class BoundingBox implements ICullable {
  6694. /**
  6695. * Gets the 8 vectors representing the bounding box in local space
  6696. */
  6697. readonly vectors: Vector3[];
  6698. /**
  6699. * Gets the center of the bounding box in local space
  6700. */
  6701. readonly center: Vector3;
  6702. /**
  6703. * Gets the center of the bounding box in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Gets the extend size in local space
  6708. */
  6709. readonly extendSize: Vector3;
  6710. /**
  6711. * Gets the extend size in world space
  6712. */
  6713. readonly extendSizeWorld: Vector3;
  6714. /**
  6715. * Gets the OBB (object bounding box) directions
  6716. */
  6717. readonly directions: Vector3[];
  6718. /**
  6719. * Gets the 8 vectors representing the bounding box in world space
  6720. */
  6721. readonly vectorsWorld: Vector3[];
  6722. /**
  6723. * Gets the minimum vector in world space
  6724. */
  6725. readonly minimumWorld: Vector3;
  6726. /**
  6727. * Gets the maximum vector in world space
  6728. */
  6729. readonly maximumWorld: Vector3;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * @hidden
  6742. */
  6743. _tag: number;
  6744. /**
  6745. * Creates a new bounding box
  6746. * @param min defines the minimum vector (in local space)
  6747. * @param max defines the maximum vector (in local space)
  6748. * @param worldMatrix defines the new world matrix
  6749. */
  6750. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6751. /**
  6752. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6753. * @param min defines the new minimum vector (in local space)
  6754. * @param max defines the new maximum vector (in local space)
  6755. * @param worldMatrix defines the new world matrix
  6756. */
  6757. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6758. /**
  6759. * Scale the current bounding box by applying a scale factor
  6760. * @param factor defines the scale factor to apply
  6761. * @returns the current bounding box
  6762. */
  6763. scale(factor: number): BoundingBox;
  6764. /**
  6765. * Gets the world matrix of the bounding box
  6766. * @returns a matrix
  6767. */
  6768. getWorldMatrix(): DeepImmutable<Matrix>;
  6769. /** @hidden */
  6770. _update(world: DeepImmutable<Matrix>): void;
  6771. /**
  6772. * Tests if the bounding box is intersecting the frustum planes
  6773. * @param frustumPlanes defines the frustum planes to test
  6774. * @returns true if there is an intersection
  6775. */
  6776. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6777. /**
  6778. * Tests if the bounding box is entirely inside the frustum planes
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if there is an inclusion
  6781. */
  6782. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding box
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding box
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Tests if the bounding box intersects with a bounding sphere
  6791. * @param sphere defines the sphere to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6795. /**
  6796. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6797. * @param min defines the min vector to use
  6798. * @param max defines the max vector to use
  6799. * @returns true if there is an intersection
  6800. */
  6801. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6802. /**
  6803. * Tests if two bounding boxes are intersections
  6804. * @param box0 defines the first box to test
  6805. * @param box1 defines the second box to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6809. /**
  6810. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6811. * @param minPoint defines the minimum vector of the bounding box
  6812. * @param maxPoint defines the maximum vector of the bounding box
  6813. * @param sphereCenter defines the sphere center
  6814. * @param sphereRadius defines the sphere radius
  6815. * @returns true if there is an intersection
  6816. */
  6817. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6818. /**
  6819. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6820. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6821. * @param frustumPlanes defines the frustum planes to test
  6822. * @return true if there is an inclusion
  6823. */
  6824. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6825. /**
  6826. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6827. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6828. * @param frustumPlanes defines the frustum planes to test
  6829. * @return true if there is an intersection
  6830. */
  6831. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6832. }
  6833. }
  6834. declare module "babylonjs/Collisions/collider" {
  6835. import { Nullable, IndicesArray } from "babylonjs/types";
  6836. import { Vector3 } from "babylonjs/Maths/math.vector";
  6837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6838. import { Plane } from "babylonjs/Maths/math.plane";
  6839. /** @hidden */
  6840. export class Collider {
  6841. /** Define if a collision was found */
  6842. collisionFound: boolean;
  6843. /**
  6844. * Define last intersection point in local space
  6845. */
  6846. intersectionPoint: Vector3;
  6847. /**
  6848. * Define last collided mesh
  6849. */
  6850. collidedMesh: Nullable<AbstractMesh>;
  6851. private _collisionPoint;
  6852. private _planeIntersectionPoint;
  6853. private _tempVector;
  6854. private _tempVector2;
  6855. private _tempVector3;
  6856. private _tempVector4;
  6857. private _edge;
  6858. private _baseToVertex;
  6859. private _destinationPoint;
  6860. private _slidePlaneNormal;
  6861. private _displacementVector;
  6862. /** @hidden */
  6863. _radius: Vector3;
  6864. /** @hidden */
  6865. _retry: number;
  6866. private _velocity;
  6867. private _basePoint;
  6868. private _epsilon;
  6869. /** @hidden */
  6870. _velocityWorldLength: number;
  6871. /** @hidden */
  6872. _basePointWorld: Vector3;
  6873. private _velocityWorld;
  6874. private _normalizedVelocity;
  6875. /** @hidden */
  6876. _initialVelocity: Vector3;
  6877. /** @hidden */
  6878. _initialPosition: Vector3;
  6879. private _nearestDistance;
  6880. private _collisionMask;
  6881. collisionMask: number;
  6882. /**
  6883. * Gets the plane normal used to compute the sliding response (in local space)
  6884. */
  6885. readonly slidePlaneNormal: Vector3;
  6886. /** @hidden */
  6887. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6888. /** @hidden */
  6889. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6890. /** @hidden */
  6891. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6892. /** @hidden */
  6893. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6894. /** @hidden */
  6895. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6896. /** @hidden */
  6897. _getResponse(pos: Vector3, vel: Vector3): void;
  6898. }
  6899. }
  6900. declare module "babylonjs/Culling/boundingInfo" {
  6901. import { DeepImmutable } from "babylonjs/types";
  6902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6903. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6904. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6905. import { Plane } from "babylonjs/Maths/math.plane";
  6906. import { Collider } from "babylonjs/Collisions/collider";
  6907. /**
  6908. * Interface for cullable objects
  6909. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6910. */
  6911. export interface ICullable {
  6912. /**
  6913. * Checks if the object or part of the object is in the frustum
  6914. * @param frustumPlanes Camera near/planes
  6915. * @returns true if the object is in frustum otherwise false
  6916. */
  6917. isInFrustum(frustumPlanes: Plane[]): boolean;
  6918. /**
  6919. * Checks if a cullable object (mesh...) is in the camera frustum
  6920. * Unlike isInFrustum this cheks the full bounding box
  6921. * @param frustumPlanes Camera near/planes
  6922. * @returns true if the object is in frustum otherwise false
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6925. }
  6926. /**
  6927. * Info for a bounding data of a mesh
  6928. */
  6929. export class BoundingInfo implements ICullable {
  6930. /**
  6931. * Bounding box for the mesh
  6932. */
  6933. readonly boundingBox: BoundingBox;
  6934. /**
  6935. * Bounding sphere for the mesh
  6936. */
  6937. readonly boundingSphere: BoundingSphere;
  6938. private _isLocked;
  6939. private static readonly TmpVector3;
  6940. /**
  6941. * Constructs bounding info
  6942. * @param minimum min vector of the bounding box/sphere
  6943. * @param maximum max vector of the bounding box/sphere
  6944. * @param worldMatrix defines the new world matrix
  6945. */
  6946. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6947. /**
  6948. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6949. * @param min defines the new minimum vector (in local space)
  6950. * @param max defines the new maximum vector (in local space)
  6951. * @param worldMatrix defines the new world matrix
  6952. */
  6953. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6954. /**
  6955. * min vector of the bounding box/sphere
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * max vector of the bounding box/sphere
  6960. */
  6961. readonly maximum: Vector3;
  6962. /**
  6963. * If the info is locked and won't be updated to avoid perf overhead
  6964. */
  6965. isLocked: boolean;
  6966. /**
  6967. * Updates the bounding sphere and box
  6968. * @param world world matrix to be used to update
  6969. */
  6970. update(world: DeepImmutable<Matrix>): void;
  6971. /**
  6972. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6973. * @param center New center of the bounding info
  6974. * @param extend New extend of the bounding info
  6975. * @returns the current bounding info
  6976. */
  6977. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6978. /**
  6979. * Scale the current bounding info by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding info
  6982. */
  6983. scale(factor: number): BoundingInfo;
  6984. /**
  6985. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6986. * @param frustumPlanes defines the frustum to test
  6987. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6988. * @returns true if the bounding info is in the frustum planes
  6989. */
  6990. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6991. /**
  6992. * Gets the world distance between the min and max points of the bounding box
  6993. */
  6994. readonly diagonalLength: number;
  6995. /**
  6996. * Checks if a cullable object (mesh...) is in the camera frustum
  6997. * Unlike isInFrustum this cheks the full bounding box
  6998. * @param frustumPlanes Camera near/planes
  6999. * @returns true if the object is in frustum otherwise false
  7000. */
  7001. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7002. /** @hidden */
  7003. _checkCollision(collider: Collider): boolean;
  7004. /**
  7005. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7007. * @param point the point to check intersection with
  7008. * @returns if the point intersects
  7009. */
  7010. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7011. /**
  7012. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7013. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7014. * @param boundingInfo the bounding info to check intersection with
  7015. * @param precise if the intersection should be done using OBB
  7016. * @returns if the bounding info intersects
  7017. */
  7018. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7019. }
  7020. }
  7021. declare module "babylonjs/Maths/math.functions" {
  7022. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7023. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7024. /**
  7025. * Extracts minimum and maximum values from a list of indexed positions
  7026. * @param positions defines the positions to use
  7027. * @param indices defines the indices to the positions
  7028. * @param indexStart defines the start index
  7029. * @param indexCount defines the end index
  7030. * @param bias defines bias value to add to the result
  7031. * @return minimum and maximum values
  7032. */
  7033. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7034. minimum: Vector3;
  7035. maximum: Vector3;
  7036. };
  7037. /**
  7038. * Extracts minimum and maximum values from a list of positions
  7039. * @param positions defines the positions to use
  7040. * @param start defines the start index in the positions array
  7041. * @param count defines the number of positions to handle
  7042. * @param bias defines bias value to add to the result
  7043. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7044. * @return minimum and maximum values
  7045. */
  7046. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7047. minimum: Vector3;
  7048. maximum: Vector3;
  7049. };
  7050. }
  7051. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7052. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7053. /** @hidden */
  7054. export class WebGLDataBuffer extends DataBuffer {
  7055. private _buffer;
  7056. constructor(resource: WebGLBuffer);
  7057. readonly underlyingResource: any;
  7058. }
  7059. }
  7060. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7061. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7062. import { Nullable } from "babylonjs/types";
  7063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7064. /** @hidden */
  7065. export class WebGLPipelineContext implements IPipelineContext {
  7066. engine: ThinEngine;
  7067. program: Nullable<WebGLProgram>;
  7068. context?: WebGLRenderingContext;
  7069. vertexShader?: WebGLShader;
  7070. fragmentShader?: WebGLShader;
  7071. isParallelCompiled: boolean;
  7072. onCompiled?: () => void;
  7073. transformFeedback?: WebGLTransformFeedback | null;
  7074. readonly isAsync: boolean;
  7075. readonly isReady: boolean;
  7076. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7077. }
  7078. }
  7079. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7080. import { FloatArray, Nullable } from "babylonjs/types";
  7081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7082. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7083. module "babylonjs/Engines/thinEngine" {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. }
  7129. declare module "babylonjs/Materials/uniformBuffer" {
  7130. import { Nullable, FloatArray } from "babylonjs/types";
  7131. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7132. import { Engine } from "babylonjs/Engines/engine";
  7133. import { Effect } from "babylonjs/Materials/effect";
  7134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7135. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7136. import { Color3 } from "babylonjs/Maths/math.color";
  7137. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7138. /**
  7139. * Uniform buffer objects.
  7140. *
  7141. * Handles blocks of uniform on the GPU.
  7142. *
  7143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7144. *
  7145. * For more information, please refer to :
  7146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7147. */
  7148. export class UniformBuffer {
  7149. private _engine;
  7150. private _buffer;
  7151. private _data;
  7152. private _bufferData;
  7153. private _dynamic?;
  7154. private _uniformLocations;
  7155. private _uniformSizes;
  7156. private _uniformLocationPointer;
  7157. private _needSync;
  7158. private _noUBO;
  7159. private _currentEffect;
  7160. /** @hidden */
  7161. _alreadyBound: boolean;
  7162. private static _MAX_UNIFORM_SIZE;
  7163. private static _tempBuffer;
  7164. /**
  7165. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7170. /**
  7171. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7172. * This is dynamic to allow compat with webgl 1 and 2.
  7173. * You will need to pass the name of the uniform as well as the value.
  7174. */
  7175. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7176. /**
  7177. * Lambda to Update a single float in a uniform buffer.
  7178. * This is dynamic to allow compat with webgl 1 and 2.
  7179. * You will need to pass the name of the uniform as well as the value.
  7180. */
  7181. updateFloat: (name: string, x: number) => void;
  7182. /**
  7183. * Lambda to Update a vec2 of float in a uniform buffer.
  7184. * This is dynamic to allow compat with webgl 1 and 2.
  7185. * You will need to pass the name of the uniform as well as the value.
  7186. */
  7187. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7188. /**
  7189. * Lambda to Update a vec3 of float in a uniform buffer.
  7190. * This is dynamic to allow compat with webgl 1 and 2.
  7191. * You will need to pass the name of the uniform as well as the value.
  7192. */
  7193. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7194. /**
  7195. * Lambda to Update a vec4 of float in a uniform buffer.
  7196. * This is dynamic to allow compat with webgl 1 and 2.
  7197. * You will need to pass the name of the uniform as well as the value.
  7198. */
  7199. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7200. /**
  7201. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7202. * This is dynamic to allow compat with webgl 1 and 2.
  7203. * You will need to pass the name of the uniform as well as the value.
  7204. */
  7205. updateMatrix: (name: string, mat: Matrix) => void;
  7206. /**
  7207. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7208. * This is dynamic to allow compat with webgl 1 and 2.
  7209. * You will need to pass the name of the uniform as well as the value.
  7210. */
  7211. updateVector3: (name: string, vector: Vector3) => void;
  7212. /**
  7213. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7214. * This is dynamic to allow compat with webgl 1 and 2.
  7215. * You will need to pass the name of the uniform as well as the value.
  7216. */
  7217. updateVector4: (name: string, vector: Vector4) => void;
  7218. /**
  7219. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7220. * This is dynamic to allow compat with webgl 1 and 2.
  7221. * You will need to pass the name of the uniform as well as the value.
  7222. */
  7223. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7224. /**
  7225. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7226. * This is dynamic to allow compat with webgl 1 and 2.
  7227. * You will need to pass the name of the uniform as well as the value.
  7228. */
  7229. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7230. /**
  7231. * Instantiates a new Uniform buffer objects.
  7232. *
  7233. * Handles blocks of uniform on the GPU.
  7234. *
  7235. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7236. *
  7237. * For more information, please refer to :
  7238. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7239. * @param engine Define the engine the buffer is associated with
  7240. * @param data Define the data contained in the buffer
  7241. * @param dynamic Define if the buffer is updatable
  7242. */
  7243. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7244. /**
  7245. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7246. * or just falling back on setUniformXXX calls.
  7247. */
  7248. readonly useUbo: boolean;
  7249. /**
  7250. * Indicates if the WebGL underlying uniform buffer is in sync
  7251. * with the javascript cache data.
  7252. */
  7253. readonly isSync: boolean;
  7254. /**
  7255. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7256. * Also, a dynamic UniformBuffer will disable cache verification and always
  7257. * update the underlying WebGL uniform buffer to the GPU.
  7258. * @returns if Dynamic, otherwise false
  7259. */
  7260. isDynamic(): boolean;
  7261. /**
  7262. * The data cache on JS side.
  7263. * @returns the underlying data as a float array
  7264. */
  7265. getData(): Float32Array;
  7266. /**
  7267. * The underlying WebGL Uniform buffer.
  7268. * @returns the webgl buffer
  7269. */
  7270. getBuffer(): Nullable<DataBuffer>;
  7271. /**
  7272. * std140 layout specifies how to align data within an UBO structure.
  7273. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7274. * for specs.
  7275. */
  7276. private _fillAlignment;
  7277. /**
  7278. * Adds an uniform in the buffer.
  7279. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7280. * for the layout to be correct !
  7281. * @param name Name of the uniform, as used in the uniform block in the shader.
  7282. * @param size Data size, or data directly.
  7283. */
  7284. addUniform(name: string, size: number | number[]): void;
  7285. /**
  7286. * Adds a Matrix 4x4 to the uniform buffer.
  7287. * @param name Name of the uniform, as used in the uniform block in the shader.
  7288. * @param mat A 4x4 matrix.
  7289. */
  7290. addMatrix(name: string, mat: Matrix): void;
  7291. /**
  7292. * Adds a vec2 to the uniform buffer.
  7293. * @param name Name of the uniform, as used in the uniform block in the shader.
  7294. * @param x Define the x component value of the vec2
  7295. * @param y Define the y component value of the vec2
  7296. */
  7297. addFloat2(name: string, x: number, y: number): void;
  7298. /**
  7299. * Adds a vec3 to the uniform buffer.
  7300. * @param name Name of the uniform, as used in the uniform block in the shader.
  7301. * @param x Define the x component value of the vec3
  7302. * @param y Define the y component value of the vec3
  7303. * @param z Define the z component value of the vec3
  7304. */
  7305. addFloat3(name: string, x: number, y: number, z: number): void;
  7306. /**
  7307. * Adds a vec3 to the uniform buffer.
  7308. * @param name Name of the uniform, as used in the uniform block in the shader.
  7309. * @param color Define the vec3 from a Color
  7310. */
  7311. addColor3(name: string, color: Color3): void;
  7312. /**
  7313. * Adds a vec4 to the uniform buffer.
  7314. * @param name Name of the uniform, as used in the uniform block in the shader.
  7315. * @param color Define the rgb components from a Color
  7316. * @param alpha Define the a component of the vec4
  7317. */
  7318. addColor4(name: string, color: Color3, alpha: number): void;
  7319. /**
  7320. * Adds a vec3 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. * @param vector Define the vec3 components from a Vector
  7323. */
  7324. addVector3(name: string, vector: Vector3): void;
  7325. /**
  7326. * Adds a Matrix 3x3 to the uniform buffer.
  7327. * @param name Name of the uniform, as used in the uniform block in the shader.
  7328. */
  7329. addMatrix3x3(name: string): void;
  7330. /**
  7331. * Adds a Matrix 2x2 to the uniform buffer.
  7332. * @param name Name of the uniform, as used in the uniform block in the shader.
  7333. */
  7334. addMatrix2x2(name: string): void;
  7335. /**
  7336. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7337. */
  7338. create(): void;
  7339. /** @hidden */
  7340. _rebuild(): void;
  7341. /**
  7342. * Updates the WebGL Uniform Buffer on the GPU.
  7343. * If the `dynamic` flag is set to true, no cache comparison is done.
  7344. * Otherwise, the buffer will be updated only if the cache differs.
  7345. */
  7346. update(): void;
  7347. /**
  7348. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7349. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7350. * @param data Define the flattened data
  7351. * @param size Define the size of the data.
  7352. */
  7353. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7354. private _valueCache;
  7355. private _cacheMatrix;
  7356. private _updateMatrix3x3ForUniform;
  7357. private _updateMatrix3x3ForEffect;
  7358. private _updateMatrix2x2ForEffect;
  7359. private _updateMatrix2x2ForUniform;
  7360. private _updateFloatForEffect;
  7361. private _updateFloatForUniform;
  7362. private _updateFloat2ForEffect;
  7363. private _updateFloat2ForUniform;
  7364. private _updateFloat3ForEffect;
  7365. private _updateFloat3ForUniform;
  7366. private _updateFloat4ForEffect;
  7367. private _updateFloat4ForUniform;
  7368. private _updateMatrixForEffect;
  7369. private _updateMatrixForUniform;
  7370. private _updateVector3ForEffect;
  7371. private _updateVector3ForUniform;
  7372. private _updateVector4ForEffect;
  7373. private _updateVector4ForUniform;
  7374. private _updateColor3ForEffect;
  7375. private _updateColor3ForUniform;
  7376. private _updateColor4ForEffect;
  7377. private _updateColor4ForUniform;
  7378. /**
  7379. * Sets a sampler uniform on the effect.
  7380. * @param name Define the name of the sampler.
  7381. * @param texture Define the texture to set in the sampler
  7382. */
  7383. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7384. /**
  7385. * Directly updates the value of the uniform in the cache AND on the GPU.
  7386. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7387. * @param data Define the flattened data
  7388. */
  7389. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7390. /**
  7391. * Binds this uniform buffer to an effect.
  7392. * @param effect Define the effect to bind the buffer to
  7393. * @param name Name of the uniform block in the shader.
  7394. */
  7395. bindToEffect(effect: Effect, name: string): void;
  7396. /**
  7397. * Disposes the uniform buffer.
  7398. */
  7399. dispose(): void;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/iInspectable" {
  7403. /**
  7404. * Enum that determines the text-wrapping mode to use.
  7405. */
  7406. export enum InspectableType {
  7407. /**
  7408. * Checkbox for booleans
  7409. */
  7410. Checkbox = 0,
  7411. /**
  7412. * Sliders for numbers
  7413. */
  7414. Slider = 1,
  7415. /**
  7416. * Vector3
  7417. */
  7418. Vector3 = 2,
  7419. /**
  7420. * Quaternions
  7421. */
  7422. Quaternion = 3,
  7423. /**
  7424. * Color3
  7425. */
  7426. Color3 = 4,
  7427. /**
  7428. * String
  7429. */
  7430. String = 5
  7431. }
  7432. /**
  7433. * Interface used to define custom inspectable properties.
  7434. * This interface is used by the inspector to display custom property grids
  7435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7436. */
  7437. export interface IInspectable {
  7438. /**
  7439. * Gets the label to display
  7440. */
  7441. label: string;
  7442. /**
  7443. * Gets the name of the property to edit
  7444. */
  7445. propertyName: string;
  7446. /**
  7447. * Gets the type of the editor to use
  7448. */
  7449. type: InspectableType;
  7450. /**
  7451. * Gets the minimum value of the property when using in "slider" mode
  7452. */
  7453. min?: number;
  7454. /**
  7455. * Gets the maximum value of the property when using in "slider" mode
  7456. */
  7457. max?: number;
  7458. /**
  7459. * Gets the setp to use when using in "slider" mode
  7460. */
  7461. step?: number;
  7462. }
  7463. }
  7464. declare module "babylonjs/Misc/timingTools" {
  7465. /**
  7466. * Class used to provide helper for timing
  7467. */
  7468. export class TimingTools {
  7469. /**
  7470. * Polyfill for setImmediate
  7471. * @param action defines the action to execute after the current execution block
  7472. */
  7473. static SetImmediate(action: () => void): void;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/instantiationTools" {
  7477. /**
  7478. * Class used to enable instatition of objects by class name
  7479. */
  7480. export class InstantiationTools {
  7481. /**
  7482. * Use this object to register external classes like custom textures or material
  7483. * to allow the laoders to instantiate them
  7484. */
  7485. static RegisteredExternalClasses: {
  7486. [key: string]: Object;
  7487. };
  7488. /**
  7489. * Tries to instantiate a new object from a given class name
  7490. * @param className defines the class name to instantiate
  7491. * @returns the new object or null if the system was not able to do the instantiation
  7492. */
  7493. static Instantiate(className: string): any;
  7494. }
  7495. }
  7496. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7497. /**
  7498. * Define options used to create a depth texture
  7499. */
  7500. export class DepthTextureCreationOptions {
  7501. /** Specifies whether or not a stencil should be allocated in the texture */
  7502. generateStencil?: boolean;
  7503. /** Specifies whether or not bilinear filtering is enable on the texture */
  7504. bilinearFiltering?: boolean;
  7505. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7506. comparisonFunction?: number;
  7507. /** Specifies if the created texture is a cube texture */
  7508. isCube?: boolean;
  7509. }
  7510. }
  7511. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7513. import { Nullable } from "babylonjs/types";
  7514. import { Scene } from "babylonjs/scene";
  7515. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7516. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7517. module "babylonjs/Engines/thinEngine" {
  7518. interface ThinEngine {
  7519. /**
  7520. * Creates a depth stencil cube texture.
  7521. * This is only available in WebGL 2.
  7522. * @param size The size of face edge in the cube texture.
  7523. * @param options The options defining the cube texture.
  7524. * @returns The cube texture
  7525. */
  7526. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7527. /**
  7528. * Creates a cube texture
  7529. * @param rootUrl defines the url where the files to load is located
  7530. * @param scene defines the current scene
  7531. * @param files defines the list of files to load (1 per face)
  7532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7533. * @param onLoad defines an optional callback raised when the texture is loaded
  7534. * @param onError defines an optional callback raised if there is an issue to load the texture
  7535. * @param format defines the format of the data
  7536. * @param forcedExtension defines the extension to use to pick the right loader
  7537. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7538. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7539. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7540. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7541. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7542. * @returns the cube texture as an InternalTexture
  7543. */
  7544. 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;
  7545. /**
  7546. * Creates a cube texture
  7547. * @param rootUrl defines the url where the files to load is located
  7548. * @param scene defines the current scene
  7549. * @param files defines the list of files to load (1 per face)
  7550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7551. * @param onLoad defines an optional callback raised when the texture is loaded
  7552. * @param onError defines an optional callback raised if there is an issue to load the texture
  7553. * @param format defines the format of the data
  7554. * @param forcedExtension defines the extension to use to pick the right loader
  7555. * @returns the cube texture as an InternalTexture
  7556. */
  7557. 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;
  7558. /**
  7559. * Creates a cube texture
  7560. * @param rootUrl defines the url where the files to load is located
  7561. * @param scene defines the current scene
  7562. * @param files defines the list of files to load (1 per face)
  7563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7564. * @param onLoad defines an optional callback raised when the texture is loaded
  7565. * @param onError defines an optional callback raised if there is an issue to load the texture
  7566. * @param format defines the format of the data
  7567. * @param forcedExtension defines the extension to use to pick the right loader
  7568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7571. * @returns the cube texture as an InternalTexture
  7572. */
  7573. 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;
  7574. /** @hidden */
  7575. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7576. /** @hidden */
  7577. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7578. /** @hidden */
  7579. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7580. /** @hidden */
  7581. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7582. /**
  7583. * @hidden
  7584. */
  7585. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7586. }
  7587. }
  7588. }
  7589. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7590. import { Nullable } from "babylonjs/types";
  7591. import { Scene } from "babylonjs/scene";
  7592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7594. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7595. /**
  7596. * Class for creating a cube texture
  7597. */
  7598. export class CubeTexture extends BaseTexture {
  7599. private _delayedOnLoad;
  7600. /**
  7601. * The url of the texture
  7602. */
  7603. url: string;
  7604. /**
  7605. * Gets or sets the center of the bounding box associated with the cube texture.
  7606. * It must define where the camera used to render the texture was set
  7607. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7608. */
  7609. boundingBoxPosition: Vector3;
  7610. private _boundingBoxSize;
  7611. /**
  7612. * Gets or sets the size of the bounding box associated with the cube texture
  7613. * When defined, the cubemap will switch to local mode
  7614. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7615. * @example https://www.babylonjs-playground.com/#RNASML
  7616. */
  7617. /**
  7618. * Returns the bounding box size
  7619. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7620. */
  7621. boundingBoxSize: Vector3;
  7622. protected _rotationY: number;
  7623. /**
  7624. * Sets texture matrix rotation angle around Y axis in radians.
  7625. */
  7626. /**
  7627. * Gets texture matrix rotation angle around Y axis radians.
  7628. */
  7629. rotationY: number;
  7630. /**
  7631. * Are mip maps generated for this texture or not.
  7632. */
  7633. readonly noMipmap: boolean;
  7634. private _noMipmap;
  7635. private _files;
  7636. protected _forcedExtension: Nullable<string>;
  7637. private _extensions;
  7638. private _textureMatrix;
  7639. private _format;
  7640. private _createPolynomials;
  7641. /** @hidden */
  7642. _prefiltered: boolean;
  7643. /**
  7644. * Creates a cube texture from an array of image urls
  7645. * @param files defines an array of image urls
  7646. * @param scene defines the hosting scene
  7647. * @param noMipmap specifies if mip maps are not used
  7648. * @returns a cube texture
  7649. */
  7650. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7651. /**
  7652. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7653. * @param url defines the url of the prefiltered texture
  7654. * @param scene defines the scene the texture is attached to
  7655. * @param forcedExtension defines the extension of the file if different from the url
  7656. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7657. * @return the prefiltered texture
  7658. */
  7659. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7660. /**
  7661. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7662. * as prefiltered data.
  7663. * @param rootUrl defines the url of the texture or the root name of the six images
  7664. * @param scene defines the scene the texture is attached to
  7665. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7666. * @param noMipmap defines if mipmaps should be created or not
  7667. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7668. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7669. * @param onError defines a callback triggered in case of error during load
  7670. * @param format defines the internal format to use for the texture once loaded
  7671. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7672. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7673. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7674. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7675. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7676. * @return the cube texture
  7677. */
  7678. 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);
  7679. /**
  7680. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7681. */
  7682. readonly isPrefiltered: boolean;
  7683. /**
  7684. * Get the current class name of the texture useful for serialization or dynamic coding.
  7685. * @returns "CubeTexture"
  7686. */
  7687. getClassName(): string;
  7688. /**
  7689. * Update the url (and optional buffer) of this texture if url was null during construction.
  7690. * @param url the url of the texture
  7691. * @param forcedExtension defines the extension to use
  7692. * @param onLoad callback called when the texture is loaded (defaults to null)
  7693. */
  7694. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7695. /**
  7696. * Delays loading of the cube texture
  7697. * @param forcedExtension defines the extension to use
  7698. */
  7699. delayLoad(forcedExtension?: string): void;
  7700. /**
  7701. * Returns the reflection texture matrix
  7702. * @returns the reflection texture matrix
  7703. */
  7704. getReflectionTextureMatrix(): Matrix;
  7705. /**
  7706. * Sets the reflection texture matrix
  7707. * @param value Reflection texture matrix
  7708. */
  7709. setReflectionTextureMatrix(value: Matrix): void;
  7710. /**
  7711. * Parses text to create a cube texture
  7712. * @param parsedTexture define the serialized text to read from
  7713. * @param scene defines the hosting scene
  7714. * @param rootUrl defines the root url of the cube texture
  7715. * @returns a cube texture
  7716. */
  7717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7718. /**
  7719. * Makes a clone, or deep copy, of the cube texture
  7720. * @returns a new cube texture
  7721. */
  7722. clone(): CubeTexture;
  7723. }
  7724. }
  7725. declare module "babylonjs/Materials/materialDefines" {
  7726. /**
  7727. * Manages the defines for the Material
  7728. */
  7729. export class MaterialDefines {
  7730. /** @hidden */
  7731. protected _keys: string[];
  7732. private _isDirty;
  7733. /** @hidden */
  7734. _renderId: number;
  7735. /** @hidden */
  7736. _areLightsDirty: boolean;
  7737. /** @hidden */
  7738. _areLightsDisposed: boolean;
  7739. /** @hidden */
  7740. _areAttributesDirty: boolean;
  7741. /** @hidden */
  7742. _areTexturesDirty: boolean;
  7743. /** @hidden */
  7744. _areFresnelDirty: boolean;
  7745. /** @hidden */
  7746. _areMiscDirty: boolean;
  7747. /** @hidden */
  7748. _areImageProcessingDirty: boolean;
  7749. /** @hidden */
  7750. _normals: boolean;
  7751. /** @hidden */
  7752. _uvs: boolean;
  7753. /** @hidden */
  7754. _needNormals: boolean;
  7755. /** @hidden */
  7756. _needUVs: boolean;
  7757. [id: string]: any;
  7758. /**
  7759. * Specifies if the material needs to be re-calculated
  7760. */
  7761. readonly isDirty: boolean;
  7762. /**
  7763. * Marks the material to indicate that it has been re-calculated
  7764. */
  7765. markAsProcessed(): void;
  7766. /**
  7767. * Marks the material to indicate that it needs to be re-calculated
  7768. */
  7769. markAsUnprocessed(): void;
  7770. /**
  7771. * Marks the material to indicate all of its defines need to be re-calculated
  7772. */
  7773. markAllAsDirty(): void;
  7774. /**
  7775. * Marks the material to indicate that image processing needs to be re-calculated
  7776. */
  7777. markAsImageProcessingDirty(): void;
  7778. /**
  7779. * Marks the material to indicate the lights need to be re-calculated
  7780. * @param disposed Defines whether the light is dirty due to dispose or not
  7781. */
  7782. markAsLightDirty(disposed?: boolean): void;
  7783. /**
  7784. * Marks the attribute state as changed
  7785. */
  7786. markAsAttributesDirty(): void;
  7787. /**
  7788. * Marks the texture state as changed
  7789. */
  7790. markAsTexturesDirty(): void;
  7791. /**
  7792. * Marks the fresnel state as changed
  7793. */
  7794. markAsFresnelDirty(): void;
  7795. /**
  7796. * Marks the misc state as changed
  7797. */
  7798. markAsMiscDirty(): void;
  7799. /**
  7800. * Rebuilds the material defines
  7801. */
  7802. rebuild(): void;
  7803. /**
  7804. * Specifies if two material defines are equal
  7805. * @param other - A material define instance to compare to
  7806. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7807. */
  7808. isEqual(other: MaterialDefines): boolean;
  7809. /**
  7810. * Clones this instance's defines to another instance
  7811. * @param other - material defines to clone values to
  7812. */
  7813. cloneTo(other: MaterialDefines): void;
  7814. /**
  7815. * Resets the material define values
  7816. */
  7817. reset(): void;
  7818. /**
  7819. * Converts the material define values to a string
  7820. * @returns - String of material define information
  7821. */
  7822. toString(): string;
  7823. }
  7824. }
  7825. declare module "babylonjs/Materials/colorCurves" {
  7826. import { Effect } from "babylonjs/Materials/effect";
  7827. /**
  7828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7830. * 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;
  7831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7832. */
  7833. export class ColorCurves {
  7834. private _dirty;
  7835. private _tempColor;
  7836. private _globalCurve;
  7837. private _highlightsCurve;
  7838. private _midtonesCurve;
  7839. private _shadowsCurve;
  7840. private _positiveCurve;
  7841. private _negativeCurve;
  7842. private _globalHue;
  7843. private _globalDensity;
  7844. private _globalSaturation;
  7845. private _globalExposure;
  7846. /**
  7847. * Gets the global Hue value.
  7848. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7849. */
  7850. /**
  7851. * Sets the global Hue value.
  7852. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7853. */
  7854. globalHue: number;
  7855. /**
  7856. * Gets the global Density value.
  7857. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7858. * Values less than zero provide a filter of opposite hue.
  7859. */
  7860. /**
  7861. * Sets the global Density value.
  7862. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7863. * Values less than zero provide a filter of opposite hue.
  7864. */
  7865. globalDensity: number;
  7866. /**
  7867. * Gets the global Saturation value.
  7868. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7869. */
  7870. /**
  7871. * Sets the global Saturation value.
  7872. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7873. */
  7874. globalSaturation: number;
  7875. /**
  7876. * Gets the global Exposure value.
  7877. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7878. */
  7879. /**
  7880. * Sets the global Exposure value.
  7881. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7882. */
  7883. globalExposure: number;
  7884. private _highlightsHue;
  7885. private _highlightsDensity;
  7886. private _highlightsSaturation;
  7887. private _highlightsExposure;
  7888. /**
  7889. * Gets the highlights Hue value.
  7890. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7891. */
  7892. /**
  7893. * Sets the highlights Hue value.
  7894. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7895. */
  7896. highlightsHue: number;
  7897. /**
  7898. * Gets the highlights Density value.
  7899. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7900. * Values less than zero provide a filter of opposite hue.
  7901. */
  7902. /**
  7903. * Sets the highlights Density value.
  7904. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7905. * Values less than zero provide a filter of opposite hue.
  7906. */
  7907. highlightsDensity: number;
  7908. /**
  7909. * Gets the highlights Saturation value.
  7910. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7911. */
  7912. /**
  7913. * Sets the highlights Saturation value.
  7914. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7915. */
  7916. highlightsSaturation: number;
  7917. /**
  7918. * Gets the highlights Exposure value.
  7919. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7920. */
  7921. /**
  7922. * Sets the highlights Exposure value.
  7923. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7924. */
  7925. highlightsExposure: number;
  7926. private _midtonesHue;
  7927. private _midtonesDensity;
  7928. private _midtonesSaturation;
  7929. private _midtonesExposure;
  7930. /**
  7931. * Gets the midtones Hue value.
  7932. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7933. */
  7934. /**
  7935. * Sets the midtones Hue value.
  7936. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7937. */
  7938. midtonesHue: number;
  7939. /**
  7940. * Gets the midtones Density value.
  7941. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the midtones Density value.
  7946. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. midtonesDensity: number;
  7950. /**
  7951. * Gets the midtones Saturation value.
  7952. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7953. */
  7954. /**
  7955. * Sets the midtones Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. midtonesSaturation: number;
  7959. /**
  7960. * Gets the midtones Exposure value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7962. */
  7963. /**
  7964. * Sets the midtones Exposure value.
  7965. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7966. */
  7967. midtonesExposure: number;
  7968. private _shadowsHue;
  7969. private _shadowsDensity;
  7970. private _shadowsSaturation;
  7971. private _shadowsExposure;
  7972. /**
  7973. * Gets the shadows Hue value.
  7974. * 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).
  7975. */
  7976. /**
  7977. * Sets the shadows Hue value.
  7978. * 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).
  7979. */
  7980. shadowsHue: number;
  7981. /**
  7982. * Gets the shadows Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. /**
  7987. * Sets the shadows Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. shadowsDensity: number;
  7992. /**
  7993. * Gets the shadows Saturation value.
  7994. * 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.
  7995. */
  7996. /**
  7997. * Sets the shadows Saturation value.
  7998. * 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.
  7999. */
  8000. shadowsSaturation: number;
  8001. /**
  8002. * Gets the shadows Exposure value.
  8003. * 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.
  8004. */
  8005. /**
  8006. * Sets the shadows Exposure value.
  8007. * 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.
  8008. */
  8009. shadowsExposure: number;
  8010. /**
  8011. * Returns the class name
  8012. * @returns The class name
  8013. */
  8014. getClassName(): string;
  8015. /**
  8016. * Binds the color curves to the shader.
  8017. * @param colorCurves The color curve to bind
  8018. * @param effect The effect to bind to
  8019. * @param positiveUniform The positive uniform shader parameter
  8020. * @param neutralUniform The neutral uniform shader parameter
  8021. * @param negativeUniform The negative uniform shader parameter
  8022. */
  8023. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8024. /**
  8025. * Prepare the list of uniforms associated with the ColorCurves effects.
  8026. * @param uniformsList The list of uniforms used in the effect
  8027. */
  8028. static PrepareUniforms(uniformsList: string[]): void;
  8029. /**
  8030. * Returns color grading data based on a hue, density, saturation and exposure value.
  8031. * @param filterHue The hue of the color filter.
  8032. * @param filterDensity The density of the color filter.
  8033. * @param saturation The saturation.
  8034. * @param exposure The exposure.
  8035. * @param result The result data container.
  8036. */
  8037. private getColorGradingDataToRef;
  8038. /**
  8039. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8040. * @param value The input slider value in range [-100,100].
  8041. * @returns Adjusted value.
  8042. */
  8043. private static applyColorGradingSliderNonlinear;
  8044. /**
  8045. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8046. * @param hue The hue (H) input.
  8047. * @param saturation The saturation (S) input.
  8048. * @param brightness The brightness (B) input.
  8049. * @result An RGBA color represented as Vector4.
  8050. */
  8051. private static fromHSBToRef;
  8052. /**
  8053. * Returns a value clamped between min and max
  8054. * @param value The value to clamp
  8055. * @param min The minimum of value
  8056. * @param max The maximum of value
  8057. * @returns The clamped value.
  8058. */
  8059. private static clamp;
  8060. /**
  8061. * Clones the current color curve instance.
  8062. * @return The cloned curves
  8063. */
  8064. clone(): ColorCurves;
  8065. /**
  8066. * Serializes the current color curve instance to a json representation.
  8067. * @return a JSON representation
  8068. */
  8069. serialize(): any;
  8070. /**
  8071. * Parses the color curve from a json representation.
  8072. * @param source the JSON source to parse
  8073. * @return The parsed curves
  8074. */
  8075. static Parse(source: any): ColorCurves;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8079. import { Observable } from "babylonjs/Misc/observable";
  8080. import { Nullable } from "babylonjs/types";
  8081. import { Color4 } from "babylonjs/Maths/math.color";
  8082. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8083. import { Effect } from "babylonjs/Materials/effect";
  8084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8085. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8086. /**
  8087. * Interface to follow in your material defines to integrate easily the
  8088. * Image proccessing functions.
  8089. * @hidden
  8090. */
  8091. export interface IImageProcessingConfigurationDefines {
  8092. IMAGEPROCESSING: boolean;
  8093. VIGNETTE: boolean;
  8094. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8095. VIGNETTEBLENDMODEOPAQUE: boolean;
  8096. TONEMAPPING: boolean;
  8097. TONEMAPPING_ACES: boolean;
  8098. CONTRAST: boolean;
  8099. EXPOSURE: boolean;
  8100. COLORCURVES: boolean;
  8101. COLORGRADING: boolean;
  8102. COLORGRADING3D: boolean;
  8103. SAMPLER3DGREENDEPTH: boolean;
  8104. SAMPLER3DBGRMAP: boolean;
  8105. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8106. }
  8107. /**
  8108. * @hidden
  8109. */
  8110. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8111. IMAGEPROCESSING: boolean;
  8112. VIGNETTE: boolean;
  8113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8114. VIGNETTEBLENDMODEOPAQUE: boolean;
  8115. TONEMAPPING: boolean;
  8116. TONEMAPPING_ACES: boolean;
  8117. CONTRAST: boolean;
  8118. COLORCURVES: boolean;
  8119. COLORGRADING: boolean;
  8120. COLORGRADING3D: boolean;
  8121. SAMPLER3DGREENDEPTH: boolean;
  8122. SAMPLER3DBGRMAP: boolean;
  8123. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8124. EXPOSURE: boolean;
  8125. constructor();
  8126. }
  8127. /**
  8128. * This groups together the common properties used for image processing either in direct forward pass
  8129. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8130. * or not.
  8131. */
  8132. export class ImageProcessingConfiguration {
  8133. /**
  8134. * Default tone mapping applied in BabylonJS.
  8135. */
  8136. static readonly TONEMAPPING_STANDARD: number;
  8137. /**
  8138. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8139. * to other engines rendering to increase portability.
  8140. */
  8141. static readonly TONEMAPPING_ACES: number;
  8142. /**
  8143. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8144. */
  8145. colorCurves: Nullable<ColorCurves>;
  8146. private _colorCurvesEnabled;
  8147. /**
  8148. * Gets wether the color curves effect is enabled.
  8149. */
  8150. /**
  8151. * Sets wether the color curves effect is enabled.
  8152. */
  8153. colorCurvesEnabled: boolean;
  8154. private _colorGradingTexture;
  8155. /**
  8156. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8157. */
  8158. /**
  8159. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8160. */
  8161. colorGradingTexture: Nullable<BaseTexture>;
  8162. private _colorGradingEnabled;
  8163. /**
  8164. * Gets wether the color grading effect is enabled.
  8165. */
  8166. /**
  8167. * Sets wether the color grading effect is enabled.
  8168. */
  8169. colorGradingEnabled: boolean;
  8170. private _colorGradingWithGreenDepth;
  8171. /**
  8172. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8173. */
  8174. /**
  8175. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8176. */
  8177. colorGradingWithGreenDepth: boolean;
  8178. private _colorGradingBGR;
  8179. /**
  8180. * Gets wether the color grading texture contains BGR values.
  8181. */
  8182. /**
  8183. * Sets wether the color grading texture contains BGR values.
  8184. */
  8185. colorGradingBGR: boolean;
  8186. /** @hidden */
  8187. _exposure: number;
  8188. /**
  8189. * Gets the Exposure used in the effect.
  8190. */
  8191. /**
  8192. * Sets the Exposure used in the effect.
  8193. */
  8194. exposure: number;
  8195. private _toneMappingEnabled;
  8196. /**
  8197. * Gets wether the tone mapping effect is enabled.
  8198. */
  8199. /**
  8200. * Sets wether the tone mapping effect is enabled.
  8201. */
  8202. toneMappingEnabled: boolean;
  8203. private _toneMappingType;
  8204. /**
  8205. * Gets the type of tone mapping effect.
  8206. */
  8207. /**
  8208. * Sets the type of tone mapping effect used in BabylonJS.
  8209. */
  8210. toneMappingType: number;
  8211. protected _contrast: number;
  8212. /**
  8213. * Gets the contrast used in the effect.
  8214. */
  8215. /**
  8216. * Sets the contrast used in the effect.
  8217. */
  8218. contrast: number;
  8219. /**
  8220. * Vignette stretch size.
  8221. */
  8222. vignetteStretch: number;
  8223. /**
  8224. * Vignette centre X Offset.
  8225. */
  8226. vignetteCentreX: number;
  8227. /**
  8228. * Vignette centre Y Offset.
  8229. */
  8230. vignetteCentreY: number;
  8231. /**
  8232. * Vignette weight or intensity of the vignette effect.
  8233. */
  8234. vignetteWeight: number;
  8235. /**
  8236. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8237. * if vignetteEnabled is set to true.
  8238. */
  8239. vignetteColor: Color4;
  8240. /**
  8241. * Camera field of view used by the Vignette effect.
  8242. */
  8243. vignetteCameraFov: number;
  8244. private _vignetteBlendMode;
  8245. /**
  8246. * Gets the vignette blend mode allowing different kind of effect.
  8247. */
  8248. /**
  8249. * Sets the vignette blend mode allowing different kind of effect.
  8250. */
  8251. vignetteBlendMode: number;
  8252. private _vignetteEnabled;
  8253. /**
  8254. * Gets wether the vignette effect is enabled.
  8255. */
  8256. /**
  8257. * Sets wether the vignette effect is enabled.
  8258. */
  8259. vignetteEnabled: boolean;
  8260. private _applyByPostProcess;
  8261. /**
  8262. * Gets wether the image processing is applied through a post process or not.
  8263. */
  8264. /**
  8265. * Sets wether the image processing is applied through a post process or not.
  8266. */
  8267. applyByPostProcess: boolean;
  8268. private _isEnabled;
  8269. /**
  8270. * Gets wether the image processing is enabled or not.
  8271. */
  8272. /**
  8273. * Sets wether the image processing is enabled or not.
  8274. */
  8275. isEnabled: boolean;
  8276. /**
  8277. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8278. */
  8279. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8280. /**
  8281. * Method called each time the image processing information changes requires to recompile the effect.
  8282. */
  8283. protected _updateParameters(): void;
  8284. /**
  8285. * Gets the current class name.
  8286. * @return "ImageProcessingConfiguration"
  8287. */
  8288. getClassName(): string;
  8289. /**
  8290. * Prepare the list of uniforms associated with the Image Processing effects.
  8291. * @param uniforms The list of uniforms used in the effect
  8292. * @param defines the list of defines currently in use
  8293. */
  8294. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8295. /**
  8296. * Prepare the list of samplers associated with the Image Processing effects.
  8297. * @param samplersList The list of uniforms used in the effect
  8298. * @param defines the list of defines currently in use
  8299. */
  8300. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8301. /**
  8302. * Prepare the list of defines associated to the shader.
  8303. * @param defines the list of defines to complete
  8304. * @param forPostProcess Define if we are currently in post process mode or not
  8305. */
  8306. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8307. /**
  8308. * Returns true if all the image processing information are ready.
  8309. * @returns True if ready, otherwise, false
  8310. */
  8311. isReady(): boolean;
  8312. /**
  8313. * Binds the image processing to the shader.
  8314. * @param effect The effect to bind to
  8315. * @param overrideAspectRatio Override the aspect ratio of the effect
  8316. */
  8317. bind(effect: Effect, overrideAspectRatio?: number): void;
  8318. /**
  8319. * Clones the current image processing instance.
  8320. * @return The cloned image processing
  8321. */
  8322. clone(): ImageProcessingConfiguration;
  8323. /**
  8324. * Serializes the current image processing instance to a json representation.
  8325. * @return a JSON representation
  8326. */
  8327. serialize(): any;
  8328. /**
  8329. * Parses the image processing from a json representation.
  8330. * @param source the JSON source to parse
  8331. * @return The parsed image processing
  8332. */
  8333. static Parse(source: any): ImageProcessingConfiguration;
  8334. private static _VIGNETTEMODE_MULTIPLY;
  8335. private static _VIGNETTEMODE_OPAQUE;
  8336. /**
  8337. * Used to apply the vignette as a mix with the pixel color.
  8338. */
  8339. static readonly VIGNETTEMODE_MULTIPLY: number;
  8340. /**
  8341. * Used to apply the vignette as a replacement of the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_OPAQUE: number;
  8344. }
  8345. }
  8346. declare module "babylonjs/Shaders/postprocess.vertex" {
  8347. /** @hidden */
  8348. export var postprocessVertexShader: {
  8349. name: string;
  8350. shader: string;
  8351. };
  8352. }
  8353. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8354. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8356. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8357. module "babylonjs/Engines/thinEngine" {
  8358. interface ThinEngine {
  8359. /**
  8360. * Creates a new render target texture
  8361. * @param size defines the size of the texture
  8362. * @param options defines the options used to create the texture
  8363. * @returns a new render target texture stored in an InternalTexture
  8364. */
  8365. createRenderTargetTexture(size: number | {
  8366. width: number;
  8367. height: number;
  8368. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8369. /**
  8370. * Creates a depth stencil texture.
  8371. * This is only available in WebGL 2 or with the depth texture extension available.
  8372. * @param size The size of face edge in the texture.
  8373. * @param options The options defining the texture.
  8374. * @returns The texture
  8375. */
  8376. createDepthStencilTexture(size: number | {
  8377. width: number;
  8378. height: number;
  8379. }, options: DepthTextureCreationOptions): InternalTexture;
  8380. /** @hidden */
  8381. _createDepthStencilTexture(size: number | {
  8382. width: number;
  8383. height: number;
  8384. }, options: DepthTextureCreationOptions): InternalTexture;
  8385. }
  8386. }
  8387. }
  8388. declare module "babylonjs/Maths/math.axis" {
  8389. import { Vector3 } from "babylonjs/Maths/math.vector";
  8390. /** Defines supported spaces */
  8391. export enum Space {
  8392. /** Local (object) space */
  8393. LOCAL = 0,
  8394. /** World space */
  8395. WORLD = 1,
  8396. /** Bone space */
  8397. BONE = 2
  8398. }
  8399. /** Defines the 3 main axes */
  8400. export class Axis {
  8401. /** X axis */
  8402. static X: Vector3;
  8403. /** Y axis */
  8404. static Y: Vector3;
  8405. /** Z axis */
  8406. static Z: Vector3;
  8407. }
  8408. }
  8409. declare module "babylonjs/Cameras/targetCamera" {
  8410. import { Nullable } from "babylonjs/types";
  8411. import { Camera } from "babylonjs/Cameras/camera";
  8412. import { Scene } from "babylonjs/scene";
  8413. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8414. /**
  8415. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8416. * This is the base of the follow, arc rotate cameras and Free camera
  8417. * @see http://doc.babylonjs.com/features/cameras
  8418. */
  8419. export class TargetCamera extends Camera {
  8420. private static _RigCamTransformMatrix;
  8421. private static _TargetTransformMatrix;
  8422. private static _TargetFocalPoint;
  8423. /**
  8424. * Define the current direction the camera is moving to
  8425. */
  8426. cameraDirection: Vector3;
  8427. /**
  8428. * Define the current rotation the camera is rotating to
  8429. */
  8430. cameraRotation: Vector2;
  8431. /**
  8432. * When set, the up vector of the camera will be updated by the rotation of the camera
  8433. */
  8434. updateUpVectorFromRotation: boolean;
  8435. private _tmpQuaternion;
  8436. /**
  8437. * Define the current rotation of the camera
  8438. */
  8439. rotation: Vector3;
  8440. /**
  8441. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8442. */
  8443. rotationQuaternion: Quaternion;
  8444. /**
  8445. * Define the current speed of the camera
  8446. */
  8447. speed: number;
  8448. /**
  8449. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8450. * around all axis.
  8451. */
  8452. noRotationConstraint: boolean;
  8453. /**
  8454. * Define the current target of the camera as an object or a position.
  8455. */
  8456. lockedTarget: any;
  8457. /** @hidden */
  8458. _currentTarget: Vector3;
  8459. /** @hidden */
  8460. _initialFocalDistance: number;
  8461. /** @hidden */
  8462. _viewMatrix: Matrix;
  8463. /** @hidden */
  8464. _camMatrix: Matrix;
  8465. /** @hidden */
  8466. _cameraTransformMatrix: Matrix;
  8467. /** @hidden */
  8468. _cameraRotationMatrix: Matrix;
  8469. /** @hidden */
  8470. _referencePoint: Vector3;
  8471. /** @hidden */
  8472. _transformedReferencePoint: Vector3;
  8473. protected _globalCurrentTarget: Vector3;
  8474. protected _globalCurrentUpVector: Vector3;
  8475. /** @hidden */
  8476. _reset: () => void;
  8477. private _defaultUp;
  8478. /**
  8479. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8480. * This is the base of the follow, arc rotate cameras and Free camera
  8481. * @see http://doc.babylonjs.com/features/cameras
  8482. * @param name Defines the name of the camera in the scene
  8483. * @param position Defines the start position of the camera in the scene
  8484. * @param scene Defines the scene the camera belongs to
  8485. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8486. */
  8487. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8488. /**
  8489. * Gets the position in front of the camera at a given distance.
  8490. * @param distance The distance from the camera we want the position to be
  8491. * @returns the position
  8492. */
  8493. getFrontPosition(distance: number): Vector3;
  8494. /** @hidden */
  8495. _getLockedTargetPosition(): Nullable<Vector3>;
  8496. private _storedPosition;
  8497. private _storedRotation;
  8498. private _storedRotationQuaternion;
  8499. /**
  8500. * Store current camera state of the camera (fov, position, rotation, etc..)
  8501. * @returns the camera
  8502. */
  8503. storeState(): Camera;
  8504. /**
  8505. * Restored camera state. You must call storeState() first
  8506. * @returns whether it was successful or not
  8507. * @hidden
  8508. */
  8509. _restoreStateValues(): boolean;
  8510. /** @hidden */
  8511. _initCache(): void;
  8512. /** @hidden */
  8513. _updateCache(ignoreParentClass?: boolean): void;
  8514. /** @hidden */
  8515. _isSynchronizedViewMatrix(): boolean;
  8516. /** @hidden */
  8517. _computeLocalCameraSpeed(): number;
  8518. /**
  8519. * Defines the target the camera should look at.
  8520. * @param target Defines the new target as a Vector or a mesh
  8521. */
  8522. setTarget(target: Vector3): void;
  8523. /**
  8524. * Return the current target position of the camera. This value is expressed in local space.
  8525. * @returns the target position
  8526. */
  8527. getTarget(): Vector3;
  8528. /** @hidden */
  8529. _decideIfNeedsToMove(): boolean;
  8530. /** @hidden */
  8531. _updatePosition(): void;
  8532. /** @hidden */
  8533. _checkInputs(): void;
  8534. protected _updateCameraRotationMatrix(): void;
  8535. /**
  8536. * 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)
  8537. * @returns the current camera
  8538. */
  8539. private _rotateUpVectorWithCameraRotationMatrix;
  8540. private _cachedRotationZ;
  8541. private _cachedQuaternionRotationZ;
  8542. /** @hidden */
  8543. _getViewMatrix(): Matrix;
  8544. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8545. /**
  8546. * @hidden
  8547. */
  8548. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8549. /**
  8550. * @hidden
  8551. */
  8552. _updateRigCameras(): void;
  8553. private _getRigCamPositionAndTarget;
  8554. /**
  8555. * Gets the current object class name.
  8556. * @return the class name
  8557. */
  8558. getClassName(): string;
  8559. }
  8560. }
  8561. declare module "babylonjs/Events/keyboardEvents" {
  8562. /**
  8563. * Gather the list of keyboard event types as constants.
  8564. */
  8565. export class KeyboardEventTypes {
  8566. /**
  8567. * The keydown event is fired when a key becomes active (pressed).
  8568. */
  8569. static readonly KEYDOWN: number;
  8570. /**
  8571. * The keyup event is fired when a key has been released.
  8572. */
  8573. static readonly KEYUP: number;
  8574. }
  8575. /**
  8576. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8577. */
  8578. export class KeyboardInfo {
  8579. /**
  8580. * Defines the type of event (KeyboardEventTypes)
  8581. */
  8582. type: number;
  8583. /**
  8584. * Defines the related dom event
  8585. */
  8586. event: KeyboardEvent;
  8587. /**
  8588. * Instantiates a new keyboard info.
  8589. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8590. * @param type Defines the type of event (KeyboardEventTypes)
  8591. * @param event Defines the related dom event
  8592. */
  8593. constructor(
  8594. /**
  8595. * Defines the type of event (KeyboardEventTypes)
  8596. */
  8597. type: number,
  8598. /**
  8599. * Defines the related dom event
  8600. */
  8601. event: KeyboardEvent);
  8602. }
  8603. /**
  8604. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8605. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8606. */
  8607. export class KeyboardInfoPre extends KeyboardInfo {
  8608. /**
  8609. * Defines the type of event (KeyboardEventTypes)
  8610. */
  8611. type: number;
  8612. /**
  8613. * Defines the related dom event
  8614. */
  8615. event: KeyboardEvent;
  8616. /**
  8617. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8618. */
  8619. skipOnPointerObservable: boolean;
  8620. /**
  8621. * Instantiates a new keyboard pre info.
  8622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8623. * @param type Defines the type of event (KeyboardEventTypes)
  8624. * @param event Defines the related dom event
  8625. */
  8626. constructor(
  8627. /**
  8628. * Defines the type of event (KeyboardEventTypes)
  8629. */
  8630. type: number,
  8631. /**
  8632. * Defines the related dom event
  8633. */
  8634. event: KeyboardEvent);
  8635. }
  8636. }
  8637. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8638. import { Nullable } from "babylonjs/types";
  8639. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8641. /**
  8642. * Manage the keyboard inputs to control the movement of a free camera.
  8643. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8644. */
  8645. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8646. /**
  8647. * Defines the camera the input is attached to.
  8648. */
  8649. camera: FreeCamera;
  8650. /**
  8651. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8652. */
  8653. keysUp: number[];
  8654. /**
  8655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8656. */
  8657. keysDown: number[];
  8658. /**
  8659. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8660. */
  8661. keysLeft: number[];
  8662. /**
  8663. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8664. */
  8665. keysRight: number[];
  8666. private _keys;
  8667. private _onCanvasBlurObserver;
  8668. private _onKeyboardObserver;
  8669. private _engine;
  8670. private _scene;
  8671. /**
  8672. * Attach the input controls to a specific dom element to get the input from.
  8673. * @param element Defines the element the controls should be listened from
  8674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8675. */
  8676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8677. /**
  8678. * Detach the current controls from the specified dom element.
  8679. * @param element Defines the element to stop listening the inputs from
  8680. */
  8681. detachControl(element: Nullable<HTMLElement>): void;
  8682. /**
  8683. * Update the current camera state depending on the inputs that have been used this frame.
  8684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8685. */
  8686. checkInputs(): void;
  8687. /**
  8688. * Gets the class name of the current intput.
  8689. * @returns the class name
  8690. */
  8691. getClassName(): string;
  8692. /** @hidden */
  8693. _onLostFocus(): void;
  8694. /**
  8695. * Get the friendly name associated with the input class.
  8696. * @returns the input friendly name
  8697. */
  8698. getSimpleName(): string;
  8699. }
  8700. }
  8701. declare module "babylonjs/Lights/shadowLight" {
  8702. import { Camera } from "babylonjs/Cameras/camera";
  8703. import { Scene } from "babylonjs/scene";
  8704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8706. import { Light } from "babylonjs/Lights/light";
  8707. /**
  8708. * Interface describing all the common properties and methods a shadow light needs to implement.
  8709. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8710. * as well as binding the different shadow properties to the effects.
  8711. */
  8712. export interface IShadowLight extends Light {
  8713. /**
  8714. * The light id in the scene (used in scene.findLighById for instance)
  8715. */
  8716. id: string;
  8717. /**
  8718. * The position the shdow will be casted from.
  8719. */
  8720. position: Vector3;
  8721. /**
  8722. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8723. */
  8724. direction: Vector3;
  8725. /**
  8726. * The transformed position. Position of the light in world space taking parenting in account.
  8727. */
  8728. transformedPosition: Vector3;
  8729. /**
  8730. * The transformed direction. Direction of the light in world space taking parenting in account.
  8731. */
  8732. transformedDirection: Vector3;
  8733. /**
  8734. * The friendly name of the light in the scene.
  8735. */
  8736. name: string;
  8737. /**
  8738. * Defines the shadow projection clipping minimum z value.
  8739. */
  8740. shadowMinZ: number;
  8741. /**
  8742. * Defines the shadow projection clipping maximum z value.
  8743. */
  8744. shadowMaxZ: number;
  8745. /**
  8746. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8747. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8748. */
  8749. computeTransformedInformation(): boolean;
  8750. /**
  8751. * Gets the scene the light belongs to.
  8752. * @returns The scene
  8753. */
  8754. getScene(): Scene;
  8755. /**
  8756. * Callback defining a custom Projection Matrix Builder.
  8757. * This can be used to override the default projection matrix computation.
  8758. */
  8759. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8760. /**
  8761. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8762. * @param matrix The materix to updated with the projection information
  8763. * @param viewMatrix The transform matrix of the light
  8764. * @param renderList The list of mesh to render in the map
  8765. * @returns The current light
  8766. */
  8767. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8768. /**
  8769. * Gets the current depth scale used in ESM.
  8770. * @returns The scale
  8771. */
  8772. getDepthScale(): number;
  8773. /**
  8774. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8775. * @returns true if a cube texture needs to be use
  8776. */
  8777. needCube(): boolean;
  8778. /**
  8779. * Detects if the projection matrix requires to be recomputed this frame.
  8780. * @returns true if it requires to be recomputed otherwise, false.
  8781. */
  8782. needProjectionMatrixCompute(): boolean;
  8783. /**
  8784. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8785. */
  8786. forceProjectionMatrixCompute(): void;
  8787. /**
  8788. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8789. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8790. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8791. */
  8792. getShadowDirection(faceIndex?: number): Vector3;
  8793. /**
  8794. * Gets the minZ used for shadow according to both the scene and the light.
  8795. * @param activeCamera The camera we are returning the min for
  8796. * @returns the depth min z
  8797. */
  8798. getDepthMinZ(activeCamera: Camera): number;
  8799. /**
  8800. * Gets the maxZ used for shadow according to both the scene and the light.
  8801. * @param activeCamera The camera we are returning the max for
  8802. * @returns the depth max z
  8803. */
  8804. getDepthMaxZ(activeCamera: Camera): number;
  8805. }
  8806. /**
  8807. * Base implementation IShadowLight
  8808. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8809. */
  8810. export abstract class ShadowLight extends Light implements IShadowLight {
  8811. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8812. protected _position: Vector3;
  8813. protected _setPosition(value: Vector3): void;
  8814. /**
  8815. * Sets the position the shadow will be casted from. Also use as the light position for both
  8816. * point and spot lights.
  8817. */
  8818. /**
  8819. * Sets the position the shadow will be casted from. Also use as the light position for both
  8820. * point and spot lights.
  8821. */
  8822. position: Vector3;
  8823. protected _direction: Vector3;
  8824. protected _setDirection(value: Vector3): void;
  8825. /**
  8826. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8827. * Also use as the light direction on spot and directional lights.
  8828. */
  8829. /**
  8830. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8831. * Also use as the light direction on spot and directional lights.
  8832. */
  8833. direction: Vector3;
  8834. private _shadowMinZ;
  8835. /**
  8836. * Gets the shadow projection clipping minimum z value.
  8837. */
  8838. /**
  8839. * Sets the shadow projection clipping minimum z value.
  8840. */
  8841. shadowMinZ: number;
  8842. private _shadowMaxZ;
  8843. /**
  8844. * Sets the shadow projection clipping maximum z value.
  8845. */
  8846. /**
  8847. * Gets the shadow projection clipping maximum z value.
  8848. */
  8849. shadowMaxZ: number;
  8850. /**
  8851. * Callback defining a custom Projection Matrix Builder.
  8852. * This can be used to override the default projection matrix computation.
  8853. */
  8854. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8855. /**
  8856. * The transformed position. Position of the light in world space taking parenting in account.
  8857. */
  8858. transformedPosition: Vector3;
  8859. /**
  8860. * The transformed direction. Direction of the light in world space taking parenting in account.
  8861. */
  8862. transformedDirection: Vector3;
  8863. private _needProjectionMatrixCompute;
  8864. /**
  8865. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8866. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8867. */
  8868. computeTransformedInformation(): boolean;
  8869. /**
  8870. * Return the depth scale used for the shadow map.
  8871. * @returns the depth scale.
  8872. */
  8873. getDepthScale(): number;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Returns the ShadowLight absolute position in the World.
  8882. * @returns the position vector in world space
  8883. */
  8884. getAbsolutePosition(): Vector3;
  8885. /**
  8886. * Sets the ShadowLight direction toward the passed target.
  8887. * @param target The point to target in local space
  8888. * @returns the updated ShadowLight direction
  8889. */
  8890. setDirectionToTarget(target: Vector3): Vector3;
  8891. /**
  8892. * Returns the light rotation in euler definition.
  8893. * @returns the x y z rotation in local space.
  8894. */
  8895. getRotation(): Vector3;
  8896. /**
  8897. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8898. * @returns true if a cube texture needs to be use
  8899. */
  8900. needCube(): boolean;
  8901. /**
  8902. * Detects if the projection matrix requires to be recomputed this frame.
  8903. * @returns true if it requires to be recomputed otherwise, false.
  8904. */
  8905. needProjectionMatrixCompute(): boolean;
  8906. /**
  8907. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8908. */
  8909. forceProjectionMatrixCompute(): void;
  8910. /** @hidden */
  8911. _initCache(): void;
  8912. /** @hidden */
  8913. _isSynchronized(): boolean;
  8914. /**
  8915. * Computes the world matrix of the node
  8916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8917. * @returns the world matrix
  8918. */
  8919. computeWorldMatrix(force?: boolean): Matrix;
  8920. /**
  8921. * Gets the minZ used for shadow according to both the scene and the light.
  8922. * @param activeCamera The camera we are returning the min for
  8923. * @returns the depth min z
  8924. */
  8925. getDepthMinZ(activeCamera: Camera): number;
  8926. /**
  8927. * Gets the maxZ used for shadow according to both the scene and the light.
  8928. * @param activeCamera The camera we are returning the max for
  8929. * @returns the depth max z
  8930. */
  8931. getDepthMaxZ(activeCamera: Camera): number;
  8932. /**
  8933. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8934. * @param matrix The materix to updated with the projection information
  8935. * @param viewMatrix The transform matrix of the light
  8936. * @param renderList The list of mesh to render in the map
  8937. * @returns The current light
  8938. */
  8939. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8940. }
  8941. }
  8942. declare module "babylonjs/Materials/effectFallbacks" {
  8943. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8944. import { Effect } from "babylonjs/Materials/effect";
  8945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8946. /**
  8947. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8948. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8949. */
  8950. export class EffectFallbacks implements IEffectFallbacks {
  8951. private _defines;
  8952. private _currentRank;
  8953. private _maxRank;
  8954. private _mesh;
  8955. /**
  8956. * Removes the fallback from the bound mesh.
  8957. */
  8958. unBindMesh(): void;
  8959. /**
  8960. * Adds a fallback on the specified property.
  8961. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8962. * @param define The name of the define in the shader
  8963. */
  8964. addFallback(rank: number, define: string): void;
  8965. /**
  8966. * Sets the mesh to use CPU skinning when needing to fallback.
  8967. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8968. * @param mesh The mesh to use the fallbacks.
  8969. */
  8970. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8971. /**
  8972. * Checks to see if more fallbacks are still availible.
  8973. */
  8974. readonly hasMoreFallbacks: boolean;
  8975. /**
  8976. * Removes the defines that should be removed when falling back.
  8977. * @param currentDefines defines the current define statements for the shader.
  8978. * @param effect defines the current effect we try to compile
  8979. * @returns The resulting defines with defines of the current rank removed.
  8980. */
  8981. reduce(currentDefines: string, effect: Effect): string;
  8982. }
  8983. }
  8984. declare module "babylonjs/Materials/materialHelper" {
  8985. import { Nullable } from "babylonjs/types";
  8986. import { Scene } from "babylonjs/scene";
  8987. import { Engine } from "babylonjs/Engines/engine";
  8988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8989. import { Light } from "babylonjs/Lights/light";
  8990. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8991. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8994. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8995. /**
  8996. * "Static Class" containing the most commonly used helper while dealing with material for
  8997. * rendering purpose.
  8998. *
  8999. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9000. *
  9001. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9002. */
  9003. export class MaterialHelper {
  9004. /**
  9005. * Bind the current view position to an effect.
  9006. * @param effect The effect to be bound
  9007. * @param scene The scene the eyes position is used from
  9008. */
  9009. static BindEyePosition(effect: Effect, scene: Scene): void;
  9010. /**
  9011. * Helps preparing the defines values about the UVs in used in the effect.
  9012. * UVs are shared as much as we can accross channels in the shaders.
  9013. * @param texture The texture we are preparing the UVs for
  9014. * @param defines The defines to update
  9015. * @param key The channel key "diffuse", "specular"... used in the shader
  9016. */
  9017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9018. /**
  9019. * Binds a texture matrix value to its corrsponding uniform
  9020. * @param texture The texture to bind the matrix for
  9021. * @param uniformBuffer The uniform buffer receivin the data
  9022. * @param key The channel key "diffuse", "specular"... used in the shader
  9023. */
  9024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9025. /**
  9026. * Gets the current status of the fog (should it be enabled?)
  9027. * @param mesh defines the mesh to evaluate for fog support
  9028. * @param scene defines the hosting scene
  9029. * @returns true if fog must be enabled
  9030. */
  9031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9032. /**
  9033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9034. * @param mesh defines the current mesh
  9035. * @param scene defines the current scene
  9036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9037. * @param pointsCloud defines if point cloud rendering has to be turned on
  9038. * @param fogEnabled defines if fog has to be turned on
  9039. * @param alphaTest defines if alpha testing has to be turned on
  9040. * @param defines defines the current list of defines
  9041. */
  9042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9043. /**
  9044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9045. * @param scene defines the current scene
  9046. * @param engine defines the current engine
  9047. * @param defines specifies the list of active defines
  9048. * @param useInstances defines if instances have to be turned on
  9049. * @param useClipPlane defines if clip plane have to be turned on
  9050. */
  9051. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9052. /**
  9053. * Prepares the defines for bones
  9054. * @param mesh The mesh containing the geometry data we will draw
  9055. * @param defines The defines to update
  9056. */
  9057. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9058. /**
  9059. * Prepares the defines for morph targets
  9060. * @param mesh The mesh containing the geometry data we will draw
  9061. * @param defines The defines to update
  9062. */
  9063. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9064. /**
  9065. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9066. * @param mesh The mesh containing the geometry data we will draw
  9067. * @param defines The defines to update
  9068. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9069. * @param useBones Precise whether bones should be used or not (override mesh info)
  9070. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9071. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9072. * @returns false if defines are considered not dirty and have not been checked
  9073. */
  9074. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9075. /**
  9076. * Prepares the defines related to multiview
  9077. * @param scene The scene we are intending to draw
  9078. * @param defines The defines to update
  9079. */
  9080. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9081. /**
  9082. * Prepares the defines related to the light information passed in parameter
  9083. * @param scene The scene we are intending to draw
  9084. * @param mesh The mesh the effect is compiling for
  9085. * @param light The light the effect is compiling for
  9086. * @param lightIndex The index of the light
  9087. * @param defines The defines to update
  9088. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9089. * @param state Defines the current state regarding what is needed (normals, etc...)
  9090. */
  9091. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9092. needNormals: boolean;
  9093. needRebuild: boolean;
  9094. shadowEnabled: boolean;
  9095. specularEnabled: boolean;
  9096. lightmapMode: boolean;
  9097. }): void;
  9098. /**
  9099. * Prepares the defines related to the light information passed in parameter
  9100. * @param scene The scene we are intending to draw
  9101. * @param mesh The mesh the effect is compiling for
  9102. * @param defines The defines to update
  9103. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9104. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9105. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9106. * @returns true if normals will be required for the rest of the effect
  9107. */
  9108. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9109. /**
  9110. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9111. * @param lightIndex defines the light index
  9112. * @param uniformsList The uniform list
  9113. * @param samplersList The sampler list
  9114. * @param projectedLightTexture defines if projected texture must be used
  9115. * @param uniformBuffersList defines an optional list of uniform buffers
  9116. */
  9117. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9118. /**
  9119. * Prepares the uniforms and samplers list to be used in the effect
  9120. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9121. * @param samplersList The sampler list
  9122. * @param defines The defines helping in the list generation
  9123. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9124. */
  9125. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9126. /**
  9127. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9128. * @param defines The defines to update while falling back
  9129. * @param fallbacks The authorized effect fallbacks
  9130. * @param maxSimultaneousLights The maximum number of lights allowed
  9131. * @param rank the current rank of the Effect
  9132. * @returns The newly affected rank
  9133. */
  9134. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9135. private static _TmpMorphInfluencers;
  9136. /**
  9137. * Prepares the list of attributes required for morph targets according to the effect defines.
  9138. * @param attribs The current list of supported attribs
  9139. * @param mesh The mesh to prepare the morph targets attributes for
  9140. * @param influencers The number of influencers
  9141. */
  9142. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9143. /**
  9144. * Prepares the list of attributes required for morph targets according to the effect defines.
  9145. * @param attribs The current list of supported attribs
  9146. * @param mesh The mesh to prepare the morph targets attributes for
  9147. * @param defines The current Defines of the effect
  9148. */
  9149. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9150. /**
  9151. * Prepares the list of attributes required for bones according to the effect defines.
  9152. * @param attribs The current list of supported attribs
  9153. * @param mesh The mesh to prepare the bones attributes for
  9154. * @param defines The current Defines of the effect
  9155. * @param fallbacks The current efffect fallback strategy
  9156. */
  9157. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9158. /**
  9159. * Check and prepare the list of attributes required for instances according to the effect defines.
  9160. * @param attribs The current list of supported attribs
  9161. * @param defines The current MaterialDefines of the effect
  9162. */
  9163. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9164. /**
  9165. * Add the list of attributes required for instances to the attribs array.
  9166. * @param attribs The current list of supported attribs
  9167. */
  9168. static PushAttributesForInstances(attribs: string[]): void;
  9169. /**
  9170. * Binds the light information to the effect.
  9171. * @param light The light containing the generator
  9172. * @param effect The effect we are binding the data to
  9173. * @param lightIndex The light index in the effect used to render
  9174. */
  9175. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9176. /**
  9177. * Binds the lights information from the scene to the effect for the given mesh.
  9178. * @param light Light to bind
  9179. * @param lightIndex Light index
  9180. * @param scene The scene where the light belongs to
  9181. * @param effect The effect we are binding the data to
  9182. * @param useSpecular Defines if specular is supported
  9183. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9184. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9185. */
  9186. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9187. /**
  9188. * Binds the lights information from the scene to the effect for the given mesh.
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param effect The effect we are binding the data to
  9192. * @param defines The generated defines for the effect
  9193. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9194. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9196. */
  9197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9198. private static _tempFogColor;
  9199. /**
  9200. * Binds the fog information from the scene to the effect for the given mesh.
  9201. * @param scene The scene the lights belongs to
  9202. * @param mesh The mesh we are binding the information to render
  9203. * @param effect The effect we are binding the data to
  9204. * @param linearSpace Defines if the fog effect is applied in linear space
  9205. */
  9206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9207. /**
  9208. * Binds the bones information from the mesh to the effect.
  9209. * @param mesh The mesh we are binding the information to render
  9210. * @param effect The effect we are binding the data to
  9211. */
  9212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9213. /**
  9214. * Binds the morph targets information from the mesh to the effect.
  9215. * @param abstractMesh The mesh we are binding the information to render
  9216. * @param effect The effect we are binding the data to
  9217. */
  9218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9219. /**
  9220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9221. * @param defines The generated defines used in the effect
  9222. * @param effect The effect we are binding the data to
  9223. * @param scene The scene we are willing to render with logarithmic scale for
  9224. */
  9225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9226. /**
  9227. * Binds the clip plane information from the scene to the effect.
  9228. * @param scene The scene the clip plane information are extracted from
  9229. * @param effect The effect we are binding the data to
  9230. */
  9231. static BindClipPlane(effect: Effect, scene: Scene): void;
  9232. }
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9235. /** @hidden */
  9236. export var packingFunctions: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9242. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9243. /** @hidden */
  9244. export var shadowMapPixelShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9250. /** @hidden */
  9251. export var bonesDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9257. /** @hidden */
  9258. export var morphTargetsVertexGlobalDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9264. /** @hidden */
  9265. export var morphTargetsVertexDeclaration: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9271. /** @hidden */
  9272. export var instancesDeclaration: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9278. /** @hidden */
  9279. export var helperFunctions: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9285. /** @hidden */
  9286. export var morphTargetsVertex: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9292. /** @hidden */
  9293. export var instancesVertex: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9299. /** @hidden */
  9300. export var bonesVertex: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9307. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9308. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9310. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9312. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9313. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9314. /** @hidden */
  9315. export var shadowMapVertexShader: {
  9316. name: string;
  9317. shader: string;
  9318. };
  9319. }
  9320. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9321. /** @hidden */
  9322. export var depthBoxBlurPixelShader: {
  9323. name: string;
  9324. shader: string;
  9325. };
  9326. }
  9327. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9328. import { Nullable } from "babylonjs/types";
  9329. import { Scene } from "babylonjs/scene";
  9330. import { Matrix } from "babylonjs/Maths/math.vector";
  9331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9333. import { Mesh } from "babylonjs/Meshes/mesh";
  9334. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9335. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9336. import { Effect } from "babylonjs/Materials/effect";
  9337. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9338. import "babylonjs/Shaders/shadowMap.fragment";
  9339. import "babylonjs/Shaders/shadowMap.vertex";
  9340. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9341. import { Observable } from "babylonjs/Misc/observable";
  9342. /**
  9343. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9344. */
  9345. export interface ICustomShaderOptions {
  9346. /**
  9347. * Gets or sets the custom shader name to use
  9348. */
  9349. shaderName: string;
  9350. /**
  9351. * The list of attribute names used in the shader
  9352. */
  9353. attributes?: string[];
  9354. /**
  9355. * The list of unifrom names used in the shader
  9356. */
  9357. uniforms?: string[];
  9358. /**
  9359. * The list of sampler names used in the shader
  9360. */
  9361. samplers?: string[];
  9362. /**
  9363. * The list of defines used in the shader
  9364. */
  9365. defines?: string[];
  9366. }
  9367. /**
  9368. * Interface to implement to create a shadow generator compatible with BJS.
  9369. */
  9370. export interface IShadowGenerator {
  9371. /**
  9372. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9373. * @returns The render target texture if present otherwise, null
  9374. */
  9375. getShadowMap(): Nullable<RenderTargetTexture>;
  9376. /**
  9377. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9378. * @returns The render target texture if the shadow map is present otherwise, null
  9379. */
  9380. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9381. /**
  9382. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9383. * @param subMesh The submesh we want to render in the shadow map
  9384. * @param useInstances Defines wether will draw in the map using instances
  9385. * @returns true if ready otherwise, false
  9386. */
  9387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9388. /**
  9389. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9390. * @param defines Defines of the material we want to update
  9391. * @param lightIndex Index of the light in the enabled light list of the material
  9392. */
  9393. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9394. /**
  9395. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9396. * defined in the generator but impacting the effect).
  9397. * It implies the unifroms available on the materials are the standard BJS ones.
  9398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9399. * @param effect The effect we are binfing the information for
  9400. */
  9401. bindShadowLight(lightIndex: string, effect: Effect): void;
  9402. /**
  9403. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9404. * (eq to shadow prjection matrix * light transform matrix)
  9405. * @returns The transform matrix used to create the shadow map
  9406. */
  9407. getTransformMatrix(): Matrix;
  9408. /**
  9409. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9410. * Cube and 2D textures for instance.
  9411. */
  9412. recreateShadowMap(): void;
  9413. /**
  9414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9415. * @param onCompiled Callback triggered at the and of the effects compilation
  9416. * @param options Sets of optional options forcing the compilation with different modes
  9417. */
  9418. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9419. useInstances: boolean;
  9420. }>): void;
  9421. /**
  9422. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9423. * @param options Sets of optional options forcing the compilation with different modes
  9424. * @returns A promise that resolves when the compilation completes
  9425. */
  9426. forceCompilationAsync(options?: Partial<{
  9427. useInstances: boolean;
  9428. }>): Promise<void>;
  9429. /**
  9430. * Serializes the shadow generator setup to a json object.
  9431. * @returns The serialized JSON object
  9432. */
  9433. serialize(): any;
  9434. /**
  9435. * Disposes the Shadow map and related Textures and effects.
  9436. */
  9437. dispose(): void;
  9438. }
  9439. /**
  9440. * Default implementation IShadowGenerator.
  9441. * This is the main object responsible of generating shadows in the framework.
  9442. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9443. */
  9444. export class ShadowGenerator implements IShadowGenerator {
  9445. /**
  9446. * Shadow generator mode None: no filtering applied.
  9447. */
  9448. static readonly FILTER_NONE: number;
  9449. /**
  9450. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9451. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9452. */
  9453. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9454. /**
  9455. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9456. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9457. */
  9458. static readonly FILTER_POISSONSAMPLING: number;
  9459. /**
  9460. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9461. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9462. */
  9463. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9464. /**
  9465. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9466. * edge artifacts on steep falloff.
  9467. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9468. */
  9469. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9470. /**
  9471. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9472. * edge artifacts on steep falloff.
  9473. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9474. */
  9475. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9476. /**
  9477. * Shadow generator mode PCF: Percentage Closer Filtering
  9478. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9479. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9480. */
  9481. static readonly FILTER_PCF: number;
  9482. /**
  9483. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9484. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9485. * Contact Hardening
  9486. */
  9487. static readonly FILTER_PCSS: number;
  9488. /**
  9489. * Reserved for PCF and PCSS
  9490. * Highest Quality.
  9491. *
  9492. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9493. *
  9494. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9495. */
  9496. static readonly QUALITY_HIGH: number;
  9497. /**
  9498. * Reserved for PCF and PCSS
  9499. * Good tradeoff for quality/perf cross devices
  9500. *
  9501. * Execute PCF on a 3*3 kernel.
  9502. *
  9503. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9504. */
  9505. static readonly QUALITY_MEDIUM: number;
  9506. /**
  9507. * Reserved for PCF and PCSS
  9508. * The lowest quality but the fastest.
  9509. *
  9510. * Execute PCF on a 1*1 kernel.
  9511. *
  9512. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9513. */
  9514. static readonly QUALITY_LOW: number;
  9515. /** Gets or sets the custom shader name to use */
  9516. customShaderOptions: ICustomShaderOptions;
  9517. /**
  9518. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9519. */
  9520. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9521. /**
  9522. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9523. */
  9524. onAfterShadowMapRenderObservable: Observable<Effect>;
  9525. /**
  9526. * Observable triggered before a mesh is rendered in the shadow map.
  9527. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9528. */
  9529. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9530. /**
  9531. * Observable triggered after a mesh is rendered in the shadow map.
  9532. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9533. */
  9534. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9535. private _bias;
  9536. /**
  9537. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9538. */
  9539. /**
  9540. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9541. */
  9542. bias: number;
  9543. private _normalBias;
  9544. /**
  9545. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9546. */
  9547. /**
  9548. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9549. */
  9550. normalBias: number;
  9551. private _blurBoxOffset;
  9552. /**
  9553. * Gets the blur box offset: offset applied during the blur pass.
  9554. * Only useful if useKernelBlur = false
  9555. */
  9556. /**
  9557. * Sets the blur box offset: offset applied during the blur pass.
  9558. * Only useful if useKernelBlur = false
  9559. */
  9560. blurBoxOffset: number;
  9561. private _blurScale;
  9562. /**
  9563. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9564. * 2 means half of the size.
  9565. */
  9566. /**
  9567. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9568. * 2 means half of the size.
  9569. */
  9570. blurScale: number;
  9571. private _blurKernel;
  9572. /**
  9573. * Gets the blur kernel: kernel size of the blur pass.
  9574. * Only useful if useKernelBlur = true
  9575. */
  9576. /**
  9577. * Sets the blur kernel: kernel size of the blur pass.
  9578. * Only useful if useKernelBlur = true
  9579. */
  9580. blurKernel: number;
  9581. private _useKernelBlur;
  9582. /**
  9583. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9584. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9585. */
  9586. /**
  9587. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9588. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9589. */
  9590. useKernelBlur: boolean;
  9591. private _depthScale;
  9592. /**
  9593. * Gets the depth scale used in ESM mode.
  9594. */
  9595. /**
  9596. * Sets the depth scale used in ESM mode.
  9597. * This can override the scale stored on the light.
  9598. */
  9599. depthScale: number;
  9600. private _filter;
  9601. /**
  9602. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9603. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9604. */
  9605. /**
  9606. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9607. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9608. */
  9609. filter: number;
  9610. /**
  9611. * Gets if the current filter is set to Poisson Sampling.
  9612. */
  9613. /**
  9614. * Sets the current filter to Poisson Sampling.
  9615. */
  9616. usePoissonSampling: boolean;
  9617. /**
  9618. * Gets if the current filter is set to ESM.
  9619. */
  9620. /**
  9621. * Sets the current filter is to ESM.
  9622. */
  9623. useExponentialShadowMap: boolean;
  9624. /**
  9625. * Gets if the current filter is set to filtered ESM.
  9626. */
  9627. /**
  9628. * Gets if the current filter is set to filtered ESM.
  9629. */
  9630. useBlurExponentialShadowMap: boolean;
  9631. /**
  9632. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9633. * exponential to prevent steep falloff artifacts).
  9634. */
  9635. /**
  9636. * Sets the current filter to "close ESM" (using the inverse of the
  9637. * exponential to prevent steep falloff artifacts).
  9638. */
  9639. useCloseExponentialShadowMap: boolean;
  9640. /**
  9641. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9642. * exponential to prevent steep falloff artifacts).
  9643. */
  9644. /**
  9645. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9646. * exponential to prevent steep falloff artifacts).
  9647. */
  9648. useBlurCloseExponentialShadowMap: boolean;
  9649. /**
  9650. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9651. */
  9652. /**
  9653. * Sets the current filter to "PCF" (percentage closer filtering).
  9654. */
  9655. usePercentageCloserFiltering: boolean;
  9656. private _filteringQuality;
  9657. /**
  9658. * Gets the PCF or PCSS Quality.
  9659. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9660. */
  9661. /**
  9662. * Sets the PCF or PCSS Quality.
  9663. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9664. */
  9665. filteringQuality: number;
  9666. /**
  9667. * Gets if the current filter is set to "PCSS" (contact hardening).
  9668. */
  9669. /**
  9670. * Sets the current filter to "PCSS" (contact hardening).
  9671. */
  9672. useContactHardeningShadow: boolean;
  9673. private _contactHardeningLightSizeUVRatio;
  9674. /**
  9675. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9676. * Using a ratio helps keeping shape stability independently of the map size.
  9677. *
  9678. * It does not account for the light projection as it was having too much
  9679. * instability during the light setup or during light position changes.
  9680. *
  9681. * Only valid if useContactHardeningShadow is true.
  9682. */
  9683. /**
  9684. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9685. * Using a ratio helps keeping shape stability independently of the map size.
  9686. *
  9687. * It does not account for the light projection as it was having too much
  9688. * instability during the light setup or during light position changes.
  9689. *
  9690. * Only valid if useContactHardeningShadow is true.
  9691. */
  9692. contactHardeningLightSizeUVRatio: number;
  9693. private _darkness;
  9694. /** Gets or sets the actual darkness of a shadow */
  9695. darkness: number;
  9696. /**
  9697. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9698. * 0 means strongest and 1 would means no shadow.
  9699. * @returns the darkness.
  9700. */
  9701. getDarkness(): number;
  9702. /**
  9703. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9704. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9705. * @returns the shadow generator allowing fluent coding.
  9706. */
  9707. setDarkness(darkness: number): ShadowGenerator;
  9708. private _transparencyShadow;
  9709. /** Gets or sets the ability to have transparent shadow */
  9710. transparencyShadow: boolean;
  9711. /**
  9712. * Sets the ability to have transparent shadow (boolean).
  9713. * @param transparent True if transparent else False
  9714. * @returns the shadow generator allowing fluent coding
  9715. */
  9716. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9717. private _shadowMap;
  9718. private _shadowMap2;
  9719. /**
  9720. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9721. * @returns The render target texture if present otherwise, null
  9722. */
  9723. getShadowMap(): Nullable<RenderTargetTexture>;
  9724. /**
  9725. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9726. * @returns The render target texture if the shadow map is present otherwise, null
  9727. */
  9728. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9729. /**
  9730. * Gets the class name of that object
  9731. * @returns "ShadowGenerator"
  9732. */
  9733. getClassName(): string;
  9734. /**
  9735. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9736. * @param mesh Mesh to add
  9737. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9738. * @returns the Shadow Generator itself
  9739. */
  9740. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9741. /**
  9742. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9743. * @param mesh Mesh to remove
  9744. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9745. * @returns the Shadow Generator itself
  9746. */
  9747. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9748. /**
  9749. * Controls the extent to which the shadows fade out at the edge of the frustum
  9750. * Used only by directionals and spots
  9751. */
  9752. frustumEdgeFalloff: number;
  9753. private _light;
  9754. /**
  9755. * Returns the associated light object.
  9756. * @returns the light generating the shadow
  9757. */
  9758. getLight(): IShadowLight;
  9759. /**
  9760. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9761. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9762. * It might on the other hand introduce peter panning.
  9763. */
  9764. forceBackFacesOnly: boolean;
  9765. private _scene;
  9766. private _lightDirection;
  9767. private _effect;
  9768. private _viewMatrix;
  9769. private _projectionMatrix;
  9770. private _transformMatrix;
  9771. private _cachedPosition;
  9772. private _cachedDirection;
  9773. private _cachedDefines;
  9774. private _currentRenderID;
  9775. private _boxBlurPostprocess;
  9776. private _kernelBlurXPostprocess;
  9777. private _kernelBlurYPostprocess;
  9778. private _blurPostProcesses;
  9779. private _mapSize;
  9780. private _currentFaceIndex;
  9781. private _currentFaceIndexCache;
  9782. private _textureType;
  9783. private _defaultTextureMatrix;
  9784. private _storedUniqueId;
  9785. /** @hidden */
  9786. static _SceneComponentInitialization: (scene: Scene) => void;
  9787. /**
  9788. * Creates a ShadowGenerator object.
  9789. * A ShadowGenerator is the required tool to use the shadows.
  9790. * Each light casting shadows needs to use its own ShadowGenerator.
  9791. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9792. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9793. * @param light The light object generating the shadows.
  9794. * @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.
  9795. */
  9796. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9797. private _initializeGenerator;
  9798. private _initializeShadowMap;
  9799. private _initializeBlurRTTAndPostProcesses;
  9800. private _renderForShadowMap;
  9801. private _renderSubMeshForShadowMap;
  9802. private _applyFilterValues;
  9803. /**
  9804. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9805. * @param onCompiled Callback triggered at the and of the effects compilation
  9806. * @param options Sets of optional options forcing the compilation with different modes
  9807. */
  9808. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9809. useInstances: boolean;
  9810. }>): void;
  9811. /**
  9812. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9813. * @param options Sets of optional options forcing the compilation with different modes
  9814. * @returns A promise that resolves when the compilation completes
  9815. */
  9816. forceCompilationAsync(options?: Partial<{
  9817. useInstances: boolean;
  9818. }>): Promise<void>;
  9819. /**
  9820. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9821. * @param subMesh The submesh we want to render in the shadow map
  9822. * @param useInstances Defines wether will draw in the map using instances
  9823. * @returns true if ready otherwise, false
  9824. */
  9825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9826. /**
  9827. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9828. * @param defines Defines of the material we want to update
  9829. * @param lightIndex Index of the light in the enabled light list of the material
  9830. */
  9831. prepareDefines(defines: any, lightIndex: number): void;
  9832. /**
  9833. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9834. * defined in the generator but impacting the effect).
  9835. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9836. * @param effect The effect we are binfing the information for
  9837. */
  9838. bindShadowLight(lightIndex: string, effect: Effect): void;
  9839. /**
  9840. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9841. * (eq to shadow prjection matrix * light transform matrix)
  9842. * @returns The transform matrix used to create the shadow map
  9843. */
  9844. getTransformMatrix(): Matrix;
  9845. /**
  9846. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9847. * Cube and 2D textures for instance.
  9848. */
  9849. recreateShadowMap(): void;
  9850. private _disposeBlurPostProcesses;
  9851. private _disposeRTTandPostProcesses;
  9852. /**
  9853. * Disposes the ShadowGenerator.
  9854. * Returns nothing.
  9855. */
  9856. dispose(): void;
  9857. /**
  9858. * Serializes the shadow generator setup to a json object.
  9859. * @returns The serialized JSON object
  9860. */
  9861. serialize(): any;
  9862. /**
  9863. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9864. * @param parsedShadowGenerator The JSON object to parse
  9865. * @param scene The scene to create the shadow map for
  9866. * @returns The parsed shadow generator
  9867. */
  9868. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9869. }
  9870. }
  9871. declare module "babylonjs/Lights/light" {
  9872. import { Nullable } from "babylonjs/types";
  9873. import { Scene } from "babylonjs/scene";
  9874. import { Vector3 } from "babylonjs/Maths/math.vector";
  9875. import { Color3 } from "babylonjs/Maths/math.color";
  9876. import { Node } from "babylonjs/node";
  9877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9878. import { Effect } from "babylonjs/Materials/effect";
  9879. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9880. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9881. /**
  9882. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9883. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9884. * 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.
  9885. */
  9886. export abstract class Light extends Node {
  9887. /**
  9888. * Falloff Default: light is falling off following the material specification:
  9889. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9890. */
  9891. static readonly FALLOFF_DEFAULT: number;
  9892. /**
  9893. * Falloff Physical: light is falling off following the inverse squared distance law.
  9894. */
  9895. static readonly FALLOFF_PHYSICAL: number;
  9896. /**
  9897. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9898. * to enhance interoperability with other engines.
  9899. */
  9900. static readonly FALLOFF_GLTF: number;
  9901. /**
  9902. * Falloff Standard: light is falling off like in the standard material
  9903. * to enhance interoperability with other materials.
  9904. */
  9905. static readonly FALLOFF_STANDARD: number;
  9906. /**
  9907. * If every light affecting the material is in this lightmapMode,
  9908. * material.lightmapTexture adds or multiplies
  9909. * (depends on material.useLightmapAsShadowmap)
  9910. * after every other light calculations.
  9911. */
  9912. static readonly LIGHTMAP_DEFAULT: number;
  9913. /**
  9914. * material.lightmapTexture as only diffuse lighting from this light
  9915. * adds only specular lighting from this light
  9916. * adds dynamic shadows
  9917. */
  9918. static readonly LIGHTMAP_SPECULAR: number;
  9919. /**
  9920. * material.lightmapTexture as only lighting
  9921. * no light calculation from this light
  9922. * only adds dynamic shadows from this light
  9923. */
  9924. static readonly LIGHTMAP_SHADOWSONLY: number;
  9925. /**
  9926. * Each light type uses the default quantity according to its type:
  9927. * point/spot lights use luminous intensity
  9928. * directional lights use illuminance
  9929. */
  9930. static readonly INTENSITYMODE_AUTOMATIC: number;
  9931. /**
  9932. * lumen (lm)
  9933. */
  9934. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9935. /**
  9936. * candela (lm/sr)
  9937. */
  9938. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9939. /**
  9940. * lux (lm/m^2)
  9941. */
  9942. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9943. /**
  9944. * nit (cd/m^2)
  9945. */
  9946. static readonly INTENSITYMODE_LUMINANCE: number;
  9947. /**
  9948. * Light type const id of the point light.
  9949. */
  9950. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9951. /**
  9952. * Light type const id of the directional light.
  9953. */
  9954. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9955. /**
  9956. * Light type const id of the spot light.
  9957. */
  9958. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9959. /**
  9960. * Light type const id of the hemispheric light.
  9961. */
  9962. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9963. /**
  9964. * Diffuse gives the basic color to an object.
  9965. */
  9966. diffuse: Color3;
  9967. /**
  9968. * Specular produces a highlight color on an object.
  9969. * Note: This is note affecting PBR materials.
  9970. */
  9971. specular: Color3;
  9972. /**
  9973. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9974. * falling off base on range or angle.
  9975. * This can be set to any values in Light.FALLOFF_x.
  9976. *
  9977. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9978. * other types of materials.
  9979. */
  9980. falloffType: number;
  9981. /**
  9982. * Strength of the light.
  9983. * Note: By default it is define in the framework own unit.
  9984. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9985. */
  9986. intensity: number;
  9987. private _range;
  9988. protected _inverseSquaredRange: number;
  9989. /**
  9990. * Defines how far from the source the light is impacting in scene units.
  9991. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9992. */
  9993. /**
  9994. * Defines how far from the source the light is impacting in scene units.
  9995. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9996. */
  9997. range: number;
  9998. /**
  9999. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10000. * of light.
  10001. */
  10002. private _photometricScale;
  10003. private _intensityMode;
  10004. /**
  10005. * Gets the photometric scale used to interpret the intensity.
  10006. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10007. */
  10008. /**
  10009. * Sets the photometric scale used to interpret the intensity.
  10010. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10011. */
  10012. intensityMode: number;
  10013. private _radius;
  10014. /**
  10015. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10016. */
  10017. /**
  10018. * sets the light radius used by PBR Materials to simulate soft area lights.
  10019. */
  10020. radius: number;
  10021. private _renderPriority;
  10022. /**
  10023. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10024. * exceeding the number allowed of the materials.
  10025. */
  10026. renderPriority: number;
  10027. private _shadowEnabled;
  10028. /**
  10029. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10030. * the current shadow generator.
  10031. */
  10032. /**
  10033. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10034. * the current shadow generator.
  10035. */
  10036. shadowEnabled: boolean;
  10037. private _includedOnlyMeshes;
  10038. /**
  10039. * Gets the only meshes impacted by this light.
  10040. */
  10041. /**
  10042. * Sets the only meshes impacted by this light.
  10043. */
  10044. includedOnlyMeshes: AbstractMesh[];
  10045. private _excludedMeshes;
  10046. /**
  10047. * Gets the meshes not impacted by this light.
  10048. */
  10049. /**
  10050. * Sets the meshes not impacted by this light.
  10051. */
  10052. excludedMeshes: AbstractMesh[];
  10053. private _excludeWithLayerMask;
  10054. /**
  10055. * Gets the layer id use to find what meshes are not impacted by the light.
  10056. * Inactive if 0
  10057. */
  10058. /**
  10059. * Sets the layer id use to find what meshes are not impacted by the light.
  10060. * Inactive if 0
  10061. */
  10062. excludeWithLayerMask: number;
  10063. private _includeOnlyWithLayerMask;
  10064. /**
  10065. * Gets the layer id use to find what meshes are impacted by the light.
  10066. * Inactive if 0
  10067. */
  10068. /**
  10069. * Sets the layer id use to find what meshes are impacted by the light.
  10070. * Inactive if 0
  10071. */
  10072. includeOnlyWithLayerMask: number;
  10073. private _lightmapMode;
  10074. /**
  10075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10076. */
  10077. /**
  10078. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10079. */
  10080. lightmapMode: number;
  10081. /**
  10082. * Shadow generator associted to the light.
  10083. * @hidden Internal use only.
  10084. */
  10085. _shadowGenerator: Nullable<IShadowGenerator>;
  10086. /**
  10087. * @hidden Internal use only.
  10088. */
  10089. _excludedMeshesIds: string[];
  10090. /**
  10091. * @hidden Internal use only.
  10092. */
  10093. _includedOnlyMeshesIds: string[];
  10094. /**
  10095. * The current light unifom buffer.
  10096. * @hidden Internal use only.
  10097. */
  10098. _uniformBuffer: UniformBuffer;
  10099. /** @hidden */
  10100. _renderId: number;
  10101. /**
  10102. * Creates a Light object in the scene.
  10103. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10104. * @param name The firendly name of the light
  10105. * @param scene The scene the light belongs too
  10106. */
  10107. constructor(name: string, scene: Scene);
  10108. protected abstract _buildUniformLayout(): void;
  10109. /**
  10110. * Sets the passed Effect "effect" with the Light information.
  10111. * @param effect The effect to update
  10112. * @param lightIndex The index of the light in the effect to update
  10113. * @returns The light
  10114. */
  10115. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10116. /**
  10117. * Sets the passed Effect "effect" with the Light information.
  10118. * @param effect The effect to update
  10119. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10120. * @returns The light
  10121. */
  10122. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10123. /**
  10124. * Returns the string "Light".
  10125. * @returns the class name
  10126. */
  10127. getClassName(): string;
  10128. /** @hidden */
  10129. readonly _isLight: boolean;
  10130. /**
  10131. * Converts the light information to a readable string for debug purpose.
  10132. * @param fullDetails Supports for multiple levels of logging within scene loading
  10133. * @returns the human readable light info
  10134. */
  10135. toString(fullDetails?: boolean): string;
  10136. /** @hidden */
  10137. protected _syncParentEnabledState(): void;
  10138. /**
  10139. * Set the enabled state of this node.
  10140. * @param value - the new enabled state
  10141. */
  10142. setEnabled(value: boolean): void;
  10143. /**
  10144. * Returns the Light associated shadow generator if any.
  10145. * @return the associated shadow generator.
  10146. */
  10147. getShadowGenerator(): Nullable<IShadowGenerator>;
  10148. /**
  10149. * Returns a Vector3, the absolute light position in the World.
  10150. * @returns the world space position of the light
  10151. */
  10152. getAbsolutePosition(): Vector3;
  10153. /**
  10154. * Specifies if the light will affect the passed mesh.
  10155. * @param mesh The mesh to test against the light
  10156. * @return true the mesh is affected otherwise, false.
  10157. */
  10158. canAffectMesh(mesh: AbstractMesh): boolean;
  10159. /**
  10160. * Sort function to order lights for rendering.
  10161. * @param a First Light object to compare to second.
  10162. * @param b Second Light object to compare first.
  10163. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10164. */
  10165. static CompareLightsPriority(a: Light, b: Light): number;
  10166. /**
  10167. * Releases resources associated with this node.
  10168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10170. */
  10171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10172. /**
  10173. * Returns the light type ID (integer).
  10174. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10175. */
  10176. getTypeID(): number;
  10177. /**
  10178. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10179. * @returns the scaled intensity in intensity mode unit
  10180. */
  10181. getScaledIntensity(): number;
  10182. /**
  10183. * Returns a new Light object, named "name", from the current one.
  10184. * @param name The name of the cloned light
  10185. * @returns the new created light
  10186. */
  10187. clone(name: string): Nullable<Light>;
  10188. /**
  10189. * Serializes the current light into a Serialization object.
  10190. * @returns the serialized object.
  10191. */
  10192. serialize(): any;
  10193. /**
  10194. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10195. * This new light is named "name" and added to the passed scene.
  10196. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10197. * @param name The friendly name of the light
  10198. * @param scene The scene the new light will belong to
  10199. * @returns the constructor function
  10200. */
  10201. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10202. /**
  10203. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10204. * @param parsedLight The JSON representation of the light
  10205. * @param scene The scene to create the parsed light in
  10206. * @returns the created light after parsing
  10207. */
  10208. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10209. private _hookArrayForExcluded;
  10210. private _hookArrayForIncludedOnly;
  10211. private _resyncMeshes;
  10212. /**
  10213. * Forces the meshes to update their light related information in their rendering used effects
  10214. * @hidden Internal Use Only
  10215. */
  10216. _markMeshesAsLightDirty(): void;
  10217. /**
  10218. * Recomputes the cached photometric scale if needed.
  10219. */
  10220. private _computePhotometricScale;
  10221. /**
  10222. * Returns the Photometric Scale according to the light type and intensity mode.
  10223. */
  10224. private _getPhotometricScale;
  10225. /**
  10226. * Reorder the light in the scene according to their defined priority.
  10227. * @hidden Internal Use Only
  10228. */
  10229. _reorderLightsInScene(): void;
  10230. /**
  10231. * Prepares the list of defines specific to the light type.
  10232. * @param defines the list of defines
  10233. * @param lightIndex defines the index of the light for the effect
  10234. */
  10235. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10236. }
  10237. }
  10238. declare module "babylonjs/Actions/action" {
  10239. import { Observable } from "babylonjs/Misc/observable";
  10240. import { Condition } from "babylonjs/Actions/condition";
  10241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10242. import { ActionManager } from "babylonjs/Actions/actionManager";
  10243. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10244. /**
  10245. * Interface used to define Action
  10246. */
  10247. export interface IAction {
  10248. /**
  10249. * Trigger for the action
  10250. */
  10251. trigger: number;
  10252. /** Options of the trigger */
  10253. triggerOptions: any;
  10254. /**
  10255. * Gets the trigger parameters
  10256. * @returns the trigger parameters
  10257. */
  10258. getTriggerParameter(): any;
  10259. /**
  10260. * Internal only - executes current action event
  10261. * @hidden
  10262. */
  10263. _executeCurrent(evt?: ActionEvent): void;
  10264. /**
  10265. * Serialize placeholder for child classes
  10266. * @param parent of child
  10267. * @returns the serialized object
  10268. */
  10269. serialize(parent: any): any;
  10270. /**
  10271. * Internal only
  10272. * @hidden
  10273. */
  10274. _prepare(): void;
  10275. /**
  10276. * Internal only - manager for action
  10277. * @hidden
  10278. */
  10279. _actionManager: AbstractActionManager;
  10280. /**
  10281. * Adds action to chain of actions, may be a DoNothingAction
  10282. * @param action defines the next action to execute
  10283. * @returns The action passed in
  10284. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10285. */
  10286. then(action: IAction): IAction;
  10287. }
  10288. /**
  10289. * The action to be carried out following a trigger
  10290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10291. */
  10292. export class Action implements IAction {
  10293. /** the trigger, with or without parameters, for the action */
  10294. triggerOptions: any;
  10295. /**
  10296. * Trigger for the action
  10297. */
  10298. trigger: number;
  10299. /**
  10300. * Internal only - manager for action
  10301. * @hidden
  10302. */
  10303. _actionManager: ActionManager;
  10304. private _nextActiveAction;
  10305. private _child;
  10306. private _condition?;
  10307. private _triggerParameter;
  10308. /**
  10309. * An event triggered prior to action being executed.
  10310. */
  10311. onBeforeExecuteObservable: Observable<Action>;
  10312. /**
  10313. * Creates a new Action
  10314. * @param triggerOptions the trigger, with or without parameters, for the action
  10315. * @param condition an optional determinant of action
  10316. */
  10317. constructor(
  10318. /** the trigger, with or without parameters, for the action */
  10319. triggerOptions: any, condition?: Condition);
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. _prepare(): void;
  10325. /**
  10326. * Gets the trigger parameters
  10327. * @returns the trigger parameters
  10328. */
  10329. getTriggerParameter(): any;
  10330. /**
  10331. * Internal only - executes current action event
  10332. * @hidden
  10333. */
  10334. _executeCurrent(evt?: ActionEvent): void;
  10335. /**
  10336. * Execute placeholder for child classes
  10337. * @param evt optional action event
  10338. */
  10339. execute(evt?: ActionEvent): void;
  10340. /**
  10341. * Skips to next active action
  10342. */
  10343. skipToNextActiveAction(): void;
  10344. /**
  10345. * Adds action to chain of actions, may be a DoNothingAction
  10346. * @param action defines the next action to execute
  10347. * @returns The action passed in
  10348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10349. */
  10350. then(action: Action): Action;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getProperty(propertyPath: string): string;
  10356. /**
  10357. * Internal only
  10358. * @hidden
  10359. */
  10360. _getEffectiveTarget(target: any, propertyPath: string): any;
  10361. /**
  10362. * Serialize placeholder for child classes
  10363. * @param parent of child
  10364. * @returns the serialized object
  10365. */
  10366. serialize(parent: any): any;
  10367. /**
  10368. * Internal only called by serialize
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedAction: any, parent?: any): any;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. static _SerializeValueAsString: (value: any) => string;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10382. name: string;
  10383. targetType: string;
  10384. value: string;
  10385. };
  10386. }
  10387. }
  10388. declare module "babylonjs/Actions/condition" {
  10389. import { ActionManager } from "babylonjs/Actions/actionManager";
  10390. /**
  10391. * A Condition applied to an Action
  10392. */
  10393. export class Condition {
  10394. /**
  10395. * Internal only - manager for action
  10396. * @hidden
  10397. */
  10398. _actionManager: ActionManager;
  10399. /**
  10400. * Internal only
  10401. * @hidden
  10402. */
  10403. _evaluationId: number;
  10404. /**
  10405. * Internal only
  10406. * @hidden
  10407. */
  10408. _currentResult: boolean;
  10409. /**
  10410. * Creates a new Condition
  10411. * @param actionManager the manager of the action the condition is applied to
  10412. */
  10413. constructor(actionManager: ActionManager);
  10414. /**
  10415. * Check if the current condition is valid
  10416. * @returns a boolean
  10417. */
  10418. isValid(): boolean;
  10419. /**
  10420. * Internal only
  10421. * @hidden
  10422. */
  10423. _getProperty(propertyPath: string): string;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _getEffectiveTarget(target: any, propertyPath: string): any;
  10429. /**
  10430. * Serialize placeholder for child classes
  10431. * @returns the serialized object
  10432. */
  10433. serialize(): any;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. protected _serialize(serializedCondition: any): any;
  10439. }
  10440. /**
  10441. * Defines specific conditional operators as extensions of Condition
  10442. */
  10443. export class ValueCondition extends Condition {
  10444. /** path to specify the property of the target the conditional operator uses */
  10445. propertyPath: string;
  10446. /** the value compared by the conditional operator against the current value of the property */
  10447. value: any;
  10448. /** the conditional operator, default ValueCondition.IsEqual */
  10449. operator: number;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private static _IsEqual;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private static _IsDifferent;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. private static _IsGreater;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. private static _IsLesser;
  10470. /**
  10471. * returns the number for IsEqual
  10472. */
  10473. static readonly IsEqual: number;
  10474. /**
  10475. * Returns the number for IsDifferent
  10476. */
  10477. static readonly IsDifferent: number;
  10478. /**
  10479. * Returns the number for IsGreater
  10480. */
  10481. static readonly IsGreater: number;
  10482. /**
  10483. * Returns the number for IsLesser
  10484. */
  10485. static readonly IsLesser: number;
  10486. /**
  10487. * Internal only The action manager for the condition
  10488. * @hidden
  10489. */
  10490. _actionManager: ActionManager;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. private _target;
  10496. /**
  10497. * Internal only
  10498. * @hidden
  10499. */
  10500. private _effectiveTarget;
  10501. /**
  10502. * Internal only
  10503. * @hidden
  10504. */
  10505. private _property;
  10506. /**
  10507. * Creates a new ValueCondition
  10508. * @param actionManager manager for the action the condition applies to
  10509. * @param target for the action
  10510. * @param propertyPath path to specify the property of the target the conditional operator uses
  10511. * @param value the value compared by the conditional operator against the current value of the property
  10512. * @param operator the conditional operator, default ValueCondition.IsEqual
  10513. */
  10514. constructor(actionManager: ActionManager, target: any,
  10515. /** path to specify the property of the target the conditional operator uses */
  10516. propertyPath: string,
  10517. /** the value compared by the conditional operator against the current value of the property */
  10518. value: any,
  10519. /** the conditional operator, default ValueCondition.IsEqual */
  10520. operator?: number);
  10521. /**
  10522. * Compares the given value with the property value for the specified conditional operator
  10523. * @returns the result of the comparison
  10524. */
  10525. isValid(): boolean;
  10526. /**
  10527. * Serialize the ValueCondition into a JSON compatible object
  10528. * @returns serialization object
  10529. */
  10530. serialize(): any;
  10531. /**
  10532. * Gets the name of the conditional operator for the ValueCondition
  10533. * @param operator the conditional operator
  10534. * @returns the name
  10535. */
  10536. static GetOperatorName(operator: number): string;
  10537. }
  10538. /**
  10539. * Defines a predicate condition as an extension of Condition
  10540. */
  10541. export class PredicateCondition extends Condition {
  10542. /** defines the predicate function used to validate the condition */
  10543. predicate: () => boolean;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Creates a new PredicateCondition
  10551. * @param actionManager manager for the action the condition applies to
  10552. * @param predicate defines the predicate function used to validate the condition
  10553. */
  10554. constructor(actionManager: ActionManager,
  10555. /** defines the predicate function used to validate the condition */
  10556. predicate: () => boolean);
  10557. /**
  10558. * @returns the validity of the predicate condition
  10559. */
  10560. isValid(): boolean;
  10561. }
  10562. /**
  10563. * Defines a state condition as an extension of Condition
  10564. */
  10565. export class StateCondition extends Condition {
  10566. /** Value to compare with target state */
  10567. value: string;
  10568. /**
  10569. * Internal only - manager for action
  10570. * @hidden
  10571. */
  10572. _actionManager: ActionManager;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. private _target;
  10578. /**
  10579. * Creates a new StateCondition
  10580. * @param actionManager manager for the action the condition applies to
  10581. * @param target of the condition
  10582. * @param value to compare with target state
  10583. */
  10584. constructor(actionManager: ActionManager, target: any,
  10585. /** Value to compare with target state */
  10586. value: string);
  10587. /**
  10588. * Gets a boolean indicating if the current condition is met
  10589. * @returns the validity of the state
  10590. */
  10591. isValid(): boolean;
  10592. /**
  10593. * Serialize the StateCondition into a JSON compatible object
  10594. * @returns serialization object
  10595. */
  10596. serialize(): any;
  10597. }
  10598. }
  10599. declare module "babylonjs/Actions/directActions" {
  10600. import { Action } from "babylonjs/Actions/action";
  10601. import { Condition } from "babylonjs/Actions/condition";
  10602. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10603. /**
  10604. * This defines an action responsible to toggle a boolean once triggered.
  10605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10606. */
  10607. export class SwitchBooleanAction extends Action {
  10608. /**
  10609. * The path to the boolean property in the target object
  10610. */
  10611. propertyPath: string;
  10612. private _target;
  10613. private _effectiveTarget;
  10614. private _property;
  10615. /**
  10616. * Instantiate the action
  10617. * @param triggerOptions defines the trigger options
  10618. * @param target defines the object containing the boolean
  10619. * @param propertyPath defines the path to the boolean property in the target object
  10620. * @param condition defines the trigger related conditions
  10621. */
  10622. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10623. /** @hidden */
  10624. _prepare(): void;
  10625. /**
  10626. * Execute the action toggle the boolean value.
  10627. */
  10628. execute(): void;
  10629. /**
  10630. * Serializes the actions and its related information.
  10631. * @param parent defines the object to serialize in
  10632. * @returns the serialized object
  10633. */
  10634. serialize(parent: any): any;
  10635. }
  10636. /**
  10637. * This defines an action responsible to set a the state field of the target
  10638. * to a desired value once triggered.
  10639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10640. */
  10641. export class SetStateAction extends Action {
  10642. /**
  10643. * The value to store in the state field.
  10644. */
  10645. value: string;
  10646. private _target;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the state property
  10651. * @param value defines the value to store in the state field
  10652. * @param condition defines the trigger related conditions
  10653. */
  10654. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10655. /**
  10656. * Execute the action and store the value on the target state property.
  10657. */
  10658. execute(): void;
  10659. /**
  10660. * Serializes the actions and its related information.
  10661. * @param parent defines the object to serialize in
  10662. * @returns the serialized object
  10663. */
  10664. serialize(parent: any): any;
  10665. }
  10666. /**
  10667. * This defines an action responsible to set a property of the target
  10668. * to a desired value once triggered.
  10669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10670. */
  10671. export class SetValueAction extends Action {
  10672. /**
  10673. * The path of the property to set in the target.
  10674. */
  10675. propertyPath: string;
  10676. /**
  10677. * The value to set in the property
  10678. */
  10679. value: any;
  10680. private _target;
  10681. private _effectiveTarget;
  10682. private _property;
  10683. /**
  10684. * Instantiate the action
  10685. * @param triggerOptions defines the trigger options
  10686. * @param target defines the object containing the property
  10687. * @param propertyPath defines the path of the property to set in the target
  10688. * @param value defines the value to set in the property
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and set the targetted property to the desired value.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible to increment the target value
  10707. * to a desired value once triggered.
  10708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10709. */
  10710. export class IncrementValueAction extends Action {
  10711. /**
  10712. * The path of the property to increment in the target.
  10713. */
  10714. propertyPath: string;
  10715. /**
  10716. * The value we should increment the property by.
  10717. */
  10718. value: any;
  10719. private _target;
  10720. private _effectiveTarget;
  10721. private _property;
  10722. /**
  10723. * Instantiate the action
  10724. * @param triggerOptions defines the trigger options
  10725. * @param target defines the object containing the property
  10726. * @param propertyPath defines the path of the property to increment in the target
  10727. * @param value defines the value value we should increment the property by
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and increment the target of the value amount.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to start an animation once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class PlayAnimationAction extends Action {
  10749. /**
  10750. * Where the animation should start (animation frame)
  10751. */
  10752. from: number;
  10753. /**
  10754. * Where the animation should stop (animation frame)
  10755. */
  10756. to: number;
  10757. /**
  10758. * Define if the animation should loop or stop after the first play.
  10759. */
  10760. loop?: boolean;
  10761. private _target;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param target defines the target animation or animation name
  10766. * @param from defines from where the animation should start (animation frame)
  10767. * @param end defines where the animation should stop (animation frame)
  10768. * @param loop defines if the animation should loop or stop after the first play
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10772. /** @hidden */
  10773. _prepare(): void;
  10774. /**
  10775. * Execute the action and play the animation.
  10776. */
  10777. execute(): void;
  10778. /**
  10779. * Serializes the actions and its related information.
  10780. * @param parent defines the object to serialize in
  10781. * @returns the serialized object
  10782. */
  10783. serialize(parent: any): any;
  10784. }
  10785. /**
  10786. * This defines an action responsible to stop an animation once triggered.
  10787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10788. */
  10789. export class StopAnimationAction extends Action {
  10790. private _target;
  10791. /**
  10792. * Instantiate the action
  10793. * @param triggerOptions defines the trigger options
  10794. * @param target defines the target animation or animation name
  10795. * @param condition defines the trigger related conditions
  10796. */
  10797. constructor(triggerOptions: any, target: any, condition?: Condition);
  10798. /** @hidden */
  10799. _prepare(): void;
  10800. /**
  10801. * Execute the action and stop the animation.
  10802. */
  10803. execute(): void;
  10804. /**
  10805. * Serializes the actions and its related information.
  10806. * @param parent defines the object to serialize in
  10807. * @returns the serialized object
  10808. */
  10809. serialize(parent: any): any;
  10810. }
  10811. /**
  10812. * This defines an action responsible that does nothing once triggered.
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10814. */
  10815. export class DoNothingAction extends Action {
  10816. /**
  10817. * Instantiate the action
  10818. * @param triggerOptions defines the trigger options
  10819. * @param condition defines the trigger related conditions
  10820. */
  10821. constructor(triggerOptions?: any, condition?: Condition);
  10822. /**
  10823. * Execute the action and do nothing.
  10824. */
  10825. execute(): void;
  10826. /**
  10827. * Serializes the actions and its related information.
  10828. * @param parent defines the object to serialize in
  10829. * @returns the serialized object
  10830. */
  10831. serialize(parent: any): any;
  10832. }
  10833. /**
  10834. * This defines an action responsible to trigger several actions once triggered.
  10835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10836. */
  10837. export class CombineAction extends Action {
  10838. /**
  10839. * The list of aggregated animations to run.
  10840. */
  10841. children: Action[];
  10842. /**
  10843. * Instantiate the action
  10844. * @param triggerOptions defines the trigger options
  10845. * @param children defines the list of aggregated animations to run
  10846. * @param condition defines the trigger related conditions
  10847. */
  10848. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10849. /** @hidden */
  10850. _prepare(): void;
  10851. /**
  10852. * Execute the action and executes all the aggregated actions.
  10853. */
  10854. execute(evt: ActionEvent): void;
  10855. /**
  10856. * Serializes the actions and its related information.
  10857. * @param parent defines the object to serialize in
  10858. * @returns the serialized object
  10859. */
  10860. serialize(parent: any): any;
  10861. }
  10862. /**
  10863. * This defines an action responsible to run code (external event) once triggered.
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10865. */
  10866. export class ExecuteCodeAction extends Action {
  10867. /**
  10868. * The callback function to run.
  10869. */
  10870. func: (evt: ActionEvent) => void;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param func defines the callback function to run
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10878. /**
  10879. * Execute the action and run the attached code.
  10880. */
  10881. execute(evt: ActionEvent): void;
  10882. }
  10883. /**
  10884. * This defines an action responsible to set the parent property of the target once triggered.
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10886. */
  10887. export class SetParentAction extends Action {
  10888. private _parent;
  10889. private _target;
  10890. /**
  10891. * Instantiate the action
  10892. * @param triggerOptions defines the trigger options
  10893. * @param target defines the target containing the parent property
  10894. * @param parent defines from where the animation should start (animation frame)
  10895. * @param condition defines the trigger related conditions
  10896. */
  10897. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10898. /** @hidden */
  10899. _prepare(): void;
  10900. /**
  10901. * Execute the action and set the parent property.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. }
  10912. declare module "babylonjs/Actions/actionManager" {
  10913. import { Nullable } from "babylonjs/types";
  10914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10915. import { Scene } from "babylonjs/scene";
  10916. import { IAction } from "babylonjs/Actions/action";
  10917. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10918. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10919. /**
  10920. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10921. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ActionManager extends AbstractActionManager {
  10925. /**
  10926. * Nothing
  10927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10928. */
  10929. static readonly NothingTrigger: number;
  10930. /**
  10931. * On pick
  10932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10933. */
  10934. static readonly OnPickTrigger: number;
  10935. /**
  10936. * On left pick
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10938. */
  10939. static readonly OnLeftPickTrigger: number;
  10940. /**
  10941. * On right pick
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10943. */
  10944. static readonly OnRightPickTrigger: number;
  10945. /**
  10946. * On center pick
  10947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10948. */
  10949. static readonly OnCenterPickTrigger: number;
  10950. /**
  10951. * On pick down
  10952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10953. */
  10954. static readonly OnPickDownTrigger: number;
  10955. /**
  10956. * On double pick
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10958. */
  10959. static readonly OnDoublePickTrigger: number;
  10960. /**
  10961. * On pick up
  10962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10963. */
  10964. static readonly OnPickUpTrigger: number;
  10965. /**
  10966. * On pick out.
  10967. * This trigger will only be raised if you also declared a OnPickDown
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10969. */
  10970. static readonly OnPickOutTrigger: number;
  10971. /**
  10972. * On long press
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10974. */
  10975. static readonly OnLongPressTrigger: number;
  10976. /**
  10977. * On pointer over
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10979. */
  10980. static readonly OnPointerOverTrigger: number;
  10981. /**
  10982. * On pointer out
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly OnPointerOutTrigger: number;
  10986. /**
  10987. * On every frame
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnEveryFrameTrigger: number;
  10991. /**
  10992. * On intersection enter
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnIntersectionEnterTrigger: number;
  10996. /**
  10997. * On intersection exit
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnIntersectionExitTrigger: number;
  11001. /**
  11002. * On key down
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnKeyDownTrigger: number;
  11006. /**
  11007. * On key up
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnKeyUpTrigger: number;
  11011. private _scene;
  11012. /**
  11013. * Creates a new action manager
  11014. * @param scene defines the hosting scene
  11015. */
  11016. constructor(scene: Scene);
  11017. /**
  11018. * Releases all associated resources
  11019. */
  11020. dispose(): void;
  11021. /**
  11022. * Gets hosting scene
  11023. * @returns the hosting scene
  11024. */
  11025. getScene(): Scene;
  11026. /**
  11027. * Does this action manager handles actions of any of the given triggers
  11028. * @param triggers defines the triggers to be tested
  11029. * @return a boolean indicating whether one (or more) of the triggers is handled
  11030. */
  11031. hasSpecificTriggers(triggers: number[]): boolean;
  11032. /**
  11033. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11034. * speed.
  11035. * @param triggerA defines the trigger to be tested
  11036. * @param triggerB defines the trigger to be tested
  11037. * @return a boolean indicating whether one (or more) of the triggers is handled
  11038. */
  11039. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11040. /**
  11041. * Does this action manager handles actions of a given trigger
  11042. * @param trigger defines the trigger to be tested
  11043. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11044. * @return whether the trigger is handled
  11045. */
  11046. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11047. /**
  11048. * Does this action manager has pointer triggers
  11049. */
  11050. readonly hasPointerTriggers: boolean;
  11051. /**
  11052. * Does this action manager has pick triggers
  11053. */
  11054. readonly hasPickTriggers: boolean;
  11055. /**
  11056. * Registers an action to this action manager
  11057. * @param action defines the action to be registered
  11058. * @return the action amended (prepared) after registration
  11059. */
  11060. registerAction(action: IAction): Nullable<IAction>;
  11061. /**
  11062. * Unregisters an action to this action manager
  11063. * @param action defines the action to be unregistered
  11064. * @return a boolean indicating whether the action has been unregistered
  11065. */
  11066. unregisterAction(action: IAction): Boolean;
  11067. /**
  11068. * Process a specific trigger
  11069. * @param trigger defines the trigger to process
  11070. * @param evt defines the event details to be processed
  11071. */
  11072. processTrigger(trigger: number, evt?: IActionEvent): void;
  11073. /** @hidden */
  11074. _getEffectiveTarget(target: any, propertyPath: string): any;
  11075. /** @hidden */
  11076. _getProperty(propertyPath: string): string;
  11077. /**
  11078. * Serialize this manager to a JSON object
  11079. * @param name defines the property name to store this manager
  11080. * @returns a JSON representation of this manager
  11081. */
  11082. serialize(name: string): any;
  11083. /**
  11084. * Creates a new ActionManager from a JSON data
  11085. * @param parsedActions defines the JSON data to read from
  11086. * @param object defines the hosting mesh
  11087. * @param scene defines the hosting scene
  11088. */
  11089. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11090. /**
  11091. * Get a trigger name by index
  11092. * @param trigger defines the trigger index
  11093. * @returns a trigger name
  11094. */
  11095. static GetTriggerName(trigger: number): string;
  11096. }
  11097. }
  11098. declare module "babylonjs/Culling/ray" {
  11099. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11100. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11104. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11105. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11106. import { Plane } from "babylonjs/Maths/math.plane";
  11107. /**
  11108. * Class representing a ray with position and direction
  11109. */
  11110. export class Ray {
  11111. /** origin point */
  11112. origin: Vector3;
  11113. /** direction */
  11114. direction: Vector3;
  11115. /** length of the ray */
  11116. length: number;
  11117. private static readonly TmpVector3;
  11118. private _tmpRay;
  11119. /**
  11120. * Creates a new ray
  11121. * @param origin origin point
  11122. * @param direction direction
  11123. * @param length length of the ray
  11124. */
  11125. constructor(
  11126. /** origin point */
  11127. origin: Vector3,
  11128. /** direction */
  11129. direction: Vector3,
  11130. /** length of the ray */
  11131. length?: number);
  11132. /**
  11133. * Checks if the ray intersects a box
  11134. * @param minimum bound of the box
  11135. * @param maximum bound of the box
  11136. * @param intersectionTreshold extra extend to be added to the box in all direction
  11137. * @returns if the box was hit
  11138. */
  11139. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11140. /**
  11141. * Checks if the ray intersects a box
  11142. * @param box the bounding box to check
  11143. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11144. * @returns if the box was hit
  11145. */
  11146. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11147. /**
  11148. * If the ray hits a sphere
  11149. * @param sphere the bounding sphere to check
  11150. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11151. * @returns true if it hits the sphere
  11152. */
  11153. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11154. /**
  11155. * If the ray hits a triange
  11156. * @param vertex0 triangle vertex
  11157. * @param vertex1 triangle vertex
  11158. * @param vertex2 triangle vertex
  11159. * @returns intersection information if hit
  11160. */
  11161. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11162. /**
  11163. * Checks if ray intersects a plane
  11164. * @param plane the plane to check
  11165. * @returns the distance away it was hit
  11166. */
  11167. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11168. /**
  11169. * Calculate the intercept of a ray on a given axis
  11170. * @param axis to check 'x' | 'y' | 'z'
  11171. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11172. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11173. */
  11174. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11175. /**
  11176. * Checks if ray intersects a mesh
  11177. * @param mesh the mesh to check
  11178. * @param fastCheck if only the bounding box should checked
  11179. * @returns picking info of the intersecton
  11180. */
  11181. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11182. /**
  11183. * Checks if ray intersects a mesh
  11184. * @param meshes the meshes to check
  11185. * @param fastCheck if only the bounding box should checked
  11186. * @param results array to store result in
  11187. * @returns Array of picking infos
  11188. */
  11189. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11190. private _comparePickingInfo;
  11191. private static smallnum;
  11192. private static rayl;
  11193. /**
  11194. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11195. * @param sega the first point of the segment to test the intersection against
  11196. * @param segb the second point of the segment to test the intersection against
  11197. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11198. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11199. */
  11200. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11201. /**
  11202. * Update the ray from viewport position
  11203. * @param x position
  11204. * @param y y position
  11205. * @param viewportWidth viewport width
  11206. * @param viewportHeight viewport height
  11207. * @param world world matrix
  11208. * @param view view matrix
  11209. * @param projection projection matrix
  11210. * @returns this ray updated
  11211. */
  11212. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11213. /**
  11214. * Creates a ray with origin and direction of 0,0,0
  11215. * @returns the new ray
  11216. */
  11217. static Zero(): Ray;
  11218. /**
  11219. * Creates a new ray from screen space and viewport
  11220. * @param x position
  11221. * @param y y position
  11222. * @param viewportWidth viewport width
  11223. * @param viewportHeight viewport height
  11224. * @param world world matrix
  11225. * @param view view matrix
  11226. * @param projection projection matrix
  11227. * @returns new ray
  11228. */
  11229. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11230. /**
  11231. * 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
  11232. * transformed to the given world matrix.
  11233. * @param origin The origin point
  11234. * @param end The end point
  11235. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11236. * @returns the new ray
  11237. */
  11238. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11239. /**
  11240. * Transforms a ray by a matrix
  11241. * @param ray ray to transform
  11242. * @param matrix matrix to apply
  11243. * @returns the resulting new ray
  11244. */
  11245. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11246. /**
  11247. * Transforms a ray by a matrix
  11248. * @param ray ray to transform
  11249. * @param matrix matrix to apply
  11250. * @param result ray to store result in
  11251. */
  11252. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11253. /**
  11254. * Unproject a ray from screen space to object space
  11255. * @param sourceX defines the screen space x coordinate to use
  11256. * @param sourceY defines the screen space y coordinate to use
  11257. * @param viewportWidth defines the current width of the viewport
  11258. * @param viewportHeight defines the current height of the viewport
  11259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11260. * @param view defines the view matrix to use
  11261. * @param projection defines the projection matrix to use
  11262. */
  11263. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11264. }
  11265. /**
  11266. * Type used to define predicate used to select faces when a mesh intersection is detected
  11267. */
  11268. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11269. module "babylonjs/scene" {
  11270. interface Scene {
  11271. /** @hidden */
  11272. _tempPickingRay: Nullable<Ray>;
  11273. /** @hidden */
  11274. _cachedRayForTransform: Ray;
  11275. /** @hidden */
  11276. _pickWithRayInverseMatrix: Matrix;
  11277. /** @hidden */
  11278. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11279. /** @hidden */
  11280. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11281. }
  11282. }
  11283. }
  11284. declare module "babylonjs/sceneComponent" {
  11285. import { Scene } from "babylonjs/scene";
  11286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11288. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11289. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11290. import { Nullable } from "babylonjs/types";
  11291. import { Camera } from "babylonjs/Cameras/camera";
  11292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11293. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11294. import { AbstractScene } from "babylonjs/abstractScene";
  11295. import { Mesh } from "babylonjs/Meshes/mesh";
  11296. /**
  11297. * Groups all the scene component constants in one place to ease maintenance.
  11298. * @hidden
  11299. */
  11300. export class SceneComponentConstants {
  11301. static readonly NAME_EFFECTLAYER: string;
  11302. static readonly NAME_LAYER: string;
  11303. static readonly NAME_LENSFLARESYSTEM: string;
  11304. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11305. static readonly NAME_PARTICLESYSTEM: string;
  11306. static readonly NAME_GAMEPAD: string;
  11307. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11308. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11309. static readonly NAME_DEPTHRENDERER: string;
  11310. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11311. static readonly NAME_SPRITE: string;
  11312. static readonly NAME_OUTLINERENDERER: string;
  11313. static readonly NAME_PROCEDURALTEXTURE: string;
  11314. static readonly NAME_SHADOWGENERATOR: string;
  11315. static readonly NAME_OCTREE: string;
  11316. static readonly NAME_PHYSICSENGINE: string;
  11317. static readonly NAME_AUDIO: string;
  11318. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11319. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11320. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11321. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11322. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11323. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11324. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11325. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11326. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11327. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11328. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11329. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11330. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11331. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11332. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11333. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11334. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11335. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11336. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11337. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11338. static readonly STEP_AFTERRENDER_AUDIO: number;
  11339. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11340. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11341. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11342. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11343. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11344. static readonly STEP_POINTERMOVE_SPRITE: number;
  11345. static readonly STEP_POINTERDOWN_SPRITE: number;
  11346. static readonly STEP_POINTERUP_SPRITE: number;
  11347. }
  11348. /**
  11349. * This represents a scene component.
  11350. *
  11351. * This is used to decouple the dependency the scene is having on the different workloads like
  11352. * layers, post processes...
  11353. */
  11354. export interface ISceneComponent {
  11355. /**
  11356. * The name of the component. Each component must have a unique name.
  11357. */
  11358. name: string;
  11359. /**
  11360. * The scene the component belongs to.
  11361. */
  11362. scene: Scene;
  11363. /**
  11364. * Register the component to one instance of a scene.
  11365. */
  11366. register(): void;
  11367. /**
  11368. * Rebuilds the elements related to this component in case of
  11369. * context lost for instance.
  11370. */
  11371. rebuild(): void;
  11372. /**
  11373. * Disposes the component and the associated ressources.
  11374. */
  11375. dispose(): void;
  11376. }
  11377. /**
  11378. * This represents a SERIALIZABLE scene component.
  11379. *
  11380. * This extends Scene Component to add Serialization methods on top.
  11381. */
  11382. export interface ISceneSerializableComponent extends ISceneComponent {
  11383. /**
  11384. * Adds all the elements from the container to the scene
  11385. * @param container the container holding the elements
  11386. */
  11387. addFromContainer(container: AbstractScene): void;
  11388. /**
  11389. * Removes all the elements in the container from the scene
  11390. * @param container contains the elements to remove
  11391. * @param dispose if the removed element should be disposed (default: false)
  11392. */
  11393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11394. /**
  11395. * Serializes the component data to the specified json object
  11396. * @param serializationObject The object to serialize to
  11397. */
  11398. serialize(serializationObject: any): void;
  11399. }
  11400. /**
  11401. * Strong typing of a Mesh related stage step action
  11402. */
  11403. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11404. /**
  11405. * Strong typing of a Evaluate Sub Mesh related stage step action
  11406. */
  11407. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11408. /**
  11409. * Strong typing of a Active Mesh related stage step action
  11410. */
  11411. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11412. /**
  11413. * Strong typing of a Camera related stage step action
  11414. */
  11415. export type CameraStageAction = (camera: Camera) => void;
  11416. /**
  11417. * Strong typing of a Camera Frame buffer related stage step action
  11418. */
  11419. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11420. /**
  11421. * Strong typing of a Render Target related stage step action
  11422. */
  11423. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11424. /**
  11425. * Strong typing of a RenderingGroup related stage step action
  11426. */
  11427. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11428. /**
  11429. * Strong typing of a Mesh Render related stage step action
  11430. */
  11431. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11432. /**
  11433. * Strong typing of a simple stage step action
  11434. */
  11435. export type SimpleStageAction = () => void;
  11436. /**
  11437. * Strong typing of a render target action.
  11438. */
  11439. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11440. /**
  11441. * Strong typing of a pointer move action.
  11442. */
  11443. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11444. /**
  11445. * Strong typing of a pointer up/down action.
  11446. */
  11447. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11448. /**
  11449. * Representation of a stage in the scene (Basically a list of ordered steps)
  11450. * @hidden
  11451. */
  11452. export class Stage<T extends Function> extends Array<{
  11453. index: number;
  11454. component: ISceneComponent;
  11455. action: T;
  11456. }> {
  11457. /**
  11458. * Hide ctor from the rest of the world.
  11459. * @param items The items to add.
  11460. */
  11461. private constructor();
  11462. /**
  11463. * Creates a new Stage.
  11464. * @returns A new instance of a Stage
  11465. */
  11466. static Create<T extends Function>(): Stage<T>;
  11467. /**
  11468. * Registers a step in an ordered way in the targeted stage.
  11469. * @param index Defines the position to register the step in
  11470. * @param component Defines the component attached to the step
  11471. * @param action Defines the action to launch during the step
  11472. */
  11473. registerStep(index: number, component: ISceneComponent, action: T): void;
  11474. /**
  11475. * Clears all the steps from the stage.
  11476. */
  11477. clear(): void;
  11478. }
  11479. }
  11480. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11481. import { Nullable } from "babylonjs/types";
  11482. import { Observable } from "babylonjs/Misc/observable";
  11483. import { Scene } from "babylonjs/scene";
  11484. import { Sprite } from "babylonjs/Sprites/sprite";
  11485. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11486. import { Ray } from "babylonjs/Culling/ray";
  11487. import { Camera } from "babylonjs/Cameras/camera";
  11488. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11489. import { ISceneComponent } from "babylonjs/sceneComponent";
  11490. module "babylonjs/scene" {
  11491. interface Scene {
  11492. /** @hidden */
  11493. _pointerOverSprite: Nullable<Sprite>;
  11494. /** @hidden */
  11495. _pickedDownSprite: Nullable<Sprite>;
  11496. /** @hidden */
  11497. _tempSpritePickingRay: Nullable<Ray>;
  11498. /**
  11499. * All of the sprite managers added to this scene
  11500. * @see http://doc.babylonjs.com/babylon101/sprites
  11501. */
  11502. spriteManagers: Array<ISpriteManager>;
  11503. /**
  11504. * An event triggered when sprites rendering is about to start
  11505. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11506. */
  11507. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11508. /**
  11509. * An event triggered when sprites rendering is done
  11510. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11511. */
  11512. onAfterSpritesRenderingObservable: Observable<Scene>;
  11513. /** @hidden */
  11514. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11515. /** Launch a ray to try to pick a sprite in the scene
  11516. * @param x position on screen
  11517. * @param y position on screen
  11518. * @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
  11519. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11520. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11521. * @returns a PickingInfo
  11522. */
  11523. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11524. /** Use the given ray to pick a sprite in the scene
  11525. * @param ray The ray (in world space) to use to pick meshes
  11526. * @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
  11527. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11528. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11529. * @returns a PickingInfo
  11530. */
  11531. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11532. /** @hidden */
  11533. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11534. /** Launch a ray to try to pick sprites in the scene
  11535. * @param x position on screen
  11536. * @param y position on screen
  11537. * @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
  11538. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11539. * @returns a PickingInfo array
  11540. */
  11541. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11542. /** Use the given ray to pick sprites in the scene
  11543. * @param ray The ray (in world space) to use to pick meshes
  11544. * @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
  11545. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11546. * @returns a PickingInfo array
  11547. */
  11548. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11549. /**
  11550. * Force the sprite under the pointer
  11551. * @param sprite defines the sprite to use
  11552. */
  11553. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11554. /**
  11555. * Gets the sprite under the pointer
  11556. * @returns a Sprite or null if no sprite is under the pointer
  11557. */
  11558. getPointerOverSprite(): Nullable<Sprite>;
  11559. }
  11560. }
  11561. /**
  11562. * Defines the sprite scene component responsible to manage sprites
  11563. * in a given scene.
  11564. */
  11565. export class SpriteSceneComponent implements ISceneComponent {
  11566. /**
  11567. * The component name helpfull to identify the component in the list of scene components.
  11568. */
  11569. readonly name: string;
  11570. /**
  11571. * The scene the component belongs to.
  11572. */
  11573. scene: Scene;
  11574. /** @hidden */
  11575. private _spritePredicate;
  11576. /**
  11577. * Creates a new instance of the component for the given scene
  11578. * @param scene Defines the scene to register the component in
  11579. */
  11580. constructor(scene: Scene);
  11581. /**
  11582. * Registers the component in a given scene
  11583. */
  11584. register(): void;
  11585. /**
  11586. * Rebuilds the elements related to this component in case of
  11587. * context lost for instance.
  11588. */
  11589. rebuild(): void;
  11590. /**
  11591. * Disposes the component and the associated ressources.
  11592. */
  11593. dispose(): void;
  11594. private _pickSpriteButKeepRay;
  11595. private _pointerMove;
  11596. private _pointerDown;
  11597. private _pointerUp;
  11598. }
  11599. }
  11600. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11601. /** @hidden */
  11602. export var fogFragmentDeclaration: {
  11603. name: string;
  11604. shader: string;
  11605. };
  11606. }
  11607. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11608. /** @hidden */
  11609. export var fogFragment: {
  11610. name: string;
  11611. shader: string;
  11612. };
  11613. }
  11614. declare module "babylonjs/Shaders/sprites.fragment" {
  11615. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11616. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11617. /** @hidden */
  11618. export var spritesPixelShader: {
  11619. name: string;
  11620. shader: string;
  11621. };
  11622. }
  11623. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11624. /** @hidden */
  11625. export var fogVertexDeclaration: {
  11626. name: string;
  11627. shader: string;
  11628. };
  11629. }
  11630. declare module "babylonjs/Shaders/sprites.vertex" {
  11631. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11632. /** @hidden */
  11633. export var spritesVertexShader: {
  11634. name: string;
  11635. shader: string;
  11636. };
  11637. }
  11638. declare module "babylonjs/Sprites/spriteManager" {
  11639. import { IDisposable, Scene } from "babylonjs/scene";
  11640. import { Nullable } from "babylonjs/types";
  11641. import { Observable } from "babylonjs/Misc/observable";
  11642. import { Sprite } from "babylonjs/Sprites/sprite";
  11643. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11644. import { Camera } from "babylonjs/Cameras/camera";
  11645. import { Texture } from "babylonjs/Materials/Textures/texture";
  11646. import "babylonjs/Shaders/sprites.fragment";
  11647. import "babylonjs/Shaders/sprites.vertex";
  11648. import { Ray } from "babylonjs/Culling/ray";
  11649. /**
  11650. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11651. */
  11652. export interface ISpriteManager extends IDisposable {
  11653. /**
  11654. * Restricts the camera to viewing objects with the same layerMask.
  11655. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11656. */
  11657. layerMask: number;
  11658. /**
  11659. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11660. */
  11661. isPickable: boolean;
  11662. /**
  11663. * Specifies the rendering group id for this mesh (0 by default)
  11664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11665. */
  11666. renderingGroupId: number;
  11667. /**
  11668. * Defines the list of sprites managed by the manager.
  11669. */
  11670. sprites: Array<Sprite>;
  11671. /**
  11672. * Tests the intersection of a sprite with a specific ray.
  11673. * @param ray The ray we are sending to test the collision
  11674. * @param camera The camera space we are sending rays in
  11675. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11676. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11677. * @returns picking info or null.
  11678. */
  11679. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11680. /**
  11681. * Intersects the sprites with a ray
  11682. * @param ray defines the ray to intersect with
  11683. * @param camera defines the current active camera
  11684. * @param predicate defines a predicate used to select candidate sprites
  11685. * @returns null if no hit or a PickingInfo array
  11686. */
  11687. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11688. /**
  11689. * Renders the list of sprites on screen.
  11690. */
  11691. render(): void;
  11692. }
  11693. /**
  11694. * Class used to manage multiple sprites on the same spritesheet
  11695. * @see http://doc.babylonjs.com/babylon101/sprites
  11696. */
  11697. export class SpriteManager implements ISpriteManager {
  11698. /** defines the manager's name */
  11699. name: string;
  11700. /** Gets the list of sprites */
  11701. sprites: Sprite[];
  11702. /** Gets or sets the rendering group id (0 by default) */
  11703. renderingGroupId: number;
  11704. /** Gets or sets camera layer mask */
  11705. layerMask: number;
  11706. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11707. fogEnabled: boolean;
  11708. /** Gets or sets a boolean indicating if the sprites are pickable */
  11709. isPickable: boolean;
  11710. /** Defines the default width of a cell in the spritesheet */
  11711. cellWidth: number;
  11712. /** Defines the default height of a cell in the spritesheet */
  11713. cellHeight: number;
  11714. /** Associative array from JSON sprite data file */
  11715. private _cellData;
  11716. /** Array of sprite names from JSON sprite data file */
  11717. private _spriteMap;
  11718. /** True when packed cell data from JSON file is ready*/
  11719. private _packedAndReady;
  11720. /**
  11721. * An event triggered when the manager is disposed.
  11722. */
  11723. onDisposeObservable: Observable<SpriteManager>;
  11724. private _onDisposeObserver;
  11725. /**
  11726. * Callback called when the manager is disposed
  11727. */
  11728. onDispose: () => void;
  11729. private _capacity;
  11730. private _fromPacked;
  11731. private _spriteTexture;
  11732. private _epsilon;
  11733. private _scene;
  11734. private _vertexData;
  11735. private _buffer;
  11736. private _vertexBuffers;
  11737. private _indexBuffer;
  11738. private _effectBase;
  11739. private _effectFog;
  11740. /**
  11741. * Gets or sets the spritesheet texture
  11742. */
  11743. texture: Texture;
  11744. /**
  11745. * Creates a new sprite manager
  11746. * @param name defines the manager's name
  11747. * @param imgUrl defines the sprite sheet url
  11748. * @param capacity defines the maximum allowed number of sprites
  11749. * @param cellSize defines the size of a sprite cell
  11750. * @param scene defines the hosting scene
  11751. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11752. * @param samplingMode defines the smapling mode to use with spritesheet
  11753. * @param fromPacked set to false; do not alter
  11754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11755. */
  11756. constructor(
  11757. /** defines the manager's name */
  11758. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11759. private _makePacked;
  11760. private _appendSpriteVertex;
  11761. /**
  11762. * Intersects the sprites with a ray
  11763. * @param ray defines the ray to intersect with
  11764. * @param camera defines the current active camera
  11765. * @param predicate defines a predicate used to select candidate sprites
  11766. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11767. * @returns null if no hit or a PickingInfo
  11768. */
  11769. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11770. /**
  11771. * Intersects the sprites with a ray
  11772. * @param ray defines the ray to intersect with
  11773. * @param camera defines the current active camera
  11774. * @param predicate defines a predicate used to select candidate sprites
  11775. * @returns null if no hit or a PickingInfo array
  11776. */
  11777. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Render all child sprites
  11780. */
  11781. render(): void;
  11782. /**
  11783. * Release associated resources
  11784. */
  11785. dispose(): void;
  11786. }
  11787. }
  11788. declare module "babylonjs/Sprites/sprite" {
  11789. import { Vector3 } from "babylonjs/Maths/math.vector";
  11790. import { Nullable } from "babylonjs/types";
  11791. import { ActionManager } from "babylonjs/Actions/actionManager";
  11792. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11793. import { Color4 } from "babylonjs/Maths/math.color";
  11794. /**
  11795. * Class used to represent a sprite
  11796. * @see http://doc.babylonjs.com/babylon101/sprites
  11797. */
  11798. export class Sprite {
  11799. /** defines the name */
  11800. name: string;
  11801. /** Gets or sets the current world position */
  11802. position: Vector3;
  11803. /** Gets or sets the main color */
  11804. color: Color4;
  11805. /** Gets or sets the width */
  11806. width: number;
  11807. /** Gets or sets the height */
  11808. height: number;
  11809. /** Gets or sets rotation angle */
  11810. angle: number;
  11811. /** Gets or sets the cell index in the sprite sheet */
  11812. cellIndex: number;
  11813. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11814. cellRef: string;
  11815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11816. invertU: number;
  11817. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11818. invertV: number;
  11819. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11820. disposeWhenFinishedAnimating: boolean;
  11821. /** Gets the list of attached animations */
  11822. animations: Animation[];
  11823. /** Gets or sets a boolean indicating if the sprite can be picked */
  11824. isPickable: boolean;
  11825. /**
  11826. * Gets or sets the associated action manager
  11827. */
  11828. actionManager: Nullable<ActionManager>;
  11829. private _animationStarted;
  11830. private _loopAnimation;
  11831. private _fromIndex;
  11832. private _toIndex;
  11833. private _delay;
  11834. private _direction;
  11835. private _manager;
  11836. private _time;
  11837. private _onAnimationEnd;
  11838. /**
  11839. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11840. */
  11841. isVisible: boolean;
  11842. /**
  11843. * Gets or sets the sprite size
  11844. */
  11845. size: number;
  11846. /**
  11847. * Creates a new Sprite
  11848. * @param name defines the name
  11849. * @param manager defines the manager
  11850. */
  11851. constructor(
  11852. /** defines the name */
  11853. name: string, manager: ISpriteManager);
  11854. /**
  11855. * Starts an animation
  11856. * @param from defines the initial key
  11857. * @param to defines the end key
  11858. * @param loop defines if the animation must loop
  11859. * @param delay defines the start delay (in ms)
  11860. * @param onAnimationEnd defines a callback to call when animation ends
  11861. */
  11862. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11863. /** Stops current animation (if any) */
  11864. stopAnimation(): void;
  11865. /** @hidden */
  11866. _animate(deltaTime: number): void;
  11867. /** Release associated resources */
  11868. dispose(): void;
  11869. }
  11870. }
  11871. declare module "babylonjs/Collisions/pickingInfo" {
  11872. import { Nullable } from "babylonjs/types";
  11873. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11875. import { Sprite } from "babylonjs/Sprites/sprite";
  11876. import { Ray } from "babylonjs/Culling/ray";
  11877. /**
  11878. * Information about the result of picking within a scene
  11879. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11880. */
  11881. export class PickingInfo {
  11882. /** @hidden */
  11883. _pickingUnavailable: boolean;
  11884. /**
  11885. * If the pick collided with an object
  11886. */
  11887. hit: boolean;
  11888. /**
  11889. * Distance away where the pick collided
  11890. */
  11891. distance: number;
  11892. /**
  11893. * The location of pick collision
  11894. */
  11895. pickedPoint: Nullable<Vector3>;
  11896. /**
  11897. * The mesh corresponding the the pick collision
  11898. */
  11899. pickedMesh: Nullable<AbstractMesh>;
  11900. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11901. bu: number;
  11902. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11903. bv: number;
  11904. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11905. faceId: number;
  11906. /** Id of the the submesh that was picked */
  11907. subMeshId: number;
  11908. /** If a sprite was picked, this will be the sprite the pick collided with */
  11909. pickedSprite: Nullable<Sprite>;
  11910. /**
  11911. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11912. */
  11913. originMesh: Nullable<AbstractMesh>;
  11914. /**
  11915. * The ray that was used to perform the picking.
  11916. */
  11917. ray: Nullable<Ray>;
  11918. /**
  11919. * Gets the normal correspodning to the face the pick collided with
  11920. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11921. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11922. * @returns The normal correspodning to the face the pick collided with
  11923. */
  11924. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11925. /**
  11926. * Gets the texture coordinates of where the pick occured
  11927. * @returns the vector containing the coordnates of the texture
  11928. */
  11929. getTextureCoordinates(): Nullable<Vector2>;
  11930. }
  11931. }
  11932. declare module "babylonjs/Events/pointerEvents" {
  11933. import { Nullable } from "babylonjs/types";
  11934. import { Vector2 } from "babylonjs/Maths/math.vector";
  11935. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11936. import { Ray } from "babylonjs/Culling/ray";
  11937. /**
  11938. * Gather the list of pointer event types as constants.
  11939. */
  11940. export class PointerEventTypes {
  11941. /**
  11942. * 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.
  11943. */
  11944. static readonly POINTERDOWN: number;
  11945. /**
  11946. * The pointerup event is fired when a pointer is no longer active.
  11947. */
  11948. static readonly POINTERUP: number;
  11949. /**
  11950. * The pointermove event is fired when a pointer changes coordinates.
  11951. */
  11952. static readonly POINTERMOVE: number;
  11953. /**
  11954. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11955. */
  11956. static readonly POINTERWHEEL: number;
  11957. /**
  11958. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11959. */
  11960. static readonly POINTERPICK: number;
  11961. /**
  11962. * The pointertap event is fired when a the object has been touched and released without drag.
  11963. */
  11964. static readonly POINTERTAP: number;
  11965. /**
  11966. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11967. */
  11968. static readonly POINTERDOUBLETAP: number;
  11969. }
  11970. /**
  11971. * Base class of pointer info types.
  11972. */
  11973. export class PointerInfoBase {
  11974. /**
  11975. * Defines the type of event (PointerEventTypes)
  11976. */
  11977. type: number;
  11978. /**
  11979. * Defines the related dom event
  11980. */
  11981. event: PointerEvent | MouseWheelEvent;
  11982. /**
  11983. * Instantiates the base class of pointers info.
  11984. * @param type Defines the type of event (PointerEventTypes)
  11985. * @param event Defines the related dom event
  11986. */
  11987. constructor(
  11988. /**
  11989. * Defines the type of event (PointerEventTypes)
  11990. */
  11991. type: number,
  11992. /**
  11993. * Defines the related dom event
  11994. */
  11995. event: PointerEvent | MouseWheelEvent);
  11996. }
  11997. /**
  11998. * This class is used to store pointer related info for the onPrePointerObservable event.
  11999. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12000. */
  12001. export class PointerInfoPre extends PointerInfoBase {
  12002. /**
  12003. * Ray from a pointer if availible (eg. 6dof controller)
  12004. */
  12005. ray: Nullable<Ray>;
  12006. /**
  12007. * Defines the local position of the pointer on the canvas.
  12008. */
  12009. localPosition: Vector2;
  12010. /**
  12011. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12012. */
  12013. skipOnPointerObservable: boolean;
  12014. /**
  12015. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12016. * @param type Defines the type of event (PointerEventTypes)
  12017. * @param event Defines the related dom event
  12018. * @param localX Defines the local x coordinates of the pointer when the event occured
  12019. * @param localY Defines the local y coordinates of the pointer when the event occured
  12020. */
  12021. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12022. }
  12023. /**
  12024. * This type contains all the data related to a pointer event in Babylon.js.
  12025. * 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.
  12026. */
  12027. export class PointerInfo extends PointerInfoBase {
  12028. /**
  12029. * Defines the picking info associated to the info (if any)\
  12030. */
  12031. pickInfo: Nullable<PickingInfo>;
  12032. /**
  12033. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12034. * @param type Defines the type of event (PointerEventTypes)
  12035. * @param event Defines the related dom event
  12036. * @param pickInfo Defines the picking info associated to the info (if any)\
  12037. */
  12038. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12039. /**
  12040. * Defines the picking info associated to the info (if any)\
  12041. */
  12042. pickInfo: Nullable<PickingInfo>);
  12043. }
  12044. /**
  12045. * Data relating to a touch event on the screen.
  12046. */
  12047. export interface PointerTouch {
  12048. /**
  12049. * X coordinate of touch.
  12050. */
  12051. x: number;
  12052. /**
  12053. * Y coordinate of touch.
  12054. */
  12055. y: number;
  12056. /**
  12057. * Id of touch. Unique for each finger.
  12058. */
  12059. pointerId: number;
  12060. /**
  12061. * Event type passed from DOM.
  12062. */
  12063. type: any;
  12064. }
  12065. }
  12066. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12067. import { Observable } from "babylonjs/Misc/observable";
  12068. import { Nullable } from "babylonjs/types";
  12069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12070. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */
  12107. _allowCameraRotation: boolean;
  12108. /**
  12109. * Manage the mouse inputs to control the movement of a free camera.
  12110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12111. * @param touchEnabled Defines if touch is enabled or not
  12112. */
  12113. constructor(
  12114. /**
  12115. * Define if touch is enabled in the mouse input
  12116. */
  12117. touchEnabled?: boolean);
  12118. /**
  12119. * Attach the input controls to a specific dom element to get the input from.
  12120. * @param element Defines the element the controls should be listened from
  12121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12122. */
  12123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12124. /**
  12125. * Called on JS contextmenu event.
  12126. * Override this method to provide functionality.
  12127. */
  12128. protected onContextMenu(evt: PointerEvent): void;
  12129. /**
  12130. * Detach the current controls from the specified dom element.
  12131. * @param element Defines the element to stop listening the inputs from
  12132. */
  12133. detachControl(element: Nullable<HTMLElement>): void;
  12134. /**
  12135. * Gets the class name of the current intput.
  12136. * @returns the class name
  12137. */
  12138. getClassName(): string;
  12139. /**
  12140. * Get the friendly name associated with the input class.
  12141. * @returns the input friendly name
  12142. */
  12143. getSimpleName(): string;
  12144. }
  12145. }
  12146. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12147. import { Nullable } from "babylonjs/types";
  12148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12149. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12150. /**
  12151. * Manage the touch inputs to control the movement of a free camera.
  12152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12153. */
  12154. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12155. /**
  12156. * Defines the camera the input is attached to.
  12157. */
  12158. camera: FreeCamera;
  12159. /**
  12160. * Defines the touch sensibility for rotation.
  12161. * The higher the faster.
  12162. */
  12163. touchAngularSensibility: number;
  12164. /**
  12165. * Defines the touch sensibility for move.
  12166. * The higher the faster.
  12167. */
  12168. touchMoveSensibility: number;
  12169. private _offsetX;
  12170. private _offsetY;
  12171. private _pointerPressed;
  12172. private _pointerInput;
  12173. private _observer;
  12174. private _onLostFocus;
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Detach the current controls from the specified dom element.
  12183. * @param element Defines the element to stop listening the inputs from
  12184. */
  12185. detachControl(element: Nullable<HTMLElement>): void;
  12186. /**
  12187. * Update the current camera state depending on the inputs that have been used this frame.
  12188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12189. */
  12190. checkInputs(): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12206. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12207. import { Nullable } from "babylonjs/types";
  12208. /**
  12209. * Default Inputs manager for the FreeCamera.
  12210. * It groups all the default supported inputs for ease of use.
  12211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12212. */
  12213. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12214. /**
  12215. * @hidden
  12216. */
  12217. _mouseInput: Nullable<FreeCameraMouseInput>;
  12218. /**
  12219. * Instantiates a new FreeCameraInputsManager.
  12220. * @param camera Defines the camera the inputs belong to
  12221. */
  12222. constructor(camera: FreeCamera);
  12223. /**
  12224. * Add keyboard input support to the input manager.
  12225. * @returns the current input manager
  12226. */
  12227. addKeyboard(): FreeCameraInputsManager;
  12228. /**
  12229. * Add mouse input support to the input manager.
  12230. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12231. * @returns the current input manager
  12232. */
  12233. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12234. /**
  12235. * Removes the mouse input support from the manager
  12236. * @returns the current input manager
  12237. */
  12238. removeMouse(): FreeCameraInputsManager;
  12239. /**
  12240. * Add touch input support to the input manager.
  12241. * @returns the current input manager
  12242. */
  12243. addTouch(): FreeCameraInputsManager;
  12244. /**
  12245. * Remove all attached input methods from a camera
  12246. */
  12247. clear(): void;
  12248. }
  12249. }
  12250. declare module "babylonjs/Cameras/freeCamera" {
  12251. import { Vector3 } from "babylonjs/Maths/math.vector";
  12252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12253. import { Scene } from "babylonjs/scene";
  12254. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12255. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12256. /**
  12257. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12258. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12259. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12260. */
  12261. export class FreeCamera extends TargetCamera {
  12262. /**
  12263. * Define the collision ellipsoid of the camera.
  12264. * This is helpful to simulate a camera body like the player body around the camera
  12265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12266. */
  12267. ellipsoid: Vector3;
  12268. /**
  12269. * Define an offset for the position of the ellipsoid around the camera.
  12270. * This can be helpful to determine the center of the body near the gravity center of the body
  12271. * instead of its head.
  12272. */
  12273. ellipsoidOffset: Vector3;
  12274. /**
  12275. * Enable or disable collisions of the camera with the rest of the scene objects.
  12276. */
  12277. checkCollisions: boolean;
  12278. /**
  12279. * Enable or disable gravity on the camera.
  12280. */
  12281. applyGravity: boolean;
  12282. /**
  12283. * Define the input manager associated to the camera.
  12284. */
  12285. inputs: FreeCameraInputsManager;
  12286. /**
  12287. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12288. * Higher values reduce sensitivity.
  12289. */
  12290. /**
  12291. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12292. * Higher values reduce sensitivity.
  12293. */
  12294. angularSensibility: number;
  12295. /**
  12296. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12297. */
  12298. keysUp: number[];
  12299. /**
  12300. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12301. */
  12302. keysDown: number[];
  12303. /**
  12304. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12305. */
  12306. keysLeft: number[];
  12307. /**
  12308. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12309. */
  12310. keysRight: number[];
  12311. /**
  12312. * Event raised when the camera collide with a mesh in the scene.
  12313. */
  12314. onCollide: (collidedMesh: AbstractMesh) => void;
  12315. private _collider;
  12316. private _needMoveForGravity;
  12317. private _oldPosition;
  12318. private _diffPosition;
  12319. private _newPosition;
  12320. /** @hidden */
  12321. _localDirection: Vector3;
  12322. /** @hidden */
  12323. _transformedDirection: Vector3;
  12324. /**
  12325. * Instantiates a Free Camera.
  12326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12327. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12329. * @param name Define the name of the camera in the scene
  12330. * @param position Define the start position of the camera in the scene
  12331. * @param scene Define the scene the camera belongs to
  12332. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12333. */
  12334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12335. /**
  12336. * Attached controls to the current camera.
  12337. * @param element Defines the element the controls should be listened from
  12338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12339. */
  12340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12341. /**
  12342. * Detach the current controls from the camera.
  12343. * The camera will stop reacting to inputs.
  12344. * @param element Defines the element to stop listening the inputs from
  12345. */
  12346. detachControl(element: HTMLElement): void;
  12347. private _collisionMask;
  12348. /**
  12349. * Define a collision mask to limit the list of object the camera can collide with
  12350. */
  12351. collisionMask: number;
  12352. /** @hidden */
  12353. _collideWithWorld(displacement: Vector3): void;
  12354. private _onCollisionPositionChange;
  12355. /** @hidden */
  12356. _checkInputs(): void;
  12357. /** @hidden */
  12358. _decideIfNeedsToMove(): boolean;
  12359. /** @hidden */
  12360. _updatePosition(): void;
  12361. /**
  12362. * Destroy the camera and release the current resources hold by it.
  12363. */
  12364. dispose(): void;
  12365. /**
  12366. * Gets the current object class name.
  12367. * @return the class name
  12368. */
  12369. getClassName(): string;
  12370. }
  12371. }
  12372. declare module "babylonjs/Gamepads/gamepad" {
  12373. import { Observable } from "babylonjs/Misc/observable";
  12374. /**
  12375. * Represents a gamepad control stick position
  12376. */
  12377. export class StickValues {
  12378. /**
  12379. * The x component of the control stick
  12380. */
  12381. x: number;
  12382. /**
  12383. * The y component of the control stick
  12384. */
  12385. y: number;
  12386. /**
  12387. * Initializes the gamepad x and y control stick values
  12388. * @param x The x component of the gamepad control stick value
  12389. * @param y The y component of the gamepad control stick value
  12390. */
  12391. constructor(
  12392. /**
  12393. * The x component of the control stick
  12394. */
  12395. x: number,
  12396. /**
  12397. * The y component of the control stick
  12398. */
  12399. y: number);
  12400. }
  12401. /**
  12402. * An interface which manages callbacks for gamepad button changes
  12403. */
  12404. export interface GamepadButtonChanges {
  12405. /**
  12406. * Called when a gamepad has been changed
  12407. */
  12408. changed: boolean;
  12409. /**
  12410. * Called when a gamepad press event has been triggered
  12411. */
  12412. pressChanged: boolean;
  12413. /**
  12414. * Called when a touch event has been triggered
  12415. */
  12416. touchChanged: boolean;
  12417. /**
  12418. * Called when a value has changed
  12419. */
  12420. valueChanged: boolean;
  12421. }
  12422. /**
  12423. * Represents a gamepad
  12424. */
  12425. export class Gamepad {
  12426. /**
  12427. * The id of the gamepad
  12428. */
  12429. id: string;
  12430. /**
  12431. * The index of the gamepad
  12432. */
  12433. index: number;
  12434. /**
  12435. * The browser gamepad
  12436. */
  12437. browserGamepad: any;
  12438. /**
  12439. * Specifies what type of gamepad this represents
  12440. */
  12441. type: number;
  12442. private _leftStick;
  12443. private _rightStick;
  12444. /** @hidden */
  12445. _isConnected: boolean;
  12446. private _leftStickAxisX;
  12447. private _leftStickAxisY;
  12448. private _rightStickAxisX;
  12449. private _rightStickAxisY;
  12450. /**
  12451. * Triggered when the left control stick has been changed
  12452. */
  12453. private _onleftstickchanged;
  12454. /**
  12455. * Triggered when the right control stick has been changed
  12456. */
  12457. private _onrightstickchanged;
  12458. /**
  12459. * Represents a gamepad controller
  12460. */
  12461. static GAMEPAD: number;
  12462. /**
  12463. * Represents a generic controller
  12464. */
  12465. static GENERIC: number;
  12466. /**
  12467. * Represents an XBox controller
  12468. */
  12469. static XBOX: number;
  12470. /**
  12471. * Represents a pose-enabled controller
  12472. */
  12473. static POSE_ENABLED: number;
  12474. /**
  12475. * Represents an Dual Shock controller
  12476. */
  12477. static DUALSHOCK: number;
  12478. /**
  12479. * Specifies whether the left control stick should be Y-inverted
  12480. */
  12481. protected _invertLeftStickY: boolean;
  12482. /**
  12483. * Specifies if the gamepad has been connected
  12484. */
  12485. readonly isConnected: boolean;
  12486. /**
  12487. * Initializes the gamepad
  12488. * @param id The id of the gamepad
  12489. * @param index The index of the gamepad
  12490. * @param browserGamepad The browser gamepad
  12491. * @param leftStickX The x component of the left joystick
  12492. * @param leftStickY The y component of the left joystick
  12493. * @param rightStickX The x component of the right joystick
  12494. * @param rightStickY The y component of the right joystick
  12495. */
  12496. constructor(
  12497. /**
  12498. * The id of the gamepad
  12499. */
  12500. id: string,
  12501. /**
  12502. * The index of the gamepad
  12503. */
  12504. index: number,
  12505. /**
  12506. * The browser gamepad
  12507. */
  12508. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12509. /**
  12510. * Callback triggered when the left joystick has changed
  12511. * @param callback
  12512. */
  12513. onleftstickchanged(callback: (values: StickValues) => void): void;
  12514. /**
  12515. * Callback triggered when the right joystick has changed
  12516. * @param callback
  12517. */
  12518. onrightstickchanged(callback: (values: StickValues) => void): void;
  12519. /**
  12520. * Gets the left joystick
  12521. */
  12522. /**
  12523. * Sets the left joystick values
  12524. */
  12525. leftStick: StickValues;
  12526. /**
  12527. * Gets the right joystick
  12528. */
  12529. /**
  12530. * Sets the right joystick value
  12531. */
  12532. rightStick: StickValues;
  12533. /**
  12534. * Updates the gamepad joystick positions
  12535. */
  12536. update(): void;
  12537. /**
  12538. * Disposes the gamepad
  12539. */
  12540. dispose(): void;
  12541. }
  12542. /**
  12543. * Represents a generic gamepad
  12544. */
  12545. export class GenericPad extends Gamepad {
  12546. private _buttons;
  12547. private _onbuttondown;
  12548. private _onbuttonup;
  12549. /**
  12550. * Observable triggered when a button has been pressed
  12551. */
  12552. onButtonDownObservable: Observable<number>;
  12553. /**
  12554. * Observable triggered when a button has been released
  12555. */
  12556. onButtonUpObservable: Observable<number>;
  12557. /**
  12558. * Callback triggered when a button has been pressed
  12559. * @param callback Called when a button has been pressed
  12560. */
  12561. onbuttondown(callback: (buttonPressed: number) => void): void;
  12562. /**
  12563. * Callback triggered when a button has been released
  12564. * @param callback Called when a button has been released
  12565. */
  12566. onbuttonup(callback: (buttonReleased: number) => void): void;
  12567. /**
  12568. * Initializes the generic gamepad
  12569. * @param id The id of the generic gamepad
  12570. * @param index The index of the generic gamepad
  12571. * @param browserGamepad The browser gamepad
  12572. */
  12573. constructor(id: string, index: number, browserGamepad: any);
  12574. private _setButtonValue;
  12575. /**
  12576. * Updates the generic gamepad
  12577. */
  12578. update(): void;
  12579. /**
  12580. * Disposes the generic gamepad
  12581. */
  12582. dispose(): void;
  12583. }
  12584. }
  12585. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12586. import { Nullable } from "babylonjs/types";
  12587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12588. import { Scene } from "babylonjs/scene";
  12589. module "babylonjs/Engines/engine" {
  12590. interface Engine {
  12591. /**
  12592. * Creates a raw texture
  12593. * @param data defines the data to store in the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param format defines the format of the data
  12597. * @param generateMipMaps defines if the engine should generate the mip levels
  12598. * @param invertY defines if data must be stored with Y axis inverted
  12599. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12600. * @param compression defines the compression used (null by default)
  12601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12602. * @returns the raw texture inside an InternalTexture
  12603. */
  12604. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12605. /**
  12606. * Update a raw texture
  12607. * @param texture defines the texture to update
  12608. * @param data defines the data to store in the texture
  12609. * @param format defines the format of the data
  12610. * @param invertY defines if data must be stored with Y axis inverted
  12611. */
  12612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12613. /**
  12614. * Update a raw texture
  12615. * @param texture defines the texture to update
  12616. * @param data defines the data to store in the texture
  12617. * @param format defines the format of the data
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @param compression defines the compression used (null by default)
  12620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12621. */
  12622. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12623. /**
  12624. * Creates a new raw cube texture
  12625. * @param data defines the array of data to use to create each face
  12626. * @param size defines the size of the textures
  12627. * @param format defines the format of the data
  12628. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12629. * @param generateMipMaps defines if the engine should generate the mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compression used (null by default)
  12633. * @returns the cube texture as an InternalTexture
  12634. */
  12635. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12636. /**
  12637. * Update a raw cube texture
  12638. * @param texture defines the texture to udpdate
  12639. * @param data defines the data to store
  12640. * @param format defines the data format
  12641. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw cube texture
  12647. * @param texture defines the texture to udpdate
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12651. * @param invertY defines if data must be stored with Y axis inverted
  12652. * @param compression defines the compression used (null by default)
  12653. */
  12654. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12655. /**
  12656. * Update a raw cube texture
  12657. * @param texture defines the texture to udpdate
  12658. * @param data defines the data to store
  12659. * @param format defines the data format
  12660. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12661. * @param invertY defines if data must be stored with Y axis inverted
  12662. * @param compression defines the compression used (null by default)
  12663. * @param level defines which level of the texture to update
  12664. */
  12665. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12666. /**
  12667. * Creates a new raw cube texture from a specified url
  12668. * @param url defines the url where the data is located
  12669. * @param scene defines the current scene
  12670. * @param size defines the size of the textures
  12671. * @param format defines the format of the data
  12672. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12673. * @param noMipmap defines if the engine should avoid generating the mip levels
  12674. * @param callback defines a callback used to extract texture data from loaded data
  12675. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12676. * @param onLoad defines a callback called when texture is loaded
  12677. * @param onError defines a callback called if there is an error
  12678. * @returns the cube texture as an InternalTexture
  12679. */
  12680. 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;
  12681. /**
  12682. * Creates a new raw cube texture from a specified url
  12683. * @param url defines the url where the data is located
  12684. * @param scene defines the current scene
  12685. * @param size defines the size of the textures
  12686. * @param format defines the format of the data
  12687. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12688. * @param noMipmap defines if the engine should avoid generating the mip levels
  12689. * @param callback defines a callback used to extract texture data from loaded data
  12690. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12691. * @param onLoad defines a callback called when texture is loaded
  12692. * @param onError defines a callback called if there is an error
  12693. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12694. * @param invertY defines if data must be stored with Y axis inverted
  12695. * @returns the cube texture as an InternalTexture
  12696. */
  12697. 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;
  12698. /**
  12699. * Creates a new raw 3D texture
  12700. * @param data defines the data used to create the texture
  12701. * @param width defines the width of the texture
  12702. * @param height defines the height of the texture
  12703. * @param depth defines the depth of the texture
  12704. * @param format defines the format of the texture
  12705. * @param generateMipMaps defines if the engine must generate mip levels
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12708. * @param compression defines the compressed used (can be null)
  12709. * @param textureType defines the compressed used (can be null)
  12710. * @returns a new raw 3D texture (stored in an InternalTexture)
  12711. */
  12712. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12713. /**
  12714. * Update a raw 3D texture
  12715. * @param texture defines the texture to update
  12716. * @param data defines the data to store
  12717. * @param format defines the data format
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. */
  12720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12721. /**
  12722. * Update a raw 3D texture
  12723. * @param texture defines the texture to update
  12724. * @param data defines the data to store
  12725. * @param format defines the data format
  12726. * @param invertY defines if data must be stored with Y axis inverted
  12727. * @param compression defines the used compression (can be null)
  12728. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12729. */
  12730. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12731. }
  12732. }
  12733. }
  12734. declare module "babylonjs/Materials/Textures/rawTexture" {
  12735. import { Scene } from "babylonjs/scene";
  12736. import { Texture } from "babylonjs/Materials/Textures/texture";
  12737. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12738. /**
  12739. * Raw texture can help creating a texture directly from an array of data.
  12740. * This can be super useful if you either get the data from an uncompressed source or
  12741. * if you wish to create your texture pixel by pixel.
  12742. */
  12743. export class RawTexture extends Texture {
  12744. /**
  12745. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12746. */
  12747. format: number;
  12748. private _engine;
  12749. /**
  12750. * Instantiates a new RawTexture.
  12751. * Raw texture can help creating a texture directly from an array of data.
  12752. * This can be super useful if you either get the data from an uncompressed source or
  12753. * if you wish to create your texture pixel by pixel.
  12754. * @param data define the array of data to use to create the texture
  12755. * @param width define the width of the texture
  12756. * @param height define the height of the texture
  12757. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12758. * @param scene define the scene the texture belongs to
  12759. * @param generateMipMaps define whether mip maps should be generated or not
  12760. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12761. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12762. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12763. */
  12764. constructor(data: ArrayBufferView, width: number, height: number,
  12765. /**
  12766. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12767. */
  12768. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12769. /**
  12770. * Updates the texture underlying data.
  12771. * @param data Define the new data of the texture
  12772. */
  12773. update(data: ArrayBufferView): void;
  12774. /**
  12775. * Creates a luminance texture from some data.
  12776. * @param data Define the texture data
  12777. * @param width Define the width of the texture
  12778. * @param height Define the height of the texture
  12779. * @param scene Define the scene the texture belongs to
  12780. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12781. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12782. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12783. * @returns the luminance texture
  12784. */
  12785. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12786. /**
  12787. * Creates a luminance alpha texture from some data.
  12788. * @param data Define the texture data
  12789. * @param width Define the width of the texture
  12790. * @param height Define the height of the texture
  12791. * @param scene Define the scene the texture belongs to
  12792. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12793. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12794. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12795. * @returns the luminance alpha texture
  12796. */
  12797. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12798. /**
  12799. * Creates an alpha texture from some data.
  12800. * @param data Define the texture data
  12801. * @param width Define the width of the texture
  12802. * @param height Define the height of the texture
  12803. * @param scene Define the scene the texture belongs to
  12804. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12805. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12806. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12807. * @returns the alpha texture
  12808. */
  12809. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12810. /**
  12811. * Creates a RGB texture from some data.
  12812. * @param data Define the texture data
  12813. * @param width Define the width of the texture
  12814. * @param height Define the height of the texture
  12815. * @param scene Define the scene the texture belongs to
  12816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12819. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12820. * @returns the RGB alpha texture
  12821. */
  12822. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12823. /**
  12824. * Creates a RGBA texture from some data.
  12825. * @param data Define the texture data
  12826. * @param width Define the width of the texture
  12827. * @param height Define the height of the texture
  12828. * @param scene Define the scene the texture belongs to
  12829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12832. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12833. * @returns the RGBA texture
  12834. */
  12835. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12836. /**
  12837. * Creates a R texture from some data.
  12838. * @param data Define the texture data
  12839. * @param width Define the width of the texture
  12840. * @param height Define the height of the texture
  12841. * @param scene Define the scene the texture belongs to
  12842. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12843. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12844. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12845. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12846. * @returns the R texture
  12847. */
  12848. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12849. }
  12850. }
  12851. declare module "babylonjs/Maths/math.size" {
  12852. /**
  12853. * Interface for the size containing width and height
  12854. */
  12855. export interface ISize {
  12856. /**
  12857. * Width
  12858. */
  12859. width: number;
  12860. /**
  12861. * Heighht
  12862. */
  12863. height: number;
  12864. }
  12865. /**
  12866. * Size containing widht and height
  12867. */
  12868. export class Size implements ISize {
  12869. /**
  12870. * Width
  12871. */
  12872. width: number;
  12873. /**
  12874. * Height
  12875. */
  12876. height: number;
  12877. /**
  12878. * Creates a Size object from the given width and height (floats).
  12879. * @param width width of the new size
  12880. * @param height height of the new size
  12881. */
  12882. constructor(width: number, height: number);
  12883. /**
  12884. * Returns a string with the Size width and height
  12885. * @returns a string with the Size width and height
  12886. */
  12887. toString(): string;
  12888. /**
  12889. * "Size"
  12890. * @returns the string "Size"
  12891. */
  12892. getClassName(): string;
  12893. /**
  12894. * Returns the Size hash code.
  12895. * @returns a hash code for a unique width and height
  12896. */
  12897. getHashCode(): number;
  12898. /**
  12899. * Updates the current size from the given one.
  12900. * @param src the given size
  12901. */
  12902. copyFrom(src: Size): void;
  12903. /**
  12904. * Updates in place the current Size from the given floats.
  12905. * @param width width of the new size
  12906. * @param height height of the new size
  12907. * @returns the updated Size.
  12908. */
  12909. copyFromFloats(width: number, height: number): Size;
  12910. /**
  12911. * Updates in place the current Size from the given floats.
  12912. * @param width width to set
  12913. * @param height height to set
  12914. * @returns the updated Size.
  12915. */
  12916. set(width: number, height: number): Size;
  12917. /**
  12918. * Multiplies the width and height by numbers
  12919. * @param w factor to multiple the width by
  12920. * @param h factor to multiple the height by
  12921. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12922. */
  12923. multiplyByFloats(w: number, h: number): Size;
  12924. /**
  12925. * Clones the size
  12926. * @returns a new Size copied from the given one.
  12927. */
  12928. clone(): Size;
  12929. /**
  12930. * True if the current Size and the given one width and height are strictly equal.
  12931. * @param other the other size to compare against
  12932. * @returns True if the current Size and the given one width and height are strictly equal.
  12933. */
  12934. equals(other: Size): boolean;
  12935. /**
  12936. * The surface of the Size : width * height (float).
  12937. */
  12938. readonly surface: number;
  12939. /**
  12940. * Create a new size of zero
  12941. * @returns a new Size set to (0.0, 0.0)
  12942. */
  12943. static Zero(): Size;
  12944. /**
  12945. * Sums the width and height of two sizes
  12946. * @param otherSize size to add to this size
  12947. * @returns a new Size set as the addition result of the current Size and the given one.
  12948. */
  12949. add(otherSize: Size): Size;
  12950. /**
  12951. * Subtracts the width and height of two
  12952. * @param otherSize size to subtract to this size
  12953. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12954. */
  12955. subtract(otherSize: Size): Size;
  12956. /**
  12957. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12958. * @param start starting size to lerp between
  12959. * @param end end size to lerp between
  12960. * @param amount amount to lerp between the start and end values
  12961. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12962. */
  12963. static Lerp(start: Size, end: Size, amount: number): Size;
  12964. }
  12965. }
  12966. declare module "babylonjs/Animations/runtimeAnimation" {
  12967. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12968. import { Animatable } from "babylonjs/Animations/animatable";
  12969. import { Scene } from "babylonjs/scene";
  12970. /**
  12971. * Defines a runtime animation
  12972. */
  12973. export class RuntimeAnimation {
  12974. private _events;
  12975. /**
  12976. * The current frame of the runtime animation
  12977. */
  12978. private _currentFrame;
  12979. /**
  12980. * The animation used by the runtime animation
  12981. */
  12982. private _animation;
  12983. /**
  12984. * The target of the runtime animation
  12985. */
  12986. private _target;
  12987. /**
  12988. * The initiating animatable
  12989. */
  12990. private _host;
  12991. /**
  12992. * The original value of the runtime animation
  12993. */
  12994. private _originalValue;
  12995. /**
  12996. * The original blend value of the runtime animation
  12997. */
  12998. private _originalBlendValue;
  12999. /**
  13000. * The offsets cache of the runtime animation
  13001. */
  13002. private _offsetsCache;
  13003. /**
  13004. * The high limits cache of the runtime animation
  13005. */
  13006. private _highLimitsCache;
  13007. /**
  13008. * Specifies if the runtime animation has been stopped
  13009. */
  13010. private _stopped;
  13011. /**
  13012. * The blending factor of the runtime animation
  13013. */
  13014. private _blendingFactor;
  13015. /**
  13016. * The BabylonJS scene
  13017. */
  13018. private _scene;
  13019. /**
  13020. * The current value of the runtime animation
  13021. */
  13022. private _currentValue;
  13023. /** @hidden */
  13024. _animationState: _IAnimationState;
  13025. /**
  13026. * The active target of the runtime animation
  13027. */
  13028. private _activeTargets;
  13029. private _currentActiveTarget;
  13030. private _directTarget;
  13031. /**
  13032. * The target path of the runtime animation
  13033. */
  13034. private _targetPath;
  13035. /**
  13036. * The weight of the runtime animation
  13037. */
  13038. private _weight;
  13039. /**
  13040. * The ratio offset of the runtime animation
  13041. */
  13042. private _ratioOffset;
  13043. /**
  13044. * The previous delay of the runtime animation
  13045. */
  13046. private _previousDelay;
  13047. /**
  13048. * The previous ratio of the runtime animation
  13049. */
  13050. private _previousRatio;
  13051. private _enableBlending;
  13052. private _keys;
  13053. private _minFrame;
  13054. private _maxFrame;
  13055. private _minValue;
  13056. private _maxValue;
  13057. private _targetIsArray;
  13058. /**
  13059. * Gets the current frame of the runtime animation
  13060. */
  13061. readonly currentFrame: number;
  13062. /**
  13063. * Gets the weight of the runtime animation
  13064. */
  13065. readonly weight: number;
  13066. /**
  13067. * Gets the current value of the runtime animation
  13068. */
  13069. readonly currentValue: any;
  13070. /**
  13071. * Gets the target path of the runtime animation
  13072. */
  13073. readonly targetPath: string;
  13074. /**
  13075. * Gets the actual target of the runtime animation
  13076. */
  13077. readonly target: any;
  13078. /** @hidden */
  13079. _onLoop: () => void;
  13080. /**
  13081. * Create a new RuntimeAnimation object
  13082. * @param target defines the target of the animation
  13083. * @param animation defines the source animation object
  13084. * @param scene defines the hosting scene
  13085. * @param host defines the initiating Animatable
  13086. */
  13087. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13088. private _preparePath;
  13089. /**
  13090. * Gets the animation from the runtime animation
  13091. */
  13092. readonly animation: Animation;
  13093. /**
  13094. * Resets the runtime animation to the beginning
  13095. * @param restoreOriginal defines whether to restore the target property to the original value
  13096. */
  13097. reset(restoreOriginal?: boolean): void;
  13098. /**
  13099. * Specifies if the runtime animation is stopped
  13100. * @returns Boolean specifying if the runtime animation is stopped
  13101. */
  13102. isStopped(): boolean;
  13103. /**
  13104. * Disposes of the runtime animation
  13105. */
  13106. dispose(): void;
  13107. /**
  13108. * Apply the interpolated value to the target
  13109. * @param currentValue defines the value computed by the animation
  13110. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13111. */
  13112. setValue(currentValue: any, weight: number): void;
  13113. private _getOriginalValues;
  13114. private _setValue;
  13115. /**
  13116. * Gets the loop pmode of the runtime animation
  13117. * @returns Loop Mode
  13118. */
  13119. private _getCorrectLoopMode;
  13120. /**
  13121. * Move the current animation to a given frame
  13122. * @param frame defines the frame to move to
  13123. */
  13124. goToFrame(frame: number): void;
  13125. /**
  13126. * @hidden Internal use only
  13127. */
  13128. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13129. /**
  13130. * Execute the current animation
  13131. * @param delay defines the delay to add to the current frame
  13132. * @param from defines the lower bound of the animation range
  13133. * @param to defines the upper bound of the animation range
  13134. * @param loop defines if the current animation must loop
  13135. * @param speedRatio defines the current speed ratio
  13136. * @param weight defines the weight of the animation (default is -1 so no weight)
  13137. * @param onLoop optional callback called when animation loops
  13138. * @returns a boolean indicating if the animation is running
  13139. */
  13140. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13141. }
  13142. }
  13143. declare module "babylonjs/Animations/animatable" {
  13144. import { Animation } from "babylonjs/Animations/animation";
  13145. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13146. import { Nullable } from "babylonjs/types";
  13147. import { Observable } from "babylonjs/Misc/observable";
  13148. import { Scene } from "babylonjs/scene";
  13149. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13150. import { Node } from "babylonjs/node";
  13151. /**
  13152. * Class used to store an actual running animation
  13153. */
  13154. export class Animatable {
  13155. /** defines the target object */
  13156. target: any;
  13157. /** defines the starting frame number (default is 0) */
  13158. fromFrame: number;
  13159. /** defines the ending frame number (default is 100) */
  13160. toFrame: number;
  13161. /** defines if the animation must loop (default is false) */
  13162. loopAnimation: boolean;
  13163. /** defines a callback to call when animation ends if it is not looping */
  13164. onAnimationEnd?: (() => void) | null | undefined;
  13165. /** defines a callback to call when animation loops */
  13166. onAnimationLoop?: (() => void) | null | undefined;
  13167. private _localDelayOffset;
  13168. private _pausedDelay;
  13169. private _runtimeAnimations;
  13170. private _paused;
  13171. private _scene;
  13172. private _speedRatio;
  13173. private _weight;
  13174. private _syncRoot;
  13175. /**
  13176. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13177. * This will only apply for non looping animation (default is true)
  13178. */
  13179. disposeOnEnd: boolean;
  13180. /**
  13181. * Gets a boolean indicating if the animation has started
  13182. */
  13183. animationStarted: boolean;
  13184. /**
  13185. * Observer raised when the animation ends
  13186. */
  13187. onAnimationEndObservable: Observable<Animatable>;
  13188. /**
  13189. * Observer raised when the animation loops
  13190. */
  13191. onAnimationLoopObservable: Observable<Animatable>;
  13192. /**
  13193. * Gets the root Animatable used to synchronize and normalize animations
  13194. */
  13195. readonly syncRoot: Nullable<Animatable>;
  13196. /**
  13197. * Gets the current frame of the first RuntimeAnimation
  13198. * Used to synchronize Animatables
  13199. */
  13200. readonly masterFrame: number;
  13201. /**
  13202. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13203. */
  13204. weight: number;
  13205. /**
  13206. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13207. */
  13208. speedRatio: number;
  13209. /**
  13210. * Creates a new Animatable
  13211. * @param scene defines the hosting scene
  13212. * @param target defines the target object
  13213. * @param fromFrame defines the starting frame number (default is 0)
  13214. * @param toFrame defines the ending frame number (default is 100)
  13215. * @param loopAnimation defines if the animation must loop (default is false)
  13216. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13217. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13218. * @param animations defines a group of animation to add to the new Animatable
  13219. * @param onAnimationLoop defines a callback to call when animation loops
  13220. */
  13221. constructor(scene: Scene,
  13222. /** defines the target object */
  13223. target: any,
  13224. /** defines the starting frame number (default is 0) */
  13225. fromFrame?: number,
  13226. /** defines the ending frame number (default is 100) */
  13227. toFrame?: number,
  13228. /** defines if the animation must loop (default is false) */
  13229. loopAnimation?: boolean, speedRatio?: number,
  13230. /** defines a callback to call when animation ends if it is not looping */
  13231. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13232. /** defines a callback to call when animation loops */
  13233. onAnimationLoop?: (() => void) | null | undefined);
  13234. /**
  13235. * Synchronize and normalize current Animatable with a source Animatable
  13236. * This is useful when using animation weights and when animations are not of the same length
  13237. * @param root defines the root Animatable to synchronize with
  13238. * @returns the current Animatable
  13239. */
  13240. syncWith(root: Animatable): Animatable;
  13241. /**
  13242. * Gets the list of runtime animations
  13243. * @returns an array of RuntimeAnimation
  13244. */
  13245. getAnimations(): RuntimeAnimation[];
  13246. /**
  13247. * Adds more animations to the current animatable
  13248. * @param target defines the target of the animations
  13249. * @param animations defines the new animations to add
  13250. */
  13251. appendAnimations(target: any, animations: Animation[]): void;
  13252. /**
  13253. * Gets the source animation for a specific property
  13254. * @param property defines the propertyu to look for
  13255. * @returns null or the source animation for the given property
  13256. */
  13257. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13258. /**
  13259. * Gets the runtime animation for a specific property
  13260. * @param property defines the propertyu to look for
  13261. * @returns null or the runtime animation for the given property
  13262. */
  13263. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13264. /**
  13265. * Resets the animatable to its original state
  13266. */
  13267. reset(): void;
  13268. /**
  13269. * Allows the animatable to blend with current running animations
  13270. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13271. * @param blendingSpeed defines the blending speed to use
  13272. */
  13273. enableBlending(blendingSpeed: number): void;
  13274. /**
  13275. * Disable animation blending
  13276. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13277. */
  13278. disableBlending(): void;
  13279. /**
  13280. * Jump directly to a given frame
  13281. * @param frame defines the frame to jump to
  13282. */
  13283. goToFrame(frame: number): void;
  13284. /**
  13285. * Pause the animation
  13286. */
  13287. pause(): void;
  13288. /**
  13289. * Restart the animation
  13290. */
  13291. restart(): void;
  13292. private _raiseOnAnimationEnd;
  13293. /**
  13294. * Stop and delete the current animation
  13295. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13296. * @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)
  13297. */
  13298. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13299. /**
  13300. * Wait asynchronously for the animation to end
  13301. * @returns a promise which will be fullfilled when the animation ends
  13302. */
  13303. waitAsync(): Promise<Animatable>;
  13304. /** @hidden */
  13305. _animate(delay: number): boolean;
  13306. }
  13307. module "babylonjs/scene" {
  13308. interface Scene {
  13309. /** @hidden */
  13310. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13311. /** @hidden */
  13312. _processLateAnimationBindingsForMatrices(holder: {
  13313. totalWeight: number;
  13314. animations: RuntimeAnimation[];
  13315. originalValue: Matrix;
  13316. }): any;
  13317. /** @hidden */
  13318. _processLateAnimationBindingsForQuaternions(holder: {
  13319. totalWeight: number;
  13320. animations: RuntimeAnimation[];
  13321. originalValue: Quaternion;
  13322. }, refQuaternion: Quaternion): Quaternion;
  13323. /** @hidden */
  13324. _processLateAnimationBindings(): void;
  13325. /**
  13326. * Will start the animation sequence of a given target
  13327. * @param target defines the target
  13328. * @param from defines from which frame should animation start
  13329. * @param to defines until which frame should animation run.
  13330. * @param weight defines the weight to apply to the animation (1.0 by default)
  13331. * @param loop defines if the animation loops
  13332. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13333. * @param onAnimationEnd defines the function to be executed when the animation ends
  13334. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13335. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13336. * @param onAnimationLoop defines the callback to call when an animation loops
  13337. * @returns the animatable object created for this animation
  13338. */
  13339. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13340. /**
  13341. * Will start the animation sequence of a given target
  13342. * @param target defines the target
  13343. * @param from defines from which frame should animation start
  13344. * @param to defines until which frame should animation run.
  13345. * @param loop defines if the animation loops
  13346. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13347. * @param onAnimationEnd defines the function to be executed when the animation ends
  13348. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13349. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13350. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13351. * @param onAnimationLoop defines the callback to call when an animation loops
  13352. * @returns the animatable object created for this animation
  13353. */
  13354. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13355. /**
  13356. * Will start the animation sequence of a given target and its hierarchy
  13357. * @param target defines the target
  13358. * @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.
  13359. * @param from defines from which frame should animation start
  13360. * @param to defines until which frame should animation run.
  13361. * @param loop defines if the animation loops
  13362. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13363. * @param onAnimationEnd defines the function to be executed when the animation ends
  13364. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13365. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13366. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13367. * @param onAnimationLoop defines the callback to call when an animation loops
  13368. * @returns the list of created animatables
  13369. */
  13370. 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[];
  13371. /**
  13372. * Begin a new animation on a given node
  13373. * @param target defines the target where the animation will take place
  13374. * @param animations defines the list of animations to start
  13375. * @param from defines the initial value
  13376. * @param to defines the final value
  13377. * @param loop defines if you want animation to loop (off by default)
  13378. * @param speedRatio defines the speed ratio to apply to all animations
  13379. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13380. * @param onAnimationLoop defines the callback to call when an animation loops
  13381. * @returns the list of created animatables
  13382. */
  13383. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13384. /**
  13385. * Begin a new animation on a given node and its hierarchy
  13386. * @param target defines the root node where the animation will take place
  13387. * @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.
  13388. * @param animations defines the list of animations to start
  13389. * @param from defines the initial value
  13390. * @param to defines the final value
  13391. * @param loop defines if you want animation to loop (off by default)
  13392. * @param speedRatio defines the speed ratio to apply to all animations
  13393. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13394. * @param onAnimationLoop defines the callback to call when an animation loops
  13395. * @returns the list of animatables created for all nodes
  13396. */
  13397. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13398. /**
  13399. * Gets the animatable associated with a specific target
  13400. * @param target defines the target of the animatable
  13401. * @returns the required animatable if found
  13402. */
  13403. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13404. /**
  13405. * Gets all animatables associated with a given target
  13406. * @param target defines the target to look animatables for
  13407. * @returns an array of Animatables
  13408. */
  13409. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13410. /**
  13411. * Stops and removes all animations that have been applied to the scene
  13412. */
  13413. stopAllAnimations(): void;
  13414. /**
  13415. * Gets the current delta time used by animation engine
  13416. */
  13417. deltaTime: number;
  13418. }
  13419. }
  13420. module "babylonjs/Bones/bone" {
  13421. interface Bone {
  13422. /**
  13423. * Copy an animation range from another bone
  13424. * @param source defines the source bone
  13425. * @param rangeName defines the range name to copy
  13426. * @param frameOffset defines the frame offset
  13427. * @param rescaleAsRequired defines if rescaling must be applied if required
  13428. * @param skelDimensionsRatio defines the scaling ratio
  13429. * @returns true if operation was successful
  13430. */
  13431. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13432. }
  13433. }
  13434. }
  13435. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13436. /**
  13437. * Class used to override all child animations of a given target
  13438. */
  13439. export class AnimationPropertiesOverride {
  13440. /**
  13441. * Gets or sets a value indicating if animation blending must be used
  13442. */
  13443. enableBlending: boolean;
  13444. /**
  13445. * Gets or sets the blending speed to use when enableBlending is true
  13446. */
  13447. blendingSpeed: number;
  13448. /**
  13449. * Gets or sets the default loop mode to use
  13450. */
  13451. loopMode: number;
  13452. }
  13453. }
  13454. declare module "babylonjs/Bones/skeleton" {
  13455. import { Bone } from "babylonjs/Bones/bone";
  13456. import { Observable } from "babylonjs/Misc/observable";
  13457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13458. import { Scene } from "babylonjs/scene";
  13459. import { Nullable } from "babylonjs/types";
  13460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13461. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13462. import { Animatable } from "babylonjs/Animations/animatable";
  13463. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13464. import { Animation } from "babylonjs/Animations/animation";
  13465. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13466. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13468. /**
  13469. * Class used to handle skinning animations
  13470. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13471. */
  13472. export class Skeleton implements IAnimatable {
  13473. /** defines the skeleton name */
  13474. name: string;
  13475. /** defines the skeleton Id */
  13476. id: string;
  13477. /**
  13478. * Defines the list of child bones
  13479. */
  13480. bones: Bone[];
  13481. /**
  13482. * Defines an estimate of the dimension of the skeleton at rest
  13483. */
  13484. dimensionsAtRest: Vector3;
  13485. /**
  13486. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13487. */
  13488. needInitialSkinMatrix: boolean;
  13489. /**
  13490. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13491. */
  13492. overrideMesh: Nullable<AbstractMesh>;
  13493. /**
  13494. * Gets the list of animations attached to this skeleton
  13495. */
  13496. animations: Array<Animation>;
  13497. private _scene;
  13498. private _isDirty;
  13499. private _transformMatrices;
  13500. private _transformMatrixTexture;
  13501. private _meshesWithPoseMatrix;
  13502. private _animatables;
  13503. private _identity;
  13504. private _synchronizedWithMesh;
  13505. private _ranges;
  13506. private _lastAbsoluteTransformsUpdateId;
  13507. private _canUseTextureForBones;
  13508. private _uniqueId;
  13509. /** @hidden */
  13510. _numBonesWithLinkedTransformNode: number;
  13511. /** @hidden */
  13512. _hasWaitingData: Nullable<boolean>;
  13513. /**
  13514. * Specifies if the skeleton should be serialized
  13515. */
  13516. doNotSerialize: boolean;
  13517. private _useTextureToStoreBoneMatrices;
  13518. /**
  13519. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13520. * Please note that this option is not available if the hardware does not support it
  13521. */
  13522. useTextureToStoreBoneMatrices: boolean;
  13523. private _animationPropertiesOverride;
  13524. /**
  13525. * Gets or sets the animation properties override
  13526. */
  13527. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13528. /**
  13529. * List of inspectable custom properties (used by the Inspector)
  13530. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13531. */
  13532. inspectableCustomProperties: IInspectable[];
  13533. /**
  13534. * An observable triggered before computing the skeleton's matrices
  13535. */
  13536. onBeforeComputeObservable: Observable<Skeleton>;
  13537. /**
  13538. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13539. */
  13540. readonly isUsingTextureForMatrices: boolean;
  13541. /**
  13542. * Gets the unique ID of this skeleton
  13543. */
  13544. readonly uniqueId: number;
  13545. /**
  13546. * Creates a new skeleton
  13547. * @param name defines the skeleton name
  13548. * @param id defines the skeleton Id
  13549. * @param scene defines the hosting scene
  13550. */
  13551. constructor(
  13552. /** defines the skeleton name */
  13553. name: string,
  13554. /** defines the skeleton Id */
  13555. id: string, scene: Scene);
  13556. /**
  13557. * Gets the current object class name.
  13558. * @return the class name
  13559. */
  13560. getClassName(): string;
  13561. /**
  13562. * Returns an array containing the root bones
  13563. * @returns an array containing the root bones
  13564. */
  13565. getChildren(): Array<Bone>;
  13566. /**
  13567. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13568. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13569. * @returns a Float32Array containing matrices data
  13570. */
  13571. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13572. /**
  13573. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13574. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13575. * @returns a raw texture containing the data
  13576. */
  13577. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13578. /**
  13579. * Gets the current hosting scene
  13580. * @returns a scene object
  13581. */
  13582. getScene(): Scene;
  13583. /**
  13584. * Gets a string representing the current skeleton data
  13585. * @param fullDetails defines a boolean indicating if we want a verbose version
  13586. * @returns a string representing the current skeleton data
  13587. */
  13588. toString(fullDetails?: boolean): string;
  13589. /**
  13590. * Get bone's index searching by name
  13591. * @param name defines bone's name to search for
  13592. * @return the indice of the bone. Returns -1 if not found
  13593. */
  13594. getBoneIndexByName(name: string): number;
  13595. /**
  13596. * Creater a new animation range
  13597. * @param name defines the name of the range
  13598. * @param from defines the start key
  13599. * @param to defines the end key
  13600. */
  13601. createAnimationRange(name: string, from: number, to: number): void;
  13602. /**
  13603. * Delete a specific animation range
  13604. * @param name defines the name of the range
  13605. * @param deleteFrames defines if frames must be removed as well
  13606. */
  13607. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13608. /**
  13609. * Gets a specific animation range
  13610. * @param name defines the name of the range to look for
  13611. * @returns the requested animation range or null if not found
  13612. */
  13613. getAnimationRange(name: string): Nullable<AnimationRange>;
  13614. /**
  13615. * Gets the list of all animation ranges defined on this skeleton
  13616. * @returns an array
  13617. */
  13618. getAnimationRanges(): Nullable<AnimationRange>[];
  13619. /**
  13620. * Copy animation range from a source skeleton.
  13621. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13622. * @param source defines the source skeleton
  13623. * @param name defines the name of the range to copy
  13624. * @param rescaleAsRequired defines if rescaling must be applied if required
  13625. * @returns true if operation was successful
  13626. */
  13627. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13628. /**
  13629. * Forces the skeleton to go to rest pose
  13630. */
  13631. returnToRest(): void;
  13632. private _getHighestAnimationFrame;
  13633. /**
  13634. * Begin a specific animation range
  13635. * @param name defines the name of the range to start
  13636. * @param loop defines if looping must be turned on (false by default)
  13637. * @param speedRatio defines the speed ratio to apply (1 by default)
  13638. * @param onAnimationEnd defines a callback which will be called when animation will end
  13639. * @returns a new animatable
  13640. */
  13641. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13642. /** @hidden */
  13643. _markAsDirty(): void;
  13644. /** @hidden */
  13645. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13646. /** @hidden */
  13647. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13648. private _computeTransformMatrices;
  13649. /**
  13650. * Build all resources required to render a skeleton
  13651. */
  13652. prepare(): void;
  13653. /**
  13654. * Gets the list of animatables currently running for this skeleton
  13655. * @returns an array of animatables
  13656. */
  13657. getAnimatables(): IAnimatable[];
  13658. /**
  13659. * Clone the current skeleton
  13660. * @param name defines the name of the new skeleton
  13661. * @param id defines the id of the new skeleton
  13662. * @returns the new skeleton
  13663. */
  13664. clone(name: string, id?: string): Skeleton;
  13665. /**
  13666. * Enable animation blending for this skeleton
  13667. * @param blendingSpeed defines the blending speed to apply
  13668. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13669. */
  13670. enableBlending(blendingSpeed?: number): void;
  13671. /**
  13672. * Releases all resources associated with the current skeleton
  13673. */
  13674. dispose(): void;
  13675. /**
  13676. * Serialize the skeleton in a JSON object
  13677. * @returns a JSON object
  13678. */
  13679. serialize(): any;
  13680. /**
  13681. * Creates a new skeleton from serialized data
  13682. * @param parsedSkeleton defines the serialized data
  13683. * @param scene defines the hosting scene
  13684. * @returns a new skeleton
  13685. */
  13686. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13687. /**
  13688. * Compute all node absolute transforms
  13689. * @param forceUpdate defines if computation must be done even if cache is up to date
  13690. */
  13691. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13692. /**
  13693. * Gets the root pose matrix
  13694. * @returns a matrix
  13695. */
  13696. getPoseMatrix(): Nullable<Matrix>;
  13697. /**
  13698. * Sorts bones per internal index
  13699. */
  13700. sortBones(): void;
  13701. private _sortBones;
  13702. }
  13703. }
  13704. declare module "babylonjs/Bones/bone" {
  13705. import { Skeleton } from "babylonjs/Bones/skeleton";
  13706. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13709. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13710. import { Node } from "babylonjs/node";
  13711. import { Space } from "babylonjs/Maths/math.axis";
  13712. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13713. /**
  13714. * Class used to store bone information
  13715. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13716. */
  13717. export class Bone extends Node {
  13718. /**
  13719. * defines the bone name
  13720. */
  13721. name: string;
  13722. private static _tmpVecs;
  13723. private static _tmpQuat;
  13724. private static _tmpMats;
  13725. /**
  13726. * Gets the list of child bones
  13727. */
  13728. children: Bone[];
  13729. /** Gets the animations associated with this bone */
  13730. animations: import("babylonjs/Animations/animation").Animation[];
  13731. /**
  13732. * Gets or sets bone length
  13733. */
  13734. length: number;
  13735. /**
  13736. * @hidden Internal only
  13737. * Set this value to map this bone to a different index in the transform matrices
  13738. * Set this value to -1 to exclude the bone from the transform matrices
  13739. */
  13740. _index: Nullable<number>;
  13741. private _skeleton;
  13742. private _localMatrix;
  13743. private _restPose;
  13744. private _baseMatrix;
  13745. private _absoluteTransform;
  13746. private _invertedAbsoluteTransform;
  13747. private _parent;
  13748. private _scalingDeterminant;
  13749. private _worldTransform;
  13750. private _localScaling;
  13751. private _localRotation;
  13752. private _localPosition;
  13753. private _needToDecompose;
  13754. private _needToCompose;
  13755. /** @hidden */
  13756. _linkedTransformNode: Nullable<TransformNode>;
  13757. /** @hidden */
  13758. _waitingTransformNodeId: Nullable<string>;
  13759. /** @hidden */
  13760. /** @hidden */
  13761. _matrix: Matrix;
  13762. /**
  13763. * Create a new bone
  13764. * @param name defines the bone name
  13765. * @param skeleton defines the parent skeleton
  13766. * @param parentBone defines the parent (can be null if the bone is the root)
  13767. * @param localMatrix defines the local matrix
  13768. * @param restPose defines the rest pose matrix
  13769. * @param baseMatrix defines the base matrix
  13770. * @param index defines index of the bone in the hiearchy
  13771. */
  13772. constructor(
  13773. /**
  13774. * defines the bone name
  13775. */
  13776. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13777. /**
  13778. * Gets the current object class name.
  13779. * @return the class name
  13780. */
  13781. getClassName(): string;
  13782. /**
  13783. * Gets the parent skeleton
  13784. * @returns a skeleton
  13785. */
  13786. getSkeleton(): Skeleton;
  13787. /**
  13788. * Gets parent bone
  13789. * @returns a bone or null if the bone is the root of the bone hierarchy
  13790. */
  13791. getParent(): Nullable<Bone>;
  13792. /**
  13793. * Returns an array containing the root bones
  13794. * @returns an array containing the root bones
  13795. */
  13796. getChildren(): Array<Bone>;
  13797. /**
  13798. * Gets the node index in matrix array generated for rendering
  13799. * @returns the node index
  13800. */
  13801. getIndex(): number;
  13802. /**
  13803. * Sets the parent bone
  13804. * @param parent defines the parent (can be null if the bone is the root)
  13805. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13806. */
  13807. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13808. /**
  13809. * Gets the local matrix
  13810. * @returns a matrix
  13811. */
  13812. getLocalMatrix(): Matrix;
  13813. /**
  13814. * Gets the base matrix (initial matrix which remains unchanged)
  13815. * @returns a matrix
  13816. */
  13817. getBaseMatrix(): Matrix;
  13818. /**
  13819. * Gets the rest pose matrix
  13820. * @returns a matrix
  13821. */
  13822. getRestPose(): Matrix;
  13823. /**
  13824. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13825. */
  13826. getWorldMatrix(): Matrix;
  13827. /**
  13828. * Sets the local matrix to rest pose matrix
  13829. */
  13830. returnToRest(): void;
  13831. /**
  13832. * Gets the inverse of the absolute transform matrix.
  13833. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13834. * @returns a matrix
  13835. */
  13836. getInvertedAbsoluteTransform(): Matrix;
  13837. /**
  13838. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13839. * @returns a matrix
  13840. */
  13841. getAbsoluteTransform(): Matrix;
  13842. /**
  13843. * Links with the given transform node.
  13844. * The local matrix of this bone is copied from the transform node every frame.
  13845. * @param transformNode defines the transform node to link to
  13846. */
  13847. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13848. /**
  13849. * Gets the node used to drive the bone's transformation
  13850. * @returns a transform node or null
  13851. */
  13852. getTransformNode(): Nullable<TransformNode>;
  13853. /** Gets or sets current position (in local space) */
  13854. position: Vector3;
  13855. /** Gets or sets current rotation (in local space) */
  13856. rotation: Vector3;
  13857. /** Gets or sets current rotation quaternion (in local space) */
  13858. rotationQuaternion: Quaternion;
  13859. /** Gets or sets current scaling (in local space) */
  13860. scaling: Vector3;
  13861. /**
  13862. * Gets the animation properties override
  13863. */
  13864. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13865. private _decompose;
  13866. private _compose;
  13867. /**
  13868. * Update the base and local matrices
  13869. * @param matrix defines the new base or local matrix
  13870. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13871. * @param updateLocalMatrix defines if the local matrix should be updated
  13872. */
  13873. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13874. /** @hidden */
  13875. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13876. /**
  13877. * Flag the bone as dirty (Forcing it to update everything)
  13878. */
  13879. markAsDirty(): void;
  13880. /** @hidden */
  13881. _markAsDirtyAndCompose(): void;
  13882. private _markAsDirtyAndDecompose;
  13883. /**
  13884. * Translate the bone in local or world space
  13885. * @param vec The amount to translate the bone
  13886. * @param space The space that the translation is in
  13887. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13888. */
  13889. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13890. /**
  13891. * Set the postion of the bone in local or world space
  13892. * @param position The position to set the bone
  13893. * @param space The space that the position is in
  13894. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13895. */
  13896. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13897. /**
  13898. * Set the absolute position of the bone (world space)
  13899. * @param position The position to set the bone
  13900. * @param mesh The mesh that this bone is attached to
  13901. */
  13902. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13903. /**
  13904. * Scale the bone on the x, y and z axes (in local space)
  13905. * @param x The amount to scale the bone on the x axis
  13906. * @param y The amount to scale the bone on the y axis
  13907. * @param z The amount to scale the bone on the z axis
  13908. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13909. */
  13910. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13911. /**
  13912. * Set the bone scaling in local space
  13913. * @param scale defines the scaling vector
  13914. */
  13915. setScale(scale: Vector3): void;
  13916. /**
  13917. * Gets the current scaling in local space
  13918. * @returns the current scaling vector
  13919. */
  13920. getScale(): Vector3;
  13921. /**
  13922. * Gets the current scaling in local space and stores it in a target vector
  13923. * @param result defines the target vector
  13924. */
  13925. getScaleToRef(result: Vector3): void;
  13926. /**
  13927. * Set the yaw, pitch, and roll of the bone in local or world space
  13928. * @param yaw The rotation of the bone on the y axis
  13929. * @param pitch The rotation of the bone on the x axis
  13930. * @param roll The rotation of the bone on the z axis
  13931. * @param space The space that the axes of rotation are in
  13932. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13933. */
  13934. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13935. /**
  13936. * Add a rotation to the bone on an axis in local or world space
  13937. * @param axis The axis to rotate the bone on
  13938. * @param amount The amount to rotate the bone
  13939. * @param space The space that the axis is in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. */
  13942. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13943. /**
  13944. * Set the rotation of the bone to a particular axis angle in local or world space
  13945. * @param axis The axis to rotate the bone on
  13946. * @param angle The angle that the bone should be rotated to
  13947. * @param space The space that the axis is in
  13948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13949. */
  13950. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13951. /**
  13952. * Set the euler rotation of the bone in local of world space
  13953. * @param rotation The euler rotation that the bone should be set to
  13954. * @param space The space that the rotation is in
  13955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13956. */
  13957. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13958. /**
  13959. * Set the quaternion rotation of the bone in local of world space
  13960. * @param quat The quaternion rotation that the bone should be set to
  13961. * @param space The space that the rotation is in
  13962. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13963. */
  13964. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13965. /**
  13966. * Set the rotation matrix of the bone in local of world space
  13967. * @param rotMat The rotation matrix that the bone should be set to
  13968. * @param space The space that the rotation is in
  13969. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13970. */
  13971. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13972. private _rotateWithMatrix;
  13973. private _getNegativeRotationToRef;
  13974. /**
  13975. * Get the position of the bone in local or world space
  13976. * @param space The space that the returned position is in
  13977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13978. * @returns The position of the bone
  13979. */
  13980. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13981. /**
  13982. * Copy the position of the bone to a vector3 in local or world space
  13983. * @param space The space that the returned position is in
  13984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13985. * @param result The vector3 to copy the position to
  13986. */
  13987. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13988. /**
  13989. * Get the absolute position of the bone (world space)
  13990. * @param mesh The mesh that this bone is attached to
  13991. * @returns The absolute position of the bone
  13992. */
  13993. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13994. /**
  13995. * Copy the absolute position of the bone (world space) to the result param
  13996. * @param mesh The mesh that this bone is attached to
  13997. * @param result The vector3 to copy the absolute position to
  13998. */
  13999. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14000. /**
  14001. * Compute the absolute transforms of this bone and its children
  14002. */
  14003. computeAbsoluteTransforms(): void;
  14004. /**
  14005. * Get the world direction from an axis that is in the local space of the bone
  14006. * @param localAxis The local direction that is used to compute the world direction
  14007. * @param mesh The mesh that this bone is attached to
  14008. * @returns The world direction
  14009. */
  14010. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14011. /**
  14012. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14013. * @param localAxis The local direction that is used to compute the world direction
  14014. * @param mesh The mesh that this bone is attached to
  14015. * @param result The vector3 that the world direction will be copied to
  14016. */
  14017. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14018. /**
  14019. * Get the euler rotation of the bone in local or world space
  14020. * @param space The space that the rotation should be in
  14021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14022. * @returns The euler rotation
  14023. */
  14024. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14025. /**
  14026. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14027. * @param space The space that the rotation should be in
  14028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14029. * @param result The vector3 that the rotation should be copied to
  14030. */
  14031. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14032. /**
  14033. * Get the quaternion rotation of the bone in either local or world space
  14034. * @param space The space that the rotation should be in
  14035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14036. * @returns The quaternion rotation
  14037. */
  14038. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14039. /**
  14040. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14041. * @param space The space that the rotation should be in
  14042. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14043. * @param result The quaternion that the rotation should be copied to
  14044. */
  14045. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14046. /**
  14047. * Get the rotation matrix of the bone in local or world space
  14048. * @param space The space that the rotation should be in
  14049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14050. * @returns The rotation matrix
  14051. */
  14052. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14053. /**
  14054. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14055. * @param space The space that the rotation should be in
  14056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14057. * @param result The quaternion that the rotation should be copied to
  14058. */
  14059. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14060. /**
  14061. * Get the world position of a point that is in the local space of the bone
  14062. * @param position The local position
  14063. * @param mesh The mesh that this bone is attached to
  14064. * @returns The world position
  14065. */
  14066. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14067. /**
  14068. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14069. * @param position The local position
  14070. * @param mesh The mesh that this bone is attached to
  14071. * @param result The vector3 that the world position should be copied to
  14072. */
  14073. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14074. /**
  14075. * Get the local position of a point that is in world space
  14076. * @param position The world position
  14077. * @param mesh The mesh that this bone is attached to
  14078. * @returns The local position
  14079. */
  14080. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14081. /**
  14082. * Get the local position of a point that is in world space and copy it to the result param
  14083. * @param position The world position
  14084. * @param mesh The mesh that this bone is attached to
  14085. * @param result The vector3 that the local position should be copied to
  14086. */
  14087. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14088. }
  14089. }
  14090. declare module "babylonjs/Meshes/transformNode" {
  14091. import { DeepImmutable } from "babylonjs/types";
  14092. import { Observable } from "babylonjs/Misc/observable";
  14093. import { Nullable } from "babylonjs/types";
  14094. import { Camera } from "babylonjs/Cameras/camera";
  14095. import { Scene } from "babylonjs/scene";
  14096. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14097. import { Node } from "babylonjs/node";
  14098. import { Bone } from "babylonjs/Bones/bone";
  14099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14100. import { Space } from "babylonjs/Maths/math.axis";
  14101. /**
  14102. * 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.
  14103. * @see https://doc.babylonjs.com/how_to/transformnode
  14104. */
  14105. export class TransformNode extends Node {
  14106. /**
  14107. * Object will not rotate to face the camera
  14108. */
  14109. static BILLBOARDMODE_NONE: number;
  14110. /**
  14111. * Object will rotate to face the camera but only on the x axis
  14112. */
  14113. static BILLBOARDMODE_X: number;
  14114. /**
  14115. * Object will rotate to face the camera but only on the y axis
  14116. */
  14117. static BILLBOARDMODE_Y: number;
  14118. /**
  14119. * Object will rotate to face the camera but only on the z axis
  14120. */
  14121. static BILLBOARDMODE_Z: number;
  14122. /**
  14123. * Object will rotate to face the camera
  14124. */
  14125. static BILLBOARDMODE_ALL: number;
  14126. /**
  14127. * Object will rotate to face the camera's position instead of orientation
  14128. */
  14129. static BILLBOARDMODE_USE_POSITION: number;
  14130. private _forward;
  14131. private _forwardInverted;
  14132. private _up;
  14133. private _right;
  14134. private _rightInverted;
  14135. private _position;
  14136. private _rotation;
  14137. private _rotationQuaternion;
  14138. protected _scaling: Vector3;
  14139. protected _isDirty: boolean;
  14140. private _transformToBoneReferal;
  14141. private _isAbsoluteSynced;
  14142. private _billboardMode;
  14143. /**
  14144. * Gets or sets the billboard mode. Default is 0.
  14145. *
  14146. * | Value | Type | Description |
  14147. * | --- | --- | --- |
  14148. * | 0 | BILLBOARDMODE_NONE | |
  14149. * | 1 | BILLBOARDMODE_X | |
  14150. * | 2 | BILLBOARDMODE_Y | |
  14151. * | 4 | BILLBOARDMODE_Z | |
  14152. * | 7 | BILLBOARDMODE_ALL | |
  14153. *
  14154. */
  14155. billboardMode: number;
  14156. private _preserveParentRotationForBillboard;
  14157. /**
  14158. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14159. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14160. */
  14161. preserveParentRotationForBillboard: boolean;
  14162. /**
  14163. * 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
  14164. */
  14165. scalingDeterminant: number;
  14166. private _infiniteDistance;
  14167. /**
  14168. * Gets or sets the distance of the object to max, often used by skybox
  14169. */
  14170. infiniteDistance: boolean;
  14171. /**
  14172. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14173. * By default the system will update normals to compensate
  14174. */
  14175. ignoreNonUniformScaling: boolean;
  14176. /**
  14177. * 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
  14178. */
  14179. reIntegrateRotationIntoRotationQuaternion: boolean;
  14180. /** @hidden */
  14181. _poseMatrix: Nullable<Matrix>;
  14182. /** @hidden */
  14183. _localMatrix: Matrix;
  14184. private _usePivotMatrix;
  14185. private _absolutePosition;
  14186. private _absoluteScaling;
  14187. private _absoluteRotationQuaternion;
  14188. private _pivotMatrix;
  14189. private _pivotMatrixInverse;
  14190. protected _postMultiplyPivotMatrix: boolean;
  14191. protected _isWorldMatrixFrozen: boolean;
  14192. /** @hidden */
  14193. _indexInSceneTransformNodesArray: number;
  14194. /**
  14195. * An event triggered after the world matrix is updated
  14196. */
  14197. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14198. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14199. /**
  14200. * Gets a string identifying the name of the class
  14201. * @returns "TransformNode" string
  14202. */
  14203. getClassName(): string;
  14204. /**
  14205. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14206. */
  14207. position: Vector3;
  14208. /**
  14209. * 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)).
  14210. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14211. */
  14212. rotation: Vector3;
  14213. /**
  14214. * 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)).
  14215. */
  14216. scaling: Vector3;
  14217. /**
  14218. * 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).
  14219. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14220. */
  14221. rotationQuaternion: Nullable<Quaternion>;
  14222. /**
  14223. * The forward direction of that transform in world space.
  14224. */
  14225. readonly forward: Vector3;
  14226. /**
  14227. * The up direction of that transform in world space.
  14228. */
  14229. readonly up: Vector3;
  14230. /**
  14231. * The right direction of that transform in world space.
  14232. */
  14233. readonly right: Vector3;
  14234. /**
  14235. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14236. * @param matrix the matrix to copy the pose from
  14237. * @returns this TransformNode.
  14238. */
  14239. updatePoseMatrix(matrix: Matrix): TransformNode;
  14240. /**
  14241. * Returns the mesh Pose matrix.
  14242. * @returns the pose matrix
  14243. */
  14244. getPoseMatrix(): Matrix;
  14245. /** @hidden */
  14246. _isSynchronized(): boolean;
  14247. /** @hidden */
  14248. _initCache(): void;
  14249. /**
  14250. * Flag the transform node as dirty (Forcing it to update everything)
  14251. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14252. * @returns this transform node
  14253. */
  14254. markAsDirty(property: string): TransformNode;
  14255. /**
  14256. * Returns the current mesh absolute position.
  14257. * Returns a Vector3.
  14258. */
  14259. readonly absolutePosition: Vector3;
  14260. /**
  14261. * Returns the current mesh absolute scaling.
  14262. * Returns a Vector3.
  14263. */
  14264. readonly absoluteScaling: Vector3;
  14265. /**
  14266. * Returns the current mesh absolute rotation.
  14267. * Returns a Quaternion.
  14268. */
  14269. readonly absoluteRotationQuaternion: Quaternion;
  14270. /**
  14271. * Sets a new matrix to apply before all other transformation
  14272. * @param matrix defines the transform matrix
  14273. * @returns the current TransformNode
  14274. */
  14275. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14276. /**
  14277. * Sets a new pivot matrix to the current node
  14278. * @param matrix defines the new pivot matrix to use
  14279. * @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
  14280. * @returns the current TransformNode
  14281. */
  14282. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14283. /**
  14284. * Returns the mesh pivot matrix.
  14285. * Default : Identity.
  14286. * @returns the matrix
  14287. */
  14288. getPivotMatrix(): Matrix;
  14289. /**
  14290. * Instantiate (when possible) or clone that node with its hierarchy
  14291. * @param newParent defines the new parent to use for the instance (or clone)
  14292. * @param options defines options to configure how copy is done
  14293. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14294. * @returns an instance (or a clone) of the current node with its hiearchy
  14295. */
  14296. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14297. doNotInstantiate: boolean;
  14298. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14299. /**
  14300. * Prevents the World matrix to be computed any longer
  14301. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14302. * @returns the TransformNode.
  14303. */
  14304. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14305. /**
  14306. * Allows back the World matrix computation.
  14307. * @returns the TransformNode.
  14308. */
  14309. unfreezeWorldMatrix(): this;
  14310. /**
  14311. * True if the World matrix has been frozen.
  14312. */
  14313. readonly isWorldMatrixFrozen: boolean;
  14314. /**
  14315. * Retuns the mesh absolute position in the World.
  14316. * @returns a Vector3.
  14317. */
  14318. getAbsolutePosition(): Vector3;
  14319. /**
  14320. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14321. * @param absolutePosition the absolute position to set
  14322. * @returns the TransformNode.
  14323. */
  14324. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14325. /**
  14326. * Sets the mesh position in its local space.
  14327. * @param vector3 the position to set in localspace
  14328. * @returns the TransformNode.
  14329. */
  14330. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14331. /**
  14332. * Returns the mesh position in the local space from the current World matrix values.
  14333. * @returns a new Vector3.
  14334. */
  14335. getPositionExpressedInLocalSpace(): Vector3;
  14336. /**
  14337. * Translates the mesh along the passed Vector3 in its local space.
  14338. * @param vector3 the distance to translate in localspace
  14339. * @returns the TransformNode.
  14340. */
  14341. locallyTranslate(vector3: Vector3): TransformNode;
  14342. private static _lookAtVectorCache;
  14343. /**
  14344. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14345. * @param targetPoint the position (must be in same space as current mesh) to look at
  14346. * @param yawCor optional yaw (y-axis) correction in radians
  14347. * @param pitchCor optional pitch (x-axis) correction in radians
  14348. * @param rollCor optional roll (z-axis) correction in radians
  14349. * @param space the choosen space of the target
  14350. * @returns the TransformNode.
  14351. */
  14352. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14353. /**
  14354. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14355. * This Vector3 is expressed in the World space.
  14356. * @param localAxis axis to rotate
  14357. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14358. */
  14359. getDirection(localAxis: Vector3): Vector3;
  14360. /**
  14361. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14362. * localAxis is expressed in the mesh local space.
  14363. * result is computed in the Wordl space from the mesh World matrix.
  14364. * @param localAxis axis to rotate
  14365. * @param result the resulting transformnode
  14366. * @returns this TransformNode.
  14367. */
  14368. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14369. /**
  14370. * Sets this transform node rotation to the given local axis.
  14371. * @param localAxis the axis in local space
  14372. * @param yawCor optional yaw (y-axis) correction in radians
  14373. * @param pitchCor optional pitch (x-axis) correction in radians
  14374. * @param rollCor optional roll (z-axis) correction in radians
  14375. * @returns this TransformNode
  14376. */
  14377. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14378. /**
  14379. * Sets a new pivot point to the current node
  14380. * @param point defines the new pivot point to use
  14381. * @param space defines if the point is in world or local space (local by default)
  14382. * @returns the current TransformNode
  14383. */
  14384. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14385. /**
  14386. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14387. * @returns the pivot point
  14388. */
  14389. getPivotPoint(): Vector3;
  14390. /**
  14391. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14392. * @param result the vector3 to store the result
  14393. * @returns this TransformNode.
  14394. */
  14395. getPivotPointToRef(result: Vector3): TransformNode;
  14396. /**
  14397. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14398. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14399. */
  14400. getAbsolutePivotPoint(): Vector3;
  14401. /**
  14402. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14403. * @param result vector3 to store the result
  14404. * @returns this TransformNode.
  14405. */
  14406. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14407. /**
  14408. * Defines the passed node as the parent of the current node.
  14409. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14410. * @see https://doc.babylonjs.com/how_to/parenting
  14411. * @param node the node ot set as the parent
  14412. * @returns this TransformNode.
  14413. */
  14414. setParent(node: Nullable<Node>): TransformNode;
  14415. private _nonUniformScaling;
  14416. /**
  14417. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14418. */
  14419. readonly nonUniformScaling: boolean;
  14420. /** @hidden */
  14421. _updateNonUniformScalingState(value: boolean): boolean;
  14422. /**
  14423. * Attach the current TransformNode to another TransformNode associated with a bone
  14424. * @param bone Bone affecting the TransformNode
  14425. * @param affectedTransformNode TransformNode associated with the bone
  14426. * @returns this object
  14427. */
  14428. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14429. /**
  14430. * Detach the transform node if its associated with a bone
  14431. * @returns this object
  14432. */
  14433. detachFromBone(): TransformNode;
  14434. private static _rotationAxisCache;
  14435. /**
  14436. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14437. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14438. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14439. * The passed axis is also normalized.
  14440. * @param axis the axis to rotate around
  14441. * @param amount the amount to rotate in radians
  14442. * @param space Space to rotate in (Default: local)
  14443. * @returns the TransformNode.
  14444. */
  14445. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14446. /**
  14447. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14448. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14449. * The passed axis is also normalized. .
  14450. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14451. * @param point the point to rotate around
  14452. * @param axis the axis to rotate around
  14453. * @param amount the amount to rotate in radians
  14454. * @returns the TransformNode
  14455. */
  14456. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14457. /**
  14458. * Translates the mesh along the axis vector for the passed distance in the given space.
  14459. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14460. * @param axis the axis to translate in
  14461. * @param distance the distance to translate
  14462. * @param space Space to rotate in (Default: local)
  14463. * @returns the TransformNode.
  14464. */
  14465. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14466. /**
  14467. * Adds a rotation step to the mesh current rotation.
  14468. * x, y, z are Euler angles expressed in radians.
  14469. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14470. * This means this rotation is made in the mesh local space only.
  14471. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14472. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14473. * ```javascript
  14474. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14475. * ```
  14476. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14477. * 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.
  14478. * @param x Rotation to add
  14479. * @param y Rotation to add
  14480. * @param z Rotation to add
  14481. * @returns the TransformNode.
  14482. */
  14483. addRotation(x: number, y: number, z: number): TransformNode;
  14484. /**
  14485. * @hidden
  14486. */
  14487. protected _getEffectiveParent(): Nullable<Node>;
  14488. /**
  14489. * Computes the world matrix of the node
  14490. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14491. * @returns the world matrix
  14492. */
  14493. computeWorldMatrix(force?: boolean): Matrix;
  14494. protected _afterComputeWorldMatrix(): void;
  14495. /**
  14496. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14497. * @param func callback function to add
  14498. *
  14499. * @returns the TransformNode.
  14500. */
  14501. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14502. /**
  14503. * Removes a registered callback function.
  14504. * @param func callback function to remove
  14505. * @returns the TransformNode.
  14506. */
  14507. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14508. /**
  14509. * Gets the position of the current mesh in camera space
  14510. * @param camera defines the camera to use
  14511. * @returns a position
  14512. */
  14513. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14514. /**
  14515. * Returns the distance from the mesh to the active camera
  14516. * @param camera defines the camera to use
  14517. * @returns the distance
  14518. */
  14519. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14520. /**
  14521. * Clone the current transform node
  14522. * @param name Name of the new clone
  14523. * @param newParent New parent for the clone
  14524. * @param doNotCloneChildren Do not clone children hierarchy
  14525. * @returns the new transform node
  14526. */
  14527. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14528. /**
  14529. * Serializes the objects information.
  14530. * @param currentSerializationObject defines the object to serialize in
  14531. * @returns the serialized object
  14532. */
  14533. serialize(currentSerializationObject?: any): any;
  14534. /**
  14535. * Returns a new TransformNode object parsed from the source provided.
  14536. * @param parsedTransformNode is the source.
  14537. * @param scene the scne the object belongs to
  14538. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14539. * @returns a new TransformNode object parsed from the source provided.
  14540. */
  14541. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14542. /**
  14543. * Get all child-transformNodes of this node
  14544. * @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
  14545. * @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
  14546. * @returns an array of TransformNode
  14547. */
  14548. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14549. /**
  14550. * Releases resources associated with this transform node.
  14551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14553. */
  14554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14555. /**
  14556. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14557. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14558. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14559. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14560. * @returns the current mesh
  14561. */
  14562. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14563. private _syncAbsoluteScalingAndRotation;
  14564. }
  14565. }
  14566. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14567. import { Observable } from "babylonjs/Misc/observable";
  14568. import { Nullable } from "babylonjs/types";
  14569. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14572. import { Ray } from "babylonjs/Culling/ray";
  14573. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14574. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14575. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14576. /**
  14577. * Defines the types of pose enabled controllers that are supported
  14578. */
  14579. export enum PoseEnabledControllerType {
  14580. /**
  14581. * HTC Vive
  14582. */
  14583. VIVE = 0,
  14584. /**
  14585. * Oculus Rift
  14586. */
  14587. OCULUS = 1,
  14588. /**
  14589. * Windows mixed reality
  14590. */
  14591. WINDOWS = 2,
  14592. /**
  14593. * Samsung gear VR
  14594. */
  14595. GEAR_VR = 3,
  14596. /**
  14597. * Google Daydream
  14598. */
  14599. DAYDREAM = 4,
  14600. /**
  14601. * Generic
  14602. */
  14603. GENERIC = 5
  14604. }
  14605. /**
  14606. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14607. */
  14608. export interface MutableGamepadButton {
  14609. /**
  14610. * Value of the button/trigger
  14611. */
  14612. value: number;
  14613. /**
  14614. * If the button/trigger is currently touched
  14615. */
  14616. touched: boolean;
  14617. /**
  14618. * If the button/trigger is currently pressed
  14619. */
  14620. pressed: boolean;
  14621. }
  14622. /**
  14623. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14624. * @hidden
  14625. */
  14626. export interface ExtendedGamepadButton extends GamepadButton {
  14627. /**
  14628. * If the button/trigger is currently pressed
  14629. */
  14630. readonly pressed: boolean;
  14631. /**
  14632. * If the button/trigger is currently touched
  14633. */
  14634. readonly touched: boolean;
  14635. /**
  14636. * Value of the button/trigger
  14637. */
  14638. readonly value: number;
  14639. }
  14640. /** @hidden */
  14641. export interface _GamePadFactory {
  14642. /**
  14643. * Returns wether or not the current gamepad can be created for this type of controller.
  14644. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14645. * @returns true if it can be created, otherwise false
  14646. */
  14647. canCreate(gamepadInfo: any): boolean;
  14648. /**
  14649. * Creates a new instance of the Gamepad.
  14650. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14651. * @returns the new gamepad instance
  14652. */
  14653. create(gamepadInfo: any): Gamepad;
  14654. }
  14655. /**
  14656. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14657. */
  14658. export class PoseEnabledControllerHelper {
  14659. /** @hidden */
  14660. static _ControllerFactories: _GamePadFactory[];
  14661. /** @hidden */
  14662. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14663. /**
  14664. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14665. * @param vrGamepad the gamepad to initialized
  14666. * @returns a vr controller of the type the gamepad identified as
  14667. */
  14668. static InitiateController(vrGamepad: any): Gamepad;
  14669. }
  14670. /**
  14671. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14672. */
  14673. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14674. /**
  14675. * If the controller is used in a webXR session
  14676. */
  14677. isXR: boolean;
  14678. private _deviceRoomPosition;
  14679. private _deviceRoomRotationQuaternion;
  14680. /**
  14681. * The device position in babylon space
  14682. */
  14683. devicePosition: Vector3;
  14684. /**
  14685. * The device rotation in babylon space
  14686. */
  14687. deviceRotationQuaternion: Quaternion;
  14688. /**
  14689. * The scale factor of the device in babylon space
  14690. */
  14691. deviceScaleFactor: number;
  14692. /**
  14693. * (Likely devicePosition should be used instead) The device position in its room space
  14694. */
  14695. position: Vector3;
  14696. /**
  14697. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14698. */
  14699. rotationQuaternion: Quaternion;
  14700. /**
  14701. * The type of controller (Eg. Windows mixed reality)
  14702. */
  14703. controllerType: PoseEnabledControllerType;
  14704. protected _calculatedPosition: Vector3;
  14705. private _calculatedRotation;
  14706. /**
  14707. * The raw pose from the device
  14708. */
  14709. rawPose: DevicePose;
  14710. private _trackPosition;
  14711. private _maxRotationDistFromHeadset;
  14712. private _draggedRoomRotation;
  14713. /**
  14714. * @hidden
  14715. */
  14716. _disableTrackPosition(fixedPosition: Vector3): void;
  14717. /**
  14718. * Internal, the mesh attached to the controller
  14719. * @hidden
  14720. */
  14721. _mesh: Nullable<AbstractMesh>;
  14722. private _poseControlledCamera;
  14723. private _leftHandSystemQuaternion;
  14724. /**
  14725. * Internal, matrix used to convert room space to babylon space
  14726. * @hidden
  14727. */
  14728. _deviceToWorld: Matrix;
  14729. /**
  14730. * Node to be used when casting a ray from the controller
  14731. * @hidden
  14732. */
  14733. _pointingPoseNode: Nullable<TransformNode>;
  14734. /**
  14735. * Name of the child mesh that can be used to cast a ray from the controller
  14736. */
  14737. static readonly POINTING_POSE: string;
  14738. /**
  14739. * Creates a new PoseEnabledController from a gamepad
  14740. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14741. */
  14742. constructor(browserGamepad: any);
  14743. private _workingMatrix;
  14744. /**
  14745. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14746. */
  14747. update(): void;
  14748. /**
  14749. * Updates only the pose device and mesh without doing any button event checking
  14750. */
  14751. protected _updatePoseAndMesh(): void;
  14752. /**
  14753. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14754. * @param poseData raw pose fromthe device
  14755. */
  14756. updateFromDevice(poseData: DevicePose): void;
  14757. /**
  14758. * @hidden
  14759. */
  14760. _meshAttachedObservable: Observable<AbstractMesh>;
  14761. /**
  14762. * Attaches a mesh to the controller
  14763. * @param mesh the mesh to be attached
  14764. */
  14765. attachToMesh(mesh: AbstractMesh): void;
  14766. /**
  14767. * Attaches the controllers mesh to a camera
  14768. * @param camera the camera the mesh should be attached to
  14769. */
  14770. attachToPoseControlledCamera(camera: TargetCamera): void;
  14771. /**
  14772. * Disposes of the controller
  14773. */
  14774. dispose(): void;
  14775. /**
  14776. * The mesh that is attached to the controller
  14777. */
  14778. readonly mesh: Nullable<AbstractMesh>;
  14779. /**
  14780. * Gets the ray of the controller in the direction the controller is pointing
  14781. * @param length the length the resulting ray should be
  14782. * @returns a ray in the direction the controller is pointing
  14783. */
  14784. getForwardRay(length?: number): Ray;
  14785. }
  14786. }
  14787. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14788. import { Observable } from "babylonjs/Misc/observable";
  14789. import { Scene } from "babylonjs/scene";
  14790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14791. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14792. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14793. import { Nullable } from "babylonjs/types";
  14794. /**
  14795. * Defines the WebVRController object that represents controllers tracked in 3D space
  14796. */
  14797. export abstract class WebVRController extends PoseEnabledController {
  14798. /**
  14799. * Internal, the default controller model for the controller
  14800. */
  14801. protected _defaultModel: Nullable<AbstractMesh>;
  14802. /**
  14803. * Fired when the trigger state has changed
  14804. */
  14805. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14806. /**
  14807. * Fired when the main button state has changed
  14808. */
  14809. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14810. /**
  14811. * Fired when the secondary button state has changed
  14812. */
  14813. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14814. /**
  14815. * Fired when the pad state has changed
  14816. */
  14817. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14818. /**
  14819. * Fired when controllers stick values have changed
  14820. */
  14821. onPadValuesChangedObservable: Observable<StickValues>;
  14822. /**
  14823. * Array of button availible on the controller
  14824. */
  14825. protected _buttons: Array<MutableGamepadButton>;
  14826. private _onButtonStateChange;
  14827. /**
  14828. * Fired when a controller button's state has changed
  14829. * @param callback the callback containing the button that was modified
  14830. */
  14831. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14832. /**
  14833. * X and Y axis corresponding to the controllers joystick
  14834. */
  14835. pad: StickValues;
  14836. /**
  14837. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14838. */
  14839. hand: string;
  14840. /**
  14841. * The default controller model for the controller
  14842. */
  14843. readonly defaultModel: Nullable<AbstractMesh>;
  14844. /**
  14845. * Creates a new WebVRController from a gamepad
  14846. * @param vrGamepad the gamepad that the WebVRController should be created from
  14847. */
  14848. constructor(vrGamepad: any);
  14849. /**
  14850. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14851. */
  14852. update(): void;
  14853. /**
  14854. * Function to be called when a button is modified
  14855. */
  14856. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14857. /**
  14858. * Loads a mesh and attaches it to the controller
  14859. * @param scene the scene the mesh should be added to
  14860. * @param meshLoaded callback for when the mesh has been loaded
  14861. */
  14862. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14863. private _setButtonValue;
  14864. private _changes;
  14865. private _checkChanges;
  14866. /**
  14867. * Disposes of th webVRCOntroller
  14868. */
  14869. dispose(): void;
  14870. }
  14871. }
  14872. declare module "babylonjs/Lights/hemisphericLight" {
  14873. import { Nullable } from "babylonjs/types";
  14874. import { Scene } from "babylonjs/scene";
  14875. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14876. import { Color3 } from "babylonjs/Maths/math.color";
  14877. import { Effect } from "babylonjs/Materials/effect";
  14878. import { Light } from "babylonjs/Lights/light";
  14879. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14880. /**
  14881. * The HemisphericLight simulates the ambient environment light,
  14882. * so the passed direction is the light reflection direction, not the incoming direction.
  14883. */
  14884. export class HemisphericLight extends Light {
  14885. /**
  14886. * The groundColor is the light in the opposite direction to the one specified during creation.
  14887. * 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.
  14888. */
  14889. groundColor: Color3;
  14890. /**
  14891. * The light reflection direction, not the incoming direction.
  14892. */
  14893. direction: Vector3;
  14894. /**
  14895. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14896. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14897. * The HemisphericLight can't cast shadows.
  14898. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14899. * @param name The friendly name of the light
  14900. * @param direction The direction of the light reflection
  14901. * @param scene The scene the light belongs to
  14902. */
  14903. constructor(name: string, direction: Vector3, scene: Scene);
  14904. protected _buildUniformLayout(): void;
  14905. /**
  14906. * Returns the string "HemisphericLight".
  14907. * @return The class name
  14908. */
  14909. getClassName(): string;
  14910. /**
  14911. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14912. * Returns the updated direction.
  14913. * @param target The target the direction should point to
  14914. * @return The computed direction
  14915. */
  14916. setDirectionToTarget(target: Vector3): Vector3;
  14917. /**
  14918. * Returns the shadow generator associated to the light.
  14919. * @returns Always null for hemispheric lights because it does not support shadows.
  14920. */
  14921. getShadowGenerator(): Nullable<IShadowGenerator>;
  14922. /**
  14923. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14924. * @param effect The effect to update
  14925. * @param lightIndex The index of the light in the effect to update
  14926. * @returns The hemispheric light
  14927. */
  14928. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14929. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14930. /**
  14931. * Computes the world matrix of the node
  14932. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14933. * @param useWasUpdatedFlag defines a reserved property
  14934. * @returns the world matrix
  14935. */
  14936. computeWorldMatrix(): Matrix;
  14937. /**
  14938. * Returns the integer 3.
  14939. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14940. */
  14941. getTypeID(): number;
  14942. /**
  14943. * Prepares the list of defines specific to the light type.
  14944. * @param defines the list of defines
  14945. * @param lightIndex defines the index of the light for the effect
  14946. */
  14947. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14948. }
  14949. }
  14950. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14951. /** @hidden */
  14952. export var vrMultiviewToSingleviewPixelShader: {
  14953. name: string;
  14954. shader: string;
  14955. };
  14956. }
  14957. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14958. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14959. import { Scene } from "babylonjs/scene";
  14960. /**
  14961. * Renders to multiple views with a single draw call
  14962. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14963. */
  14964. export class MultiviewRenderTarget extends RenderTargetTexture {
  14965. /**
  14966. * Creates a multiview render target
  14967. * @param scene scene used with the render target
  14968. * @param size the size of the render target (used for each view)
  14969. */
  14970. constructor(scene: Scene, size?: number | {
  14971. width: number;
  14972. height: number;
  14973. } | {
  14974. ratio: number;
  14975. });
  14976. /**
  14977. * @hidden
  14978. * @param faceIndex the face index, if its a cube texture
  14979. */
  14980. _bindFrameBuffer(faceIndex?: number): void;
  14981. /**
  14982. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14983. * @returns the view count
  14984. */
  14985. getViewCount(): number;
  14986. }
  14987. }
  14988. declare module "babylonjs/Maths/math.frustum" {
  14989. import { Matrix } from "babylonjs/Maths/math.vector";
  14990. import { DeepImmutable } from "babylonjs/types";
  14991. import { Plane } from "babylonjs/Maths/math.plane";
  14992. /**
  14993. * Represents a camera frustum
  14994. */
  14995. export class Frustum {
  14996. /**
  14997. * Gets the planes representing the frustum
  14998. * @param transform matrix to be applied to the returned planes
  14999. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15000. */
  15001. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15002. /**
  15003. * Gets the near frustum plane transformed by the transform matrix
  15004. * @param transform transformation matrix to be applied to the resulting frustum plane
  15005. * @param frustumPlane the resuling frustum plane
  15006. */
  15007. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15008. /**
  15009. * Gets the far frustum plane transformed by the transform matrix
  15010. * @param transform transformation matrix to be applied to the resulting frustum plane
  15011. * @param frustumPlane the resuling frustum plane
  15012. */
  15013. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15014. /**
  15015. * Gets the left frustum plane transformed by the transform matrix
  15016. * @param transform transformation matrix to be applied to the resulting frustum plane
  15017. * @param frustumPlane the resuling frustum plane
  15018. */
  15019. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15020. /**
  15021. * Gets the right frustum plane transformed by the transform matrix
  15022. * @param transform transformation matrix to be applied to the resulting frustum plane
  15023. * @param frustumPlane the resuling frustum plane
  15024. */
  15025. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15026. /**
  15027. * Gets the top frustum plane transformed by the transform matrix
  15028. * @param transform transformation matrix to be applied to the resulting frustum plane
  15029. * @param frustumPlane the resuling frustum plane
  15030. */
  15031. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15032. /**
  15033. * Gets the bottom frustum plane transformed by the transform matrix
  15034. * @param transform transformation matrix to be applied to the resulting frustum plane
  15035. * @param frustumPlane the resuling frustum plane
  15036. */
  15037. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15038. /**
  15039. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15040. * @param transform transformation matrix to be applied to the resulting frustum planes
  15041. * @param frustumPlanes the resuling frustum planes
  15042. */
  15043. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15044. }
  15045. }
  15046. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15047. import { Camera } from "babylonjs/Cameras/camera";
  15048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15049. import { Nullable } from "babylonjs/types";
  15050. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15051. import { Matrix } from "babylonjs/Maths/math.vector";
  15052. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15053. module "babylonjs/Engines/engine" {
  15054. interface Engine {
  15055. /**
  15056. * Creates a new multiview render target
  15057. * @param width defines the width of the texture
  15058. * @param height defines the height of the texture
  15059. * @returns the created multiview texture
  15060. */
  15061. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15062. /**
  15063. * Binds a multiview framebuffer to be drawn to
  15064. * @param multiviewTexture texture to bind
  15065. */
  15066. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15067. }
  15068. }
  15069. module "babylonjs/Cameras/camera" {
  15070. interface Camera {
  15071. /**
  15072. * @hidden
  15073. * 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)
  15074. */
  15075. _useMultiviewToSingleView: boolean;
  15076. /**
  15077. * @hidden
  15078. * 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)
  15079. */
  15080. _multiviewTexture: Nullable<RenderTargetTexture>;
  15081. /**
  15082. * @hidden
  15083. * ensures the multiview texture of the camera exists and has the specified width/height
  15084. * @param width height to set on the multiview texture
  15085. * @param height width to set on the multiview texture
  15086. */
  15087. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15088. }
  15089. }
  15090. module "babylonjs/scene" {
  15091. interface Scene {
  15092. /** @hidden */
  15093. _transformMatrixR: Matrix;
  15094. /** @hidden */
  15095. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15096. /** @hidden */
  15097. _createMultiviewUbo(): void;
  15098. /** @hidden */
  15099. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15100. /** @hidden */
  15101. _renderMultiviewToSingleView(camera: Camera): void;
  15102. }
  15103. }
  15104. }
  15105. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15106. import { Camera } from "babylonjs/Cameras/camera";
  15107. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15108. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15109. import "babylonjs/Engines/Extensions/engine.multiview";
  15110. /**
  15111. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15112. * This will not be used for webXR as it supports displaying texture arrays directly
  15113. */
  15114. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15115. /**
  15116. * Initializes a VRMultiviewToSingleview
  15117. * @param name name of the post process
  15118. * @param camera camera to be applied to
  15119. * @param scaleFactor scaling factor to the size of the output texture
  15120. */
  15121. constructor(name: string, camera: Camera, scaleFactor: number);
  15122. }
  15123. }
  15124. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15125. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15126. import { Nullable } from "babylonjs/types";
  15127. import { Size } from "babylonjs/Maths/math.size";
  15128. import { Observable } from "babylonjs/Misc/observable";
  15129. module "babylonjs/Engines/engine" {
  15130. interface Engine {
  15131. /** @hidden */
  15132. _vrDisplay: any;
  15133. /** @hidden */
  15134. _vrSupported: boolean;
  15135. /** @hidden */
  15136. _oldSize: Size;
  15137. /** @hidden */
  15138. _oldHardwareScaleFactor: number;
  15139. /** @hidden */
  15140. _vrExclusivePointerMode: boolean;
  15141. /** @hidden */
  15142. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15143. /** @hidden */
  15144. _onVRDisplayPointerRestricted: () => void;
  15145. /** @hidden */
  15146. _onVRDisplayPointerUnrestricted: () => void;
  15147. /** @hidden */
  15148. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15149. /** @hidden */
  15150. _onVrDisplayDisconnect: Nullable<() => void>;
  15151. /** @hidden */
  15152. _onVrDisplayPresentChange: Nullable<() => void>;
  15153. /**
  15154. * Observable signaled when VR display mode changes
  15155. */
  15156. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15157. /**
  15158. * Observable signaled when VR request present is complete
  15159. */
  15160. onVRRequestPresentComplete: Observable<boolean>;
  15161. /**
  15162. * Observable signaled when VR request present starts
  15163. */
  15164. onVRRequestPresentStart: Observable<Engine>;
  15165. /**
  15166. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15167. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15168. */
  15169. isInVRExclusivePointerMode: boolean;
  15170. /**
  15171. * Gets a boolean indicating if a webVR device was detected
  15172. * @returns true if a webVR device was detected
  15173. */
  15174. isVRDevicePresent(): boolean;
  15175. /**
  15176. * Gets the current webVR device
  15177. * @returns the current webVR device (or null)
  15178. */
  15179. getVRDevice(): any;
  15180. /**
  15181. * Initializes a webVR display and starts listening to display change events
  15182. * The onVRDisplayChangedObservable will be notified upon these changes
  15183. * @returns A promise containing a VRDisplay and if vr is supported
  15184. */
  15185. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15186. /** @hidden */
  15187. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15188. /**
  15189. * Call this function to switch to webVR mode
  15190. * Will do nothing if webVR is not supported or if there is no webVR device
  15191. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15192. */
  15193. enableVR(): void;
  15194. /** @hidden */
  15195. _onVRFullScreenTriggered(): void;
  15196. }
  15197. }
  15198. }
  15199. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15200. import { Nullable } from "babylonjs/types";
  15201. import { Observable } from "babylonjs/Misc/observable";
  15202. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15203. import { Scene } from "babylonjs/scene";
  15204. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15205. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15206. import { Node } from "babylonjs/node";
  15207. import { Ray } from "babylonjs/Culling/ray";
  15208. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15209. import "babylonjs/Engines/Extensions/engine.webVR";
  15210. /**
  15211. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15212. * IMPORTANT!! The data is right-hand data.
  15213. * @export
  15214. * @interface DevicePose
  15215. */
  15216. export interface DevicePose {
  15217. /**
  15218. * The position of the device, values in array are [x,y,z].
  15219. */
  15220. readonly position: Nullable<Float32Array>;
  15221. /**
  15222. * The linearVelocity of the device, values in array are [x,y,z].
  15223. */
  15224. readonly linearVelocity: Nullable<Float32Array>;
  15225. /**
  15226. * The linearAcceleration of the device, values in array are [x,y,z].
  15227. */
  15228. readonly linearAcceleration: Nullable<Float32Array>;
  15229. /**
  15230. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15231. */
  15232. readonly orientation: Nullable<Float32Array>;
  15233. /**
  15234. * The angularVelocity of the device, values in array are [x,y,z].
  15235. */
  15236. readonly angularVelocity: Nullable<Float32Array>;
  15237. /**
  15238. * The angularAcceleration of the device, values in array are [x,y,z].
  15239. */
  15240. readonly angularAcceleration: Nullable<Float32Array>;
  15241. }
  15242. /**
  15243. * Interface representing a pose controlled object in Babylon.
  15244. * A pose controlled object has both regular pose values as well as pose values
  15245. * from an external device such as a VR head mounted display
  15246. */
  15247. export interface PoseControlled {
  15248. /**
  15249. * The position of the object in babylon space.
  15250. */
  15251. position: Vector3;
  15252. /**
  15253. * The rotation quaternion of the object in babylon space.
  15254. */
  15255. rotationQuaternion: Quaternion;
  15256. /**
  15257. * The position of the device in babylon space.
  15258. */
  15259. devicePosition?: Vector3;
  15260. /**
  15261. * The rotation quaternion of the device in babylon space.
  15262. */
  15263. deviceRotationQuaternion: Quaternion;
  15264. /**
  15265. * The raw pose coming from the device.
  15266. */
  15267. rawPose: Nullable<DevicePose>;
  15268. /**
  15269. * The scale of the device to be used when translating from device space to babylon space.
  15270. */
  15271. deviceScaleFactor: number;
  15272. /**
  15273. * Updates the poseControlled values based on the input device pose.
  15274. * @param poseData the pose data to update the object with
  15275. */
  15276. updateFromDevice(poseData: DevicePose): void;
  15277. }
  15278. /**
  15279. * Set of options to customize the webVRCamera
  15280. */
  15281. export interface WebVROptions {
  15282. /**
  15283. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15284. */
  15285. trackPosition?: boolean;
  15286. /**
  15287. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15288. */
  15289. positionScale?: number;
  15290. /**
  15291. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15292. */
  15293. displayName?: string;
  15294. /**
  15295. * Should the native controller meshes be initialized. (default: true)
  15296. */
  15297. controllerMeshes?: boolean;
  15298. /**
  15299. * Creating a default HemiLight only on controllers. (default: true)
  15300. */
  15301. defaultLightingOnControllers?: boolean;
  15302. /**
  15303. * If you don't want to use the default VR button of the helper. (default: false)
  15304. */
  15305. useCustomVRButton?: boolean;
  15306. /**
  15307. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15308. */
  15309. customVRButton?: HTMLButtonElement;
  15310. /**
  15311. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15312. */
  15313. rayLength?: number;
  15314. /**
  15315. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15316. */
  15317. defaultHeight?: number;
  15318. /**
  15319. * If multiview should be used if availible (default: false)
  15320. */
  15321. useMultiview?: boolean;
  15322. }
  15323. /**
  15324. * This represents a WebVR camera.
  15325. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15326. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15327. */
  15328. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15329. private webVROptions;
  15330. /**
  15331. * @hidden
  15332. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15333. */
  15334. _vrDevice: any;
  15335. /**
  15336. * The rawPose of the vrDevice.
  15337. */
  15338. rawPose: Nullable<DevicePose>;
  15339. private _onVREnabled;
  15340. private _specsVersion;
  15341. private _attached;
  15342. private _frameData;
  15343. protected _descendants: Array<Node>;
  15344. private _deviceRoomPosition;
  15345. /** @hidden */
  15346. _deviceRoomRotationQuaternion: Quaternion;
  15347. private _standingMatrix;
  15348. /**
  15349. * Represents device position in babylon space.
  15350. */
  15351. devicePosition: Vector3;
  15352. /**
  15353. * Represents device rotation in babylon space.
  15354. */
  15355. deviceRotationQuaternion: Quaternion;
  15356. /**
  15357. * The scale of the device to be used when translating from device space to babylon space.
  15358. */
  15359. deviceScaleFactor: number;
  15360. private _deviceToWorld;
  15361. private _worldToDevice;
  15362. /**
  15363. * References to the webVR controllers for the vrDevice.
  15364. */
  15365. controllers: Array<WebVRController>;
  15366. /**
  15367. * Emits an event when a controller is attached.
  15368. */
  15369. onControllersAttachedObservable: Observable<WebVRController[]>;
  15370. /**
  15371. * Emits an event when a controller's mesh has been loaded;
  15372. */
  15373. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15374. /**
  15375. * Emits an event when the HMD's pose has been updated.
  15376. */
  15377. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15378. private _poseSet;
  15379. /**
  15380. * If the rig cameras be used as parent instead of this camera.
  15381. */
  15382. rigParenting: boolean;
  15383. private _lightOnControllers;
  15384. private _defaultHeight?;
  15385. /**
  15386. * Instantiates a WebVRFreeCamera.
  15387. * @param name The name of the WebVRFreeCamera
  15388. * @param position The starting anchor position for the camera
  15389. * @param scene The scene the camera belongs to
  15390. * @param webVROptions a set of customizable options for the webVRCamera
  15391. */
  15392. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15393. /**
  15394. * Gets the device distance from the ground in meters.
  15395. * @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.
  15396. */
  15397. deviceDistanceToRoomGround(): number;
  15398. /**
  15399. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15400. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15401. */
  15402. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15403. /**
  15404. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15405. * @returns A promise with a boolean set to if the standing matrix is supported.
  15406. */
  15407. useStandingMatrixAsync(): Promise<boolean>;
  15408. /**
  15409. * Disposes the camera
  15410. */
  15411. dispose(): void;
  15412. /**
  15413. * Gets a vrController by name.
  15414. * @param name The name of the controller to retreive
  15415. * @returns the controller matching the name specified or null if not found
  15416. */
  15417. getControllerByName(name: string): Nullable<WebVRController>;
  15418. private _leftController;
  15419. /**
  15420. * The controller corresponding to the users left hand.
  15421. */
  15422. readonly leftController: Nullable<WebVRController>;
  15423. private _rightController;
  15424. /**
  15425. * The controller corresponding to the users right hand.
  15426. */
  15427. readonly rightController: Nullable<WebVRController>;
  15428. /**
  15429. * Casts a ray forward from the vrCamera's gaze.
  15430. * @param length Length of the ray (default: 100)
  15431. * @returns the ray corresponding to the gaze
  15432. */
  15433. getForwardRay(length?: number): Ray;
  15434. /**
  15435. * @hidden
  15436. * Updates the camera based on device's frame data
  15437. */
  15438. _checkInputs(): void;
  15439. /**
  15440. * Updates the poseControlled values based on the input device pose.
  15441. * @param poseData Pose coming from the device
  15442. */
  15443. updateFromDevice(poseData: DevicePose): void;
  15444. private _htmlElementAttached;
  15445. private _detachIfAttached;
  15446. /**
  15447. * WebVR's attach control will start broadcasting frames to the device.
  15448. * Note that in certain browsers (chrome for example) this function must be called
  15449. * within a user-interaction callback. Example:
  15450. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15451. *
  15452. * @param element html element to attach the vrDevice to
  15453. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15454. */
  15455. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15456. /**
  15457. * Detaches the camera from the html element and disables VR
  15458. *
  15459. * @param element html element to detach from
  15460. */
  15461. detachControl(element: HTMLElement): void;
  15462. /**
  15463. * @returns the name of this class
  15464. */
  15465. getClassName(): string;
  15466. /**
  15467. * Calls resetPose on the vrDisplay
  15468. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15469. */
  15470. resetToCurrentRotation(): void;
  15471. /**
  15472. * @hidden
  15473. * Updates the rig cameras (left and right eye)
  15474. */
  15475. _updateRigCameras(): void;
  15476. private _workingVector;
  15477. private _oneVector;
  15478. private _workingMatrix;
  15479. private updateCacheCalled;
  15480. private _correctPositionIfNotTrackPosition;
  15481. /**
  15482. * @hidden
  15483. * Updates the cached values of the camera
  15484. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15485. */
  15486. _updateCache(ignoreParentClass?: boolean): void;
  15487. /**
  15488. * @hidden
  15489. * Get current device position in babylon world
  15490. */
  15491. _computeDevicePosition(): void;
  15492. /**
  15493. * Updates the current device position and rotation in the babylon world
  15494. */
  15495. update(): void;
  15496. /**
  15497. * @hidden
  15498. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15499. * @returns an identity matrix
  15500. */
  15501. _getViewMatrix(): Matrix;
  15502. private _tmpMatrix;
  15503. /**
  15504. * This function is called by the two RIG cameras.
  15505. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15506. * @hidden
  15507. */
  15508. _getWebVRViewMatrix(): Matrix;
  15509. /** @hidden */
  15510. _getWebVRProjectionMatrix(): Matrix;
  15511. private _onGamepadConnectedObserver;
  15512. private _onGamepadDisconnectedObserver;
  15513. private _updateCacheWhenTrackingDisabledObserver;
  15514. /**
  15515. * Initializes the controllers and their meshes
  15516. */
  15517. initControllers(): void;
  15518. }
  15519. }
  15520. declare module "babylonjs/PostProcesses/postProcess" {
  15521. import { Nullable } from "babylonjs/types";
  15522. import { SmartArray } from "babylonjs/Misc/smartArray";
  15523. import { Observable } from "babylonjs/Misc/observable";
  15524. import { Vector2 } from "babylonjs/Maths/math.vector";
  15525. import { Camera } from "babylonjs/Cameras/camera";
  15526. import { Effect } from "babylonjs/Materials/effect";
  15527. import "babylonjs/Shaders/postprocess.vertex";
  15528. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15529. import { Engine } from "babylonjs/Engines/engine";
  15530. import { Color4 } from "babylonjs/Maths/math.color";
  15531. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15532. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15533. /**
  15534. * Size options for a post process
  15535. */
  15536. export type PostProcessOptions = {
  15537. width: number;
  15538. height: number;
  15539. };
  15540. /**
  15541. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15542. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15543. */
  15544. export class PostProcess {
  15545. /** Name of the PostProcess. */
  15546. name: string;
  15547. /**
  15548. * Gets or sets the unique id of the post process
  15549. */
  15550. uniqueId: number;
  15551. /**
  15552. * Width of the texture to apply the post process on
  15553. */
  15554. width: number;
  15555. /**
  15556. * Height of the texture to apply the post process on
  15557. */
  15558. height: number;
  15559. /**
  15560. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15561. * @hidden
  15562. */
  15563. _outputTexture: Nullable<InternalTexture>;
  15564. /**
  15565. * Sampling mode used by the shader
  15566. * See https://doc.babylonjs.com/classes/3.1/texture
  15567. */
  15568. renderTargetSamplingMode: number;
  15569. /**
  15570. * Clear color to use when screen clearing
  15571. */
  15572. clearColor: Color4;
  15573. /**
  15574. * If the buffer needs to be cleared before applying the post process. (default: true)
  15575. * Should be set to false if shader will overwrite all previous pixels.
  15576. */
  15577. autoClear: boolean;
  15578. /**
  15579. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15580. */
  15581. alphaMode: number;
  15582. /**
  15583. * Sets the setAlphaBlendConstants of the babylon engine
  15584. */
  15585. alphaConstants: Color4;
  15586. /**
  15587. * Animations to be used for the post processing
  15588. */
  15589. animations: import("babylonjs/Animations/animation").Animation[];
  15590. /**
  15591. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15592. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15593. */
  15594. enablePixelPerfectMode: boolean;
  15595. /**
  15596. * Force the postprocess to be applied without taking in account viewport
  15597. */
  15598. forceFullscreenViewport: boolean;
  15599. /**
  15600. * List of inspectable custom properties (used by the Inspector)
  15601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15602. */
  15603. inspectableCustomProperties: IInspectable[];
  15604. /**
  15605. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15606. *
  15607. * | Value | Type | Description |
  15608. * | ----- | ----------------------------------- | ----------- |
  15609. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15610. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15611. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15612. *
  15613. */
  15614. scaleMode: number;
  15615. /**
  15616. * Force textures to be a power of two (default: false)
  15617. */
  15618. alwaysForcePOT: boolean;
  15619. private _samples;
  15620. /**
  15621. * Number of sample textures (default: 1)
  15622. */
  15623. samples: number;
  15624. /**
  15625. * Modify the scale of the post process to be the same as the viewport (default: false)
  15626. */
  15627. adaptScaleToCurrentViewport: boolean;
  15628. private _camera;
  15629. private _scene;
  15630. private _engine;
  15631. private _options;
  15632. private _reusable;
  15633. private _textureType;
  15634. /**
  15635. * Smart array of input and output textures for the post process.
  15636. * @hidden
  15637. */
  15638. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15639. /**
  15640. * The index in _textures that corresponds to the output texture.
  15641. * @hidden
  15642. */
  15643. _currentRenderTextureInd: number;
  15644. private _effect;
  15645. private _samplers;
  15646. private _fragmentUrl;
  15647. private _vertexUrl;
  15648. private _parameters;
  15649. private _scaleRatio;
  15650. protected _indexParameters: any;
  15651. private _shareOutputWithPostProcess;
  15652. private _texelSize;
  15653. private _forcedOutputTexture;
  15654. /**
  15655. * Returns the fragment url or shader name used in the post process.
  15656. * @returns the fragment url or name in the shader store.
  15657. */
  15658. getEffectName(): string;
  15659. /**
  15660. * An event triggered when the postprocess is activated.
  15661. */
  15662. onActivateObservable: Observable<Camera>;
  15663. private _onActivateObserver;
  15664. /**
  15665. * A function that is added to the onActivateObservable
  15666. */
  15667. onActivate: Nullable<(camera: Camera) => void>;
  15668. /**
  15669. * An event triggered when the postprocess changes its size.
  15670. */
  15671. onSizeChangedObservable: Observable<PostProcess>;
  15672. private _onSizeChangedObserver;
  15673. /**
  15674. * A function that is added to the onSizeChangedObservable
  15675. */
  15676. onSizeChanged: (postProcess: PostProcess) => void;
  15677. /**
  15678. * An event triggered when the postprocess applies its effect.
  15679. */
  15680. onApplyObservable: Observable<Effect>;
  15681. private _onApplyObserver;
  15682. /**
  15683. * A function that is added to the onApplyObservable
  15684. */
  15685. onApply: (effect: Effect) => void;
  15686. /**
  15687. * An event triggered before rendering the postprocess
  15688. */
  15689. onBeforeRenderObservable: Observable<Effect>;
  15690. private _onBeforeRenderObserver;
  15691. /**
  15692. * A function that is added to the onBeforeRenderObservable
  15693. */
  15694. onBeforeRender: (effect: Effect) => void;
  15695. /**
  15696. * An event triggered after rendering the postprocess
  15697. */
  15698. onAfterRenderObservable: Observable<Effect>;
  15699. private _onAfterRenderObserver;
  15700. /**
  15701. * A function that is added to the onAfterRenderObservable
  15702. */
  15703. onAfterRender: (efect: Effect) => void;
  15704. /**
  15705. * 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
  15706. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15707. */
  15708. inputTexture: InternalTexture;
  15709. /**
  15710. * Gets the camera which post process is applied to.
  15711. * @returns The camera the post process is applied to.
  15712. */
  15713. getCamera(): Camera;
  15714. /**
  15715. * Gets the texel size of the postprocess.
  15716. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15717. */
  15718. readonly texelSize: Vector2;
  15719. /**
  15720. * Creates a new instance PostProcess
  15721. * @param name The name of the PostProcess.
  15722. * @param fragmentUrl The url of the fragment shader to be used.
  15723. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15724. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15725. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15726. * @param camera The camera to apply the render pass to.
  15727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15728. * @param engine The engine which the post process will be applied. (default: current engine)
  15729. * @param reusable If the post process can be reused on the same frame. (default: false)
  15730. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15731. * @param textureType Type of textures used when performing the post process. (default: 0)
  15732. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15733. * @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
  15734. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15735. */
  15736. constructor(
  15737. /** Name of the PostProcess. */
  15738. 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);
  15739. /**
  15740. * Gets a string idenfifying the name of the class
  15741. * @returns "PostProcess" string
  15742. */
  15743. getClassName(): string;
  15744. /**
  15745. * Gets the engine which this post process belongs to.
  15746. * @returns The engine the post process was enabled with.
  15747. */
  15748. getEngine(): Engine;
  15749. /**
  15750. * The effect that is created when initializing the post process.
  15751. * @returns The created effect corresponding the the postprocess.
  15752. */
  15753. getEffect(): Effect;
  15754. /**
  15755. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15756. * @param postProcess The post process to share the output with.
  15757. * @returns This post process.
  15758. */
  15759. shareOutputWith(postProcess: PostProcess): PostProcess;
  15760. /**
  15761. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15762. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15763. */
  15764. useOwnOutput(): void;
  15765. /**
  15766. * Updates the effect with the current post process compile time values and recompiles the shader.
  15767. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15768. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15769. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15770. * @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
  15771. * @param onCompiled Called when the shader has been compiled.
  15772. * @param onError Called if there is an error when compiling a shader.
  15773. */
  15774. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15775. /**
  15776. * The post process is reusable if it can be used multiple times within one frame.
  15777. * @returns If the post process is reusable
  15778. */
  15779. isReusable(): boolean;
  15780. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15781. markTextureDirty(): void;
  15782. /**
  15783. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15784. * 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.
  15785. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15786. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15787. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15788. * @returns The target texture that was bound to be written to.
  15789. */
  15790. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15791. /**
  15792. * If the post process is supported.
  15793. */
  15794. readonly isSupported: boolean;
  15795. /**
  15796. * The aspect ratio of the output texture.
  15797. */
  15798. readonly aspectRatio: number;
  15799. /**
  15800. * Get a value indicating if the post-process is ready to be used
  15801. * @returns true if the post-process is ready (shader is compiled)
  15802. */
  15803. isReady(): boolean;
  15804. /**
  15805. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15806. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15807. */
  15808. apply(): Nullable<Effect>;
  15809. private _disposeTextures;
  15810. /**
  15811. * Disposes the post process.
  15812. * @param camera The camera to dispose the post process on.
  15813. */
  15814. dispose(camera?: Camera): void;
  15815. }
  15816. }
  15817. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15818. /** @hidden */
  15819. export var kernelBlurVaryingDeclaration: {
  15820. name: string;
  15821. shader: string;
  15822. };
  15823. }
  15824. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15825. /** @hidden */
  15826. export var kernelBlurFragment: {
  15827. name: string;
  15828. shader: string;
  15829. };
  15830. }
  15831. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15832. /** @hidden */
  15833. export var kernelBlurFragment2: {
  15834. name: string;
  15835. shader: string;
  15836. };
  15837. }
  15838. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15839. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15840. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15841. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15842. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15843. /** @hidden */
  15844. export var kernelBlurPixelShader: {
  15845. name: string;
  15846. shader: string;
  15847. };
  15848. }
  15849. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15850. /** @hidden */
  15851. export var kernelBlurVertex: {
  15852. name: string;
  15853. shader: string;
  15854. };
  15855. }
  15856. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15857. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15858. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15859. /** @hidden */
  15860. export var kernelBlurVertexShader: {
  15861. name: string;
  15862. shader: string;
  15863. };
  15864. }
  15865. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15866. import { Vector2 } from "babylonjs/Maths/math.vector";
  15867. import { Nullable } from "babylonjs/types";
  15868. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15869. import { Camera } from "babylonjs/Cameras/camera";
  15870. import { Effect } from "babylonjs/Materials/effect";
  15871. import { Engine } from "babylonjs/Engines/engine";
  15872. import "babylonjs/Shaders/kernelBlur.fragment";
  15873. import "babylonjs/Shaders/kernelBlur.vertex";
  15874. /**
  15875. * The Blur Post Process which blurs an image based on a kernel and direction.
  15876. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15877. */
  15878. export class BlurPostProcess extends PostProcess {
  15879. /** The direction in which to blur the image. */
  15880. direction: Vector2;
  15881. private blockCompilation;
  15882. protected _kernel: number;
  15883. protected _idealKernel: number;
  15884. protected _packedFloat: boolean;
  15885. private _staticDefines;
  15886. /**
  15887. * Sets the length in pixels of the blur sample region
  15888. */
  15889. /**
  15890. * Gets the length in pixels of the blur sample region
  15891. */
  15892. kernel: number;
  15893. /**
  15894. * Sets wether or not the blur needs to unpack/repack floats
  15895. */
  15896. /**
  15897. * Gets wether or not the blur is unpacking/repacking floats
  15898. */
  15899. packedFloat: boolean;
  15900. /**
  15901. * Creates a new instance BlurPostProcess
  15902. * @param name The name of the effect.
  15903. * @param direction The direction in which to blur the image.
  15904. * @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.
  15905. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15906. * @param camera The camera to apply the render pass to.
  15907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15908. * @param engine The engine which the post process will be applied. (default: current engine)
  15909. * @param reusable If the post process can be reused on the same frame. (default: false)
  15910. * @param textureType Type of textures used when performing the post process. (default: 0)
  15911. * @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)
  15912. */
  15913. constructor(name: string,
  15914. /** The direction in which to blur the image. */
  15915. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15916. /**
  15917. * Updates the effect with the current post process compile time values and recompiles the shader.
  15918. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15919. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15920. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15921. * @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
  15922. * @param onCompiled Called when the shader has been compiled.
  15923. * @param onError Called if there is an error when compiling a shader.
  15924. */
  15925. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15926. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15927. /**
  15928. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15929. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15930. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15931. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15932. * The gaps between physical kernels are compensated for in the weighting of the samples
  15933. * @param idealKernel Ideal blur kernel.
  15934. * @return Nearest best kernel.
  15935. */
  15936. protected _nearestBestKernel(idealKernel: number): number;
  15937. /**
  15938. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15939. * @param x The point on the Gaussian distribution to sample.
  15940. * @return the value of the Gaussian function at x.
  15941. */
  15942. protected _gaussianWeight(x: number): number;
  15943. /**
  15944. * Generates a string that can be used as a floating point number in GLSL.
  15945. * @param x Value to print.
  15946. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15947. * @return GLSL float string.
  15948. */
  15949. protected _glslFloat(x: number, decimalFigures?: number): string;
  15950. }
  15951. }
  15952. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15953. import { Scene } from "babylonjs/scene";
  15954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15955. import { Plane } from "babylonjs/Maths/math.plane";
  15956. /**
  15957. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15958. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15959. * You can then easily use it as a reflectionTexture on a flat surface.
  15960. * In case the surface is not a plane, please consider relying on reflection probes.
  15961. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15962. */
  15963. export class MirrorTexture extends RenderTargetTexture {
  15964. private scene;
  15965. /**
  15966. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15967. * 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.
  15968. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15969. */
  15970. mirrorPlane: Plane;
  15971. /**
  15972. * Define the blur ratio used to blur the reflection if needed.
  15973. */
  15974. blurRatio: number;
  15975. /**
  15976. * Define the adaptive blur kernel used to blur the reflection if needed.
  15977. * This will autocompute the closest best match for the `blurKernel`
  15978. */
  15979. adaptiveBlurKernel: number;
  15980. /**
  15981. * Define the blur kernel used to blur the reflection if needed.
  15982. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15983. */
  15984. blurKernel: number;
  15985. /**
  15986. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15987. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15988. */
  15989. blurKernelX: number;
  15990. /**
  15991. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15992. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15993. */
  15994. blurKernelY: number;
  15995. private _autoComputeBlurKernel;
  15996. protected _onRatioRescale(): void;
  15997. private _updateGammaSpace;
  15998. private _imageProcessingConfigChangeObserver;
  15999. private _transformMatrix;
  16000. private _mirrorMatrix;
  16001. private _savedViewMatrix;
  16002. private _blurX;
  16003. private _blurY;
  16004. private _adaptiveBlurKernel;
  16005. private _blurKernelX;
  16006. private _blurKernelY;
  16007. private _blurRatio;
  16008. /**
  16009. * Instantiates a Mirror Texture.
  16010. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16011. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16012. * You can then easily use it as a reflectionTexture on a flat surface.
  16013. * In case the surface is not a plane, please consider relying on reflection probes.
  16014. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16015. * @param name
  16016. * @param size
  16017. * @param scene
  16018. * @param generateMipMaps
  16019. * @param type
  16020. * @param samplingMode
  16021. * @param generateDepthBuffer
  16022. */
  16023. constructor(name: string, size: number | {
  16024. width: number;
  16025. height: number;
  16026. } | {
  16027. ratio: number;
  16028. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16029. private _preparePostProcesses;
  16030. /**
  16031. * Clone the mirror texture.
  16032. * @returns the cloned texture
  16033. */
  16034. clone(): MirrorTexture;
  16035. /**
  16036. * Serialize the texture to a JSON representation you could use in Parse later on
  16037. * @returns the serialized JSON representation
  16038. */
  16039. serialize(): any;
  16040. /**
  16041. * Dispose the texture and release its associated resources.
  16042. */
  16043. dispose(): void;
  16044. }
  16045. }
  16046. declare module "babylonjs/Materials/Textures/texture" {
  16047. import { Observable } from "babylonjs/Misc/observable";
  16048. import { Nullable } from "babylonjs/types";
  16049. import { Matrix } from "babylonjs/Maths/math.vector";
  16050. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16051. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16052. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16053. import { Scene } from "babylonjs/scene";
  16054. /**
  16055. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16056. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16057. */
  16058. export class Texture extends BaseTexture {
  16059. /**
  16060. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16061. */
  16062. static SerializeBuffers: boolean;
  16063. /** @hidden */
  16064. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16065. /** @hidden */
  16066. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16067. /** @hidden */
  16068. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16069. /** nearest is mag = nearest and min = nearest and mip = linear */
  16070. static readonly NEAREST_SAMPLINGMODE: number;
  16071. /** nearest is mag = nearest and min = nearest and mip = linear */
  16072. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16073. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16074. static readonly BILINEAR_SAMPLINGMODE: number;
  16075. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16076. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16077. /** Trilinear is mag = linear and min = linear and mip = linear */
  16078. static readonly TRILINEAR_SAMPLINGMODE: number;
  16079. /** Trilinear is mag = linear and min = linear and mip = linear */
  16080. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16081. /** mag = nearest and min = nearest and mip = nearest */
  16082. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16083. /** mag = nearest and min = linear and mip = nearest */
  16084. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16085. /** mag = nearest and min = linear and mip = linear */
  16086. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16087. /** mag = nearest and min = linear and mip = none */
  16088. static readonly NEAREST_LINEAR: number;
  16089. /** mag = nearest and min = nearest and mip = none */
  16090. static readonly NEAREST_NEAREST: number;
  16091. /** mag = linear and min = nearest and mip = nearest */
  16092. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16093. /** mag = linear and min = nearest and mip = linear */
  16094. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16095. /** mag = linear and min = linear and mip = none */
  16096. static readonly LINEAR_LINEAR: number;
  16097. /** mag = linear and min = nearest and mip = none */
  16098. static readonly LINEAR_NEAREST: number;
  16099. /** Explicit coordinates mode */
  16100. static readonly EXPLICIT_MODE: number;
  16101. /** Spherical coordinates mode */
  16102. static readonly SPHERICAL_MODE: number;
  16103. /** Planar coordinates mode */
  16104. static readonly PLANAR_MODE: number;
  16105. /** Cubic coordinates mode */
  16106. static readonly CUBIC_MODE: number;
  16107. /** Projection coordinates mode */
  16108. static readonly PROJECTION_MODE: number;
  16109. /** Inverse Cubic coordinates mode */
  16110. static readonly SKYBOX_MODE: number;
  16111. /** Inverse Cubic coordinates mode */
  16112. static readonly INVCUBIC_MODE: number;
  16113. /** Equirectangular coordinates mode */
  16114. static readonly EQUIRECTANGULAR_MODE: number;
  16115. /** Equirectangular Fixed coordinates mode */
  16116. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16117. /** Equirectangular Fixed Mirrored coordinates mode */
  16118. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16119. /** Texture is not repeating outside of 0..1 UVs */
  16120. static readonly CLAMP_ADDRESSMODE: number;
  16121. /** Texture is repeating outside of 0..1 UVs */
  16122. static readonly WRAP_ADDRESSMODE: number;
  16123. /** Texture is repeating and mirrored */
  16124. static readonly MIRROR_ADDRESSMODE: number;
  16125. /**
  16126. * 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
  16127. */
  16128. static UseSerializedUrlIfAny: boolean;
  16129. /**
  16130. * Define the url of the texture.
  16131. */
  16132. url: Nullable<string>;
  16133. /**
  16134. * Define an offset on the texture to offset the u coordinates of the UVs
  16135. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16136. */
  16137. uOffset: number;
  16138. /**
  16139. * Define an offset on the texture to offset the v coordinates of the UVs
  16140. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16141. */
  16142. vOffset: number;
  16143. /**
  16144. * Define an offset on the texture to scale the u coordinates of the UVs
  16145. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16146. */
  16147. uScale: number;
  16148. /**
  16149. * Define an offset on the texture to scale the v coordinates of the UVs
  16150. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16151. */
  16152. vScale: number;
  16153. /**
  16154. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16155. * @see http://doc.babylonjs.com/how_to/more_materials
  16156. */
  16157. uAng: number;
  16158. /**
  16159. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16160. * @see http://doc.babylonjs.com/how_to/more_materials
  16161. */
  16162. vAng: number;
  16163. /**
  16164. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16165. * @see http://doc.babylonjs.com/how_to/more_materials
  16166. */
  16167. wAng: number;
  16168. /**
  16169. * Defines the center of rotation (U)
  16170. */
  16171. uRotationCenter: number;
  16172. /**
  16173. * Defines the center of rotation (V)
  16174. */
  16175. vRotationCenter: number;
  16176. /**
  16177. * Defines the center of rotation (W)
  16178. */
  16179. wRotationCenter: number;
  16180. /**
  16181. * Are mip maps generated for this texture or not.
  16182. */
  16183. readonly noMipmap: boolean;
  16184. /**
  16185. * List of inspectable custom properties (used by the Inspector)
  16186. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16187. */
  16188. inspectableCustomProperties: Nullable<IInspectable[]>;
  16189. private _noMipmap;
  16190. /** @hidden */
  16191. _invertY: boolean;
  16192. private _rowGenerationMatrix;
  16193. private _cachedTextureMatrix;
  16194. private _projectionModeMatrix;
  16195. private _t0;
  16196. private _t1;
  16197. private _t2;
  16198. private _cachedUOffset;
  16199. private _cachedVOffset;
  16200. private _cachedUScale;
  16201. private _cachedVScale;
  16202. private _cachedUAng;
  16203. private _cachedVAng;
  16204. private _cachedWAng;
  16205. private _cachedProjectionMatrixId;
  16206. private _cachedCoordinatesMode;
  16207. /** @hidden */
  16208. protected _initialSamplingMode: number;
  16209. /** @hidden */
  16210. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16211. private _deleteBuffer;
  16212. protected _format: Nullable<number>;
  16213. private _delayedOnLoad;
  16214. private _delayedOnError;
  16215. private _mimeType?;
  16216. /**
  16217. * Observable triggered once the texture has been loaded.
  16218. */
  16219. onLoadObservable: Observable<Texture>;
  16220. protected _isBlocking: boolean;
  16221. /**
  16222. * Is the texture preventing material to render while loading.
  16223. * If false, a default texture will be used instead of the loading one during the preparation step.
  16224. */
  16225. isBlocking: boolean;
  16226. /**
  16227. * Get the current sampling mode associated with the texture.
  16228. */
  16229. readonly samplingMode: number;
  16230. /**
  16231. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16232. */
  16233. readonly invertY: boolean;
  16234. /**
  16235. * Instantiates a new texture.
  16236. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16237. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16238. * @param url defines the url of the picture to load as a texture
  16239. * @param scene defines the scene or engine the texture will belong to
  16240. * @param noMipmap defines if the texture will require mip maps or not
  16241. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16242. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16243. * @param onLoad defines a callback triggered when the texture has been loaded
  16244. * @param onError defines a callback triggered when an error occurred during the loading session
  16245. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16246. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16247. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16248. * @param mimeType defines an optional mime type information
  16249. */
  16250. 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 | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16251. /**
  16252. * Update the url (and optional buffer) of this texture if url was null during construction.
  16253. * @param url the url of the texture
  16254. * @param buffer the buffer of the texture (defaults to null)
  16255. * @param onLoad callback called when the texture is loaded (defaults to null)
  16256. */
  16257. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16258. /**
  16259. * Finish the loading sequence of a texture flagged as delayed load.
  16260. * @hidden
  16261. */
  16262. delayLoad(): void;
  16263. private _prepareRowForTextureGeneration;
  16264. /**
  16265. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16266. * @returns the transform matrix of the texture.
  16267. */
  16268. getTextureMatrix(): Matrix;
  16269. /**
  16270. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16271. * @returns The reflection texture transform
  16272. */
  16273. getReflectionTextureMatrix(): Matrix;
  16274. /**
  16275. * Clones the texture.
  16276. * @returns the cloned texture
  16277. */
  16278. clone(): Texture;
  16279. /**
  16280. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16281. * @returns The JSON representation of the texture
  16282. */
  16283. serialize(): any;
  16284. /**
  16285. * Get the current class name of the texture useful for serialization or dynamic coding.
  16286. * @returns "Texture"
  16287. */
  16288. getClassName(): string;
  16289. /**
  16290. * Dispose the texture and release its associated resources.
  16291. */
  16292. dispose(): void;
  16293. /**
  16294. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16295. * @param parsedTexture Define the JSON representation of the texture
  16296. * @param scene Define the scene the parsed texture should be instantiated in
  16297. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16298. * @returns The parsed texture if successful
  16299. */
  16300. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16301. /**
  16302. * Creates a texture from its base 64 representation.
  16303. * @param data Define the base64 payload without the data: prefix
  16304. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16305. * @param scene Define the scene the texture should belong to
  16306. * @param noMipmap Forces the texture to not create mip map information if true
  16307. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16308. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16309. * @param onLoad define a callback triggered when the texture has been loaded
  16310. * @param onError define a callback triggered when an error occurred during the loading session
  16311. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16312. * @returns the created texture
  16313. */
  16314. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16315. /**
  16316. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16317. * @param data Define the base64 payload without the data: prefix
  16318. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16319. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16320. * @param scene Define the scene the texture should belong to
  16321. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16322. * @param noMipmap Forces the texture to not create mip map information if true
  16323. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16324. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16325. * @param onLoad define a callback triggered when the texture has been loaded
  16326. * @param onError define a callback triggered when an error occurred during the loading session
  16327. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16328. * @returns the created texture
  16329. */
  16330. 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;
  16331. }
  16332. }
  16333. declare module "babylonjs/PostProcesses/postProcessManager" {
  16334. import { Nullable } from "babylonjs/types";
  16335. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16336. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16337. import { Scene } from "babylonjs/scene";
  16338. /**
  16339. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16340. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16341. */
  16342. export class PostProcessManager {
  16343. private _scene;
  16344. private _indexBuffer;
  16345. private _vertexBuffers;
  16346. /**
  16347. * Creates a new instance PostProcess
  16348. * @param scene The scene that the post process is associated with.
  16349. */
  16350. constructor(scene: Scene);
  16351. private _prepareBuffers;
  16352. private _buildIndexBuffer;
  16353. /**
  16354. * Rebuilds the vertex buffers of the manager.
  16355. * @hidden
  16356. */
  16357. _rebuild(): void;
  16358. /**
  16359. * Prepares a frame to be run through a post process.
  16360. * @param sourceTexture The input texture to the post procesess. (default: null)
  16361. * @param postProcesses An array of post processes to be run. (default: null)
  16362. * @returns True if the post processes were able to be run.
  16363. * @hidden
  16364. */
  16365. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16366. /**
  16367. * Manually render a set of post processes to a texture.
  16368. * @param postProcesses An array of post processes to be run.
  16369. * @param targetTexture The target texture to render to.
  16370. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16371. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16372. * @param lodLevel defines which lod of the texture to render to
  16373. */
  16374. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16375. /**
  16376. * Finalize the result of the output of the postprocesses.
  16377. * @param doNotPresent If true the result will not be displayed to the screen.
  16378. * @param targetTexture The target texture to render to.
  16379. * @param faceIndex The index of the face to bind the target texture to.
  16380. * @param postProcesses The array of post processes to render.
  16381. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16382. * @hidden
  16383. */
  16384. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16385. /**
  16386. * Disposes of the post process manager.
  16387. */
  16388. dispose(): void;
  16389. }
  16390. }
  16391. declare module "babylonjs/Misc/gradients" {
  16392. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16393. /** Interface used by value gradients (color, factor, ...) */
  16394. export interface IValueGradient {
  16395. /**
  16396. * Gets or sets the gradient value (between 0 and 1)
  16397. */
  16398. gradient: number;
  16399. }
  16400. /** Class used to store color4 gradient */
  16401. export class ColorGradient implements IValueGradient {
  16402. /**
  16403. * Gets or sets the gradient value (between 0 and 1)
  16404. */
  16405. gradient: number;
  16406. /**
  16407. * Gets or sets first associated color
  16408. */
  16409. color1: Color4;
  16410. /**
  16411. * Gets or sets second associated color
  16412. */
  16413. color2?: Color4;
  16414. /**
  16415. * Will get a color picked randomly between color1 and color2.
  16416. * If color2 is undefined then color1 will be used
  16417. * @param result defines the target Color4 to store the result in
  16418. */
  16419. getColorToRef(result: Color4): void;
  16420. }
  16421. /** Class used to store color 3 gradient */
  16422. export class Color3Gradient implements IValueGradient {
  16423. /**
  16424. * Gets or sets the gradient value (between 0 and 1)
  16425. */
  16426. gradient: number;
  16427. /**
  16428. * Gets or sets the associated color
  16429. */
  16430. color: Color3;
  16431. }
  16432. /** Class used to store factor gradient */
  16433. export class FactorGradient implements IValueGradient {
  16434. /**
  16435. * Gets or sets the gradient value (between 0 and 1)
  16436. */
  16437. gradient: number;
  16438. /**
  16439. * Gets or sets first associated factor
  16440. */
  16441. factor1: number;
  16442. /**
  16443. * Gets or sets second associated factor
  16444. */
  16445. factor2?: number;
  16446. /**
  16447. * Will get a number picked randomly between factor1 and factor2.
  16448. * If factor2 is undefined then factor1 will be used
  16449. * @returns the picked number
  16450. */
  16451. getFactor(): number;
  16452. }
  16453. /**
  16454. * Helper used to simplify some generic gradient tasks
  16455. */
  16456. export class GradientHelper {
  16457. /**
  16458. * Gets the current gradient from an array of IValueGradient
  16459. * @param ratio defines the current ratio to get
  16460. * @param gradients defines the array of IValueGradient
  16461. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16462. */
  16463. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16464. }
  16465. }
  16466. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16467. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16468. import { Nullable } from "babylonjs/types";
  16469. module "babylonjs/Engines/thinEngine" {
  16470. interface ThinEngine {
  16471. /**
  16472. * Creates a dynamic texture
  16473. * @param width defines the width of the texture
  16474. * @param height defines the height of the texture
  16475. * @param generateMipMaps defines if the engine should generate the mip levels
  16476. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16477. * @returns the dynamic texture inside an InternalTexture
  16478. */
  16479. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16480. /**
  16481. * Update the content of a dynamic texture
  16482. * @param texture defines the texture to update
  16483. * @param canvas defines the canvas containing the source
  16484. * @param invertY defines if data must be stored with Y axis inverted
  16485. * @param premulAlpha defines if alpha is stored as premultiplied
  16486. * @param format defines the format of the data
  16487. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16488. */
  16489. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16490. }
  16491. }
  16492. }
  16493. declare module "babylonjs/Misc/canvasGenerator" {
  16494. /**
  16495. * Helper class used to generate a canvas to manipulate images
  16496. */
  16497. export class CanvasGenerator {
  16498. /**
  16499. * Create a new canvas (or offscreen canvas depending on the context)
  16500. * @param width defines the expected width
  16501. * @param height defines the expected height
  16502. * @return a new canvas or offscreen canvas
  16503. */
  16504. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16505. }
  16506. }
  16507. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16508. import { Scene } from "babylonjs/scene";
  16509. import { Texture } from "babylonjs/Materials/Textures/texture";
  16510. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16511. /**
  16512. * A class extending Texture allowing drawing on a texture
  16513. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16514. */
  16515. export class DynamicTexture extends Texture {
  16516. private _generateMipMaps;
  16517. private _canvas;
  16518. private _context;
  16519. private _engine;
  16520. /**
  16521. * Creates a DynamicTexture
  16522. * @param name defines the name of the texture
  16523. * @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
  16524. * @param scene defines the scene where you want the texture
  16525. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16526. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16527. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16528. */
  16529. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16530. /**
  16531. * Get the current class name of the texture useful for serialization or dynamic coding.
  16532. * @returns "DynamicTexture"
  16533. */
  16534. getClassName(): string;
  16535. /**
  16536. * Gets the current state of canRescale
  16537. */
  16538. readonly canRescale: boolean;
  16539. private _recreate;
  16540. /**
  16541. * Scales the texture
  16542. * @param ratio the scale factor to apply to both width and height
  16543. */
  16544. scale(ratio: number): void;
  16545. /**
  16546. * Resizes the texture
  16547. * @param width the new width
  16548. * @param height the new height
  16549. */
  16550. scaleTo(width: number, height: number): void;
  16551. /**
  16552. * Gets the context of the canvas used by the texture
  16553. * @returns the canvas context of the dynamic texture
  16554. */
  16555. getContext(): CanvasRenderingContext2D;
  16556. /**
  16557. * Clears the texture
  16558. */
  16559. clear(): void;
  16560. /**
  16561. * Updates the texture
  16562. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16563. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16564. */
  16565. update(invertY?: boolean, premulAlpha?: boolean): void;
  16566. /**
  16567. * Draws text onto the texture
  16568. * @param text defines the text to be drawn
  16569. * @param x defines the placement of the text from the left
  16570. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16571. * @param font defines the font to be used with font-style, font-size, font-name
  16572. * @param color defines the color used for the text
  16573. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16574. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16575. * @param update defines whether texture is immediately update (default is true)
  16576. */
  16577. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16578. /**
  16579. * Clones the texture
  16580. * @returns the clone of the texture.
  16581. */
  16582. clone(): DynamicTexture;
  16583. /**
  16584. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16585. * @returns a serialized dynamic texture object
  16586. */
  16587. serialize(): any;
  16588. /** @hidden */
  16589. _rebuild(): void;
  16590. }
  16591. }
  16592. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16593. import { Scene } from "babylonjs/scene";
  16594. import { ISceneComponent } from "babylonjs/sceneComponent";
  16595. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16596. module "babylonjs/abstractScene" {
  16597. interface AbstractScene {
  16598. /**
  16599. * The list of procedural textures added to the scene
  16600. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16601. */
  16602. proceduralTextures: Array<ProceduralTexture>;
  16603. }
  16604. }
  16605. /**
  16606. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16607. * in a given scene.
  16608. */
  16609. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16610. /**
  16611. * The component name helpfull to identify the component in the list of scene components.
  16612. */
  16613. readonly name: string;
  16614. /**
  16615. * The scene the component belongs to.
  16616. */
  16617. scene: Scene;
  16618. /**
  16619. * Creates a new instance of the component for the given scene
  16620. * @param scene Defines the scene to register the component in
  16621. */
  16622. constructor(scene: Scene);
  16623. /**
  16624. * Registers the component in a given scene
  16625. */
  16626. register(): void;
  16627. /**
  16628. * Rebuilds the elements related to this component in case of
  16629. * context lost for instance.
  16630. */
  16631. rebuild(): void;
  16632. /**
  16633. * Disposes the component and the associated ressources.
  16634. */
  16635. dispose(): void;
  16636. private _beforeClear;
  16637. }
  16638. }
  16639. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16640. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16641. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16642. module "babylonjs/Engines/thinEngine" {
  16643. interface ThinEngine {
  16644. /**
  16645. * Creates a new render target cube texture
  16646. * @param size defines the size of the texture
  16647. * @param options defines the options used to create the texture
  16648. * @returns a new render target cube texture stored in an InternalTexture
  16649. */
  16650. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16651. }
  16652. }
  16653. }
  16654. declare module "babylonjs/Shaders/procedural.vertex" {
  16655. /** @hidden */
  16656. export var proceduralVertexShader: {
  16657. name: string;
  16658. shader: string;
  16659. };
  16660. }
  16661. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16662. import { Observable } from "babylonjs/Misc/observable";
  16663. import { Nullable } from "babylonjs/types";
  16664. import { Scene } from "babylonjs/scene";
  16665. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16666. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16667. import { Effect } from "babylonjs/Materials/effect";
  16668. import { Texture } from "babylonjs/Materials/Textures/texture";
  16669. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16670. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16671. import "babylonjs/Shaders/procedural.vertex";
  16672. /**
  16673. * 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.
  16674. * This is the base class of any Procedural texture and contains most of the shareable code.
  16675. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16676. */
  16677. export class ProceduralTexture extends Texture {
  16678. isCube: boolean;
  16679. /**
  16680. * Define if the texture is enabled or not (disabled texture will not render)
  16681. */
  16682. isEnabled: boolean;
  16683. /**
  16684. * Define if the texture must be cleared before rendering (default is true)
  16685. */
  16686. autoClear: boolean;
  16687. /**
  16688. * Callback called when the texture is generated
  16689. */
  16690. onGenerated: () => void;
  16691. /**
  16692. * Event raised when the texture is generated
  16693. */
  16694. onGeneratedObservable: Observable<ProceduralTexture>;
  16695. /** @hidden */
  16696. _generateMipMaps: boolean;
  16697. /** @hidden **/
  16698. _effect: Effect;
  16699. /** @hidden */
  16700. _textures: {
  16701. [key: string]: Texture;
  16702. };
  16703. private _size;
  16704. private _currentRefreshId;
  16705. private _refreshRate;
  16706. private _vertexBuffers;
  16707. private _indexBuffer;
  16708. private _uniforms;
  16709. private _samplers;
  16710. private _fragment;
  16711. private _floats;
  16712. private _ints;
  16713. private _floatsArrays;
  16714. private _colors3;
  16715. private _colors4;
  16716. private _vectors2;
  16717. private _vectors3;
  16718. private _matrices;
  16719. private _fallbackTexture;
  16720. private _fallbackTextureUsed;
  16721. private _engine;
  16722. private _cachedDefines;
  16723. private _contentUpdateId;
  16724. private _contentData;
  16725. /**
  16726. * Instantiates a new procedural texture.
  16727. * 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.
  16728. * This is the base class of any Procedural texture and contains most of the shareable code.
  16729. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16730. * @param name Define the name of the texture
  16731. * @param size Define the size of the texture to create
  16732. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16733. * @param scene Define the scene the texture belongs to
  16734. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16735. * @param generateMipMaps Define if the texture should creates mip maps or not
  16736. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16737. */
  16738. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16739. /**
  16740. * The effect that is created when initializing the post process.
  16741. * @returns The created effect corresponding the the postprocess.
  16742. */
  16743. getEffect(): Effect;
  16744. /**
  16745. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16746. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16747. */
  16748. getContent(): Nullable<ArrayBufferView>;
  16749. private _createIndexBuffer;
  16750. /** @hidden */
  16751. _rebuild(): void;
  16752. /**
  16753. * Resets the texture in order to recreate its associated resources.
  16754. * This can be called in case of context loss
  16755. */
  16756. reset(): void;
  16757. protected _getDefines(): string;
  16758. /**
  16759. * Is the texture ready to be used ? (rendered at least once)
  16760. * @returns true if ready, otherwise, false.
  16761. */
  16762. isReady(): boolean;
  16763. /**
  16764. * Resets the refresh counter of the texture and start bak from scratch.
  16765. * Could be useful to regenerate the texture if it is setup to render only once.
  16766. */
  16767. resetRefreshCounter(): void;
  16768. /**
  16769. * Set the fragment shader to use in order to render the texture.
  16770. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16771. */
  16772. setFragment(fragment: any): void;
  16773. /**
  16774. * Define the refresh rate of the texture or the rendering frequency.
  16775. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16776. */
  16777. refreshRate: number;
  16778. /** @hidden */
  16779. _shouldRender(): boolean;
  16780. /**
  16781. * Get the size the texture is rendering at.
  16782. * @returns the size (texture is always squared)
  16783. */
  16784. getRenderSize(): number;
  16785. /**
  16786. * Resize the texture to new value.
  16787. * @param size Define the new size the texture should have
  16788. * @param generateMipMaps Define whether the new texture should create mip maps
  16789. */
  16790. resize(size: number, generateMipMaps: boolean): void;
  16791. private _checkUniform;
  16792. /**
  16793. * Set a texture in the shader program used to render.
  16794. * @param name Define the name of the uniform samplers as defined in the shader
  16795. * @param texture Define the texture to bind to this sampler
  16796. * @return the texture itself allowing "fluent" like uniform updates
  16797. */
  16798. setTexture(name: string, texture: Texture): ProceduralTexture;
  16799. /**
  16800. * Set a float in the shader.
  16801. * @param name Define the name of the uniform as defined in the shader
  16802. * @param value Define the value to give to the uniform
  16803. * @return the texture itself allowing "fluent" like uniform updates
  16804. */
  16805. setFloat(name: string, value: number): ProceduralTexture;
  16806. /**
  16807. * Set a int in the shader.
  16808. * @param name Define the name of the uniform as defined in the shader
  16809. * @param value Define the value to give to the uniform
  16810. * @return the texture itself allowing "fluent" like uniform updates
  16811. */
  16812. setInt(name: string, value: number): ProceduralTexture;
  16813. /**
  16814. * Set an array of floats in the shader.
  16815. * @param name Define the name of the uniform as defined in the shader
  16816. * @param value Define the value to give to the uniform
  16817. * @return the texture itself allowing "fluent" like uniform updates
  16818. */
  16819. setFloats(name: string, value: number[]): ProceduralTexture;
  16820. /**
  16821. * Set a vec3 in the shader from a Color3.
  16822. * @param name Define the name of the uniform as defined in the shader
  16823. * @param value Define the value to give to the uniform
  16824. * @return the texture itself allowing "fluent" like uniform updates
  16825. */
  16826. setColor3(name: string, value: Color3): ProceduralTexture;
  16827. /**
  16828. * Set a vec4 in the shader from a Color4.
  16829. * @param name Define the name of the uniform as defined in the shader
  16830. * @param value Define the value to give to the uniform
  16831. * @return the texture itself allowing "fluent" like uniform updates
  16832. */
  16833. setColor4(name: string, value: Color4): ProceduralTexture;
  16834. /**
  16835. * Set a vec2 in the shader from a Vector2.
  16836. * @param name Define the name of the uniform as defined in the shader
  16837. * @param value Define the value to give to the uniform
  16838. * @return the texture itself allowing "fluent" like uniform updates
  16839. */
  16840. setVector2(name: string, value: Vector2): ProceduralTexture;
  16841. /**
  16842. * Set a vec3 in the shader from a Vector3.
  16843. * @param name Define the name of the uniform as defined in the shader
  16844. * @param value Define the value to give to the uniform
  16845. * @return the texture itself allowing "fluent" like uniform updates
  16846. */
  16847. setVector3(name: string, value: Vector3): ProceduralTexture;
  16848. /**
  16849. * Set a mat4 in the shader from a MAtrix.
  16850. * @param name Define the name of the uniform as defined in the shader
  16851. * @param value Define the value to give to the uniform
  16852. * @return the texture itself allowing "fluent" like uniform updates
  16853. */
  16854. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16855. /**
  16856. * Render the texture to its associated render target.
  16857. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16858. */
  16859. render(useCameraPostProcess?: boolean): void;
  16860. /**
  16861. * Clone the texture.
  16862. * @returns the cloned texture
  16863. */
  16864. clone(): ProceduralTexture;
  16865. /**
  16866. * Dispose the texture and release its asoociated resources.
  16867. */
  16868. dispose(): void;
  16869. }
  16870. }
  16871. declare module "babylonjs/Particles/baseParticleSystem" {
  16872. import { Nullable } from "babylonjs/types";
  16873. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16875. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16876. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16877. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16878. import { Scene } from "babylonjs/scene";
  16879. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16880. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16881. import { Texture } from "babylonjs/Materials/Textures/texture";
  16882. import { Color4 } from "babylonjs/Maths/math.color";
  16883. import { Animation } from "babylonjs/Animations/animation";
  16884. /**
  16885. * This represents the base class for particle system in Babylon.
  16886. * 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.
  16887. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16888. * @example https://doc.babylonjs.com/babylon101/particles
  16889. */
  16890. export class BaseParticleSystem {
  16891. /**
  16892. * Source color is added to the destination color without alpha affecting the result
  16893. */
  16894. static BLENDMODE_ONEONE: number;
  16895. /**
  16896. * Blend current color and particle color using particle’s alpha
  16897. */
  16898. static BLENDMODE_STANDARD: number;
  16899. /**
  16900. * Add current color and particle color multiplied by particle’s alpha
  16901. */
  16902. static BLENDMODE_ADD: number;
  16903. /**
  16904. * Multiply current color with particle color
  16905. */
  16906. static BLENDMODE_MULTIPLY: number;
  16907. /**
  16908. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16909. */
  16910. static BLENDMODE_MULTIPLYADD: number;
  16911. /**
  16912. * List of animations used by the particle system.
  16913. */
  16914. animations: Animation[];
  16915. /**
  16916. * The id of the Particle system.
  16917. */
  16918. id: string;
  16919. /**
  16920. * The friendly name of the Particle system.
  16921. */
  16922. name: string;
  16923. /**
  16924. * The rendering group used by the Particle system to chose when to render.
  16925. */
  16926. renderingGroupId: number;
  16927. /**
  16928. * The emitter represents the Mesh or position we are attaching the particle system to.
  16929. */
  16930. emitter: Nullable<AbstractMesh | Vector3>;
  16931. /**
  16932. * The maximum number of particles to emit per frame
  16933. */
  16934. emitRate: number;
  16935. /**
  16936. * If you want to launch only a few particles at once, that can be done, as well.
  16937. */
  16938. manualEmitCount: number;
  16939. /**
  16940. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16941. */
  16942. updateSpeed: number;
  16943. /**
  16944. * The amount of time the particle system is running (depends of the overall update speed).
  16945. */
  16946. targetStopDuration: number;
  16947. /**
  16948. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16949. */
  16950. disposeOnStop: boolean;
  16951. /**
  16952. * Minimum power of emitting particles.
  16953. */
  16954. minEmitPower: number;
  16955. /**
  16956. * Maximum power of emitting particles.
  16957. */
  16958. maxEmitPower: number;
  16959. /**
  16960. * Minimum life time of emitting particles.
  16961. */
  16962. minLifeTime: number;
  16963. /**
  16964. * Maximum life time of emitting particles.
  16965. */
  16966. maxLifeTime: number;
  16967. /**
  16968. * Minimum Size of emitting particles.
  16969. */
  16970. minSize: number;
  16971. /**
  16972. * Maximum Size of emitting particles.
  16973. */
  16974. maxSize: number;
  16975. /**
  16976. * Minimum scale of emitting particles on X axis.
  16977. */
  16978. minScaleX: number;
  16979. /**
  16980. * Maximum scale of emitting particles on X axis.
  16981. */
  16982. maxScaleX: number;
  16983. /**
  16984. * Minimum scale of emitting particles on Y axis.
  16985. */
  16986. minScaleY: number;
  16987. /**
  16988. * Maximum scale of emitting particles on Y axis.
  16989. */
  16990. maxScaleY: number;
  16991. /**
  16992. * Gets or sets the minimal initial rotation in radians.
  16993. */
  16994. minInitialRotation: number;
  16995. /**
  16996. * Gets or sets the maximal initial rotation in radians.
  16997. */
  16998. maxInitialRotation: number;
  16999. /**
  17000. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17001. */
  17002. minAngularSpeed: number;
  17003. /**
  17004. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17005. */
  17006. maxAngularSpeed: number;
  17007. /**
  17008. * The texture used to render each particle. (this can be a spritesheet)
  17009. */
  17010. particleTexture: Nullable<Texture>;
  17011. /**
  17012. * The layer mask we are rendering the particles through.
  17013. */
  17014. layerMask: number;
  17015. /**
  17016. * This can help using your own shader to render the particle system.
  17017. * The according effect will be created
  17018. */
  17019. customShader: any;
  17020. /**
  17021. * By default particle system starts as soon as they are created. This prevents the
  17022. * automatic start to happen and let you decide when to start emitting particles.
  17023. */
  17024. preventAutoStart: boolean;
  17025. private _noiseTexture;
  17026. /**
  17027. * Gets or sets a texture used to add random noise to particle positions
  17028. */
  17029. noiseTexture: Nullable<ProceduralTexture>;
  17030. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17031. noiseStrength: Vector3;
  17032. /**
  17033. * Callback triggered when the particle animation is ending.
  17034. */
  17035. onAnimationEnd: Nullable<() => void>;
  17036. /**
  17037. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17038. */
  17039. blendMode: number;
  17040. /**
  17041. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17042. * to override the particles.
  17043. */
  17044. forceDepthWrite: boolean;
  17045. /** 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 */
  17046. preWarmCycles: number;
  17047. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17048. preWarmStepOffset: number;
  17049. /**
  17050. * 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)
  17051. */
  17052. spriteCellChangeSpeed: number;
  17053. /**
  17054. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17055. */
  17056. startSpriteCellID: number;
  17057. /**
  17058. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17059. */
  17060. endSpriteCellID: number;
  17061. /**
  17062. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17063. */
  17064. spriteCellWidth: number;
  17065. /**
  17066. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17067. */
  17068. spriteCellHeight: number;
  17069. /**
  17070. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17071. */
  17072. spriteRandomStartCell: boolean;
  17073. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17074. translationPivot: Vector2;
  17075. /** @hidden */
  17076. protected _isAnimationSheetEnabled: boolean;
  17077. /**
  17078. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17079. */
  17080. beginAnimationOnStart: boolean;
  17081. /**
  17082. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17083. */
  17084. beginAnimationFrom: number;
  17085. /**
  17086. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17087. */
  17088. beginAnimationTo: number;
  17089. /**
  17090. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17091. */
  17092. beginAnimationLoop: boolean;
  17093. /**
  17094. * Gets or sets a world offset applied to all particles
  17095. */
  17096. worldOffset: Vector3;
  17097. /**
  17098. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17099. */
  17100. isAnimationSheetEnabled: boolean;
  17101. /**
  17102. * Get hosting scene
  17103. * @returns the scene
  17104. */
  17105. getScene(): Scene;
  17106. /**
  17107. * You can use gravity if you want to give an orientation to your particles.
  17108. */
  17109. gravity: Vector3;
  17110. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17111. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17112. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17113. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17114. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17115. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17116. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17117. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17118. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17119. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17120. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17121. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17122. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17123. /**
  17124. * Defines the delay in milliseconds before starting the system (0 by default)
  17125. */
  17126. startDelay: number;
  17127. /**
  17128. * Gets the current list of drag gradients.
  17129. * You must use addDragGradient and removeDragGradient to udpate this list
  17130. * @returns the list of drag gradients
  17131. */
  17132. getDragGradients(): Nullable<Array<FactorGradient>>;
  17133. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17134. limitVelocityDamping: number;
  17135. /**
  17136. * Gets the current list of limit velocity gradients.
  17137. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17138. * @returns the list of limit velocity gradients
  17139. */
  17140. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17141. /**
  17142. * Gets the current list of color gradients.
  17143. * You must use addColorGradient and removeColorGradient to udpate this list
  17144. * @returns the list of color gradients
  17145. */
  17146. getColorGradients(): Nullable<Array<ColorGradient>>;
  17147. /**
  17148. * Gets the current list of size gradients.
  17149. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17150. * @returns the list of size gradients
  17151. */
  17152. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17153. /**
  17154. * Gets the current list of color remap gradients.
  17155. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17156. * @returns the list of color remap gradients
  17157. */
  17158. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17159. /**
  17160. * Gets the current list of alpha remap gradients.
  17161. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17162. * @returns the list of alpha remap gradients
  17163. */
  17164. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17165. /**
  17166. * Gets the current list of life time gradients.
  17167. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17168. * @returns the list of life time gradients
  17169. */
  17170. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17171. /**
  17172. * Gets the current list of angular speed gradients.
  17173. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17174. * @returns the list of angular speed gradients
  17175. */
  17176. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17177. /**
  17178. * Gets the current list of velocity gradients.
  17179. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17180. * @returns the list of velocity gradients
  17181. */
  17182. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17183. /**
  17184. * Gets the current list of start size gradients.
  17185. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17186. * @returns the list of start size gradients
  17187. */
  17188. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17189. /**
  17190. * Gets the current list of emit rate gradients.
  17191. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17192. * @returns the list of emit rate gradients
  17193. */
  17194. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17195. /**
  17196. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17198. */
  17199. direction1: Vector3;
  17200. /**
  17201. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17202. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17203. */
  17204. direction2: Vector3;
  17205. /**
  17206. * 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.
  17207. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17208. */
  17209. minEmitBox: Vector3;
  17210. /**
  17211. * 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.
  17212. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17213. */
  17214. maxEmitBox: Vector3;
  17215. /**
  17216. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17217. */
  17218. color1: Color4;
  17219. /**
  17220. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17221. */
  17222. color2: Color4;
  17223. /**
  17224. * Color the particle will have at the end of its lifetime
  17225. */
  17226. colorDead: Color4;
  17227. /**
  17228. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17229. */
  17230. textureMask: Color4;
  17231. /**
  17232. * The particle emitter type defines the emitter used by the particle system.
  17233. * It can be for example box, sphere, or cone...
  17234. */
  17235. particleEmitterType: IParticleEmitterType;
  17236. /** @hidden */
  17237. _isSubEmitter: boolean;
  17238. /**
  17239. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17240. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17241. */
  17242. billboardMode: number;
  17243. protected _isBillboardBased: boolean;
  17244. /**
  17245. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17246. */
  17247. isBillboardBased: boolean;
  17248. /**
  17249. * The scene the particle system belongs to.
  17250. */
  17251. protected _scene: Scene;
  17252. /**
  17253. * Local cache of defines for image processing.
  17254. */
  17255. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17256. /**
  17257. * Default configuration related to image processing available in the standard Material.
  17258. */
  17259. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17260. /**
  17261. * Gets the image processing configuration used either in this material.
  17262. */
  17263. /**
  17264. * Sets the Default image processing configuration used either in the this material.
  17265. *
  17266. * If sets to null, the scene one is in use.
  17267. */
  17268. imageProcessingConfiguration: ImageProcessingConfiguration;
  17269. /**
  17270. * Attaches a new image processing configuration to the Standard Material.
  17271. * @param configuration
  17272. */
  17273. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17274. /** @hidden */
  17275. protected _reset(): void;
  17276. /** @hidden */
  17277. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17278. /**
  17279. * Instantiates a particle system.
  17280. * 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.
  17281. * @param name The name of the particle system
  17282. */
  17283. constructor(name: string);
  17284. /**
  17285. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17286. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17287. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17288. * @returns the emitter
  17289. */
  17290. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17291. /**
  17292. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17293. * @param radius The radius of the hemisphere to emit from
  17294. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17295. * @returns the emitter
  17296. */
  17297. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17298. /**
  17299. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17300. * @param radius The radius of the sphere to emit from
  17301. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17302. * @returns the emitter
  17303. */
  17304. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17305. /**
  17306. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17307. * @param radius The radius of the sphere to emit from
  17308. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17309. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17310. * @returns the emitter
  17311. */
  17312. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17313. /**
  17314. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17315. * @param radius The radius of the emission cylinder
  17316. * @param height The height of the emission cylinder
  17317. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17318. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17319. * @returns the emitter
  17320. */
  17321. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17322. /**
  17323. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17324. * @param radius The radius of the cylinder to emit from
  17325. * @param height The height of the emission cylinder
  17326. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17329. * @returns the emitter
  17330. */
  17331. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17332. /**
  17333. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17334. * @param radius The radius of the cone to emit from
  17335. * @param angle The base angle of the cone
  17336. * @returns the emitter
  17337. */
  17338. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17339. /**
  17340. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17343. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17344. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17345. * @returns the emitter
  17346. */
  17347. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17348. }
  17349. }
  17350. declare module "babylonjs/Particles/subEmitter" {
  17351. import { Scene } from "babylonjs/scene";
  17352. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17353. /**
  17354. * Type of sub emitter
  17355. */
  17356. export enum SubEmitterType {
  17357. /**
  17358. * Attached to the particle over it's lifetime
  17359. */
  17360. ATTACHED = 0,
  17361. /**
  17362. * Created when the particle dies
  17363. */
  17364. END = 1
  17365. }
  17366. /**
  17367. * Sub emitter class used to emit particles from an existing particle
  17368. */
  17369. export class SubEmitter {
  17370. /**
  17371. * the particle system to be used by the sub emitter
  17372. */
  17373. particleSystem: ParticleSystem;
  17374. /**
  17375. * Type of the submitter (Default: END)
  17376. */
  17377. type: SubEmitterType;
  17378. /**
  17379. * 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)
  17380. * Note: This only is supported when using an emitter of type Mesh
  17381. */
  17382. inheritDirection: boolean;
  17383. /**
  17384. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17385. */
  17386. inheritedVelocityAmount: number;
  17387. /**
  17388. * Creates a sub emitter
  17389. * @param particleSystem the particle system to be used by the sub emitter
  17390. */
  17391. constructor(
  17392. /**
  17393. * the particle system to be used by the sub emitter
  17394. */
  17395. particleSystem: ParticleSystem);
  17396. /**
  17397. * Clones the sub emitter
  17398. * @returns the cloned sub emitter
  17399. */
  17400. clone(): SubEmitter;
  17401. /**
  17402. * Serialize current object to a JSON object
  17403. * @returns the serialized object
  17404. */
  17405. serialize(): any;
  17406. /** @hidden */
  17407. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17408. /**
  17409. * Creates a new SubEmitter from a serialized JSON version
  17410. * @param serializationObject defines the JSON object to read from
  17411. * @param scene defines the hosting scene
  17412. * @param rootUrl defines the rootUrl for data loading
  17413. * @returns a new SubEmitter
  17414. */
  17415. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17416. /** Release associated resources */
  17417. dispose(): void;
  17418. }
  17419. }
  17420. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17421. /** @hidden */
  17422. export var clipPlaneFragmentDeclaration: {
  17423. name: string;
  17424. shader: string;
  17425. };
  17426. }
  17427. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17428. /** @hidden */
  17429. export var imageProcessingDeclaration: {
  17430. name: string;
  17431. shader: string;
  17432. };
  17433. }
  17434. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17435. /** @hidden */
  17436. export var imageProcessingFunctions: {
  17437. name: string;
  17438. shader: string;
  17439. };
  17440. }
  17441. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17442. /** @hidden */
  17443. export var clipPlaneFragment: {
  17444. name: string;
  17445. shader: string;
  17446. };
  17447. }
  17448. declare module "babylonjs/Shaders/particles.fragment" {
  17449. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17450. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17451. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17452. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17453. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17454. /** @hidden */
  17455. export var particlesPixelShader: {
  17456. name: string;
  17457. shader: string;
  17458. };
  17459. }
  17460. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17461. /** @hidden */
  17462. export var clipPlaneVertexDeclaration: {
  17463. name: string;
  17464. shader: string;
  17465. };
  17466. }
  17467. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17468. /** @hidden */
  17469. export var clipPlaneVertex: {
  17470. name: string;
  17471. shader: string;
  17472. };
  17473. }
  17474. declare module "babylonjs/Shaders/particles.vertex" {
  17475. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17476. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17477. /** @hidden */
  17478. export var particlesVertexShader: {
  17479. name: string;
  17480. shader: string;
  17481. };
  17482. }
  17483. declare module "babylonjs/Particles/particleSystem" {
  17484. import { Nullable } from "babylonjs/types";
  17485. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17486. import { Observable } from "babylonjs/Misc/observable";
  17487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17488. import { Effect } from "babylonjs/Materials/effect";
  17489. import { Scene, IDisposable } from "babylonjs/scene";
  17490. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17491. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17492. import { Particle } from "babylonjs/Particles/particle";
  17493. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17494. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17495. import "babylonjs/Shaders/particles.fragment";
  17496. import "babylonjs/Shaders/particles.vertex";
  17497. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17498. /**
  17499. * This represents a particle system in Babylon.
  17500. * 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.
  17501. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17502. * @example https://doc.babylonjs.com/babylon101/particles
  17503. */
  17504. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17505. /**
  17506. * Billboard mode will only apply to Y axis
  17507. */
  17508. static readonly BILLBOARDMODE_Y: number;
  17509. /**
  17510. * Billboard mode will apply to all axes
  17511. */
  17512. static readonly BILLBOARDMODE_ALL: number;
  17513. /**
  17514. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17515. */
  17516. static readonly BILLBOARDMODE_STRETCHED: number;
  17517. /**
  17518. * This function can be defined to provide custom update for active particles.
  17519. * This function will be called instead of regular update (age, position, color, etc.).
  17520. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17521. */
  17522. updateFunction: (particles: Particle[]) => void;
  17523. private _emitterWorldMatrix;
  17524. /**
  17525. * This function can be defined to specify initial direction for every new particle.
  17526. * It by default use the emitterType defined function
  17527. */
  17528. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17529. /**
  17530. * This function can be defined to specify initial position for every new particle.
  17531. * It by default use the emitterType defined function
  17532. */
  17533. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17534. /**
  17535. * @hidden
  17536. */
  17537. _inheritedVelocityOffset: Vector3;
  17538. /**
  17539. * An event triggered when the system is disposed
  17540. */
  17541. onDisposeObservable: Observable<ParticleSystem>;
  17542. private _onDisposeObserver;
  17543. /**
  17544. * Sets a callback that will be triggered when the system is disposed
  17545. */
  17546. onDispose: () => void;
  17547. private _particles;
  17548. private _epsilon;
  17549. private _capacity;
  17550. private _stockParticles;
  17551. private _newPartsExcess;
  17552. private _vertexData;
  17553. private _vertexBuffer;
  17554. private _vertexBuffers;
  17555. private _spriteBuffer;
  17556. private _indexBuffer;
  17557. private _effect;
  17558. private _customEffect;
  17559. private _cachedDefines;
  17560. private _scaledColorStep;
  17561. private _colorDiff;
  17562. private _scaledDirection;
  17563. private _scaledGravity;
  17564. private _currentRenderId;
  17565. private _alive;
  17566. private _useInstancing;
  17567. private _started;
  17568. private _stopped;
  17569. private _actualFrame;
  17570. private _scaledUpdateSpeed;
  17571. private _vertexBufferSize;
  17572. /** @hidden */
  17573. _currentEmitRateGradient: Nullable<FactorGradient>;
  17574. /** @hidden */
  17575. _currentEmitRate1: number;
  17576. /** @hidden */
  17577. _currentEmitRate2: number;
  17578. /** @hidden */
  17579. _currentStartSizeGradient: Nullable<FactorGradient>;
  17580. /** @hidden */
  17581. _currentStartSize1: number;
  17582. /** @hidden */
  17583. _currentStartSize2: number;
  17584. private readonly _rawTextureWidth;
  17585. private _rampGradientsTexture;
  17586. private _useRampGradients;
  17587. /** Gets or sets a boolean indicating that ramp gradients must be used
  17588. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17589. */
  17590. useRampGradients: boolean;
  17591. /**
  17592. * 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.
  17593. * 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: [])
  17594. */
  17595. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17596. private _subEmitters;
  17597. /**
  17598. * @hidden
  17599. * If the particle systems emitter should be disposed when the particle system is disposed
  17600. */
  17601. _disposeEmitterOnDispose: boolean;
  17602. /**
  17603. * The current active Sub-systems, this property is used by the root particle system only.
  17604. */
  17605. activeSubSystems: Array<ParticleSystem>;
  17606. private _rootParticleSystem;
  17607. /**
  17608. * Gets the current list of active particles
  17609. */
  17610. readonly particles: Particle[];
  17611. /**
  17612. * Returns the string "ParticleSystem"
  17613. * @returns a string containing the class name
  17614. */
  17615. getClassName(): string;
  17616. /**
  17617. * Instantiates a particle system.
  17618. * 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.
  17619. * @param name The name of the particle system
  17620. * @param capacity The max number of particles alive at the same time
  17621. * @param scene The scene the particle system belongs to
  17622. * @param customEffect a custom effect used to change the way particles are rendered by default
  17623. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17624. * @param epsilon Offset used to render the particles
  17625. */
  17626. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17627. private _addFactorGradient;
  17628. private _removeFactorGradient;
  17629. /**
  17630. * Adds a new life time gradient
  17631. * @param gradient defines the gradient to use (between 0 and 1)
  17632. * @param factor defines the life time factor to affect to the specified gradient
  17633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17634. * @returns the current particle system
  17635. */
  17636. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17637. /**
  17638. * Remove a specific life time gradient
  17639. * @param gradient defines the gradient to remove
  17640. * @returns the current particle system
  17641. */
  17642. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17643. /**
  17644. * Adds a new size gradient
  17645. * @param gradient defines the gradient to use (between 0 and 1)
  17646. * @param factor defines the size factor to affect to the specified gradient
  17647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17648. * @returns the current particle system
  17649. */
  17650. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17651. /**
  17652. * Remove a specific size gradient
  17653. * @param gradient defines the gradient to remove
  17654. * @returns the current particle system
  17655. */
  17656. removeSizeGradient(gradient: number): IParticleSystem;
  17657. /**
  17658. * Adds a new color remap gradient
  17659. * @param gradient defines the gradient to use (between 0 and 1)
  17660. * @param min defines the color remap minimal range
  17661. * @param max defines the color remap maximal range
  17662. * @returns the current particle system
  17663. */
  17664. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17665. /**
  17666. * Remove a specific color remap gradient
  17667. * @param gradient defines the gradient to remove
  17668. * @returns the current particle system
  17669. */
  17670. removeColorRemapGradient(gradient: number): IParticleSystem;
  17671. /**
  17672. * Adds a new alpha remap gradient
  17673. * @param gradient defines the gradient to use (between 0 and 1)
  17674. * @param min defines the alpha remap minimal range
  17675. * @param max defines the alpha remap maximal range
  17676. * @returns the current particle system
  17677. */
  17678. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17679. /**
  17680. * Remove a specific alpha remap gradient
  17681. * @param gradient defines the gradient to remove
  17682. * @returns the current particle system
  17683. */
  17684. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17685. /**
  17686. * Adds a new angular speed gradient
  17687. * @param gradient defines the gradient to use (between 0 and 1)
  17688. * @param factor defines the angular speed to affect to the specified gradient
  17689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17690. * @returns the current particle system
  17691. */
  17692. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17693. /**
  17694. * Remove a specific angular speed gradient
  17695. * @param gradient defines the gradient to remove
  17696. * @returns the current particle system
  17697. */
  17698. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17699. /**
  17700. * Adds a new velocity gradient
  17701. * @param gradient defines the gradient to use (between 0 and 1)
  17702. * @param factor defines the velocity to affect to the specified gradient
  17703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17704. * @returns the current particle system
  17705. */
  17706. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17707. /**
  17708. * Remove a specific velocity gradient
  17709. * @param gradient defines the gradient to remove
  17710. * @returns the current particle system
  17711. */
  17712. removeVelocityGradient(gradient: number): IParticleSystem;
  17713. /**
  17714. * Adds a new limit velocity gradient
  17715. * @param gradient defines the gradient to use (between 0 and 1)
  17716. * @param factor defines the limit velocity value to affect to the specified gradient
  17717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17718. * @returns the current particle system
  17719. */
  17720. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17721. /**
  17722. * Remove a specific limit velocity gradient
  17723. * @param gradient defines the gradient to remove
  17724. * @returns the current particle system
  17725. */
  17726. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17727. /**
  17728. * Adds a new drag gradient
  17729. * @param gradient defines the gradient to use (between 0 and 1)
  17730. * @param factor defines the drag value to affect to the specified gradient
  17731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17732. * @returns the current particle system
  17733. */
  17734. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17735. /**
  17736. * Remove a specific drag gradient
  17737. * @param gradient defines the gradient to remove
  17738. * @returns the current particle system
  17739. */
  17740. removeDragGradient(gradient: number): IParticleSystem;
  17741. /**
  17742. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17743. * @param gradient defines the gradient to use (between 0 and 1)
  17744. * @param factor defines the emit rate value to affect to the specified gradient
  17745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17746. * @returns the current particle system
  17747. */
  17748. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17749. /**
  17750. * Remove a specific emit rate gradient
  17751. * @param gradient defines the gradient to remove
  17752. * @returns the current particle system
  17753. */
  17754. removeEmitRateGradient(gradient: number): IParticleSystem;
  17755. /**
  17756. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17757. * @param gradient defines the gradient to use (between 0 and 1)
  17758. * @param factor defines the start size value to affect to the specified gradient
  17759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17760. * @returns the current particle system
  17761. */
  17762. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17763. /**
  17764. * Remove a specific start size gradient
  17765. * @param gradient defines the gradient to remove
  17766. * @returns the current particle system
  17767. */
  17768. removeStartSizeGradient(gradient: number): IParticleSystem;
  17769. private _createRampGradientTexture;
  17770. /**
  17771. * Gets the current list of ramp gradients.
  17772. * You must use addRampGradient and removeRampGradient to udpate this list
  17773. * @returns the list of ramp gradients
  17774. */
  17775. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17776. /**
  17777. * Adds a new ramp gradient used to remap particle colors
  17778. * @param gradient defines the gradient to use (between 0 and 1)
  17779. * @param color defines the color to affect to the specified gradient
  17780. * @returns the current particle system
  17781. */
  17782. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17783. /**
  17784. * Remove a specific ramp gradient
  17785. * @param gradient defines the gradient to remove
  17786. * @returns the current particle system
  17787. */
  17788. removeRampGradient(gradient: number): ParticleSystem;
  17789. /**
  17790. * Adds a new color gradient
  17791. * @param gradient defines the gradient to use (between 0 and 1)
  17792. * @param color1 defines the color to affect to the specified gradient
  17793. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17794. * @returns this particle system
  17795. */
  17796. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17797. /**
  17798. * Remove a specific color gradient
  17799. * @param gradient defines the gradient to remove
  17800. * @returns this particle system
  17801. */
  17802. removeColorGradient(gradient: number): IParticleSystem;
  17803. private _fetchR;
  17804. protected _reset(): void;
  17805. private _resetEffect;
  17806. private _createVertexBuffers;
  17807. private _createIndexBuffer;
  17808. /**
  17809. * Gets the maximum number of particles active at the same time.
  17810. * @returns The max number of active particles.
  17811. */
  17812. getCapacity(): number;
  17813. /**
  17814. * Gets whether there are still active particles in the system.
  17815. * @returns True if it is alive, otherwise false.
  17816. */
  17817. isAlive(): boolean;
  17818. /**
  17819. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17820. * @returns True if it has been started, otherwise false.
  17821. */
  17822. isStarted(): boolean;
  17823. private _prepareSubEmitterInternalArray;
  17824. /**
  17825. * Starts the particle system and begins to emit
  17826. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17827. */
  17828. start(delay?: number): void;
  17829. /**
  17830. * Stops the particle system.
  17831. * @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.
  17832. */
  17833. stop(stopSubEmitters?: boolean): void;
  17834. /**
  17835. * Remove all active particles
  17836. */
  17837. reset(): void;
  17838. /**
  17839. * @hidden (for internal use only)
  17840. */
  17841. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17842. /**
  17843. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17844. * Its lifetime will start back at 0.
  17845. */
  17846. recycleParticle: (particle: Particle) => void;
  17847. private _stopSubEmitters;
  17848. private _createParticle;
  17849. private _removeFromRoot;
  17850. private _emitFromParticle;
  17851. private _update;
  17852. /** @hidden */
  17853. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17854. /** @hidden */
  17855. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17856. /** @hidden */
  17857. private _getEffect;
  17858. /**
  17859. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17860. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17861. */
  17862. animate(preWarmOnly?: boolean): void;
  17863. private _appendParticleVertices;
  17864. /**
  17865. * Rebuilds the particle system.
  17866. */
  17867. rebuild(): void;
  17868. /**
  17869. * Is this system ready to be used/rendered
  17870. * @return true if the system is ready
  17871. */
  17872. isReady(): boolean;
  17873. private _render;
  17874. /**
  17875. * Renders the particle system in its current state.
  17876. * @returns the current number of particles
  17877. */
  17878. render(): number;
  17879. /**
  17880. * Disposes the particle system and free the associated resources
  17881. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17882. */
  17883. dispose(disposeTexture?: boolean): void;
  17884. /**
  17885. * Clones the particle system.
  17886. * @param name The name of the cloned object
  17887. * @param newEmitter The new emitter to use
  17888. * @returns the cloned particle system
  17889. */
  17890. clone(name: string, newEmitter: any): ParticleSystem;
  17891. /**
  17892. * Serializes the particle system to a JSON object.
  17893. * @returns the JSON object
  17894. */
  17895. serialize(): any;
  17896. /** @hidden */
  17897. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17898. /** @hidden */
  17899. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17900. /**
  17901. * Parses a JSON object to create a particle system.
  17902. * @param parsedParticleSystem The JSON object to parse
  17903. * @param scene The scene to create the particle system in
  17904. * @param rootUrl The root url to use to load external dependencies like texture
  17905. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17906. * @returns the Parsed particle system
  17907. */
  17908. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17909. }
  17910. }
  17911. declare module "babylonjs/Particles/particle" {
  17912. import { Nullable } from "babylonjs/types";
  17913. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17914. import { Color4 } from "babylonjs/Maths/math.color";
  17915. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17916. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17917. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17918. /**
  17919. * A particle represents one of the element emitted by a particle system.
  17920. * This is mainly define by its coordinates, direction, velocity and age.
  17921. */
  17922. export class Particle {
  17923. /**
  17924. * The particle system the particle belongs to.
  17925. */
  17926. particleSystem: ParticleSystem;
  17927. private static _Count;
  17928. /**
  17929. * Unique ID of the particle
  17930. */
  17931. id: number;
  17932. /**
  17933. * The world position of the particle in the scene.
  17934. */
  17935. position: Vector3;
  17936. /**
  17937. * The world direction of the particle in the scene.
  17938. */
  17939. direction: Vector3;
  17940. /**
  17941. * The color of the particle.
  17942. */
  17943. color: Color4;
  17944. /**
  17945. * The color change of the particle per step.
  17946. */
  17947. colorStep: Color4;
  17948. /**
  17949. * Defines how long will the life of the particle be.
  17950. */
  17951. lifeTime: number;
  17952. /**
  17953. * The current age of the particle.
  17954. */
  17955. age: number;
  17956. /**
  17957. * The current size of the particle.
  17958. */
  17959. size: number;
  17960. /**
  17961. * The current scale of the particle.
  17962. */
  17963. scale: Vector2;
  17964. /**
  17965. * The current angle of the particle.
  17966. */
  17967. angle: number;
  17968. /**
  17969. * Defines how fast is the angle changing.
  17970. */
  17971. angularSpeed: number;
  17972. /**
  17973. * Defines the cell index used by the particle to be rendered from a sprite.
  17974. */
  17975. cellIndex: number;
  17976. /**
  17977. * The information required to support color remapping
  17978. */
  17979. remapData: Vector4;
  17980. /** @hidden */
  17981. _randomCellOffset?: number;
  17982. /** @hidden */
  17983. _initialDirection: Nullable<Vector3>;
  17984. /** @hidden */
  17985. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17986. /** @hidden */
  17987. _initialStartSpriteCellID: number;
  17988. /** @hidden */
  17989. _initialEndSpriteCellID: number;
  17990. /** @hidden */
  17991. _currentColorGradient: Nullable<ColorGradient>;
  17992. /** @hidden */
  17993. _currentColor1: Color4;
  17994. /** @hidden */
  17995. _currentColor2: Color4;
  17996. /** @hidden */
  17997. _currentSizeGradient: Nullable<FactorGradient>;
  17998. /** @hidden */
  17999. _currentSize1: number;
  18000. /** @hidden */
  18001. _currentSize2: number;
  18002. /** @hidden */
  18003. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18004. /** @hidden */
  18005. _currentAngularSpeed1: number;
  18006. /** @hidden */
  18007. _currentAngularSpeed2: number;
  18008. /** @hidden */
  18009. _currentVelocityGradient: Nullable<FactorGradient>;
  18010. /** @hidden */
  18011. _currentVelocity1: number;
  18012. /** @hidden */
  18013. _currentVelocity2: number;
  18014. /** @hidden */
  18015. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18016. /** @hidden */
  18017. _currentLimitVelocity1: number;
  18018. /** @hidden */
  18019. _currentLimitVelocity2: number;
  18020. /** @hidden */
  18021. _currentDragGradient: Nullable<FactorGradient>;
  18022. /** @hidden */
  18023. _currentDrag1: number;
  18024. /** @hidden */
  18025. _currentDrag2: number;
  18026. /** @hidden */
  18027. _randomNoiseCoordinates1: Vector3;
  18028. /** @hidden */
  18029. _randomNoiseCoordinates2: Vector3;
  18030. /**
  18031. * Creates a new instance Particle
  18032. * @param particleSystem the particle system the particle belongs to
  18033. */
  18034. constructor(
  18035. /**
  18036. * The particle system the particle belongs to.
  18037. */
  18038. particleSystem: ParticleSystem);
  18039. private updateCellInfoFromSystem;
  18040. /**
  18041. * Defines how the sprite cell index is updated for the particle
  18042. */
  18043. updateCellIndex(): void;
  18044. /** @hidden */
  18045. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18046. /** @hidden */
  18047. _inheritParticleInfoToSubEmitters(): void;
  18048. /** @hidden */
  18049. _reset(): void;
  18050. /**
  18051. * Copy the properties of particle to another one.
  18052. * @param other the particle to copy the information to.
  18053. */
  18054. copyTo(other: Particle): void;
  18055. }
  18056. }
  18057. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18058. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18059. import { Effect } from "babylonjs/Materials/effect";
  18060. import { Particle } from "babylonjs/Particles/particle";
  18061. /**
  18062. * Particle emitter represents a volume emitting particles.
  18063. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18064. */
  18065. export interface IParticleEmitterType {
  18066. /**
  18067. * Called by the particle System when the direction is computed for the created particle.
  18068. * @param worldMatrix is the world matrix of the particle system
  18069. * @param directionToUpdate is the direction vector to update with the result
  18070. * @param particle is the particle we are computed the direction for
  18071. */
  18072. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18073. /**
  18074. * Called by the particle System when the position is computed for the created particle.
  18075. * @param worldMatrix is the world matrix of the particle system
  18076. * @param positionToUpdate is the position vector to update with the result
  18077. * @param particle is the particle we are computed the position for
  18078. */
  18079. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18080. /**
  18081. * Clones the current emitter and returns a copy of it
  18082. * @returns the new emitter
  18083. */
  18084. clone(): IParticleEmitterType;
  18085. /**
  18086. * Called by the GPUParticleSystem to setup the update shader
  18087. * @param effect defines the update shader
  18088. */
  18089. applyToShader(effect: Effect): void;
  18090. /**
  18091. * Returns a string to use to update the GPU particles update shader
  18092. * @returns the effect defines string
  18093. */
  18094. getEffectDefines(): string;
  18095. /**
  18096. * Returns a string representing the class name
  18097. * @returns a string containing the class name
  18098. */
  18099. getClassName(): string;
  18100. /**
  18101. * Serializes the particle system to a JSON object.
  18102. * @returns the JSON object
  18103. */
  18104. serialize(): any;
  18105. /**
  18106. * Parse properties from a JSON object
  18107. * @param serializationObject defines the JSON object
  18108. */
  18109. parse(serializationObject: any): void;
  18110. }
  18111. }
  18112. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18113. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18114. import { Effect } from "babylonjs/Materials/effect";
  18115. import { Particle } from "babylonjs/Particles/particle";
  18116. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18117. /**
  18118. * Particle emitter emitting particles from the inside of a box.
  18119. * It emits the particles randomly between 2 given directions.
  18120. */
  18121. export class BoxParticleEmitter implements IParticleEmitterType {
  18122. /**
  18123. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18124. */
  18125. direction1: Vector3;
  18126. /**
  18127. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18128. */
  18129. direction2: Vector3;
  18130. /**
  18131. * 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.
  18132. */
  18133. minEmitBox: Vector3;
  18134. /**
  18135. * 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.
  18136. */
  18137. maxEmitBox: Vector3;
  18138. /**
  18139. * Creates a new instance BoxParticleEmitter
  18140. */
  18141. constructor();
  18142. /**
  18143. * Called by the particle System when the direction is computed for the created particle.
  18144. * @param worldMatrix is the world matrix of the particle system
  18145. * @param directionToUpdate is the direction vector to update with the result
  18146. * @param particle is the particle we are computed the direction for
  18147. */
  18148. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18149. /**
  18150. * Called by the particle System when the position is computed for the created particle.
  18151. * @param worldMatrix is the world matrix of the particle system
  18152. * @param positionToUpdate is the position vector to update with the result
  18153. * @param particle is the particle we are computed the position for
  18154. */
  18155. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18156. /**
  18157. * Clones the current emitter and returns a copy of it
  18158. * @returns the new emitter
  18159. */
  18160. clone(): BoxParticleEmitter;
  18161. /**
  18162. * Called by the GPUParticleSystem to setup the update shader
  18163. * @param effect defines the update shader
  18164. */
  18165. applyToShader(effect: Effect): void;
  18166. /**
  18167. * Returns a string to use to update the GPU particles update shader
  18168. * @returns a string containng the defines string
  18169. */
  18170. getEffectDefines(): string;
  18171. /**
  18172. * Returns the string "BoxParticleEmitter"
  18173. * @returns a string containing the class name
  18174. */
  18175. getClassName(): string;
  18176. /**
  18177. * Serializes the particle system to a JSON object.
  18178. * @returns the JSON object
  18179. */
  18180. serialize(): any;
  18181. /**
  18182. * Parse properties from a JSON object
  18183. * @param serializationObject defines the JSON object
  18184. */
  18185. parse(serializationObject: any): void;
  18186. }
  18187. }
  18188. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18189. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18190. import { Effect } from "babylonjs/Materials/effect";
  18191. import { Particle } from "babylonjs/Particles/particle";
  18192. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18193. /**
  18194. * Particle emitter emitting particles from the inside of a cone.
  18195. * It emits the particles alongside the cone volume from the base to the particle.
  18196. * The emission direction might be randomized.
  18197. */
  18198. export class ConeParticleEmitter implements IParticleEmitterType {
  18199. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18200. directionRandomizer: number;
  18201. private _radius;
  18202. private _angle;
  18203. private _height;
  18204. /**
  18205. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18206. */
  18207. radiusRange: number;
  18208. /**
  18209. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18210. */
  18211. heightRange: number;
  18212. /**
  18213. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18214. */
  18215. emitFromSpawnPointOnly: boolean;
  18216. /**
  18217. * Gets or sets the radius of the emission cone
  18218. */
  18219. radius: number;
  18220. /**
  18221. * Gets or sets the angle of the emission cone
  18222. */
  18223. angle: number;
  18224. private _buildHeight;
  18225. /**
  18226. * Creates a new instance ConeParticleEmitter
  18227. * @param radius the radius of the emission cone (1 by default)
  18228. * @param angle the cone base angle (PI by default)
  18229. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18230. */
  18231. constructor(radius?: number, angle?: number,
  18232. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18233. directionRandomizer?: number);
  18234. /**
  18235. * Called by the particle System when the direction is computed for the created particle.
  18236. * @param worldMatrix is the world matrix of the particle system
  18237. * @param directionToUpdate is the direction vector to update with the result
  18238. * @param particle is the particle we are computed the direction for
  18239. */
  18240. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18241. /**
  18242. * Called by the particle System when the position is computed for the created particle.
  18243. * @param worldMatrix is the world matrix of the particle system
  18244. * @param positionToUpdate is the position vector to update with the result
  18245. * @param particle is the particle we are computed the position for
  18246. */
  18247. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18248. /**
  18249. * Clones the current emitter and returns a copy of it
  18250. * @returns the new emitter
  18251. */
  18252. clone(): ConeParticleEmitter;
  18253. /**
  18254. * Called by the GPUParticleSystem to setup the update shader
  18255. * @param effect defines the update shader
  18256. */
  18257. applyToShader(effect: Effect): void;
  18258. /**
  18259. * Returns a string to use to update the GPU particles update shader
  18260. * @returns a string containng the defines string
  18261. */
  18262. getEffectDefines(): string;
  18263. /**
  18264. * Returns the string "ConeParticleEmitter"
  18265. * @returns a string containing the class name
  18266. */
  18267. getClassName(): string;
  18268. /**
  18269. * Serializes the particle system to a JSON object.
  18270. * @returns the JSON object
  18271. */
  18272. serialize(): any;
  18273. /**
  18274. * Parse properties from a JSON object
  18275. * @param serializationObject defines the JSON object
  18276. */
  18277. parse(serializationObject: any): void;
  18278. }
  18279. }
  18280. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18281. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18282. import { Effect } from "babylonjs/Materials/effect";
  18283. import { Particle } from "babylonjs/Particles/particle";
  18284. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18285. /**
  18286. * Particle emitter emitting particles from the inside of a cylinder.
  18287. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18288. */
  18289. export class CylinderParticleEmitter implements IParticleEmitterType {
  18290. /**
  18291. * The radius of the emission cylinder.
  18292. */
  18293. radius: number;
  18294. /**
  18295. * The height of the emission cylinder.
  18296. */
  18297. height: number;
  18298. /**
  18299. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18300. */
  18301. radiusRange: number;
  18302. /**
  18303. * How much to randomize the particle direction [0-1].
  18304. */
  18305. directionRandomizer: number;
  18306. /**
  18307. * Creates a new instance CylinderParticleEmitter
  18308. * @param radius the radius of the emission cylinder (1 by default)
  18309. * @param height the height of the emission cylinder (1 by default)
  18310. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18311. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18312. */
  18313. constructor(
  18314. /**
  18315. * The radius of the emission cylinder.
  18316. */
  18317. radius?: number,
  18318. /**
  18319. * The height of the emission cylinder.
  18320. */
  18321. height?: number,
  18322. /**
  18323. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18324. */
  18325. radiusRange?: number,
  18326. /**
  18327. * How much to randomize the particle direction [0-1].
  18328. */
  18329. directionRandomizer?: number);
  18330. /**
  18331. * Called by the particle System when the direction is computed for the created particle.
  18332. * @param worldMatrix is the world matrix of the particle system
  18333. * @param directionToUpdate is the direction vector to update with the result
  18334. * @param particle is the particle we are computed the direction for
  18335. */
  18336. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18337. /**
  18338. * Called by the particle System when the position is computed for the created particle.
  18339. * @param worldMatrix is the world matrix of the particle system
  18340. * @param positionToUpdate is the position vector to update with the result
  18341. * @param particle is the particle we are computed the position for
  18342. */
  18343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18344. /**
  18345. * Clones the current emitter and returns a copy of it
  18346. * @returns the new emitter
  18347. */
  18348. clone(): CylinderParticleEmitter;
  18349. /**
  18350. * Called by the GPUParticleSystem to setup the update shader
  18351. * @param effect defines the update shader
  18352. */
  18353. applyToShader(effect: Effect): void;
  18354. /**
  18355. * Returns a string to use to update the GPU particles update shader
  18356. * @returns a string containng the defines string
  18357. */
  18358. getEffectDefines(): string;
  18359. /**
  18360. * Returns the string "CylinderParticleEmitter"
  18361. * @returns a string containing the class name
  18362. */
  18363. getClassName(): string;
  18364. /**
  18365. * Serializes the particle system to a JSON object.
  18366. * @returns the JSON object
  18367. */
  18368. serialize(): any;
  18369. /**
  18370. * Parse properties from a JSON object
  18371. * @param serializationObject defines the JSON object
  18372. */
  18373. parse(serializationObject: any): void;
  18374. }
  18375. /**
  18376. * Particle emitter emitting particles from the inside of a cylinder.
  18377. * It emits the particles randomly between two vectors.
  18378. */
  18379. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18380. /**
  18381. * The min limit of the emission direction.
  18382. */
  18383. direction1: Vector3;
  18384. /**
  18385. * The max limit of the emission direction.
  18386. */
  18387. direction2: Vector3;
  18388. /**
  18389. * Creates a new instance CylinderDirectedParticleEmitter
  18390. * @param radius the radius of the emission cylinder (1 by default)
  18391. * @param height the height of the emission cylinder (1 by default)
  18392. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18393. * @param direction1 the min limit of the emission direction (up vector by default)
  18394. * @param direction2 the max limit of the emission direction (up vector by default)
  18395. */
  18396. constructor(radius?: number, height?: number, radiusRange?: number,
  18397. /**
  18398. * The min limit of the emission direction.
  18399. */
  18400. direction1?: Vector3,
  18401. /**
  18402. * The max limit of the emission direction.
  18403. */
  18404. direction2?: Vector3);
  18405. /**
  18406. * Called by the particle System when the direction is computed for the created particle.
  18407. * @param worldMatrix is the world matrix of the particle system
  18408. * @param directionToUpdate is the direction vector to update with the result
  18409. * @param particle is the particle we are computed the direction for
  18410. */
  18411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18412. /**
  18413. * Clones the current emitter and returns a copy of it
  18414. * @returns the new emitter
  18415. */
  18416. clone(): CylinderDirectedParticleEmitter;
  18417. /**
  18418. * Called by the GPUParticleSystem to setup the update shader
  18419. * @param effect defines the update shader
  18420. */
  18421. applyToShader(effect: Effect): void;
  18422. /**
  18423. * Returns a string to use to update the GPU particles update shader
  18424. * @returns a string containng the defines string
  18425. */
  18426. getEffectDefines(): string;
  18427. /**
  18428. * Returns the string "CylinderDirectedParticleEmitter"
  18429. * @returns a string containing the class name
  18430. */
  18431. getClassName(): string;
  18432. /**
  18433. * Serializes the particle system to a JSON object.
  18434. * @returns the JSON object
  18435. */
  18436. serialize(): any;
  18437. /**
  18438. * Parse properties from a JSON object
  18439. * @param serializationObject defines the JSON object
  18440. */
  18441. parse(serializationObject: any): void;
  18442. }
  18443. }
  18444. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18445. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18446. import { Effect } from "babylonjs/Materials/effect";
  18447. import { Particle } from "babylonjs/Particles/particle";
  18448. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18449. /**
  18450. * Particle emitter emitting particles from the inside of a hemisphere.
  18451. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18452. */
  18453. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18454. /**
  18455. * The radius of the emission hemisphere.
  18456. */
  18457. radius: number;
  18458. /**
  18459. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18460. */
  18461. radiusRange: number;
  18462. /**
  18463. * How much to randomize the particle direction [0-1].
  18464. */
  18465. directionRandomizer: number;
  18466. /**
  18467. * Creates a new instance HemisphericParticleEmitter
  18468. * @param radius the radius of the emission hemisphere (1 by default)
  18469. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18470. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18471. */
  18472. constructor(
  18473. /**
  18474. * The radius of the emission hemisphere.
  18475. */
  18476. radius?: number,
  18477. /**
  18478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18479. */
  18480. radiusRange?: number,
  18481. /**
  18482. * How much to randomize the particle direction [0-1].
  18483. */
  18484. directionRandomizer?: number);
  18485. /**
  18486. * Called by the particle System when the direction is computed for the created particle.
  18487. * @param worldMatrix is the world matrix of the particle system
  18488. * @param directionToUpdate is the direction vector to update with the result
  18489. * @param particle is the particle we are computed the direction for
  18490. */
  18491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18492. /**
  18493. * Called by the particle System when the position is computed for the created particle.
  18494. * @param worldMatrix is the world matrix of the particle system
  18495. * @param positionToUpdate is the position vector to update with the result
  18496. * @param particle is the particle we are computed the position for
  18497. */
  18498. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18499. /**
  18500. * Clones the current emitter and returns a copy of it
  18501. * @returns the new emitter
  18502. */
  18503. clone(): HemisphericParticleEmitter;
  18504. /**
  18505. * Called by the GPUParticleSystem to setup the update shader
  18506. * @param effect defines the update shader
  18507. */
  18508. applyToShader(effect: Effect): void;
  18509. /**
  18510. * Returns a string to use to update the GPU particles update shader
  18511. * @returns a string containng the defines string
  18512. */
  18513. getEffectDefines(): string;
  18514. /**
  18515. * Returns the string "HemisphericParticleEmitter"
  18516. * @returns a string containing the class name
  18517. */
  18518. getClassName(): string;
  18519. /**
  18520. * Serializes the particle system to a JSON object.
  18521. * @returns the JSON object
  18522. */
  18523. serialize(): any;
  18524. /**
  18525. * Parse properties from a JSON object
  18526. * @param serializationObject defines the JSON object
  18527. */
  18528. parse(serializationObject: any): void;
  18529. }
  18530. }
  18531. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18532. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18533. import { Effect } from "babylonjs/Materials/effect";
  18534. import { Particle } from "babylonjs/Particles/particle";
  18535. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18536. /**
  18537. * Particle emitter emitting particles from a point.
  18538. * It emits the particles randomly between 2 given directions.
  18539. */
  18540. export class PointParticleEmitter implements IParticleEmitterType {
  18541. /**
  18542. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18543. */
  18544. direction1: Vector3;
  18545. /**
  18546. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18547. */
  18548. direction2: Vector3;
  18549. /**
  18550. * Creates a new instance PointParticleEmitter
  18551. */
  18552. constructor();
  18553. /**
  18554. * Called by the particle System when the direction is computed for the created particle.
  18555. * @param worldMatrix is the world matrix of the particle system
  18556. * @param directionToUpdate is the direction vector to update with the result
  18557. * @param particle is the particle we are computed the direction for
  18558. */
  18559. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18560. /**
  18561. * Called by the particle System when the position is computed for the created particle.
  18562. * @param worldMatrix is the world matrix of the particle system
  18563. * @param positionToUpdate is the position vector to update with the result
  18564. * @param particle is the particle we are computed the position for
  18565. */
  18566. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18567. /**
  18568. * Clones the current emitter and returns a copy of it
  18569. * @returns the new emitter
  18570. */
  18571. clone(): PointParticleEmitter;
  18572. /**
  18573. * Called by the GPUParticleSystem to setup the update shader
  18574. * @param effect defines the update shader
  18575. */
  18576. applyToShader(effect: Effect): void;
  18577. /**
  18578. * Returns a string to use to update the GPU particles update shader
  18579. * @returns a string containng the defines string
  18580. */
  18581. getEffectDefines(): string;
  18582. /**
  18583. * Returns the string "PointParticleEmitter"
  18584. * @returns a string containing the class name
  18585. */
  18586. getClassName(): string;
  18587. /**
  18588. * Serializes the particle system to a JSON object.
  18589. * @returns the JSON object
  18590. */
  18591. serialize(): any;
  18592. /**
  18593. * Parse properties from a JSON object
  18594. * @param serializationObject defines the JSON object
  18595. */
  18596. parse(serializationObject: any): void;
  18597. }
  18598. }
  18599. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18600. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18601. import { Effect } from "babylonjs/Materials/effect";
  18602. import { Particle } from "babylonjs/Particles/particle";
  18603. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18604. /**
  18605. * Particle emitter emitting particles from the inside of a sphere.
  18606. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18607. */
  18608. export class SphereParticleEmitter implements IParticleEmitterType {
  18609. /**
  18610. * The radius of the emission sphere.
  18611. */
  18612. radius: number;
  18613. /**
  18614. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18615. */
  18616. radiusRange: number;
  18617. /**
  18618. * How much to randomize the particle direction [0-1].
  18619. */
  18620. directionRandomizer: number;
  18621. /**
  18622. * Creates a new instance SphereParticleEmitter
  18623. * @param radius the radius of the emission sphere (1 by default)
  18624. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18625. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18626. */
  18627. constructor(
  18628. /**
  18629. * The radius of the emission sphere.
  18630. */
  18631. radius?: number,
  18632. /**
  18633. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18634. */
  18635. radiusRange?: number,
  18636. /**
  18637. * How much to randomize the particle direction [0-1].
  18638. */
  18639. directionRandomizer?: number);
  18640. /**
  18641. * Called by the particle System when the direction is computed for the created particle.
  18642. * @param worldMatrix is the world matrix of the particle system
  18643. * @param directionToUpdate is the direction vector to update with the result
  18644. * @param particle is the particle we are computed the direction for
  18645. */
  18646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18647. /**
  18648. * Called by the particle System when the position is computed for the created particle.
  18649. * @param worldMatrix is the world matrix of the particle system
  18650. * @param positionToUpdate is the position vector to update with the result
  18651. * @param particle is the particle we are computed the position for
  18652. */
  18653. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18654. /**
  18655. * Clones the current emitter and returns a copy of it
  18656. * @returns the new emitter
  18657. */
  18658. clone(): SphereParticleEmitter;
  18659. /**
  18660. * Called by the GPUParticleSystem to setup the update shader
  18661. * @param effect defines the update shader
  18662. */
  18663. applyToShader(effect: Effect): void;
  18664. /**
  18665. * Returns a string to use to update the GPU particles update shader
  18666. * @returns a string containng the defines string
  18667. */
  18668. getEffectDefines(): string;
  18669. /**
  18670. * Returns the string "SphereParticleEmitter"
  18671. * @returns a string containing the class name
  18672. */
  18673. getClassName(): string;
  18674. /**
  18675. * Serializes the particle system to a JSON object.
  18676. * @returns the JSON object
  18677. */
  18678. serialize(): any;
  18679. /**
  18680. * Parse properties from a JSON object
  18681. * @param serializationObject defines the JSON object
  18682. */
  18683. parse(serializationObject: any): void;
  18684. }
  18685. /**
  18686. * Particle emitter emitting particles from the inside of a sphere.
  18687. * It emits the particles randomly between two vectors.
  18688. */
  18689. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18690. /**
  18691. * The min limit of the emission direction.
  18692. */
  18693. direction1: Vector3;
  18694. /**
  18695. * The max limit of the emission direction.
  18696. */
  18697. direction2: Vector3;
  18698. /**
  18699. * Creates a new instance SphereDirectedParticleEmitter
  18700. * @param radius the radius of the emission sphere (1 by default)
  18701. * @param direction1 the min limit of the emission direction (up vector by default)
  18702. * @param direction2 the max limit of the emission direction (up vector by default)
  18703. */
  18704. constructor(radius?: number,
  18705. /**
  18706. * The min limit of the emission direction.
  18707. */
  18708. direction1?: Vector3,
  18709. /**
  18710. * The max limit of the emission direction.
  18711. */
  18712. direction2?: Vector3);
  18713. /**
  18714. * Called by the particle System when the direction is computed for the created particle.
  18715. * @param worldMatrix is the world matrix of the particle system
  18716. * @param directionToUpdate is the direction vector to update with the result
  18717. * @param particle is the particle we are computed the direction for
  18718. */
  18719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18720. /**
  18721. * Clones the current emitter and returns a copy of it
  18722. * @returns the new emitter
  18723. */
  18724. clone(): SphereDirectedParticleEmitter;
  18725. /**
  18726. * Called by the GPUParticleSystem to setup the update shader
  18727. * @param effect defines the update shader
  18728. */
  18729. applyToShader(effect: Effect): void;
  18730. /**
  18731. * Returns a string to use to update the GPU particles update shader
  18732. * @returns a string containng the defines string
  18733. */
  18734. getEffectDefines(): string;
  18735. /**
  18736. * Returns the string "SphereDirectedParticleEmitter"
  18737. * @returns a string containing the class name
  18738. */
  18739. getClassName(): string;
  18740. /**
  18741. * Serializes the particle system to a JSON object.
  18742. * @returns the JSON object
  18743. */
  18744. serialize(): any;
  18745. /**
  18746. * Parse properties from a JSON object
  18747. * @param serializationObject defines the JSON object
  18748. */
  18749. parse(serializationObject: any): void;
  18750. }
  18751. }
  18752. declare module "babylonjs/Particles/EmitterTypes/index" {
  18753. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18754. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18755. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18756. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18757. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18758. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18759. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18760. }
  18761. declare module "babylonjs/Particles/IParticleSystem" {
  18762. import { Nullable } from "babylonjs/types";
  18763. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18764. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18767. import { Texture } from "babylonjs/Materials/Textures/texture";
  18768. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18769. import { Scene } from "babylonjs/scene";
  18770. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18771. import { Animation } from "babylonjs/Animations/animation";
  18772. /**
  18773. * Interface representing a particle system in Babylon.js.
  18774. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18775. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18776. */
  18777. export interface IParticleSystem {
  18778. /**
  18779. * List of animations used by the particle system.
  18780. */
  18781. animations: Animation[];
  18782. /**
  18783. * The id of the Particle system.
  18784. */
  18785. id: string;
  18786. /**
  18787. * The name of the Particle system.
  18788. */
  18789. name: string;
  18790. /**
  18791. * The emitter represents the Mesh or position we are attaching the particle system to.
  18792. */
  18793. emitter: Nullable<AbstractMesh | Vector3>;
  18794. /**
  18795. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18796. */
  18797. isBillboardBased: boolean;
  18798. /**
  18799. * The rendering group used by the Particle system to chose when to render.
  18800. */
  18801. renderingGroupId: number;
  18802. /**
  18803. * The layer mask we are rendering the particles through.
  18804. */
  18805. layerMask: number;
  18806. /**
  18807. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18808. */
  18809. updateSpeed: number;
  18810. /**
  18811. * The amount of time the particle system is running (depends of the overall update speed).
  18812. */
  18813. targetStopDuration: number;
  18814. /**
  18815. * The texture used to render each particle. (this can be a spritesheet)
  18816. */
  18817. particleTexture: Nullable<Texture>;
  18818. /**
  18819. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18820. */
  18821. blendMode: number;
  18822. /**
  18823. * Minimum life time of emitting particles.
  18824. */
  18825. minLifeTime: number;
  18826. /**
  18827. * Maximum life time of emitting particles.
  18828. */
  18829. maxLifeTime: number;
  18830. /**
  18831. * Minimum Size of emitting particles.
  18832. */
  18833. minSize: number;
  18834. /**
  18835. * Maximum Size of emitting particles.
  18836. */
  18837. maxSize: number;
  18838. /**
  18839. * Minimum scale of emitting particles on X axis.
  18840. */
  18841. minScaleX: number;
  18842. /**
  18843. * Maximum scale of emitting particles on X axis.
  18844. */
  18845. maxScaleX: number;
  18846. /**
  18847. * Minimum scale of emitting particles on Y axis.
  18848. */
  18849. minScaleY: number;
  18850. /**
  18851. * Maximum scale of emitting particles on Y axis.
  18852. */
  18853. maxScaleY: number;
  18854. /**
  18855. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18856. */
  18857. color1: Color4;
  18858. /**
  18859. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18860. */
  18861. color2: Color4;
  18862. /**
  18863. * Color the particle will have at the end of its lifetime.
  18864. */
  18865. colorDead: Color4;
  18866. /**
  18867. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18868. */
  18869. emitRate: number;
  18870. /**
  18871. * You can use gravity if you want to give an orientation to your particles.
  18872. */
  18873. gravity: Vector3;
  18874. /**
  18875. * Minimum power of emitting particles.
  18876. */
  18877. minEmitPower: number;
  18878. /**
  18879. * Maximum power of emitting particles.
  18880. */
  18881. maxEmitPower: number;
  18882. /**
  18883. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18884. */
  18885. minAngularSpeed: number;
  18886. /**
  18887. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18888. */
  18889. maxAngularSpeed: number;
  18890. /**
  18891. * Gets or sets the minimal initial rotation in radians.
  18892. */
  18893. minInitialRotation: number;
  18894. /**
  18895. * Gets or sets the maximal initial rotation in radians.
  18896. */
  18897. maxInitialRotation: number;
  18898. /**
  18899. * The particle emitter type defines the emitter used by the particle system.
  18900. * It can be for example box, sphere, or cone...
  18901. */
  18902. particleEmitterType: Nullable<IParticleEmitterType>;
  18903. /**
  18904. * Defines the delay in milliseconds before starting the system (0 by default)
  18905. */
  18906. startDelay: number;
  18907. /**
  18908. * 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
  18909. */
  18910. preWarmCycles: number;
  18911. /**
  18912. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18913. */
  18914. preWarmStepOffset: number;
  18915. /**
  18916. * 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)
  18917. */
  18918. spriteCellChangeSpeed: number;
  18919. /**
  18920. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18921. */
  18922. startSpriteCellID: number;
  18923. /**
  18924. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18925. */
  18926. endSpriteCellID: number;
  18927. /**
  18928. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18929. */
  18930. spriteCellWidth: number;
  18931. /**
  18932. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18933. */
  18934. spriteCellHeight: number;
  18935. /**
  18936. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18937. */
  18938. spriteRandomStartCell: boolean;
  18939. /**
  18940. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18941. */
  18942. isAnimationSheetEnabled: boolean;
  18943. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18944. translationPivot: Vector2;
  18945. /**
  18946. * Gets or sets a texture used to add random noise to particle positions
  18947. */
  18948. noiseTexture: Nullable<BaseTexture>;
  18949. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18950. noiseStrength: Vector3;
  18951. /**
  18952. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18953. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18954. */
  18955. billboardMode: number;
  18956. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18957. limitVelocityDamping: number;
  18958. /**
  18959. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18960. */
  18961. beginAnimationOnStart: boolean;
  18962. /**
  18963. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18964. */
  18965. beginAnimationFrom: number;
  18966. /**
  18967. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18968. */
  18969. beginAnimationTo: number;
  18970. /**
  18971. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18972. */
  18973. beginAnimationLoop: boolean;
  18974. /**
  18975. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18976. */
  18977. disposeOnStop: boolean;
  18978. /**
  18979. * Gets the maximum number of particles active at the same time.
  18980. * @returns The max number of active particles.
  18981. */
  18982. getCapacity(): number;
  18983. /**
  18984. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18985. * @returns True if it has been started, otherwise false.
  18986. */
  18987. isStarted(): boolean;
  18988. /**
  18989. * Animates the particle system for this frame.
  18990. */
  18991. animate(): void;
  18992. /**
  18993. * Renders the particle system in its current state.
  18994. * @returns the current number of particles
  18995. */
  18996. render(): number;
  18997. /**
  18998. * Dispose the particle system and frees its associated resources.
  18999. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19000. */
  19001. dispose(disposeTexture?: boolean): void;
  19002. /**
  19003. * Clones the particle system.
  19004. * @param name The name of the cloned object
  19005. * @param newEmitter The new emitter to use
  19006. * @returns the cloned particle system
  19007. */
  19008. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19009. /**
  19010. * Serializes the particle system to a JSON object.
  19011. * @returns the JSON object
  19012. */
  19013. serialize(): any;
  19014. /**
  19015. * Rebuild the particle system
  19016. */
  19017. rebuild(): void;
  19018. /**
  19019. * Starts the particle system and begins to emit
  19020. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19021. */
  19022. start(delay?: number): void;
  19023. /**
  19024. * Stops the particle system.
  19025. */
  19026. stop(): void;
  19027. /**
  19028. * Remove all active particles
  19029. */
  19030. reset(): void;
  19031. /**
  19032. * Is this system ready to be used/rendered
  19033. * @return true if the system is ready
  19034. */
  19035. isReady(): boolean;
  19036. /**
  19037. * Adds a new color gradient
  19038. * @param gradient defines the gradient to use (between 0 and 1)
  19039. * @param color1 defines the color to affect to the specified gradient
  19040. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19041. * @returns the current particle system
  19042. */
  19043. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19044. /**
  19045. * Remove a specific color gradient
  19046. * @param gradient defines the gradient to remove
  19047. * @returns the current particle system
  19048. */
  19049. removeColorGradient(gradient: number): IParticleSystem;
  19050. /**
  19051. * Adds a new size gradient
  19052. * @param gradient defines the gradient to use (between 0 and 1)
  19053. * @param factor defines the size factor to affect to the specified gradient
  19054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19055. * @returns the current particle system
  19056. */
  19057. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19058. /**
  19059. * Remove a specific size gradient
  19060. * @param gradient defines the gradient to remove
  19061. * @returns the current particle system
  19062. */
  19063. removeSizeGradient(gradient: number): IParticleSystem;
  19064. /**
  19065. * Gets the current list of color gradients.
  19066. * You must use addColorGradient and removeColorGradient to udpate this list
  19067. * @returns the list of color gradients
  19068. */
  19069. getColorGradients(): Nullable<Array<ColorGradient>>;
  19070. /**
  19071. * Gets the current list of size gradients.
  19072. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19073. * @returns the list of size gradients
  19074. */
  19075. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19076. /**
  19077. * Gets the current list of angular speed gradients.
  19078. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19079. * @returns the list of angular speed gradients
  19080. */
  19081. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19082. /**
  19083. * Adds a new angular speed gradient
  19084. * @param gradient defines the gradient to use (between 0 and 1)
  19085. * @param factor defines the angular speed to affect to the specified gradient
  19086. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19087. * @returns the current particle system
  19088. */
  19089. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19090. /**
  19091. * Remove a specific angular speed gradient
  19092. * @param gradient defines the gradient to remove
  19093. * @returns the current particle system
  19094. */
  19095. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19096. /**
  19097. * Gets the current list of velocity gradients.
  19098. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19099. * @returns the list of velocity gradients
  19100. */
  19101. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19102. /**
  19103. * Adds a new velocity gradient
  19104. * @param gradient defines the gradient to use (between 0 and 1)
  19105. * @param factor defines the velocity to affect to the specified gradient
  19106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19107. * @returns the current particle system
  19108. */
  19109. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19110. /**
  19111. * Remove a specific velocity gradient
  19112. * @param gradient defines the gradient to remove
  19113. * @returns the current particle system
  19114. */
  19115. removeVelocityGradient(gradient: number): IParticleSystem;
  19116. /**
  19117. * Gets the current list of limit velocity gradients.
  19118. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19119. * @returns the list of limit velocity gradients
  19120. */
  19121. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19122. /**
  19123. * Adds a new limit velocity gradient
  19124. * @param gradient defines the gradient to use (between 0 and 1)
  19125. * @param factor defines the limit velocity to affect to the specified gradient
  19126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19127. * @returns the current particle system
  19128. */
  19129. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19130. /**
  19131. * Remove a specific limit velocity gradient
  19132. * @param gradient defines the gradient to remove
  19133. * @returns the current particle system
  19134. */
  19135. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19136. /**
  19137. * Adds a new drag gradient
  19138. * @param gradient defines the gradient to use (between 0 and 1)
  19139. * @param factor defines the drag to affect to the specified gradient
  19140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19141. * @returns the current particle system
  19142. */
  19143. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19144. /**
  19145. * Remove a specific drag gradient
  19146. * @param gradient defines the gradient to remove
  19147. * @returns the current particle system
  19148. */
  19149. removeDragGradient(gradient: number): IParticleSystem;
  19150. /**
  19151. * Gets the current list of drag gradients.
  19152. * You must use addDragGradient and removeDragGradient to udpate this list
  19153. * @returns the list of drag gradients
  19154. */
  19155. getDragGradients(): Nullable<Array<FactorGradient>>;
  19156. /**
  19157. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19158. * @param gradient defines the gradient to use (between 0 and 1)
  19159. * @param factor defines the emit rate to affect to the specified gradient
  19160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19161. * @returns the current particle system
  19162. */
  19163. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19164. /**
  19165. * Remove a specific emit rate gradient
  19166. * @param gradient defines the gradient to remove
  19167. * @returns the current particle system
  19168. */
  19169. removeEmitRateGradient(gradient: number): IParticleSystem;
  19170. /**
  19171. * Gets the current list of emit rate gradients.
  19172. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19173. * @returns the list of emit rate gradients
  19174. */
  19175. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19176. /**
  19177. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19178. * @param gradient defines the gradient to use (between 0 and 1)
  19179. * @param factor defines the start size to affect to the specified gradient
  19180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19181. * @returns the current particle system
  19182. */
  19183. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19184. /**
  19185. * Remove a specific start size gradient
  19186. * @param gradient defines the gradient to remove
  19187. * @returns the current particle system
  19188. */
  19189. removeStartSizeGradient(gradient: number): IParticleSystem;
  19190. /**
  19191. * Gets the current list of start size gradients.
  19192. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19193. * @returns the list of start size gradients
  19194. */
  19195. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19196. /**
  19197. * Adds a new life time gradient
  19198. * @param gradient defines the gradient to use (between 0 and 1)
  19199. * @param factor defines the life time factor to affect to the specified gradient
  19200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19201. * @returns the current particle system
  19202. */
  19203. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19204. /**
  19205. * Remove a specific life time gradient
  19206. * @param gradient defines the gradient to remove
  19207. * @returns the current particle system
  19208. */
  19209. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19210. /**
  19211. * Gets the current list of life time gradients.
  19212. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19213. * @returns the list of life time gradients
  19214. */
  19215. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19216. /**
  19217. * Gets the current list of color gradients.
  19218. * You must use addColorGradient and removeColorGradient to udpate this list
  19219. * @returns the list of color gradients
  19220. */
  19221. getColorGradients(): Nullable<Array<ColorGradient>>;
  19222. /**
  19223. * Adds a new ramp gradient used to remap particle colors
  19224. * @param gradient defines the gradient to use (between 0 and 1)
  19225. * @param color defines the color to affect to the specified gradient
  19226. * @returns the current particle system
  19227. */
  19228. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19229. /**
  19230. * Gets the current list of ramp gradients.
  19231. * You must use addRampGradient and removeRampGradient to udpate this list
  19232. * @returns the list of ramp gradients
  19233. */
  19234. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19235. /** Gets or sets a boolean indicating that ramp gradients must be used
  19236. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19237. */
  19238. useRampGradients: boolean;
  19239. /**
  19240. * Adds a new color remap gradient
  19241. * @param gradient defines the gradient to use (between 0 and 1)
  19242. * @param min defines the color remap minimal range
  19243. * @param max defines the color remap maximal range
  19244. * @returns the current particle system
  19245. */
  19246. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19247. /**
  19248. * Gets the current list of color remap gradients.
  19249. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19250. * @returns the list of color remap gradients
  19251. */
  19252. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19253. /**
  19254. * Adds a new alpha remap gradient
  19255. * @param gradient defines the gradient to use (between 0 and 1)
  19256. * @param min defines the alpha remap minimal range
  19257. * @param max defines the alpha remap maximal range
  19258. * @returns the current particle system
  19259. */
  19260. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19261. /**
  19262. * Gets the current list of alpha remap gradients.
  19263. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19264. * @returns the list of alpha remap gradients
  19265. */
  19266. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19267. /**
  19268. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19269. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19270. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19271. * @returns the emitter
  19272. */
  19273. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19274. /**
  19275. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19276. * @param radius The radius of the hemisphere to emit from
  19277. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19278. * @returns the emitter
  19279. */
  19280. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19281. /**
  19282. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19283. * @param radius The radius of the sphere to emit from
  19284. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19285. * @returns the emitter
  19286. */
  19287. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19288. /**
  19289. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19290. * @param radius The radius of the sphere to emit from
  19291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19293. * @returns the emitter
  19294. */
  19295. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19296. /**
  19297. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19298. * @param radius The radius of the emission cylinder
  19299. * @param height The height of the emission cylinder
  19300. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19301. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19302. * @returns the emitter
  19303. */
  19304. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19305. /**
  19306. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19307. * @param radius The radius of the cylinder to emit from
  19308. * @param height The height of the emission cylinder
  19309. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19310. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19311. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19312. * @returns the emitter
  19313. */
  19314. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19315. /**
  19316. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19317. * @param radius The radius of the cone to emit from
  19318. * @param angle The base angle of the cone
  19319. * @returns the emitter
  19320. */
  19321. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19322. /**
  19323. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19324. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19325. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19326. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19327. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19328. * @returns the emitter
  19329. */
  19330. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19331. /**
  19332. * Get hosting scene
  19333. * @returns the scene
  19334. */
  19335. getScene(): Scene;
  19336. }
  19337. }
  19338. declare module "babylonjs/Meshes/instancedMesh" {
  19339. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19340. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19341. import { Camera } from "babylonjs/Cameras/camera";
  19342. import { Node } from "babylonjs/node";
  19343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19344. import { Mesh } from "babylonjs/Meshes/mesh";
  19345. import { Material } from "babylonjs/Materials/material";
  19346. import { Skeleton } from "babylonjs/Bones/skeleton";
  19347. import { Light } from "babylonjs/Lights/light";
  19348. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19349. /**
  19350. * Creates an instance based on a source mesh.
  19351. */
  19352. export class InstancedMesh extends AbstractMesh {
  19353. private _sourceMesh;
  19354. private _currentLOD;
  19355. /** @hidden */
  19356. _indexInSourceMeshInstanceArray: number;
  19357. constructor(name: string, source: Mesh);
  19358. /**
  19359. * Returns the string "InstancedMesh".
  19360. */
  19361. getClassName(): string;
  19362. /** Gets the list of lights affecting that mesh */
  19363. readonly lightSources: Light[];
  19364. _resyncLightSources(): void;
  19365. _resyncLighSource(light: Light): void;
  19366. _removeLightSource(light: Light, dispose: boolean): void;
  19367. /**
  19368. * If the source mesh receives shadows
  19369. */
  19370. readonly receiveShadows: boolean;
  19371. /**
  19372. * The material of the source mesh
  19373. */
  19374. readonly material: Nullable<Material>;
  19375. /**
  19376. * Visibility of the source mesh
  19377. */
  19378. readonly visibility: number;
  19379. /**
  19380. * Skeleton of the source mesh
  19381. */
  19382. readonly skeleton: Nullable<Skeleton>;
  19383. /**
  19384. * Rendering ground id of the source mesh
  19385. */
  19386. renderingGroupId: number;
  19387. /**
  19388. * Returns the total number of vertices (integer).
  19389. */
  19390. getTotalVertices(): number;
  19391. /**
  19392. * Returns a positive integer : the total number of indices in this mesh geometry.
  19393. * @returns the numner of indices or zero if the mesh has no geometry.
  19394. */
  19395. getTotalIndices(): number;
  19396. /**
  19397. * The source mesh of the instance
  19398. */
  19399. readonly sourceMesh: Mesh;
  19400. /**
  19401. * Is this node ready to be used/rendered
  19402. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19403. * @return {boolean} is it ready
  19404. */
  19405. isReady(completeCheck?: boolean): boolean;
  19406. /**
  19407. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19408. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19409. * @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.
  19410. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19411. */
  19412. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19413. /**
  19414. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19415. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19416. * The `data` are either a numeric array either a Float32Array.
  19417. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19418. * 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).
  19419. * Note that a new underlying VertexBuffer object is created each call.
  19420. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19421. *
  19422. * Possible `kind` values :
  19423. * - VertexBuffer.PositionKind
  19424. * - VertexBuffer.UVKind
  19425. * - VertexBuffer.UV2Kind
  19426. * - VertexBuffer.UV3Kind
  19427. * - VertexBuffer.UV4Kind
  19428. * - VertexBuffer.UV5Kind
  19429. * - VertexBuffer.UV6Kind
  19430. * - VertexBuffer.ColorKind
  19431. * - VertexBuffer.MatricesIndicesKind
  19432. * - VertexBuffer.MatricesIndicesExtraKind
  19433. * - VertexBuffer.MatricesWeightsKind
  19434. * - VertexBuffer.MatricesWeightsExtraKind
  19435. *
  19436. * Returns the Mesh.
  19437. */
  19438. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19439. /**
  19440. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19441. * If the mesh has no geometry, it is simply returned as it is.
  19442. * The `data` are either a numeric array either a Float32Array.
  19443. * No new underlying VertexBuffer object is created.
  19444. * 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.
  19445. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19446. *
  19447. * Possible `kind` values :
  19448. * - VertexBuffer.PositionKind
  19449. * - VertexBuffer.UVKind
  19450. * - VertexBuffer.UV2Kind
  19451. * - VertexBuffer.UV3Kind
  19452. * - VertexBuffer.UV4Kind
  19453. * - VertexBuffer.UV5Kind
  19454. * - VertexBuffer.UV6Kind
  19455. * - VertexBuffer.ColorKind
  19456. * - VertexBuffer.MatricesIndicesKind
  19457. * - VertexBuffer.MatricesIndicesExtraKind
  19458. * - VertexBuffer.MatricesWeightsKind
  19459. * - VertexBuffer.MatricesWeightsExtraKind
  19460. *
  19461. * Returns the Mesh.
  19462. */
  19463. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19464. /**
  19465. * Sets the mesh indices.
  19466. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19467. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19468. * This method creates a new index buffer each call.
  19469. * Returns the Mesh.
  19470. */
  19471. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19472. /**
  19473. * Boolean : True if the mesh owns the requested kind of data.
  19474. */
  19475. isVerticesDataPresent(kind: string): boolean;
  19476. /**
  19477. * Returns an array of indices (IndicesArray).
  19478. */
  19479. getIndices(): Nullable<IndicesArray>;
  19480. readonly _positions: Nullable<Vector3[]>;
  19481. /**
  19482. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19483. * This means the mesh underlying bounding box and sphere are recomputed.
  19484. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19485. * @returns the current mesh
  19486. */
  19487. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19488. /** @hidden */
  19489. _preActivate(): InstancedMesh;
  19490. /** @hidden */
  19491. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19492. /** @hidden */
  19493. _postActivate(): void;
  19494. getWorldMatrix(): Matrix;
  19495. readonly isAnInstance: boolean;
  19496. /**
  19497. * Returns the current associated LOD AbstractMesh.
  19498. */
  19499. getLOD(camera: Camera): AbstractMesh;
  19500. /** @hidden */
  19501. _syncSubMeshes(): InstancedMesh;
  19502. /** @hidden */
  19503. _generatePointsArray(): boolean;
  19504. /**
  19505. * Creates a new InstancedMesh from the current mesh.
  19506. * - name (string) : the cloned mesh name
  19507. * - newParent (optional Node) : the optional Node to parent the clone to.
  19508. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19509. *
  19510. * Returns the clone.
  19511. */
  19512. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19513. /**
  19514. * Disposes the InstancedMesh.
  19515. * Returns nothing.
  19516. */
  19517. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19518. }
  19519. module "babylonjs/Meshes/mesh" {
  19520. interface Mesh {
  19521. /**
  19522. * Register a custom buffer that will be instanced
  19523. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19524. * @param kind defines the buffer kind
  19525. * @param stride defines the stride in floats
  19526. */
  19527. registerInstancedBuffer(kind: string, stride: number): void;
  19528. /** @hidden */
  19529. _userInstancedBuffersStorage: {
  19530. data: {
  19531. [key: string]: Float32Array;
  19532. };
  19533. sizes: {
  19534. [key: string]: number;
  19535. };
  19536. vertexBuffers: {
  19537. [key: string]: Nullable<VertexBuffer>;
  19538. };
  19539. strides: {
  19540. [key: string]: number;
  19541. };
  19542. };
  19543. }
  19544. }
  19545. module "babylonjs/Meshes/abstractMesh" {
  19546. interface AbstractMesh {
  19547. /**
  19548. * Object used to store instanced buffers defined by user
  19549. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19550. */
  19551. instancedBuffers: {
  19552. [key: string]: any;
  19553. };
  19554. }
  19555. }
  19556. }
  19557. declare module "babylonjs/Materials/shaderMaterial" {
  19558. import { Scene } from "babylonjs/scene";
  19559. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19561. import { Mesh } from "babylonjs/Meshes/mesh";
  19562. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19564. import { Texture } from "babylonjs/Materials/Textures/texture";
  19565. import { Material } from "babylonjs/Materials/material";
  19566. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19567. /**
  19568. * Defines the options associated with the creation of a shader material.
  19569. */
  19570. export interface IShaderMaterialOptions {
  19571. /**
  19572. * Does the material work in alpha blend mode
  19573. */
  19574. needAlphaBlending: boolean;
  19575. /**
  19576. * Does the material work in alpha test mode
  19577. */
  19578. needAlphaTesting: boolean;
  19579. /**
  19580. * The list of attribute names used in the shader
  19581. */
  19582. attributes: string[];
  19583. /**
  19584. * The list of unifrom names used in the shader
  19585. */
  19586. uniforms: string[];
  19587. /**
  19588. * The list of UBO names used in the shader
  19589. */
  19590. uniformBuffers: string[];
  19591. /**
  19592. * The list of sampler names used in the shader
  19593. */
  19594. samplers: string[];
  19595. /**
  19596. * The list of defines used in the shader
  19597. */
  19598. defines: string[];
  19599. }
  19600. /**
  19601. * 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.
  19602. *
  19603. * This returned material effects how the mesh will look based on the code in the shaders.
  19604. *
  19605. * @see http://doc.babylonjs.com/how_to/shader_material
  19606. */
  19607. export class ShaderMaterial extends Material {
  19608. private _shaderPath;
  19609. private _options;
  19610. private _textures;
  19611. private _textureArrays;
  19612. private _floats;
  19613. private _ints;
  19614. private _floatsArrays;
  19615. private _colors3;
  19616. private _colors3Arrays;
  19617. private _colors4;
  19618. private _colors4Arrays;
  19619. private _vectors2;
  19620. private _vectors3;
  19621. private _vectors4;
  19622. private _matrices;
  19623. private _matrices3x3;
  19624. private _matrices2x2;
  19625. private _vectors2Arrays;
  19626. private _vectors3Arrays;
  19627. private _vectors4Arrays;
  19628. private _cachedWorldViewMatrix;
  19629. private _cachedWorldViewProjectionMatrix;
  19630. private _renderId;
  19631. /**
  19632. * Instantiate a new shader material.
  19633. * 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.
  19634. * This returned material effects how the mesh will look based on the code in the shaders.
  19635. * @see http://doc.babylonjs.com/how_to/shader_material
  19636. * @param name Define the name of the material in the scene
  19637. * @param scene Define the scene the material belongs to
  19638. * @param shaderPath Defines the route to the shader code in one of three ways:
  19639. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19640. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19641. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19642. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19643. * @param options Define the options used to create the shader
  19644. */
  19645. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19646. /**
  19647. * Gets the options used to compile the shader.
  19648. * They can be modified to trigger a new compilation
  19649. */
  19650. readonly options: IShaderMaterialOptions;
  19651. /**
  19652. * Gets the current class name of the material e.g. "ShaderMaterial"
  19653. * Mainly use in serialization.
  19654. * @returns the class name
  19655. */
  19656. getClassName(): string;
  19657. /**
  19658. * Specifies if the material will require alpha blending
  19659. * @returns a boolean specifying if alpha blending is needed
  19660. */
  19661. needAlphaBlending(): boolean;
  19662. /**
  19663. * Specifies if this material should be rendered in alpha test mode
  19664. * @returns a boolean specifying if an alpha test is needed.
  19665. */
  19666. needAlphaTesting(): boolean;
  19667. private _checkUniform;
  19668. /**
  19669. * Set a texture in the shader.
  19670. * @param name Define the name of the uniform samplers as defined in the shader
  19671. * @param texture Define the texture to bind to this sampler
  19672. * @return the material itself allowing "fluent" like uniform updates
  19673. */
  19674. setTexture(name: string, texture: Texture): ShaderMaterial;
  19675. /**
  19676. * Set a texture array in the shader.
  19677. * @param name Define the name of the uniform sampler array as defined in the shader
  19678. * @param textures Define the list of textures to bind to this sampler
  19679. * @return the material itself allowing "fluent" like uniform updates
  19680. */
  19681. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19682. /**
  19683. * Set a float in the shader.
  19684. * @param name Define the name of the uniform as defined in the shader
  19685. * @param value Define the value to give to the uniform
  19686. * @return the material itself allowing "fluent" like uniform updates
  19687. */
  19688. setFloat(name: string, value: number): ShaderMaterial;
  19689. /**
  19690. * Set a int in the shader.
  19691. * @param name Define the name of the uniform as defined in the shader
  19692. * @param value Define the value to give to the uniform
  19693. * @return the material itself allowing "fluent" like uniform updates
  19694. */
  19695. setInt(name: string, value: number): ShaderMaterial;
  19696. /**
  19697. * Set an array of floats in the shader.
  19698. * @param name Define the name of the uniform as defined in the shader
  19699. * @param value Define the value to give to the uniform
  19700. * @return the material itself allowing "fluent" like uniform updates
  19701. */
  19702. setFloats(name: string, value: number[]): ShaderMaterial;
  19703. /**
  19704. * Set a vec3 in the shader from a Color3.
  19705. * @param name Define the name of the uniform as defined in the shader
  19706. * @param value Define the value to give to the uniform
  19707. * @return the material itself allowing "fluent" like uniform updates
  19708. */
  19709. setColor3(name: string, value: Color3): ShaderMaterial;
  19710. /**
  19711. * Set a vec3 array in the shader from a Color3 array.
  19712. * @param name Define the name of the uniform as defined in the shader
  19713. * @param value Define the value to give to the uniform
  19714. * @return the material itself allowing "fluent" like uniform updates
  19715. */
  19716. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19717. /**
  19718. * Set a vec4 in the shader from a Color4.
  19719. * @param name Define the name of the uniform as defined in the shader
  19720. * @param value Define the value to give to the uniform
  19721. * @return the material itself allowing "fluent" like uniform updates
  19722. */
  19723. setColor4(name: string, value: Color4): ShaderMaterial;
  19724. /**
  19725. * Set a vec4 array in the shader from a Color4 array.
  19726. * @param name Define the name of the uniform as defined in the shader
  19727. * @param value Define the value to give to the uniform
  19728. * @return the material itself allowing "fluent" like uniform updates
  19729. */
  19730. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19731. /**
  19732. * Set a vec2 in the shader from a Vector2.
  19733. * @param name Define the name of the uniform as defined in the shader
  19734. * @param value Define the value to give to the uniform
  19735. * @return the material itself allowing "fluent" like uniform updates
  19736. */
  19737. setVector2(name: string, value: Vector2): ShaderMaterial;
  19738. /**
  19739. * Set a vec3 in the shader from a Vector3.
  19740. * @param name Define the name of the uniform as defined in the shader
  19741. * @param value Define the value to give to the uniform
  19742. * @return the material itself allowing "fluent" like uniform updates
  19743. */
  19744. setVector3(name: string, value: Vector3): ShaderMaterial;
  19745. /**
  19746. * Set a vec4 in the shader from a Vector4.
  19747. * @param name Define the name of the uniform as defined in the shader
  19748. * @param value Define the value to give to the uniform
  19749. * @return the material itself allowing "fluent" like uniform updates
  19750. */
  19751. setVector4(name: string, value: Vector4): ShaderMaterial;
  19752. /**
  19753. * Set a mat4 in the shader from a Matrix.
  19754. * @param name Define the name of the uniform as defined in the shader
  19755. * @param value Define the value to give to the uniform
  19756. * @return the material itself allowing "fluent" like uniform updates
  19757. */
  19758. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19759. /**
  19760. * Set a mat3 in the shader from a Float32Array.
  19761. * @param name Define the name of the uniform as defined in the shader
  19762. * @param value Define the value to give to the uniform
  19763. * @return the material itself allowing "fluent" like uniform updates
  19764. */
  19765. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19766. /**
  19767. * Set a mat2 in the shader from a Float32Array.
  19768. * @param name Define the name of the uniform as defined in the shader
  19769. * @param value Define the value to give to the uniform
  19770. * @return the material itself allowing "fluent" like uniform updates
  19771. */
  19772. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19773. /**
  19774. * Set a vec2 array in the shader from a number array.
  19775. * @param name Define the name of the uniform as defined in the shader
  19776. * @param value Define the value to give to the uniform
  19777. * @return the material itself allowing "fluent" like uniform updates
  19778. */
  19779. setArray2(name: string, value: number[]): ShaderMaterial;
  19780. /**
  19781. * Set a vec3 array in the shader from a number array.
  19782. * @param name Define the name of the uniform as defined in the shader
  19783. * @param value Define the value to give to the uniform
  19784. * @return the material itself allowing "fluent" like uniform updates
  19785. */
  19786. setArray3(name: string, value: number[]): ShaderMaterial;
  19787. /**
  19788. * Set a vec4 array in the shader from a number array.
  19789. * @param name Define the name of the uniform as defined in the shader
  19790. * @param value Define the value to give to the uniform
  19791. * @return the material itself allowing "fluent" like uniform updates
  19792. */
  19793. setArray4(name: string, value: number[]): ShaderMaterial;
  19794. private _checkCache;
  19795. /**
  19796. * Specifies that the submesh is ready to be used
  19797. * @param mesh defines the mesh to check
  19798. * @param subMesh defines which submesh to check
  19799. * @param useInstances specifies that instances should be used
  19800. * @returns a boolean indicating that the submesh is ready or not
  19801. */
  19802. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19803. /**
  19804. * Checks if the material is ready to render the requested mesh
  19805. * @param mesh Define the mesh to render
  19806. * @param useInstances Define whether or not the material is used with instances
  19807. * @returns true if ready, otherwise false
  19808. */
  19809. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19810. /**
  19811. * Binds the world matrix to the material
  19812. * @param world defines the world transformation matrix
  19813. */
  19814. bindOnlyWorldMatrix(world: Matrix): void;
  19815. /**
  19816. * Binds the material to the mesh
  19817. * @param world defines the world transformation matrix
  19818. * @param mesh defines the mesh to bind the material to
  19819. */
  19820. bind(world: Matrix, mesh?: Mesh): void;
  19821. /**
  19822. * Gets the active textures from the material
  19823. * @returns an array of textures
  19824. */
  19825. getActiveTextures(): BaseTexture[];
  19826. /**
  19827. * Specifies if the material uses a texture
  19828. * @param texture defines the texture to check against the material
  19829. * @returns a boolean specifying if the material uses the texture
  19830. */
  19831. hasTexture(texture: BaseTexture): boolean;
  19832. /**
  19833. * Makes a duplicate of the material, and gives it a new name
  19834. * @param name defines the new name for the duplicated material
  19835. * @returns the cloned material
  19836. */
  19837. clone(name: string): ShaderMaterial;
  19838. /**
  19839. * Disposes the material
  19840. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19841. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19842. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19843. */
  19844. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19845. /**
  19846. * Serializes this material in a JSON representation
  19847. * @returns the serialized material object
  19848. */
  19849. serialize(): any;
  19850. /**
  19851. * Creates a shader material from parsed shader material data
  19852. * @param source defines the JSON represnetation of the material
  19853. * @param scene defines the hosting scene
  19854. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19855. * @returns a new material
  19856. */
  19857. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19858. }
  19859. }
  19860. declare module "babylonjs/Shaders/color.fragment" {
  19861. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19862. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19863. /** @hidden */
  19864. export var colorPixelShader: {
  19865. name: string;
  19866. shader: string;
  19867. };
  19868. }
  19869. declare module "babylonjs/Shaders/color.vertex" {
  19870. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19871. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19872. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19873. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19874. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19875. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19876. /** @hidden */
  19877. export var colorVertexShader: {
  19878. name: string;
  19879. shader: string;
  19880. };
  19881. }
  19882. declare module "babylonjs/Meshes/linesMesh" {
  19883. import { Nullable } from "babylonjs/types";
  19884. import { Scene } from "babylonjs/scene";
  19885. import { Color3 } from "babylonjs/Maths/math.color";
  19886. import { Node } from "babylonjs/node";
  19887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19888. import { Mesh } from "babylonjs/Meshes/mesh";
  19889. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19890. import { Effect } from "babylonjs/Materials/effect";
  19891. import { Material } from "babylonjs/Materials/material";
  19892. import "babylonjs/Shaders/color.fragment";
  19893. import "babylonjs/Shaders/color.vertex";
  19894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19895. /**
  19896. * Line mesh
  19897. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19898. */
  19899. export class LinesMesh extends Mesh {
  19900. /**
  19901. * If vertex color should be applied to the mesh
  19902. */
  19903. readonly useVertexColor?: boolean | undefined;
  19904. /**
  19905. * If vertex alpha should be applied to the mesh
  19906. */
  19907. readonly useVertexAlpha?: boolean | undefined;
  19908. /**
  19909. * Color of the line (Default: White)
  19910. */
  19911. color: Color3;
  19912. /**
  19913. * Alpha of the line (Default: 1)
  19914. */
  19915. alpha: number;
  19916. /**
  19917. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19918. * This margin is expressed in world space coordinates, so its value may vary.
  19919. * Default value is 0.1
  19920. */
  19921. intersectionThreshold: number;
  19922. private _colorShader;
  19923. private color4;
  19924. /**
  19925. * Creates a new LinesMesh
  19926. * @param name defines the name
  19927. * @param scene defines the hosting scene
  19928. * @param parent defines the parent mesh if any
  19929. * @param source defines the optional source LinesMesh used to clone data from
  19930. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19931. * When false, achieved by calling a clone(), also passing False.
  19932. * This will make creation of children, recursive.
  19933. * @param useVertexColor defines if this LinesMesh supports vertex color
  19934. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19935. */
  19936. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19937. /**
  19938. * If vertex color should be applied to the mesh
  19939. */
  19940. useVertexColor?: boolean | undefined,
  19941. /**
  19942. * If vertex alpha should be applied to the mesh
  19943. */
  19944. useVertexAlpha?: boolean | undefined);
  19945. private _addClipPlaneDefine;
  19946. private _removeClipPlaneDefine;
  19947. isReady(): boolean;
  19948. /**
  19949. * Returns the string "LineMesh"
  19950. */
  19951. getClassName(): string;
  19952. /**
  19953. * @hidden
  19954. */
  19955. /**
  19956. * @hidden
  19957. */
  19958. material: Material;
  19959. /**
  19960. * @hidden
  19961. */
  19962. readonly checkCollisions: boolean;
  19963. /** @hidden */
  19964. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19965. /** @hidden */
  19966. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19967. /**
  19968. * Disposes of the line mesh
  19969. * @param doNotRecurse If children should be disposed
  19970. */
  19971. dispose(doNotRecurse?: boolean): void;
  19972. /**
  19973. * Returns a new LineMesh object cloned from the current one.
  19974. */
  19975. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19976. /**
  19977. * Creates a new InstancedLinesMesh object from the mesh model.
  19978. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19979. * @param name defines the name of the new instance
  19980. * @returns a new InstancedLinesMesh
  19981. */
  19982. createInstance(name: string): InstancedLinesMesh;
  19983. }
  19984. /**
  19985. * Creates an instance based on a source LinesMesh
  19986. */
  19987. export class InstancedLinesMesh extends InstancedMesh {
  19988. /**
  19989. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19990. * This margin is expressed in world space coordinates, so its value may vary.
  19991. * Initilized with the intersectionThreshold value of the source LinesMesh
  19992. */
  19993. intersectionThreshold: number;
  19994. constructor(name: string, source: LinesMesh);
  19995. /**
  19996. * Returns the string "InstancedLinesMesh".
  19997. */
  19998. getClassName(): string;
  19999. }
  20000. }
  20001. declare module "babylonjs/Shaders/line.fragment" {
  20002. /** @hidden */
  20003. export var linePixelShader: {
  20004. name: string;
  20005. shader: string;
  20006. };
  20007. }
  20008. declare module "babylonjs/Shaders/line.vertex" {
  20009. /** @hidden */
  20010. export var lineVertexShader: {
  20011. name: string;
  20012. shader: string;
  20013. };
  20014. }
  20015. declare module "babylonjs/Rendering/edgesRenderer" {
  20016. import { Nullable } from "babylonjs/types";
  20017. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20019. import { Vector3 } from "babylonjs/Maths/math.vector";
  20020. import { IDisposable } from "babylonjs/scene";
  20021. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20022. import "babylonjs/Shaders/line.fragment";
  20023. import "babylonjs/Shaders/line.vertex";
  20024. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20025. module "babylonjs/Meshes/abstractMesh" {
  20026. interface AbstractMesh {
  20027. /**
  20028. * Gets the edgesRenderer associated with the mesh
  20029. */
  20030. edgesRenderer: Nullable<EdgesRenderer>;
  20031. }
  20032. }
  20033. module "babylonjs/Meshes/linesMesh" {
  20034. interface LinesMesh {
  20035. /**
  20036. * Enables the edge rendering mode on the mesh.
  20037. * This mode makes the mesh edges visible
  20038. * @param epsilon defines the maximal distance between two angles to detect a face
  20039. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20040. * @returns the currentAbstractMesh
  20041. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20042. */
  20043. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20044. }
  20045. }
  20046. module "babylonjs/Meshes/linesMesh" {
  20047. interface InstancedLinesMesh {
  20048. /**
  20049. * Enables the edge rendering mode on the mesh.
  20050. * This mode makes the mesh edges visible
  20051. * @param epsilon defines the maximal distance between two angles to detect a face
  20052. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20053. * @returns the current InstancedLinesMesh
  20054. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20055. */
  20056. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20057. }
  20058. }
  20059. /**
  20060. * Defines the minimum contract an Edges renderer should follow.
  20061. */
  20062. export interface IEdgesRenderer extends IDisposable {
  20063. /**
  20064. * Gets or sets a boolean indicating if the edgesRenderer is active
  20065. */
  20066. isEnabled: boolean;
  20067. /**
  20068. * Renders the edges of the attached mesh,
  20069. */
  20070. render(): void;
  20071. /**
  20072. * Checks wether or not the edges renderer is ready to render.
  20073. * @return true if ready, otherwise false.
  20074. */
  20075. isReady(): boolean;
  20076. }
  20077. /**
  20078. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20079. */
  20080. export class EdgesRenderer implements IEdgesRenderer {
  20081. /**
  20082. * Define the size of the edges with an orthographic camera
  20083. */
  20084. edgesWidthScalerForOrthographic: number;
  20085. /**
  20086. * Define the size of the edges with a perspective camera
  20087. */
  20088. edgesWidthScalerForPerspective: number;
  20089. protected _source: AbstractMesh;
  20090. protected _linesPositions: number[];
  20091. protected _linesNormals: number[];
  20092. protected _linesIndices: number[];
  20093. protected _epsilon: number;
  20094. protected _indicesCount: number;
  20095. protected _lineShader: ShaderMaterial;
  20096. protected _ib: DataBuffer;
  20097. protected _buffers: {
  20098. [key: string]: Nullable<VertexBuffer>;
  20099. };
  20100. protected _checkVerticesInsteadOfIndices: boolean;
  20101. private _meshRebuildObserver;
  20102. private _meshDisposeObserver;
  20103. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20104. isEnabled: boolean;
  20105. /**
  20106. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20107. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20108. * @param source Mesh used to create edges
  20109. * @param epsilon sum of angles in adjacency to check for edge
  20110. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20111. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20112. */
  20113. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20114. protected _prepareRessources(): void;
  20115. /** @hidden */
  20116. _rebuild(): void;
  20117. /**
  20118. * Releases the required resources for the edges renderer
  20119. */
  20120. dispose(): void;
  20121. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20122. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20123. /**
  20124. * Checks if the pair of p0 and p1 is en edge
  20125. * @param faceIndex
  20126. * @param edge
  20127. * @param faceNormals
  20128. * @param p0
  20129. * @param p1
  20130. * @private
  20131. */
  20132. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20133. /**
  20134. * push line into the position, normal and index buffer
  20135. * @protected
  20136. */
  20137. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20138. /**
  20139. * Generates lines edges from adjacencjes
  20140. * @private
  20141. */
  20142. _generateEdgesLines(): void;
  20143. /**
  20144. * Checks wether or not the edges renderer is ready to render.
  20145. * @return true if ready, otherwise false.
  20146. */
  20147. isReady(): boolean;
  20148. /**
  20149. * Renders the edges of the attached mesh,
  20150. */
  20151. render(): void;
  20152. }
  20153. /**
  20154. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20155. */
  20156. export class LineEdgesRenderer extends EdgesRenderer {
  20157. /**
  20158. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20159. * @param source LineMesh used to generate edges
  20160. * @param epsilon not important (specified angle for edge detection)
  20161. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20162. */
  20163. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20164. /**
  20165. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20166. */
  20167. _generateEdgesLines(): void;
  20168. }
  20169. }
  20170. declare module "babylonjs/Rendering/renderingGroup" {
  20171. import { SmartArray } from "babylonjs/Misc/smartArray";
  20172. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20174. import { Nullable } from "babylonjs/types";
  20175. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20176. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20177. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20178. import { Material } from "babylonjs/Materials/material";
  20179. import { Scene } from "babylonjs/scene";
  20180. /**
  20181. * This represents the object necessary to create a rendering group.
  20182. * This is exclusively used and created by the rendering manager.
  20183. * To modify the behavior, you use the available helpers in your scene or meshes.
  20184. * @hidden
  20185. */
  20186. export class RenderingGroup {
  20187. index: number;
  20188. private static _zeroVector;
  20189. private _scene;
  20190. private _opaqueSubMeshes;
  20191. private _transparentSubMeshes;
  20192. private _alphaTestSubMeshes;
  20193. private _depthOnlySubMeshes;
  20194. private _particleSystems;
  20195. private _spriteManagers;
  20196. private _opaqueSortCompareFn;
  20197. private _alphaTestSortCompareFn;
  20198. private _transparentSortCompareFn;
  20199. private _renderOpaque;
  20200. private _renderAlphaTest;
  20201. private _renderTransparent;
  20202. /** @hidden */
  20203. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20204. onBeforeTransparentRendering: () => void;
  20205. /**
  20206. * Set the opaque sort comparison function.
  20207. * If null the sub meshes will be render in the order they were created
  20208. */
  20209. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20210. /**
  20211. * Set the alpha test sort comparison function.
  20212. * If null the sub meshes will be render in the order they were created
  20213. */
  20214. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20215. /**
  20216. * Set the transparent sort comparison function.
  20217. * If null the sub meshes will be render in the order they were created
  20218. */
  20219. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20220. /**
  20221. * Creates a new rendering group.
  20222. * @param index The rendering group index
  20223. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20224. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20225. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20226. */
  20227. 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>);
  20228. /**
  20229. * Render all the sub meshes contained in the group.
  20230. * @param customRenderFunction Used to override the default render behaviour of the group.
  20231. * @returns true if rendered some submeshes.
  20232. */
  20233. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20234. /**
  20235. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20236. * @param subMeshes The submeshes to render
  20237. */
  20238. private renderOpaqueSorted;
  20239. /**
  20240. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20241. * @param subMeshes The submeshes to render
  20242. */
  20243. private renderAlphaTestSorted;
  20244. /**
  20245. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20246. * @param subMeshes The submeshes to render
  20247. */
  20248. private renderTransparentSorted;
  20249. /**
  20250. * Renders the submeshes in a specified order.
  20251. * @param subMeshes The submeshes to sort before render
  20252. * @param sortCompareFn The comparison function use to sort
  20253. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20254. * @param transparent Specifies to activate blending if true
  20255. */
  20256. private static renderSorted;
  20257. /**
  20258. * Renders the submeshes in the order they were dispatched (no sort applied).
  20259. * @param subMeshes The submeshes to render
  20260. */
  20261. private static renderUnsorted;
  20262. /**
  20263. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20264. * are rendered back to front if in the same alpha index.
  20265. *
  20266. * @param a The first submesh
  20267. * @param b The second submesh
  20268. * @returns The result of the comparison
  20269. */
  20270. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20271. /**
  20272. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20273. * are rendered back to front.
  20274. *
  20275. * @param a The first submesh
  20276. * @param b The second submesh
  20277. * @returns The result of the comparison
  20278. */
  20279. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20280. /**
  20281. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20282. * are rendered front to back (prevent overdraw).
  20283. *
  20284. * @param a The first submesh
  20285. * @param b The second submesh
  20286. * @returns The result of the comparison
  20287. */
  20288. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20289. /**
  20290. * Resets the different lists of submeshes to prepare a new frame.
  20291. */
  20292. prepare(): void;
  20293. dispose(): void;
  20294. /**
  20295. * Inserts the submesh in its correct queue depending on its material.
  20296. * @param subMesh The submesh to dispatch
  20297. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20298. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20299. */
  20300. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20301. dispatchSprites(spriteManager: ISpriteManager): void;
  20302. dispatchParticles(particleSystem: IParticleSystem): void;
  20303. private _renderParticles;
  20304. private _renderSprites;
  20305. }
  20306. }
  20307. declare module "babylonjs/Rendering/renderingManager" {
  20308. import { Nullable } from "babylonjs/types";
  20309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20311. import { SmartArray } from "babylonjs/Misc/smartArray";
  20312. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20313. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20314. import { Material } from "babylonjs/Materials/material";
  20315. import { Scene } from "babylonjs/scene";
  20316. import { Camera } from "babylonjs/Cameras/camera";
  20317. /**
  20318. * Interface describing the different options available in the rendering manager
  20319. * regarding Auto Clear between groups.
  20320. */
  20321. export interface IRenderingManagerAutoClearSetup {
  20322. /**
  20323. * Defines whether or not autoclear is enable.
  20324. */
  20325. autoClear: boolean;
  20326. /**
  20327. * Defines whether or not to autoclear the depth buffer.
  20328. */
  20329. depth: boolean;
  20330. /**
  20331. * Defines whether or not to autoclear the stencil buffer.
  20332. */
  20333. stencil: boolean;
  20334. }
  20335. /**
  20336. * This class is used by the onRenderingGroupObservable
  20337. */
  20338. export class RenderingGroupInfo {
  20339. /**
  20340. * The Scene that being rendered
  20341. */
  20342. scene: Scene;
  20343. /**
  20344. * The camera currently used for the rendering pass
  20345. */
  20346. camera: Nullable<Camera>;
  20347. /**
  20348. * The ID of the renderingGroup being processed
  20349. */
  20350. renderingGroupId: number;
  20351. }
  20352. /**
  20353. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20354. * It is enable to manage the different groups as well as the different necessary sort functions.
  20355. * This should not be used directly aside of the few static configurations
  20356. */
  20357. export class RenderingManager {
  20358. /**
  20359. * The max id used for rendering groups (not included)
  20360. */
  20361. static MAX_RENDERINGGROUPS: number;
  20362. /**
  20363. * The min id used for rendering groups (included)
  20364. */
  20365. static MIN_RENDERINGGROUPS: number;
  20366. /**
  20367. * Used to globally prevent autoclearing scenes.
  20368. */
  20369. static AUTOCLEAR: boolean;
  20370. /**
  20371. * @hidden
  20372. */
  20373. _useSceneAutoClearSetup: boolean;
  20374. private _scene;
  20375. private _renderingGroups;
  20376. private _depthStencilBufferAlreadyCleaned;
  20377. private _autoClearDepthStencil;
  20378. private _customOpaqueSortCompareFn;
  20379. private _customAlphaTestSortCompareFn;
  20380. private _customTransparentSortCompareFn;
  20381. private _renderingGroupInfo;
  20382. /**
  20383. * Instantiates a new rendering group for a particular scene
  20384. * @param scene Defines the scene the groups belongs to
  20385. */
  20386. constructor(scene: Scene);
  20387. private _clearDepthStencilBuffer;
  20388. /**
  20389. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20390. * @hidden
  20391. */
  20392. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20393. /**
  20394. * Resets the different information of the group to prepare a new frame
  20395. * @hidden
  20396. */
  20397. reset(): void;
  20398. /**
  20399. * Dispose and release the group and its associated resources.
  20400. * @hidden
  20401. */
  20402. dispose(): void;
  20403. /**
  20404. * Clear the info related to rendering groups preventing retention points during dispose.
  20405. */
  20406. freeRenderingGroups(): void;
  20407. private _prepareRenderingGroup;
  20408. /**
  20409. * Add a sprite manager to the rendering manager in order to render it this frame.
  20410. * @param spriteManager Define the sprite manager to render
  20411. */
  20412. dispatchSprites(spriteManager: ISpriteManager): void;
  20413. /**
  20414. * Add a particle system to the rendering manager in order to render it this frame.
  20415. * @param particleSystem Define the particle system to render
  20416. */
  20417. dispatchParticles(particleSystem: IParticleSystem): void;
  20418. /**
  20419. * Add a submesh to the manager in order to render it this frame
  20420. * @param subMesh The submesh to dispatch
  20421. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20422. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20423. */
  20424. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20425. /**
  20426. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20427. * This allowed control for front to back rendering or reversly depending of the special needs.
  20428. *
  20429. * @param renderingGroupId The rendering group id corresponding to its index
  20430. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20431. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20432. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20433. */
  20434. 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;
  20435. /**
  20436. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20437. *
  20438. * @param renderingGroupId The rendering group id corresponding to its index
  20439. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20440. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20441. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20442. */
  20443. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20444. /**
  20445. * Gets the current auto clear configuration for one rendering group of the rendering
  20446. * manager.
  20447. * @param index the rendering group index to get the information for
  20448. * @returns The auto clear setup for the requested rendering group
  20449. */
  20450. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20451. }
  20452. }
  20453. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20454. import { Observable } from "babylonjs/Misc/observable";
  20455. import { SmartArray } from "babylonjs/Misc/smartArray";
  20456. import { Nullable } from "babylonjs/types";
  20457. import { Camera } from "babylonjs/Cameras/camera";
  20458. import { Scene } from "babylonjs/scene";
  20459. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20460. import { Color4 } from "babylonjs/Maths/math.color";
  20461. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20463. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20465. import { Texture } from "babylonjs/Materials/Textures/texture";
  20466. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20467. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20468. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20469. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20470. import { Engine } from "babylonjs/Engines/engine";
  20471. /**
  20472. * This Helps creating a texture that will be created from a camera in your scene.
  20473. * It is basically a dynamic texture that could be used to create special effects for instance.
  20474. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20475. */
  20476. export class RenderTargetTexture extends Texture {
  20477. isCube: boolean;
  20478. /**
  20479. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20480. */
  20481. static readonly REFRESHRATE_RENDER_ONCE: number;
  20482. /**
  20483. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20484. */
  20485. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20486. /**
  20487. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20488. * the central point of your effect and can save a lot of performances.
  20489. */
  20490. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20491. /**
  20492. * Use this predicate to dynamically define the list of mesh you want to render.
  20493. * If set, the renderList property will be overwritten.
  20494. */
  20495. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20496. private _renderList;
  20497. /**
  20498. * Use this list to define the list of mesh you want to render.
  20499. */
  20500. renderList: Nullable<Array<AbstractMesh>>;
  20501. private _hookArray;
  20502. /**
  20503. * Define if particles should be rendered in your texture.
  20504. */
  20505. renderParticles: boolean;
  20506. /**
  20507. * Define if sprites should be rendered in your texture.
  20508. */
  20509. renderSprites: boolean;
  20510. /**
  20511. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20512. */
  20513. coordinatesMode: number;
  20514. /**
  20515. * Define the camera used to render the texture.
  20516. */
  20517. activeCamera: Nullable<Camera>;
  20518. /**
  20519. * Override the render function of the texture with your own one.
  20520. */
  20521. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20522. /**
  20523. * Define if camera post processes should be use while rendering the texture.
  20524. */
  20525. useCameraPostProcesses: boolean;
  20526. /**
  20527. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20528. */
  20529. ignoreCameraViewport: boolean;
  20530. private _postProcessManager;
  20531. private _postProcesses;
  20532. private _resizeObserver;
  20533. /**
  20534. * An event triggered when the texture is unbind.
  20535. */
  20536. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20537. /**
  20538. * An event triggered when the texture is unbind.
  20539. */
  20540. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20541. private _onAfterUnbindObserver;
  20542. /**
  20543. * Set a after unbind callback in the texture.
  20544. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20545. */
  20546. onAfterUnbind: () => void;
  20547. /**
  20548. * An event triggered before rendering the texture
  20549. */
  20550. onBeforeRenderObservable: Observable<number>;
  20551. private _onBeforeRenderObserver;
  20552. /**
  20553. * Set a before render callback in the texture.
  20554. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20555. */
  20556. onBeforeRender: (faceIndex: number) => void;
  20557. /**
  20558. * An event triggered after rendering the texture
  20559. */
  20560. onAfterRenderObservable: Observable<number>;
  20561. private _onAfterRenderObserver;
  20562. /**
  20563. * Set a after render callback in the texture.
  20564. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20565. */
  20566. onAfterRender: (faceIndex: number) => void;
  20567. /**
  20568. * An event triggered after the texture clear
  20569. */
  20570. onClearObservable: Observable<Engine>;
  20571. private _onClearObserver;
  20572. /**
  20573. * Set a clear callback in the texture.
  20574. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20575. */
  20576. onClear: (Engine: Engine) => void;
  20577. /**
  20578. * An event triggered when the texture is resized.
  20579. */
  20580. onResizeObservable: Observable<RenderTargetTexture>;
  20581. /**
  20582. * Define the clear color of the Render Target if it should be different from the scene.
  20583. */
  20584. clearColor: Color4;
  20585. protected _size: number | {
  20586. width: number;
  20587. height: number;
  20588. };
  20589. protected _initialSizeParameter: number | {
  20590. width: number;
  20591. height: number;
  20592. } | {
  20593. ratio: number;
  20594. };
  20595. protected _sizeRatio: Nullable<number>;
  20596. /** @hidden */
  20597. _generateMipMaps: boolean;
  20598. protected _renderingManager: RenderingManager;
  20599. /** @hidden */
  20600. _waitingRenderList: string[];
  20601. protected _doNotChangeAspectRatio: boolean;
  20602. protected _currentRefreshId: number;
  20603. protected _refreshRate: number;
  20604. protected _textureMatrix: Matrix;
  20605. protected _samples: number;
  20606. protected _renderTargetOptions: RenderTargetCreationOptions;
  20607. /**
  20608. * Gets render target creation options that were used.
  20609. */
  20610. readonly renderTargetOptions: RenderTargetCreationOptions;
  20611. protected _engine: Engine;
  20612. protected _onRatioRescale(): void;
  20613. /**
  20614. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20615. * It must define where the camera used to render the texture is set
  20616. */
  20617. boundingBoxPosition: Vector3;
  20618. private _boundingBoxSize;
  20619. /**
  20620. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20621. * When defined, the cubemap will switch to local mode
  20622. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20623. * @example https://www.babylonjs-playground.com/#RNASML
  20624. */
  20625. boundingBoxSize: Vector3;
  20626. /**
  20627. * In case the RTT has been created with a depth texture, get the associated
  20628. * depth texture.
  20629. * Otherwise, return null.
  20630. */
  20631. depthStencilTexture: Nullable<InternalTexture>;
  20632. /**
  20633. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20634. * or used a shadow, depth texture...
  20635. * @param name The friendly name of the texture
  20636. * @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)
  20637. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20638. * @param generateMipMaps True if mip maps need to be generated after render.
  20639. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20640. * @param type The type of the buffer in the RTT (int, half float, float...)
  20641. * @param isCube True if a cube texture needs to be created
  20642. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20643. * @param generateDepthBuffer True to generate a depth buffer
  20644. * @param generateStencilBuffer True to generate a stencil buffer
  20645. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20646. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20647. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20648. */
  20649. constructor(name: string, size: number | {
  20650. width: number;
  20651. height: number;
  20652. } | {
  20653. ratio: number;
  20654. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20655. /**
  20656. * Creates a depth stencil texture.
  20657. * This is only available in WebGL 2 or with the depth texture extension available.
  20658. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20659. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20660. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20661. */
  20662. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20663. private _processSizeParameter;
  20664. /**
  20665. * Define the number of samples to use in case of MSAA.
  20666. * It defaults to one meaning no MSAA has been enabled.
  20667. */
  20668. samples: number;
  20669. /**
  20670. * Resets the refresh counter of the texture and start bak from scratch.
  20671. * Could be useful to regenerate the texture if it is setup to render only once.
  20672. */
  20673. resetRefreshCounter(): void;
  20674. /**
  20675. * Define the refresh rate of the texture or the rendering frequency.
  20676. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20677. */
  20678. refreshRate: number;
  20679. /**
  20680. * Adds a post process to the render target rendering passes.
  20681. * @param postProcess define the post process to add
  20682. */
  20683. addPostProcess(postProcess: PostProcess): void;
  20684. /**
  20685. * Clear all the post processes attached to the render target
  20686. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20687. */
  20688. clearPostProcesses(dispose?: boolean): void;
  20689. /**
  20690. * Remove one of the post process from the list of attached post processes to the texture
  20691. * @param postProcess define the post process to remove from the list
  20692. */
  20693. removePostProcess(postProcess: PostProcess): void;
  20694. /** @hidden */
  20695. _shouldRender(): boolean;
  20696. /**
  20697. * Gets the actual render size of the texture.
  20698. * @returns the width of the render size
  20699. */
  20700. getRenderSize(): number;
  20701. /**
  20702. * Gets the actual render width of the texture.
  20703. * @returns the width of the render size
  20704. */
  20705. getRenderWidth(): number;
  20706. /**
  20707. * Gets the actual render height of the texture.
  20708. * @returns the height of the render size
  20709. */
  20710. getRenderHeight(): number;
  20711. /**
  20712. * Get if the texture can be rescaled or not.
  20713. */
  20714. readonly canRescale: boolean;
  20715. /**
  20716. * Resize the texture using a ratio.
  20717. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20718. */
  20719. scale(ratio: number): void;
  20720. /**
  20721. * Get the texture reflection matrix used to rotate/transform the reflection.
  20722. * @returns the reflection matrix
  20723. */
  20724. getReflectionTextureMatrix(): Matrix;
  20725. /**
  20726. * Resize the texture to a new desired size.
  20727. * Be carrefull as it will recreate all the data in the new texture.
  20728. * @param size Define the new size. It can be:
  20729. * - a number for squared texture,
  20730. * - an object containing { width: number, height: number }
  20731. * - or an object containing a ratio { ratio: number }
  20732. */
  20733. resize(size: number | {
  20734. width: number;
  20735. height: number;
  20736. } | {
  20737. ratio: number;
  20738. }): void;
  20739. /**
  20740. * Renders all the objects from the render list into the texture.
  20741. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20742. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20743. */
  20744. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20745. private _bestReflectionRenderTargetDimension;
  20746. /**
  20747. * @hidden
  20748. * @param faceIndex face index to bind to if this is a cubetexture
  20749. */
  20750. _bindFrameBuffer(faceIndex?: number): void;
  20751. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20752. private renderToTarget;
  20753. /**
  20754. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20755. * This allowed control for front to back rendering or reversly depending of the special needs.
  20756. *
  20757. * @param renderingGroupId The rendering group id corresponding to its index
  20758. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20759. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20760. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20761. */
  20762. 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;
  20763. /**
  20764. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20765. *
  20766. * @param renderingGroupId The rendering group id corresponding to its index
  20767. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20768. */
  20769. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20770. /**
  20771. * Clones the texture.
  20772. * @returns the cloned texture
  20773. */
  20774. clone(): RenderTargetTexture;
  20775. /**
  20776. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20777. * @returns The JSON representation of the texture
  20778. */
  20779. serialize(): any;
  20780. /**
  20781. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20782. */
  20783. disposeFramebufferObjects(): void;
  20784. /**
  20785. * Dispose the texture and release its associated resources.
  20786. */
  20787. dispose(): void;
  20788. /** @hidden */
  20789. _rebuild(): void;
  20790. /**
  20791. * Clear the info related to rendering groups preventing retention point in material dispose.
  20792. */
  20793. freeRenderingGroups(): void;
  20794. /**
  20795. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20796. * @returns the view count
  20797. */
  20798. getViewCount(): number;
  20799. }
  20800. }
  20801. declare module "babylonjs/Materials/material" {
  20802. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20803. import { SmartArray } from "babylonjs/Misc/smartArray";
  20804. import { Observable } from "babylonjs/Misc/observable";
  20805. import { Nullable } from "babylonjs/types";
  20806. import { Scene } from "babylonjs/scene";
  20807. import { Matrix } from "babylonjs/Maths/math.vector";
  20808. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20810. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20811. import { Effect } from "babylonjs/Materials/effect";
  20812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20813. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20814. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20815. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20816. import { Mesh } from "babylonjs/Meshes/mesh";
  20817. import { Animation } from "babylonjs/Animations/animation";
  20818. /**
  20819. * Options for compiling materials.
  20820. */
  20821. export interface IMaterialCompilationOptions {
  20822. /**
  20823. * Defines whether clip planes are enabled.
  20824. */
  20825. clipPlane: boolean;
  20826. /**
  20827. * Defines whether instances are enabled.
  20828. */
  20829. useInstances: boolean;
  20830. }
  20831. /**
  20832. * Base class for the main features of a material in Babylon.js
  20833. */
  20834. export class Material implements IAnimatable {
  20835. /**
  20836. * Returns the triangle fill mode
  20837. */
  20838. static readonly TriangleFillMode: number;
  20839. /**
  20840. * Returns the wireframe mode
  20841. */
  20842. static readonly WireFrameFillMode: number;
  20843. /**
  20844. * Returns the point fill mode
  20845. */
  20846. static readonly PointFillMode: number;
  20847. /**
  20848. * Returns the point list draw mode
  20849. */
  20850. static readonly PointListDrawMode: number;
  20851. /**
  20852. * Returns the line list draw mode
  20853. */
  20854. static readonly LineListDrawMode: number;
  20855. /**
  20856. * Returns the line loop draw mode
  20857. */
  20858. static readonly LineLoopDrawMode: number;
  20859. /**
  20860. * Returns the line strip draw mode
  20861. */
  20862. static readonly LineStripDrawMode: number;
  20863. /**
  20864. * Returns the triangle strip draw mode
  20865. */
  20866. static readonly TriangleStripDrawMode: number;
  20867. /**
  20868. * Returns the triangle fan draw mode
  20869. */
  20870. static readonly TriangleFanDrawMode: number;
  20871. /**
  20872. * Stores the clock-wise side orientation
  20873. */
  20874. static readonly ClockWiseSideOrientation: number;
  20875. /**
  20876. * Stores the counter clock-wise side orientation
  20877. */
  20878. static readonly CounterClockWiseSideOrientation: number;
  20879. /**
  20880. * The dirty texture flag value
  20881. */
  20882. static readonly TextureDirtyFlag: number;
  20883. /**
  20884. * The dirty light flag value
  20885. */
  20886. static readonly LightDirtyFlag: number;
  20887. /**
  20888. * The dirty fresnel flag value
  20889. */
  20890. static readonly FresnelDirtyFlag: number;
  20891. /**
  20892. * The dirty attribute flag value
  20893. */
  20894. static readonly AttributesDirtyFlag: number;
  20895. /**
  20896. * The dirty misc flag value
  20897. */
  20898. static readonly MiscDirtyFlag: number;
  20899. /**
  20900. * The all dirty flag value
  20901. */
  20902. static readonly AllDirtyFlag: number;
  20903. /**
  20904. * The ID of the material
  20905. */
  20906. id: string;
  20907. /**
  20908. * Gets or sets the unique id of the material
  20909. */
  20910. uniqueId: number;
  20911. /**
  20912. * The name of the material
  20913. */
  20914. name: string;
  20915. /**
  20916. * Gets or sets user defined metadata
  20917. */
  20918. metadata: any;
  20919. /**
  20920. * For internal use only. Please do not use.
  20921. */
  20922. reservedDataStore: any;
  20923. /**
  20924. * Specifies if the ready state should be checked on each call
  20925. */
  20926. checkReadyOnEveryCall: boolean;
  20927. /**
  20928. * Specifies if the ready state should be checked once
  20929. */
  20930. checkReadyOnlyOnce: boolean;
  20931. /**
  20932. * The state of the material
  20933. */
  20934. state: string;
  20935. /**
  20936. * The alpha value of the material
  20937. */
  20938. protected _alpha: number;
  20939. /**
  20940. * List of inspectable custom properties (used by the Inspector)
  20941. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20942. */
  20943. inspectableCustomProperties: IInspectable[];
  20944. /**
  20945. * Sets the alpha value of the material
  20946. */
  20947. /**
  20948. * Gets the alpha value of the material
  20949. */
  20950. alpha: number;
  20951. /**
  20952. * Specifies if back face culling is enabled
  20953. */
  20954. protected _backFaceCulling: boolean;
  20955. /**
  20956. * Sets the back-face culling state
  20957. */
  20958. /**
  20959. * Gets the back-face culling state
  20960. */
  20961. backFaceCulling: boolean;
  20962. /**
  20963. * Stores the value for side orientation
  20964. */
  20965. sideOrientation: number;
  20966. /**
  20967. * Callback triggered when the material is compiled
  20968. */
  20969. onCompiled: Nullable<(effect: Effect) => void>;
  20970. /**
  20971. * Callback triggered when an error occurs
  20972. */
  20973. onError: Nullable<(effect: Effect, errors: string) => void>;
  20974. /**
  20975. * Callback triggered to get the render target textures
  20976. */
  20977. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20978. /**
  20979. * Gets a boolean indicating that current material needs to register RTT
  20980. */
  20981. readonly hasRenderTargetTextures: boolean;
  20982. /**
  20983. * Specifies if the material should be serialized
  20984. */
  20985. doNotSerialize: boolean;
  20986. /**
  20987. * @hidden
  20988. */
  20989. _storeEffectOnSubMeshes: boolean;
  20990. /**
  20991. * Stores the animations for the material
  20992. */
  20993. animations: Nullable<Array<Animation>>;
  20994. /**
  20995. * An event triggered when the material is disposed
  20996. */
  20997. onDisposeObservable: Observable<Material>;
  20998. /**
  20999. * An observer which watches for dispose events
  21000. */
  21001. private _onDisposeObserver;
  21002. private _onUnBindObservable;
  21003. /**
  21004. * Called during a dispose event
  21005. */
  21006. onDispose: () => void;
  21007. private _onBindObservable;
  21008. /**
  21009. * An event triggered when the material is bound
  21010. */
  21011. readonly onBindObservable: Observable<AbstractMesh>;
  21012. /**
  21013. * An observer which watches for bind events
  21014. */
  21015. private _onBindObserver;
  21016. /**
  21017. * Called during a bind event
  21018. */
  21019. onBind: (Mesh: AbstractMesh) => void;
  21020. /**
  21021. * An event triggered when the material is unbound
  21022. */
  21023. readonly onUnBindObservable: Observable<Material>;
  21024. /**
  21025. * Stores the value of the alpha mode
  21026. */
  21027. private _alphaMode;
  21028. /**
  21029. * Sets the value of the alpha mode.
  21030. *
  21031. * | Value | Type | Description |
  21032. * | --- | --- | --- |
  21033. * | 0 | ALPHA_DISABLE | |
  21034. * | 1 | ALPHA_ADD | |
  21035. * | 2 | ALPHA_COMBINE | |
  21036. * | 3 | ALPHA_SUBTRACT | |
  21037. * | 4 | ALPHA_MULTIPLY | |
  21038. * | 5 | ALPHA_MAXIMIZED | |
  21039. * | 6 | ALPHA_ONEONE | |
  21040. * | 7 | ALPHA_PREMULTIPLIED | |
  21041. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21042. * | 9 | ALPHA_INTERPOLATE | |
  21043. * | 10 | ALPHA_SCREENMODE | |
  21044. *
  21045. */
  21046. /**
  21047. * Gets the value of the alpha mode
  21048. */
  21049. alphaMode: number;
  21050. /**
  21051. * Stores the state of the need depth pre-pass value
  21052. */
  21053. private _needDepthPrePass;
  21054. /**
  21055. * Sets the need depth pre-pass value
  21056. */
  21057. /**
  21058. * Gets the depth pre-pass value
  21059. */
  21060. needDepthPrePass: boolean;
  21061. /**
  21062. * Specifies if depth writing should be disabled
  21063. */
  21064. disableDepthWrite: boolean;
  21065. /**
  21066. * Specifies if depth writing should be forced
  21067. */
  21068. forceDepthWrite: boolean;
  21069. /**
  21070. * Specifies if there should be a separate pass for culling
  21071. */
  21072. separateCullingPass: boolean;
  21073. /**
  21074. * Stores the state specifing if fog should be enabled
  21075. */
  21076. private _fogEnabled;
  21077. /**
  21078. * Sets the state for enabling fog
  21079. */
  21080. /**
  21081. * Gets the value of the fog enabled state
  21082. */
  21083. fogEnabled: boolean;
  21084. /**
  21085. * Stores the size of points
  21086. */
  21087. pointSize: number;
  21088. /**
  21089. * Stores the z offset value
  21090. */
  21091. zOffset: number;
  21092. /**
  21093. * Gets a value specifying if wireframe mode is enabled
  21094. */
  21095. /**
  21096. * Sets the state of wireframe mode
  21097. */
  21098. wireframe: boolean;
  21099. /**
  21100. * Gets the value specifying if point clouds are enabled
  21101. */
  21102. /**
  21103. * Sets the state of point cloud mode
  21104. */
  21105. pointsCloud: boolean;
  21106. /**
  21107. * Gets the material fill mode
  21108. */
  21109. /**
  21110. * Sets the material fill mode
  21111. */
  21112. fillMode: number;
  21113. /**
  21114. * @hidden
  21115. * Stores the effects for the material
  21116. */
  21117. _effect: Nullable<Effect>;
  21118. /**
  21119. * @hidden
  21120. * Specifies if the material was previously ready
  21121. */
  21122. _wasPreviouslyReady: boolean;
  21123. /**
  21124. * Specifies if uniform buffers should be used
  21125. */
  21126. private _useUBO;
  21127. /**
  21128. * Stores a reference to the scene
  21129. */
  21130. private _scene;
  21131. /**
  21132. * Stores the fill mode state
  21133. */
  21134. private _fillMode;
  21135. /**
  21136. * Specifies if the depth write state should be cached
  21137. */
  21138. private _cachedDepthWriteState;
  21139. /**
  21140. * Stores the uniform buffer
  21141. */
  21142. protected _uniformBuffer: UniformBuffer;
  21143. /** @hidden */
  21144. _indexInSceneMaterialArray: number;
  21145. /** @hidden */
  21146. meshMap: Nullable<{
  21147. [id: string]: AbstractMesh | undefined;
  21148. }>;
  21149. /**
  21150. * Creates a material instance
  21151. * @param name defines the name of the material
  21152. * @param scene defines the scene to reference
  21153. * @param doNotAdd specifies if the material should be added to the scene
  21154. */
  21155. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21156. /**
  21157. * Returns a string representation of the current material
  21158. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21159. * @returns a string with material information
  21160. */
  21161. toString(fullDetails?: boolean): string;
  21162. /**
  21163. * Gets the class name of the material
  21164. * @returns a string with the class name of the material
  21165. */
  21166. getClassName(): string;
  21167. /**
  21168. * Specifies if updates for the material been locked
  21169. */
  21170. readonly isFrozen: boolean;
  21171. /**
  21172. * Locks updates for the material
  21173. */
  21174. freeze(): void;
  21175. /**
  21176. * Unlocks updates for the material
  21177. */
  21178. unfreeze(): void;
  21179. /**
  21180. * Specifies if the material is ready to be used
  21181. * @param mesh defines the mesh to check
  21182. * @param useInstances specifies if instances should be used
  21183. * @returns a boolean indicating if the material is ready to be used
  21184. */
  21185. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21186. /**
  21187. * Specifies that the submesh is ready to be used
  21188. * @param mesh defines the mesh to check
  21189. * @param subMesh defines which submesh to check
  21190. * @param useInstances specifies that instances should be used
  21191. * @returns a boolean indicating that the submesh is ready or not
  21192. */
  21193. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21194. /**
  21195. * Returns the material effect
  21196. * @returns the effect associated with the material
  21197. */
  21198. getEffect(): Nullable<Effect>;
  21199. /**
  21200. * Returns the current scene
  21201. * @returns a Scene
  21202. */
  21203. getScene(): Scene;
  21204. /**
  21205. * Specifies if the material will require alpha blending
  21206. * @returns a boolean specifying if alpha blending is needed
  21207. */
  21208. needAlphaBlending(): boolean;
  21209. /**
  21210. * Specifies if the mesh will require alpha blending
  21211. * @param mesh defines the mesh to check
  21212. * @returns a boolean specifying if alpha blending is needed for the mesh
  21213. */
  21214. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21215. /**
  21216. * Specifies if this material should be rendered in alpha test mode
  21217. * @returns a boolean specifying if an alpha test is needed.
  21218. */
  21219. needAlphaTesting(): boolean;
  21220. /**
  21221. * Gets the texture used for the alpha test
  21222. * @returns the texture to use for alpha testing
  21223. */
  21224. getAlphaTestTexture(): Nullable<BaseTexture>;
  21225. /**
  21226. * Marks the material to indicate that it needs to be re-calculated
  21227. */
  21228. markDirty(): void;
  21229. /** @hidden */
  21230. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21231. /**
  21232. * Binds the material to the mesh
  21233. * @param world defines the world transformation matrix
  21234. * @param mesh defines the mesh to bind the material to
  21235. */
  21236. bind(world: Matrix, mesh?: Mesh): void;
  21237. /**
  21238. * Binds the submesh to the material
  21239. * @param world defines the world transformation matrix
  21240. * @param mesh defines the mesh containing the submesh
  21241. * @param subMesh defines the submesh to bind the material to
  21242. */
  21243. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21244. /**
  21245. * Binds the world matrix to the material
  21246. * @param world defines the world transformation matrix
  21247. */
  21248. bindOnlyWorldMatrix(world: Matrix): void;
  21249. /**
  21250. * Binds the scene's uniform buffer to the effect.
  21251. * @param effect defines the effect to bind to the scene uniform buffer
  21252. * @param sceneUbo defines the uniform buffer storing scene data
  21253. */
  21254. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21255. /**
  21256. * Binds the view matrix to the effect
  21257. * @param effect defines the effect to bind the view matrix to
  21258. */
  21259. bindView(effect: Effect): void;
  21260. /**
  21261. * Binds the view projection matrix to the effect
  21262. * @param effect defines the effect to bind the view projection matrix to
  21263. */
  21264. bindViewProjection(effect: Effect): void;
  21265. /**
  21266. * Specifies if material alpha testing should be turned on for the mesh
  21267. * @param mesh defines the mesh to check
  21268. */
  21269. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21270. /**
  21271. * Processes to execute after binding the material to a mesh
  21272. * @param mesh defines the rendered mesh
  21273. */
  21274. protected _afterBind(mesh?: Mesh): void;
  21275. /**
  21276. * Unbinds the material from the mesh
  21277. */
  21278. unbind(): void;
  21279. /**
  21280. * Gets the active textures from the material
  21281. * @returns an array of textures
  21282. */
  21283. getActiveTextures(): BaseTexture[];
  21284. /**
  21285. * Specifies if the material uses a texture
  21286. * @param texture defines the texture to check against the material
  21287. * @returns a boolean specifying if the material uses the texture
  21288. */
  21289. hasTexture(texture: BaseTexture): boolean;
  21290. /**
  21291. * Makes a duplicate of the material, and gives it a new name
  21292. * @param name defines the new name for the duplicated material
  21293. * @returns the cloned material
  21294. */
  21295. clone(name: string): Nullable<Material>;
  21296. /**
  21297. * Gets the meshes bound to the material
  21298. * @returns an array of meshes bound to the material
  21299. */
  21300. getBindedMeshes(): AbstractMesh[];
  21301. /**
  21302. * Force shader compilation
  21303. * @param mesh defines the mesh associated with this material
  21304. * @param onCompiled defines a function to execute once the material is compiled
  21305. * @param options defines the options to configure the compilation
  21306. * @param onError defines a function to execute if the material fails compiling
  21307. */
  21308. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21309. /**
  21310. * Force shader compilation
  21311. * @param mesh defines the mesh that will use this material
  21312. * @param options defines additional options for compiling the shaders
  21313. * @returns a promise that resolves when the compilation completes
  21314. */
  21315. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21316. private static readonly _AllDirtyCallBack;
  21317. private static readonly _ImageProcessingDirtyCallBack;
  21318. private static readonly _TextureDirtyCallBack;
  21319. private static readonly _FresnelDirtyCallBack;
  21320. private static readonly _MiscDirtyCallBack;
  21321. private static readonly _LightsDirtyCallBack;
  21322. private static readonly _AttributeDirtyCallBack;
  21323. private static _FresnelAndMiscDirtyCallBack;
  21324. private static _TextureAndMiscDirtyCallBack;
  21325. private static readonly _DirtyCallbackArray;
  21326. private static readonly _RunDirtyCallBacks;
  21327. /**
  21328. * Marks a define in the material to indicate that it needs to be re-computed
  21329. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21330. */
  21331. markAsDirty(flag: number): void;
  21332. /**
  21333. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21334. * @param func defines a function which checks material defines against the submeshes
  21335. */
  21336. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21337. /**
  21338. * Indicates that we need to re-calculated for all submeshes
  21339. */
  21340. protected _markAllSubMeshesAsAllDirty(): void;
  21341. /**
  21342. * Indicates that image processing needs to be re-calculated for all submeshes
  21343. */
  21344. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21345. /**
  21346. * Indicates that textures need to be re-calculated for all submeshes
  21347. */
  21348. protected _markAllSubMeshesAsTexturesDirty(): void;
  21349. /**
  21350. * Indicates that fresnel needs to be re-calculated for all submeshes
  21351. */
  21352. protected _markAllSubMeshesAsFresnelDirty(): void;
  21353. /**
  21354. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21355. */
  21356. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21357. /**
  21358. * Indicates that lights need to be re-calculated for all submeshes
  21359. */
  21360. protected _markAllSubMeshesAsLightsDirty(): void;
  21361. /**
  21362. * Indicates that attributes need to be re-calculated for all submeshes
  21363. */
  21364. protected _markAllSubMeshesAsAttributesDirty(): void;
  21365. /**
  21366. * Indicates that misc needs to be re-calculated for all submeshes
  21367. */
  21368. protected _markAllSubMeshesAsMiscDirty(): void;
  21369. /**
  21370. * Indicates that textures and misc need to be re-calculated for all submeshes
  21371. */
  21372. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21373. /**
  21374. * Disposes the material
  21375. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21376. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21377. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21378. */
  21379. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21380. /** @hidden */
  21381. private releaseVertexArrayObject;
  21382. /**
  21383. * Serializes this material
  21384. * @returns the serialized material object
  21385. */
  21386. serialize(): any;
  21387. /**
  21388. * Creates a material from parsed material data
  21389. * @param parsedMaterial defines parsed material data
  21390. * @param scene defines the hosting scene
  21391. * @param rootUrl defines the root URL to use to load textures
  21392. * @returns a new material
  21393. */
  21394. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21395. }
  21396. }
  21397. declare module "babylonjs/Materials/multiMaterial" {
  21398. import { Nullable } from "babylonjs/types";
  21399. import { Scene } from "babylonjs/scene";
  21400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21401. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21403. import { Material } from "babylonjs/Materials/material";
  21404. /**
  21405. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21406. * separate meshes. This can be use to improve performances.
  21407. * @see http://doc.babylonjs.com/how_to/multi_materials
  21408. */
  21409. export class MultiMaterial extends Material {
  21410. private _subMaterials;
  21411. /**
  21412. * Gets or Sets the list of Materials used within the multi material.
  21413. * They need to be ordered according to the submeshes order in the associated mesh
  21414. */
  21415. subMaterials: Nullable<Material>[];
  21416. /**
  21417. * Function used to align with Node.getChildren()
  21418. * @returns the list of Materials used within the multi material
  21419. */
  21420. getChildren(): Nullable<Material>[];
  21421. /**
  21422. * Instantiates a new Multi Material
  21423. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21424. * separate meshes. This can be use to improve performances.
  21425. * @see http://doc.babylonjs.com/how_to/multi_materials
  21426. * @param name Define the name in the scene
  21427. * @param scene Define the scene the material belongs to
  21428. */
  21429. constructor(name: string, scene: Scene);
  21430. private _hookArray;
  21431. /**
  21432. * Get one of the submaterial by its index in the submaterials array
  21433. * @param index The index to look the sub material at
  21434. * @returns The Material if the index has been defined
  21435. */
  21436. getSubMaterial(index: number): Nullable<Material>;
  21437. /**
  21438. * Get the list of active textures for the whole sub materials list.
  21439. * @returns All the textures that will be used during the rendering
  21440. */
  21441. getActiveTextures(): BaseTexture[];
  21442. /**
  21443. * Gets the current class name of the material e.g. "MultiMaterial"
  21444. * Mainly use in serialization.
  21445. * @returns the class name
  21446. */
  21447. getClassName(): string;
  21448. /**
  21449. * Checks if the material is ready to render the requested sub mesh
  21450. * @param mesh Define the mesh the submesh belongs to
  21451. * @param subMesh Define the sub mesh to look readyness for
  21452. * @param useInstances Define whether or not the material is used with instances
  21453. * @returns true if ready, otherwise false
  21454. */
  21455. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21456. /**
  21457. * Clones the current material and its related sub materials
  21458. * @param name Define the name of the newly cloned material
  21459. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21460. * @returns the cloned material
  21461. */
  21462. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21463. /**
  21464. * Serializes the materials into a JSON representation.
  21465. * @returns the JSON representation
  21466. */
  21467. serialize(): any;
  21468. /**
  21469. * Dispose the material and release its associated resources
  21470. * @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)
  21471. * @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)
  21472. * @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)
  21473. */
  21474. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21475. /**
  21476. * Creates a MultiMaterial from parsed MultiMaterial data.
  21477. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21478. * @param scene defines the hosting scene
  21479. * @returns a new MultiMaterial
  21480. */
  21481. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21482. }
  21483. }
  21484. declare module "babylonjs/Meshes/subMesh" {
  21485. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21486. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21487. import { Engine } from "babylonjs/Engines/engine";
  21488. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21489. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21490. import { Effect } from "babylonjs/Materials/effect";
  21491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21492. import { Plane } from "babylonjs/Maths/math.plane";
  21493. import { Collider } from "babylonjs/Collisions/collider";
  21494. import { Material } from "babylonjs/Materials/material";
  21495. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21497. import { Mesh } from "babylonjs/Meshes/mesh";
  21498. import { Ray } from "babylonjs/Culling/ray";
  21499. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21500. /**
  21501. * Base class for submeshes
  21502. */
  21503. export class BaseSubMesh {
  21504. /** @hidden */
  21505. _materialDefines: Nullable<MaterialDefines>;
  21506. /** @hidden */
  21507. _materialEffect: Nullable<Effect>;
  21508. /**
  21509. * Gets associated effect
  21510. */
  21511. readonly effect: Nullable<Effect>;
  21512. /**
  21513. * Sets associated effect (effect used to render this submesh)
  21514. * @param effect defines the effect to associate with
  21515. * @param defines defines the set of defines used to compile this effect
  21516. */
  21517. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21518. }
  21519. /**
  21520. * Defines a subdivision inside a mesh
  21521. */
  21522. export class SubMesh extends BaseSubMesh implements ICullable {
  21523. /** the material index to use */
  21524. materialIndex: number;
  21525. /** vertex index start */
  21526. verticesStart: number;
  21527. /** vertices count */
  21528. verticesCount: number;
  21529. /** index start */
  21530. indexStart: number;
  21531. /** indices count */
  21532. indexCount: number;
  21533. /** @hidden */
  21534. _linesIndexCount: number;
  21535. private _mesh;
  21536. private _renderingMesh;
  21537. private _boundingInfo;
  21538. private _linesIndexBuffer;
  21539. /** @hidden */
  21540. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21541. /** @hidden */
  21542. _trianglePlanes: Plane[];
  21543. /** @hidden */
  21544. _lastColliderTransformMatrix: Nullable<Matrix>;
  21545. /** @hidden */
  21546. _renderId: number;
  21547. /** @hidden */
  21548. _alphaIndex: number;
  21549. /** @hidden */
  21550. _distanceToCamera: number;
  21551. /** @hidden */
  21552. _id: number;
  21553. private _currentMaterial;
  21554. /**
  21555. * Add a new submesh to a mesh
  21556. * @param materialIndex defines the material index to use
  21557. * @param verticesStart defines vertex index start
  21558. * @param verticesCount defines vertices count
  21559. * @param indexStart defines index start
  21560. * @param indexCount defines indices count
  21561. * @param mesh defines the parent mesh
  21562. * @param renderingMesh defines an optional rendering mesh
  21563. * @param createBoundingBox defines if bounding box should be created for this submesh
  21564. * @returns the new submesh
  21565. */
  21566. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21567. /**
  21568. * Creates a new submesh
  21569. * @param materialIndex defines the material index to use
  21570. * @param verticesStart defines vertex index start
  21571. * @param verticesCount defines vertices count
  21572. * @param indexStart defines index start
  21573. * @param indexCount defines indices count
  21574. * @param mesh defines the parent mesh
  21575. * @param renderingMesh defines an optional rendering mesh
  21576. * @param createBoundingBox defines if bounding box should be created for this submesh
  21577. */
  21578. constructor(
  21579. /** the material index to use */
  21580. materialIndex: number,
  21581. /** vertex index start */
  21582. verticesStart: number,
  21583. /** vertices count */
  21584. verticesCount: number,
  21585. /** index start */
  21586. indexStart: number,
  21587. /** indices count */
  21588. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21589. /**
  21590. * Returns true if this submesh covers the entire parent mesh
  21591. * @ignorenaming
  21592. */
  21593. readonly IsGlobal: boolean;
  21594. /**
  21595. * Returns the submesh BoudingInfo object
  21596. * @returns current bounding info (or mesh's one if the submesh is global)
  21597. */
  21598. getBoundingInfo(): BoundingInfo;
  21599. /**
  21600. * Sets the submesh BoundingInfo
  21601. * @param boundingInfo defines the new bounding info to use
  21602. * @returns the SubMesh
  21603. */
  21604. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21605. /**
  21606. * Returns the mesh of the current submesh
  21607. * @return the parent mesh
  21608. */
  21609. getMesh(): AbstractMesh;
  21610. /**
  21611. * Returns the rendering mesh of the submesh
  21612. * @returns the rendering mesh (could be different from parent mesh)
  21613. */
  21614. getRenderingMesh(): Mesh;
  21615. /**
  21616. * Returns the submesh material
  21617. * @returns null or the current material
  21618. */
  21619. getMaterial(): Nullable<Material>;
  21620. /**
  21621. * Sets a new updated BoundingInfo object to the submesh
  21622. * @param data defines an optional position array to use to determine the bounding info
  21623. * @returns the SubMesh
  21624. */
  21625. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21626. /** @hidden */
  21627. _checkCollision(collider: Collider): boolean;
  21628. /**
  21629. * Updates the submesh BoundingInfo
  21630. * @param world defines the world matrix to use to update the bounding info
  21631. * @returns the submesh
  21632. */
  21633. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21634. /**
  21635. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21636. * @param frustumPlanes defines the frustum planes
  21637. * @returns true if the submesh is intersecting with the frustum
  21638. */
  21639. isInFrustum(frustumPlanes: Plane[]): boolean;
  21640. /**
  21641. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21642. * @param frustumPlanes defines the frustum planes
  21643. * @returns true if the submesh is inside the frustum
  21644. */
  21645. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21646. /**
  21647. * Renders the submesh
  21648. * @param enableAlphaMode defines if alpha needs to be used
  21649. * @returns the submesh
  21650. */
  21651. render(enableAlphaMode: boolean): SubMesh;
  21652. /**
  21653. * @hidden
  21654. */
  21655. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21656. /**
  21657. * Checks if the submesh intersects with a ray
  21658. * @param ray defines the ray to test
  21659. * @returns true is the passed ray intersects the submesh bounding box
  21660. */
  21661. canIntersects(ray: Ray): boolean;
  21662. /**
  21663. * Intersects current submesh with a ray
  21664. * @param ray defines the ray to test
  21665. * @param positions defines mesh's positions array
  21666. * @param indices defines mesh's indices array
  21667. * @param fastCheck defines if only bounding info should be used
  21668. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21669. * @returns intersection info or null if no intersection
  21670. */
  21671. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21672. /** @hidden */
  21673. private _intersectLines;
  21674. /** @hidden */
  21675. private _intersectUnIndexedLines;
  21676. /** @hidden */
  21677. private _intersectTriangles;
  21678. /** @hidden */
  21679. private _intersectUnIndexedTriangles;
  21680. /** @hidden */
  21681. _rebuild(): void;
  21682. /**
  21683. * Creates a new submesh from the passed mesh
  21684. * @param newMesh defines the new hosting mesh
  21685. * @param newRenderingMesh defines an optional rendering mesh
  21686. * @returns the new submesh
  21687. */
  21688. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21689. /**
  21690. * Release associated resources
  21691. */
  21692. dispose(): void;
  21693. /**
  21694. * Gets the class name
  21695. * @returns the string "SubMesh".
  21696. */
  21697. getClassName(): string;
  21698. /**
  21699. * Creates a new submesh from indices data
  21700. * @param materialIndex the index of the main mesh material
  21701. * @param startIndex the index where to start the copy in the mesh indices array
  21702. * @param indexCount the number of indices to copy then from the startIndex
  21703. * @param mesh the main mesh to create the submesh from
  21704. * @param renderingMesh the optional rendering mesh
  21705. * @returns a new submesh
  21706. */
  21707. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21708. }
  21709. }
  21710. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21711. /**
  21712. * Class used to represent data loading progression
  21713. */
  21714. export class SceneLoaderFlags {
  21715. private static _ForceFullSceneLoadingForIncremental;
  21716. private static _ShowLoadingScreen;
  21717. private static _CleanBoneMatrixWeights;
  21718. private static _loggingLevel;
  21719. /**
  21720. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21721. */
  21722. static ForceFullSceneLoadingForIncremental: boolean;
  21723. /**
  21724. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21725. */
  21726. static ShowLoadingScreen: boolean;
  21727. /**
  21728. * Defines the current logging level (while loading the scene)
  21729. * @ignorenaming
  21730. */
  21731. static loggingLevel: number;
  21732. /**
  21733. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21734. */
  21735. static CleanBoneMatrixWeights: boolean;
  21736. }
  21737. }
  21738. declare module "babylonjs/Meshes/geometry" {
  21739. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21740. import { Scene } from "babylonjs/scene";
  21741. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21742. import { Engine } from "babylonjs/Engines/engine";
  21743. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21744. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21745. import { Effect } from "babylonjs/Materials/effect";
  21746. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21747. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21748. import { Mesh } from "babylonjs/Meshes/mesh";
  21749. /**
  21750. * Class used to store geometry data (vertex buffers + index buffer)
  21751. */
  21752. export class Geometry implements IGetSetVerticesData {
  21753. /**
  21754. * Gets or sets the ID of the geometry
  21755. */
  21756. id: string;
  21757. /**
  21758. * Gets or sets the unique ID of the geometry
  21759. */
  21760. uniqueId: number;
  21761. /**
  21762. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21763. */
  21764. delayLoadState: number;
  21765. /**
  21766. * Gets the file containing the data to load when running in delay load state
  21767. */
  21768. delayLoadingFile: Nullable<string>;
  21769. /**
  21770. * Callback called when the geometry is updated
  21771. */
  21772. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21773. private _scene;
  21774. private _engine;
  21775. private _meshes;
  21776. private _totalVertices;
  21777. /** @hidden */
  21778. _indices: IndicesArray;
  21779. /** @hidden */
  21780. _vertexBuffers: {
  21781. [key: string]: VertexBuffer;
  21782. };
  21783. private _isDisposed;
  21784. private _extend;
  21785. private _boundingBias;
  21786. /** @hidden */
  21787. _delayInfo: Array<string>;
  21788. private _indexBuffer;
  21789. private _indexBufferIsUpdatable;
  21790. /** @hidden */
  21791. _boundingInfo: Nullable<BoundingInfo>;
  21792. /** @hidden */
  21793. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21794. /** @hidden */
  21795. _softwareSkinningFrameId: number;
  21796. private _vertexArrayObjects;
  21797. private _updatable;
  21798. /** @hidden */
  21799. _positions: Nullable<Vector3[]>;
  21800. /**
  21801. * 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
  21802. */
  21803. /**
  21804. * 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
  21805. */
  21806. boundingBias: Vector2;
  21807. /**
  21808. * Static function used to attach a new empty geometry to a mesh
  21809. * @param mesh defines the mesh to attach the geometry to
  21810. * @returns the new Geometry
  21811. */
  21812. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21813. /**
  21814. * Creates a new geometry
  21815. * @param id defines the unique ID
  21816. * @param scene defines the hosting scene
  21817. * @param vertexData defines the VertexData used to get geometry data
  21818. * @param updatable defines if geometry must be updatable (false by default)
  21819. * @param mesh defines the mesh that will be associated with the geometry
  21820. */
  21821. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21822. /**
  21823. * Gets the current extend of the geometry
  21824. */
  21825. readonly extend: {
  21826. minimum: Vector3;
  21827. maximum: Vector3;
  21828. };
  21829. /**
  21830. * Gets the hosting scene
  21831. * @returns the hosting Scene
  21832. */
  21833. getScene(): Scene;
  21834. /**
  21835. * Gets the hosting engine
  21836. * @returns the hosting Engine
  21837. */
  21838. getEngine(): Engine;
  21839. /**
  21840. * Defines if the geometry is ready to use
  21841. * @returns true if the geometry is ready to be used
  21842. */
  21843. isReady(): boolean;
  21844. /**
  21845. * Gets a value indicating that the geometry should not be serialized
  21846. */
  21847. readonly doNotSerialize: boolean;
  21848. /** @hidden */
  21849. _rebuild(): void;
  21850. /**
  21851. * Affects all geometry data in one call
  21852. * @param vertexData defines the geometry data
  21853. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21854. */
  21855. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21856. /**
  21857. * Set specific vertex data
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param data defines the vertex data to use
  21860. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21861. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21862. */
  21863. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21864. /**
  21865. * Removes a specific vertex data
  21866. * @param kind defines the data kind (Position, normal, etc...)
  21867. */
  21868. removeVerticesData(kind: string): void;
  21869. /**
  21870. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21871. * @param buffer defines the vertex buffer to use
  21872. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21873. */
  21874. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21875. /**
  21876. * Update a specific vertex buffer
  21877. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21878. * It will do nothing if the buffer is not updatable
  21879. * @param kind defines the data kind (Position, normal, etc...)
  21880. * @param data defines the data to use
  21881. * @param offset defines the offset in the target buffer where to store the data
  21882. * @param useBytes set to true if the offset is in bytes
  21883. */
  21884. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21885. /**
  21886. * Update a specific vertex buffer
  21887. * This function will create a new buffer if the current one is not updatable
  21888. * @param kind defines the data kind (Position, normal, etc...)
  21889. * @param data defines the data to use
  21890. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21891. */
  21892. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21893. private _updateBoundingInfo;
  21894. /** @hidden */
  21895. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21896. /**
  21897. * Gets total number of vertices
  21898. * @returns the total number of vertices
  21899. */
  21900. getTotalVertices(): number;
  21901. /**
  21902. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21903. * @param kind defines the data kind (Position, normal, etc...)
  21904. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21905. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21906. * @returns a float array containing vertex data
  21907. */
  21908. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21909. /**
  21910. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21911. * @param kind defines the data kind (Position, normal, etc...)
  21912. * @returns true if the vertex buffer with the specified kind is updatable
  21913. */
  21914. isVertexBufferUpdatable(kind: string): boolean;
  21915. /**
  21916. * Gets a specific vertex buffer
  21917. * @param kind defines the data kind (Position, normal, etc...)
  21918. * @returns a VertexBuffer
  21919. */
  21920. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21921. /**
  21922. * Returns all vertex buffers
  21923. * @return an object holding all vertex buffers indexed by kind
  21924. */
  21925. getVertexBuffers(): Nullable<{
  21926. [key: string]: VertexBuffer;
  21927. }>;
  21928. /**
  21929. * Gets a boolean indicating if specific vertex buffer is present
  21930. * @param kind defines the data kind (Position, normal, etc...)
  21931. * @returns true if data is present
  21932. */
  21933. isVerticesDataPresent(kind: string): boolean;
  21934. /**
  21935. * Gets a list of all attached data kinds (Position, normal, etc...)
  21936. * @returns a list of string containing all kinds
  21937. */
  21938. getVerticesDataKinds(): string[];
  21939. /**
  21940. * Update index buffer
  21941. * @param indices defines the indices to store in the index buffer
  21942. * @param offset defines the offset in the target buffer where to store the data
  21943. * @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)
  21944. */
  21945. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21946. /**
  21947. * Creates a new index buffer
  21948. * @param indices defines the indices to store in the index buffer
  21949. * @param totalVertices defines the total number of vertices (could be null)
  21950. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21951. */
  21952. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21953. /**
  21954. * Return the total number of indices
  21955. * @returns the total number of indices
  21956. */
  21957. getTotalIndices(): number;
  21958. /**
  21959. * Gets the index buffer array
  21960. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21961. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21962. * @returns the index buffer array
  21963. */
  21964. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21965. /**
  21966. * Gets the index buffer
  21967. * @return the index buffer
  21968. */
  21969. getIndexBuffer(): Nullable<DataBuffer>;
  21970. /** @hidden */
  21971. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21972. /**
  21973. * Release the associated resources for a specific mesh
  21974. * @param mesh defines the source mesh
  21975. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21976. */
  21977. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21978. /**
  21979. * Apply current geometry to a given mesh
  21980. * @param mesh defines the mesh to apply geometry to
  21981. */
  21982. applyToMesh(mesh: Mesh): void;
  21983. private _updateExtend;
  21984. private _applyToMesh;
  21985. private notifyUpdate;
  21986. /**
  21987. * Load the geometry if it was flagged as delay loaded
  21988. * @param scene defines the hosting scene
  21989. * @param onLoaded defines a callback called when the geometry is loaded
  21990. */
  21991. load(scene: Scene, onLoaded?: () => void): void;
  21992. private _queueLoad;
  21993. /**
  21994. * Invert the geometry to move from a right handed system to a left handed one.
  21995. */
  21996. toLeftHanded(): void;
  21997. /** @hidden */
  21998. _resetPointsArrayCache(): void;
  21999. /** @hidden */
  22000. _generatePointsArray(): boolean;
  22001. /**
  22002. * Gets a value indicating if the geometry is disposed
  22003. * @returns true if the geometry was disposed
  22004. */
  22005. isDisposed(): boolean;
  22006. private _disposeVertexArrayObjects;
  22007. /**
  22008. * Free all associated resources
  22009. */
  22010. dispose(): void;
  22011. /**
  22012. * Clone the current geometry into a new geometry
  22013. * @param id defines the unique ID of the new geometry
  22014. * @returns a new geometry object
  22015. */
  22016. copy(id: string): Geometry;
  22017. /**
  22018. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22019. * @return a JSON representation of the current geometry data (without the vertices data)
  22020. */
  22021. serialize(): any;
  22022. private toNumberArray;
  22023. /**
  22024. * Serialize all vertices data into a JSON oject
  22025. * @returns a JSON representation of the current geometry data
  22026. */
  22027. serializeVerticeData(): any;
  22028. /**
  22029. * Extracts a clone of a mesh geometry
  22030. * @param mesh defines the source mesh
  22031. * @param id defines the unique ID of the new geometry object
  22032. * @returns the new geometry object
  22033. */
  22034. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22035. /**
  22036. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22037. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22038. * Be aware Math.random() could cause collisions, but:
  22039. * "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"
  22040. * @returns a string containing a new GUID
  22041. */
  22042. static RandomId(): string;
  22043. /** @hidden */
  22044. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22045. private static _CleanMatricesWeights;
  22046. /**
  22047. * Create a new geometry from persisted data (Using .babylon file format)
  22048. * @param parsedVertexData defines the persisted data
  22049. * @param scene defines the hosting scene
  22050. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22051. * @returns the new geometry object
  22052. */
  22053. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22054. }
  22055. }
  22056. declare module "babylonjs/Meshes/mesh.vertexData" {
  22057. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22058. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22059. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22060. import { Geometry } from "babylonjs/Meshes/geometry";
  22061. import { Mesh } from "babylonjs/Meshes/mesh";
  22062. /**
  22063. * Define an interface for all classes that will get and set the data on vertices
  22064. */
  22065. export interface IGetSetVerticesData {
  22066. /**
  22067. * Gets a boolean indicating if specific vertex data is present
  22068. * @param kind defines the vertex data kind to use
  22069. * @returns true is data kind is present
  22070. */
  22071. isVerticesDataPresent(kind: string): boolean;
  22072. /**
  22073. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22074. * @param kind defines the data kind (Position, normal, etc...)
  22075. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22076. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22077. * @returns a float array containing vertex data
  22078. */
  22079. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22080. /**
  22081. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22082. * @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.
  22083. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22084. * @returns the indices array or an empty array if the mesh has no geometry
  22085. */
  22086. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22087. /**
  22088. * Set specific vertex data
  22089. * @param kind defines the data kind (Position, normal, etc...)
  22090. * @param data defines the vertex data to use
  22091. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22092. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22093. */
  22094. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22095. /**
  22096. * Update a specific associated vertex buffer
  22097. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22098. * - VertexBuffer.PositionKind
  22099. * - VertexBuffer.UVKind
  22100. * - VertexBuffer.UV2Kind
  22101. * - VertexBuffer.UV3Kind
  22102. * - VertexBuffer.UV4Kind
  22103. * - VertexBuffer.UV5Kind
  22104. * - VertexBuffer.UV6Kind
  22105. * - VertexBuffer.ColorKind
  22106. * - VertexBuffer.MatricesIndicesKind
  22107. * - VertexBuffer.MatricesIndicesExtraKind
  22108. * - VertexBuffer.MatricesWeightsKind
  22109. * - VertexBuffer.MatricesWeightsExtraKind
  22110. * @param data defines the data source
  22111. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22112. * @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)
  22113. */
  22114. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22115. /**
  22116. * Creates a new index buffer
  22117. * @param indices defines the indices to store in the index buffer
  22118. * @param totalVertices defines the total number of vertices (could be null)
  22119. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22120. */
  22121. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22122. }
  22123. /**
  22124. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22125. */
  22126. export class VertexData {
  22127. /**
  22128. * Mesh side orientation : usually the external or front surface
  22129. */
  22130. static readonly FRONTSIDE: number;
  22131. /**
  22132. * Mesh side orientation : usually the internal or back surface
  22133. */
  22134. static readonly BACKSIDE: number;
  22135. /**
  22136. * Mesh side orientation : both internal and external or front and back surfaces
  22137. */
  22138. static readonly DOUBLESIDE: number;
  22139. /**
  22140. * Mesh side orientation : by default, `FRONTSIDE`
  22141. */
  22142. static readonly DEFAULTSIDE: number;
  22143. /**
  22144. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22145. */
  22146. positions: Nullable<FloatArray>;
  22147. /**
  22148. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22149. */
  22150. normals: Nullable<FloatArray>;
  22151. /**
  22152. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22153. */
  22154. tangents: Nullable<FloatArray>;
  22155. /**
  22156. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22157. */
  22158. uvs: Nullable<FloatArray>;
  22159. /**
  22160. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22161. */
  22162. uvs2: Nullable<FloatArray>;
  22163. /**
  22164. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22165. */
  22166. uvs3: Nullable<FloatArray>;
  22167. /**
  22168. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22169. */
  22170. uvs4: Nullable<FloatArray>;
  22171. /**
  22172. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22173. */
  22174. uvs5: Nullable<FloatArray>;
  22175. /**
  22176. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22177. */
  22178. uvs6: Nullable<FloatArray>;
  22179. /**
  22180. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22181. */
  22182. colors: Nullable<FloatArray>;
  22183. /**
  22184. * 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).
  22185. */
  22186. matricesIndices: Nullable<FloatArray>;
  22187. /**
  22188. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22189. */
  22190. matricesWeights: Nullable<FloatArray>;
  22191. /**
  22192. * An array extending the number of possible indices
  22193. */
  22194. matricesIndicesExtra: Nullable<FloatArray>;
  22195. /**
  22196. * An array extending the number of possible weights when the number of indices is extended
  22197. */
  22198. matricesWeightsExtra: Nullable<FloatArray>;
  22199. /**
  22200. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22201. */
  22202. indices: Nullable<IndicesArray>;
  22203. /**
  22204. * Uses the passed data array to set the set the values for the specified kind of data
  22205. * @param data a linear array of floating numbers
  22206. * @param kind the type of data that is being set, eg positions, colors etc
  22207. */
  22208. set(data: FloatArray, kind: string): void;
  22209. /**
  22210. * Associates the vertexData to the passed Mesh.
  22211. * Sets it as updatable or not (default `false`)
  22212. * @param mesh the mesh the vertexData is applied to
  22213. * @param updatable when used and having the value true allows new data to update the vertexData
  22214. * @returns the VertexData
  22215. */
  22216. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22217. /**
  22218. * Associates the vertexData to the passed Geometry.
  22219. * Sets it as updatable or not (default `false`)
  22220. * @param geometry the geometry the vertexData is applied to
  22221. * @param updatable when used and having the value true allows new data to update the vertexData
  22222. * @returns VertexData
  22223. */
  22224. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22225. /**
  22226. * Updates the associated mesh
  22227. * @param mesh the mesh to be updated
  22228. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22229. * @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
  22230. * @returns VertexData
  22231. */
  22232. updateMesh(mesh: Mesh): VertexData;
  22233. /**
  22234. * Updates the associated geometry
  22235. * @param geometry the geometry to be updated
  22236. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22237. * @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
  22238. * @returns VertexData.
  22239. */
  22240. updateGeometry(geometry: Geometry): VertexData;
  22241. private _applyTo;
  22242. private _update;
  22243. /**
  22244. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22245. * @param matrix the transforming matrix
  22246. * @returns the VertexData
  22247. */
  22248. transform(matrix: Matrix): VertexData;
  22249. /**
  22250. * Merges the passed VertexData into the current one
  22251. * @param other the VertexData to be merged into the current one
  22252. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22253. * @returns the modified VertexData
  22254. */
  22255. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22256. private _mergeElement;
  22257. private _validate;
  22258. /**
  22259. * Serializes the VertexData
  22260. * @returns a serialized object
  22261. */
  22262. serialize(): any;
  22263. /**
  22264. * Extracts the vertexData from a mesh
  22265. * @param mesh the mesh from which to extract the VertexData
  22266. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22267. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22268. * @returns the object VertexData associated to the passed mesh
  22269. */
  22270. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22271. /**
  22272. * Extracts the vertexData from the geometry
  22273. * @param geometry the geometry from which to extract the VertexData
  22274. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22275. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22276. * @returns the object VertexData associated to the passed mesh
  22277. */
  22278. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22279. private static _ExtractFrom;
  22280. /**
  22281. * Creates the VertexData for a Ribbon
  22282. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22283. * * pathArray array of paths, each of which an array of successive Vector3
  22284. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22285. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22286. * * 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
  22287. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22288. * * 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)
  22289. * * 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)
  22290. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22291. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22292. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22293. * @returns the VertexData of the ribbon
  22294. */
  22295. static CreateRibbon(options: {
  22296. pathArray: Vector3[][];
  22297. closeArray?: boolean;
  22298. closePath?: boolean;
  22299. offset?: number;
  22300. sideOrientation?: number;
  22301. frontUVs?: Vector4;
  22302. backUVs?: Vector4;
  22303. invertUV?: boolean;
  22304. uvs?: Vector2[];
  22305. colors?: Color4[];
  22306. }): VertexData;
  22307. /**
  22308. * Creates the VertexData for a box
  22309. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22310. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22311. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22312. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22313. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22314. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22315. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22317. * * 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)
  22318. * * 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)
  22319. * @returns the VertexData of the box
  22320. */
  22321. static CreateBox(options: {
  22322. size?: number;
  22323. width?: number;
  22324. height?: number;
  22325. depth?: number;
  22326. faceUV?: Vector4[];
  22327. faceColors?: Color4[];
  22328. sideOrientation?: number;
  22329. frontUVs?: Vector4;
  22330. backUVs?: Vector4;
  22331. }): VertexData;
  22332. /**
  22333. * Creates the VertexData for a tiled box
  22334. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22335. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22336. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22337. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22339. * @returns the VertexData of the box
  22340. */
  22341. static CreateTiledBox(options: {
  22342. pattern?: number;
  22343. width?: number;
  22344. height?: number;
  22345. depth?: number;
  22346. tileSize?: number;
  22347. tileWidth?: number;
  22348. tileHeight?: number;
  22349. alignHorizontal?: number;
  22350. alignVertical?: number;
  22351. faceUV?: Vector4[];
  22352. faceColors?: Color4[];
  22353. sideOrientation?: number;
  22354. }): VertexData;
  22355. /**
  22356. * Creates the VertexData for a tiled plane
  22357. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22358. * * pattern a limited pattern arrangement depending on the number
  22359. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22360. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22361. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22362. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22363. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22364. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22365. * @returns the VertexData of the tiled plane
  22366. */
  22367. static CreateTiledPlane(options: {
  22368. pattern?: number;
  22369. tileSize?: number;
  22370. tileWidth?: number;
  22371. tileHeight?: number;
  22372. size?: number;
  22373. width?: number;
  22374. height?: number;
  22375. alignHorizontal?: number;
  22376. alignVertical?: number;
  22377. sideOrientation?: number;
  22378. frontUVs?: Vector4;
  22379. backUVs?: Vector4;
  22380. }): VertexData;
  22381. /**
  22382. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22383. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22384. * * segments sets the number of horizontal strips optional, default 32
  22385. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22386. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22387. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22388. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22389. * * 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
  22390. * * 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
  22391. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22392. * * 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)
  22393. * * 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)
  22394. * @returns the VertexData of the ellipsoid
  22395. */
  22396. static CreateSphere(options: {
  22397. segments?: number;
  22398. diameter?: number;
  22399. diameterX?: number;
  22400. diameterY?: number;
  22401. diameterZ?: number;
  22402. arc?: number;
  22403. slice?: number;
  22404. sideOrientation?: number;
  22405. frontUVs?: Vector4;
  22406. backUVs?: Vector4;
  22407. }): VertexData;
  22408. /**
  22409. * Creates the VertexData for a cylinder, cone or prism
  22410. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22411. * * height sets the height (y direction) of the cylinder, optional, default 2
  22412. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22413. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22414. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22415. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22416. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22417. * * 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
  22418. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22419. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22420. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22421. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22422. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22423. * * 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)
  22424. * * 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)
  22425. * @returns the VertexData of the cylinder, cone or prism
  22426. */
  22427. static CreateCylinder(options: {
  22428. height?: number;
  22429. diameterTop?: number;
  22430. diameterBottom?: number;
  22431. diameter?: number;
  22432. tessellation?: number;
  22433. subdivisions?: number;
  22434. arc?: number;
  22435. faceColors?: Color4[];
  22436. faceUV?: Vector4[];
  22437. hasRings?: boolean;
  22438. enclose?: boolean;
  22439. sideOrientation?: number;
  22440. frontUVs?: Vector4;
  22441. backUVs?: Vector4;
  22442. }): VertexData;
  22443. /**
  22444. * Creates the VertexData for a torus
  22445. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22446. * * diameter the diameter of the torus, optional default 1
  22447. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22448. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22449. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22450. * * 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)
  22451. * * 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)
  22452. * @returns the VertexData of the torus
  22453. */
  22454. static CreateTorus(options: {
  22455. diameter?: number;
  22456. thickness?: number;
  22457. tessellation?: number;
  22458. sideOrientation?: number;
  22459. frontUVs?: Vector4;
  22460. backUVs?: Vector4;
  22461. }): VertexData;
  22462. /**
  22463. * Creates the VertexData of the LineSystem
  22464. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22465. * - lines an array of lines, each line being an array of successive Vector3
  22466. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22467. * @returns the VertexData of the LineSystem
  22468. */
  22469. static CreateLineSystem(options: {
  22470. lines: Vector3[][];
  22471. colors?: Nullable<Color4[][]>;
  22472. }): VertexData;
  22473. /**
  22474. * Create the VertexData for a DashedLines
  22475. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22476. * - points an array successive Vector3
  22477. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22478. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22479. * - dashNb the intended total number of dashes, optional, default 200
  22480. * @returns the VertexData for the DashedLines
  22481. */
  22482. static CreateDashedLines(options: {
  22483. points: Vector3[];
  22484. dashSize?: number;
  22485. gapSize?: number;
  22486. dashNb?: number;
  22487. }): VertexData;
  22488. /**
  22489. * Creates the VertexData for a Ground
  22490. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22491. * - width the width (x direction) of the ground, optional, default 1
  22492. * - height the height (z direction) of the ground, optional, default 1
  22493. * - subdivisions the number of subdivisions per side, optional, default 1
  22494. * @returns the VertexData of the Ground
  22495. */
  22496. static CreateGround(options: {
  22497. width?: number;
  22498. height?: number;
  22499. subdivisions?: number;
  22500. subdivisionsX?: number;
  22501. subdivisionsY?: number;
  22502. }): VertexData;
  22503. /**
  22504. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22505. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22506. * * xmin the ground minimum X coordinate, optional, default -1
  22507. * * zmin the ground minimum Z coordinate, optional, default -1
  22508. * * xmax the ground maximum X coordinate, optional, default 1
  22509. * * zmax the ground maximum Z coordinate, optional, default 1
  22510. * * 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}
  22511. * * 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}
  22512. * @returns the VertexData of the TiledGround
  22513. */
  22514. static CreateTiledGround(options: {
  22515. xmin: number;
  22516. zmin: number;
  22517. xmax: number;
  22518. zmax: number;
  22519. subdivisions?: {
  22520. w: number;
  22521. h: number;
  22522. };
  22523. precision?: {
  22524. w: number;
  22525. h: number;
  22526. };
  22527. }): VertexData;
  22528. /**
  22529. * Creates the VertexData of the Ground designed from a heightmap
  22530. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22531. * * width the width (x direction) of the ground
  22532. * * height the height (z direction) of the ground
  22533. * * subdivisions the number of subdivisions per side
  22534. * * minHeight the minimum altitude on the ground, optional, default 0
  22535. * * maxHeight the maximum altitude on the ground, optional default 1
  22536. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22537. * * buffer the array holding the image color data
  22538. * * bufferWidth the width of image
  22539. * * bufferHeight the height of image
  22540. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22541. * @returns the VertexData of the Ground designed from a heightmap
  22542. */
  22543. static CreateGroundFromHeightMap(options: {
  22544. width: number;
  22545. height: number;
  22546. subdivisions: number;
  22547. minHeight: number;
  22548. maxHeight: number;
  22549. colorFilter: Color3;
  22550. buffer: Uint8Array;
  22551. bufferWidth: number;
  22552. bufferHeight: number;
  22553. alphaFilter: number;
  22554. }): VertexData;
  22555. /**
  22556. * Creates the VertexData for a Plane
  22557. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22558. * * size sets the width and height of the plane to the value of size, optional default 1
  22559. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22560. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22562. * * 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)
  22563. * * 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)
  22564. * @returns the VertexData of the box
  22565. */
  22566. static CreatePlane(options: {
  22567. size?: number;
  22568. width?: number;
  22569. height?: number;
  22570. sideOrientation?: number;
  22571. frontUVs?: Vector4;
  22572. backUVs?: Vector4;
  22573. }): VertexData;
  22574. /**
  22575. * Creates the VertexData of the Disc or regular Polygon
  22576. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22577. * * radius the radius of the disc, optional default 0.5
  22578. * * tessellation the number of polygon sides, optional, default 64
  22579. * * 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
  22580. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22581. * * 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)
  22582. * * 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)
  22583. * @returns the VertexData of the box
  22584. */
  22585. static CreateDisc(options: {
  22586. radius?: number;
  22587. tessellation?: number;
  22588. arc?: number;
  22589. sideOrientation?: number;
  22590. frontUVs?: Vector4;
  22591. backUVs?: Vector4;
  22592. }): VertexData;
  22593. /**
  22594. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22595. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22596. * @param polygon a mesh built from polygonTriangulation.build()
  22597. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22598. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22599. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22600. * @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)
  22601. * @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)
  22602. * @returns the VertexData of the Polygon
  22603. */
  22604. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22605. /**
  22606. * Creates the VertexData of the IcoSphere
  22607. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22608. * * radius the radius of the IcoSphere, optional default 1
  22609. * * radiusX allows stretching in the x direction, optional, default radius
  22610. * * radiusY allows stretching in the y direction, optional, default radius
  22611. * * radiusZ allows stretching in the z direction, optional, default radius
  22612. * * flat when true creates a flat shaded mesh, optional, default true
  22613. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22615. * * 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)
  22616. * * 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)
  22617. * @returns the VertexData of the IcoSphere
  22618. */
  22619. static CreateIcoSphere(options: {
  22620. radius?: number;
  22621. radiusX?: number;
  22622. radiusY?: number;
  22623. radiusZ?: number;
  22624. flat?: boolean;
  22625. subdivisions?: number;
  22626. sideOrientation?: number;
  22627. frontUVs?: Vector4;
  22628. backUVs?: Vector4;
  22629. }): VertexData;
  22630. /**
  22631. * Creates the VertexData for a Polyhedron
  22632. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22633. * * type provided types are:
  22634. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22635. * * 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)
  22636. * * size the size of the IcoSphere, optional default 1
  22637. * * sizeX allows stretching in the x direction, optional, default size
  22638. * * sizeY allows stretching in the y direction, optional, default size
  22639. * * sizeZ allows stretching in the z direction, optional, default size
  22640. * * 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
  22641. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22642. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22643. * * flat when true creates a flat shaded mesh, optional, default true
  22644. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22645. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22646. * * 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)
  22647. * * 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)
  22648. * @returns the VertexData of the Polyhedron
  22649. */
  22650. static CreatePolyhedron(options: {
  22651. type?: number;
  22652. size?: number;
  22653. sizeX?: number;
  22654. sizeY?: number;
  22655. sizeZ?: number;
  22656. custom?: any;
  22657. faceUV?: Vector4[];
  22658. faceColors?: Color4[];
  22659. flat?: boolean;
  22660. sideOrientation?: number;
  22661. frontUVs?: Vector4;
  22662. backUVs?: Vector4;
  22663. }): VertexData;
  22664. /**
  22665. * Creates the VertexData for a TorusKnot
  22666. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22667. * * radius the radius of the torus knot, optional, default 2
  22668. * * tube the thickness of the tube, optional, default 0.5
  22669. * * radialSegments the number of sides on each tube segments, optional, default 32
  22670. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22671. * * p the number of windings around the z axis, optional, default 2
  22672. * * q the number of windings around the x axis, optional, default 3
  22673. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22674. * * 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)
  22675. * * 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)
  22676. * @returns the VertexData of the Torus Knot
  22677. */
  22678. static CreateTorusKnot(options: {
  22679. radius?: number;
  22680. tube?: number;
  22681. radialSegments?: number;
  22682. tubularSegments?: number;
  22683. p?: number;
  22684. q?: number;
  22685. sideOrientation?: number;
  22686. frontUVs?: Vector4;
  22687. backUVs?: Vector4;
  22688. }): VertexData;
  22689. /**
  22690. * Compute normals for given positions and indices
  22691. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22692. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22693. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22694. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22695. * * facetNormals : optional array of facet normals (vector3)
  22696. * * facetPositions : optional array of facet positions (vector3)
  22697. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22698. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22699. * * bInfo : optional bounding info, required for facetPartitioning computation
  22700. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22701. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22702. * * useRightHandedSystem: optional boolean to for right handed system computation
  22703. * * depthSort : optional boolean to enable the facet depth sort computation
  22704. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22705. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22706. */
  22707. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22708. facetNormals?: any;
  22709. facetPositions?: any;
  22710. facetPartitioning?: any;
  22711. ratio?: number;
  22712. bInfo?: any;
  22713. bbSize?: Vector3;
  22714. subDiv?: any;
  22715. useRightHandedSystem?: boolean;
  22716. depthSort?: boolean;
  22717. distanceTo?: Vector3;
  22718. depthSortedFacets?: any;
  22719. }): void;
  22720. /** @hidden */
  22721. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22722. /**
  22723. * Applies VertexData created from the imported parameters to the geometry
  22724. * @param parsedVertexData the parsed data from an imported file
  22725. * @param geometry the geometry to apply the VertexData to
  22726. */
  22727. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22728. }
  22729. }
  22730. declare module "babylonjs/Morph/morphTarget" {
  22731. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22732. import { Observable } from "babylonjs/Misc/observable";
  22733. import { Nullable, FloatArray } from "babylonjs/types";
  22734. import { Scene } from "babylonjs/scene";
  22735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22736. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22737. /**
  22738. * Defines a target to use with MorphTargetManager
  22739. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22740. */
  22741. export class MorphTarget implements IAnimatable {
  22742. /** defines the name of the target */
  22743. name: string;
  22744. /**
  22745. * Gets or sets the list of animations
  22746. */
  22747. animations: import("babylonjs/Animations/animation").Animation[];
  22748. private _scene;
  22749. private _positions;
  22750. private _normals;
  22751. private _tangents;
  22752. private _uvs;
  22753. private _influence;
  22754. private _uniqueId;
  22755. /**
  22756. * Observable raised when the influence changes
  22757. */
  22758. onInfluenceChanged: Observable<boolean>;
  22759. /** @hidden */
  22760. _onDataLayoutChanged: Observable<void>;
  22761. /**
  22762. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22763. */
  22764. influence: number;
  22765. /**
  22766. * Gets or sets the id of the morph Target
  22767. */
  22768. id: string;
  22769. private _animationPropertiesOverride;
  22770. /**
  22771. * Gets or sets the animation properties override
  22772. */
  22773. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22774. /**
  22775. * Creates a new MorphTarget
  22776. * @param name defines the name of the target
  22777. * @param influence defines the influence to use
  22778. * @param scene defines the scene the morphtarget belongs to
  22779. */
  22780. constructor(
  22781. /** defines the name of the target */
  22782. name: string, influence?: number, scene?: Nullable<Scene>);
  22783. /**
  22784. * Gets the unique ID of this manager
  22785. */
  22786. readonly uniqueId: number;
  22787. /**
  22788. * Gets a boolean defining if the target contains position data
  22789. */
  22790. readonly hasPositions: boolean;
  22791. /**
  22792. * Gets a boolean defining if the target contains normal data
  22793. */
  22794. readonly hasNormals: boolean;
  22795. /**
  22796. * Gets a boolean defining if the target contains tangent data
  22797. */
  22798. readonly hasTangents: boolean;
  22799. /**
  22800. * Gets a boolean defining if the target contains texture coordinates data
  22801. */
  22802. readonly hasUVs: boolean;
  22803. /**
  22804. * Affects position data to this target
  22805. * @param data defines the position data to use
  22806. */
  22807. setPositions(data: Nullable<FloatArray>): void;
  22808. /**
  22809. * Gets the position data stored in this target
  22810. * @returns a FloatArray containing the position data (or null if not present)
  22811. */
  22812. getPositions(): Nullable<FloatArray>;
  22813. /**
  22814. * Affects normal data to this target
  22815. * @param data defines the normal data to use
  22816. */
  22817. setNormals(data: Nullable<FloatArray>): void;
  22818. /**
  22819. * Gets the normal data stored in this target
  22820. * @returns a FloatArray containing the normal data (or null if not present)
  22821. */
  22822. getNormals(): Nullable<FloatArray>;
  22823. /**
  22824. * Affects tangent data to this target
  22825. * @param data defines the tangent data to use
  22826. */
  22827. setTangents(data: Nullable<FloatArray>): void;
  22828. /**
  22829. * Gets the tangent data stored in this target
  22830. * @returns a FloatArray containing the tangent data (or null if not present)
  22831. */
  22832. getTangents(): Nullable<FloatArray>;
  22833. /**
  22834. * Affects texture coordinates data to this target
  22835. * @param data defines the texture coordinates data to use
  22836. */
  22837. setUVs(data: Nullable<FloatArray>): void;
  22838. /**
  22839. * Gets the texture coordinates data stored in this target
  22840. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22841. */
  22842. getUVs(): Nullable<FloatArray>;
  22843. /**
  22844. * Clone the current target
  22845. * @returns a new MorphTarget
  22846. */
  22847. clone(): MorphTarget;
  22848. /**
  22849. * Serializes the current target into a Serialization object
  22850. * @returns the serialized object
  22851. */
  22852. serialize(): any;
  22853. /**
  22854. * Returns the string "MorphTarget"
  22855. * @returns "MorphTarget"
  22856. */
  22857. getClassName(): string;
  22858. /**
  22859. * Creates a new target from serialized data
  22860. * @param serializationObject defines the serialized data to use
  22861. * @returns a new MorphTarget
  22862. */
  22863. static Parse(serializationObject: any): MorphTarget;
  22864. /**
  22865. * Creates a MorphTarget from mesh data
  22866. * @param mesh defines the source mesh
  22867. * @param name defines the name to use for the new target
  22868. * @param influence defines the influence to attach to the target
  22869. * @returns a new MorphTarget
  22870. */
  22871. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22872. }
  22873. }
  22874. declare module "babylonjs/Morph/morphTargetManager" {
  22875. import { Nullable } from "babylonjs/types";
  22876. import { Scene } from "babylonjs/scene";
  22877. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22878. /**
  22879. * This class is used to deform meshes using morphing between different targets
  22880. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22881. */
  22882. export class MorphTargetManager {
  22883. private _targets;
  22884. private _targetInfluenceChangedObservers;
  22885. private _targetDataLayoutChangedObservers;
  22886. private _activeTargets;
  22887. private _scene;
  22888. private _influences;
  22889. private _supportsNormals;
  22890. private _supportsTangents;
  22891. private _supportsUVs;
  22892. private _vertexCount;
  22893. private _uniqueId;
  22894. private _tempInfluences;
  22895. /**
  22896. * Gets or sets a boolean indicating if normals must be morphed
  22897. */
  22898. enableNormalMorphing: boolean;
  22899. /**
  22900. * Gets or sets a boolean indicating if tangents must be morphed
  22901. */
  22902. enableTangentMorphing: boolean;
  22903. /**
  22904. * Gets or sets a boolean indicating if UV must be morphed
  22905. */
  22906. enableUVMorphing: boolean;
  22907. /**
  22908. * Creates a new MorphTargetManager
  22909. * @param scene defines the current scene
  22910. */
  22911. constructor(scene?: Nullable<Scene>);
  22912. /**
  22913. * Gets the unique ID of this manager
  22914. */
  22915. readonly uniqueId: number;
  22916. /**
  22917. * Gets the number of vertices handled by this manager
  22918. */
  22919. readonly vertexCount: number;
  22920. /**
  22921. * Gets a boolean indicating if this manager supports morphing of normals
  22922. */
  22923. readonly supportsNormals: boolean;
  22924. /**
  22925. * Gets a boolean indicating if this manager supports morphing of tangents
  22926. */
  22927. readonly supportsTangents: boolean;
  22928. /**
  22929. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22930. */
  22931. readonly supportsUVs: boolean;
  22932. /**
  22933. * Gets the number of targets stored in this manager
  22934. */
  22935. readonly numTargets: number;
  22936. /**
  22937. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22938. */
  22939. readonly numInfluencers: number;
  22940. /**
  22941. * Gets the list of influences (one per target)
  22942. */
  22943. readonly influences: Float32Array;
  22944. /**
  22945. * Gets the active target at specified index. An active target is a target with an influence > 0
  22946. * @param index defines the index to check
  22947. * @returns the requested target
  22948. */
  22949. getActiveTarget(index: number): MorphTarget;
  22950. /**
  22951. * Gets the target at specified index
  22952. * @param index defines the index to check
  22953. * @returns the requested target
  22954. */
  22955. getTarget(index: number): MorphTarget;
  22956. /**
  22957. * Add a new target to this manager
  22958. * @param target defines the target to add
  22959. */
  22960. addTarget(target: MorphTarget): void;
  22961. /**
  22962. * Removes a target from the manager
  22963. * @param target defines the target to remove
  22964. */
  22965. removeTarget(target: MorphTarget): void;
  22966. /**
  22967. * Clone the current manager
  22968. * @returns a new MorphTargetManager
  22969. */
  22970. clone(): MorphTargetManager;
  22971. /**
  22972. * Serializes the current manager into a Serialization object
  22973. * @returns the serialized object
  22974. */
  22975. serialize(): any;
  22976. private _syncActiveTargets;
  22977. /**
  22978. * Syncrhonize the targets with all the meshes using this morph target manager
  22979. */
  22980. synchronize(): void;
  22981. /**
  22982. * Creates a new MorphTargetManager from serialized data
  22983. * @param serializationObject defines the serialized data
  22984. * @param scene defines the hosting scene
  22985. * @returns the new MorphTargetManager
  22986. */
  22987. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22988. }
  22989. }
  22990. declare module "babylonjs/Meshes/meshLODLevel" {
  22991. import { Mesh } from "babylonjs/Meshes/mesh";
  22992. import { Nullable } from "babylonjs/types";
  22993. /**
  22994. * Class used to represent a specific level of detail of a mesh
  22995. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22996. */
  22997. export class MeshLODLevel {
  22998. /** Defines the distance where this level should start being displayed */
  22999. distance: number;
  23000. /** Defines the mesh to use to render this level */
  23001. mesh: Nullable<Mesh>;
  23002. /**
  23003. * Creates a new LOD level
  23004. * @param distance defines the distance where this level should star being displayed
  23005. * @param mesh defines the mesh to use to render this level
  23006. */
  23007. constructor(
  23008. /** Defines the distance where this level should start being displayed */
  23009. distance: number,
  23010. /** Defines the mesh to use to render this level */
  23011. mesh: Nullable<Mesh>);
  23012. }
  23013. }
  23014. declare module "babylonjs/Meshes/groundMesh" {
  23015. import { Scene } from "babylonjs/scene";
  23016. import { Vector3 } from "babylonjs/Maths/math.vector";
  23017. import { Mesh } from "babylonjs/Meshes/mesh";
  23018. /**
  23019. * Mesh representing the gorund
  23020. */
  23021. export class GroundMesh extends Mesh {
  23022. /** If octree should be generated */
  23023. generateOctree: boolean;
  23024. private _heightQuads;
  23025. /** @hidden */
  23026. _subdivisionsX: number;
  23027. /** @hidden */
  23028. _subdivisionsY: number;
  23029. /** @hidden */
  23030. _width: number;
  23031. /** @hidden */
  23032. _height: number;
  23033. /** @hidden */
  23034. _minX: number;
  23035. /** @hidden */
  23036. _maxX: number;
  23037. /** @hidden */
  23038. _minZ: number;
  23039. /** @hidden */
  23040. _maxZ: number;
  23041. constructor(name: string, scene: Scene);
  23042. /**
  23043. * "GroundMesh"
  23044. * @returns "GroundMesh"
  23045. */
  23046. getClassName(): string;
  23047. /**
  23048. * The minimum of x and y subdivisions
  23049. */
  23050. readonly subdivisions: number;
  23051. /**
  23052. * X subdivisions
  23053. */
  23054. readonly subdivisionsX: number;
  23055. /**
  23056. * Y subdivisions
  23057. */
  23058. readonly subdivisionsY: number;
  23059. /**
  23060. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23061. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23062. * @param chunksCount the number of subdivisions for x and y
  23063. * @param octreeBlocksSize (Default: 32)
  23064. */
  23065. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23066. /**
  23067. * Returns a height (y) value in the Worl system :
  23068. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23069. * @param x x coordinate
  23070. * @param z z coordinate
  23071. * @returns the ground y position if (x, z) are outside the ground surface.
  23072. */
  23073. getHeightAtCoordinates(x: number, z: number): number;
  23074. /**
  23075. * Returns a normalized vector (Vector3) orthogonal to the ground
  23076. * at the ground coordinates (x, z) expressed in the World system.
  23077. * @param x x coordinate
  23078. * @param z z coordinate
  23079. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23080. */
  23081. getNormalAtCoordinates(x: number, z: number): Vector3;
  23082. /**
  23083. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23084. * at the ground coordinates (x, z) expressed in the World system.
  23085. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23086. * @param x x coordinate
  23087. * @param z z coordinate
  23088. * @param ref vector to store the result
  23089. * @returns the GroundMesh.
  23090. */
  23091. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23092. /**
  23093. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23094. * if the ground has been updated.
  23095. * This can be used in the render loop.
  23096. * @returns the GroundMesh.
  23097. */
  23098. updateCoordinateHeights(): GroundMesh;
  23099. private _getFacetAt;
  23100. private _initHeightQuads;
  23101. private _computeHeightQuads;
  23102. /**
  23103. * Serializes this ground mesh
  23104. * @param serializationObject object to write serialization to
  23105. */
  23106. serialize(serializationObject: any): void;
  23107. /**
  23108. * Parses a serialized ground mesh
  23109. * @param parsedMesh the serialized mesh
  23110. * @param scene the scene to create the ground mesh in
  23111. * @returns the created ground mesh
  23112. */
  23113. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23114. }
  23115. }
  23116. declare module "babylonjs/Physics/physicsJoint" {
  23117. import { Vector3 } from "babylonjs/Maths/math.vector";
  23118. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23119. /**
  23120. * Interface for Physics-Joint data
  23121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23122. */
  23123. export interface PhysicsJointData {
  23124. /**
  23125. * The main pivot of the joint
  23126. */
  23127. mainPivot?: Vector3;
  23128. /**
  23129. * The connected pivot of the joint
  23130. */
  23131. connectedPivot?: Vector3;
  23132. /**
  23133. * The main axis of the joint
  23134. */
  23135. mainAxis?: Vector3;
  23136. /**
  23137. * The connected axis of the joint
  23138. */
  23139. connectedAxis?: Vector3;
  23140. /**
  23141. * The collision of the joint
  23142. */
  23143. collision?: boolean;
  23144. /**
  23145. * Native Oimo/Cannon/Energy data
  23146. */
  23147. nativeParams?: any;
  23148. }
  23149. /**
  23150. * This is a holder class for the physics joint created by the physics plugin
  23151. * It holds a set of functions to control the underlying joint
  23152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23153. */
  23154. export class PhysicsJoint {
  23155. /**
  23156. * The type of the physics joint
  23157. */
  23158. type: number;
  23159. /**
  23160. * The data for the physics joint
  23161. */
  23162. jointData: PhysicsJointData;
  23163. private _physicsJoint;
  23164. protected _physicsPlugin: IPhysicsEnginePlugin;
  23165. /**
  23166. * Initializes the physics joint
  23167. * @param type The type of the physics joint
  23168. * @param jointData The data for the physics joint
  23169. */
  23170. constructor(
  23171. /**
  23172. * The type of the physics joint
  23173. */
  23174. type: number,
  23175. /**
  23176. * The data for the physics joint
  23177. */
  23178. jointData: PhysicsJointData);
  23179. /**
  23180. * Gets the physics joint
  23181. */
  23182. /**
  23183. * Sets the physics joint
  23184. */
  23185. physicsJoint: any;
  23186. /**
  23187. * Sets the physics plugin
  23188. */
  23189. physicsPlugin: IPhysicsEnginePlugin;
  23190. /**
  23191. * Execute a function that is physics-plugin specific.
  23192. * @param {Function} func the function that will be executed.
  23193. * It accepts two parameters: the physics world and the physics joint
  23194. */
  23195. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23196. /**
  23197. * Distance-Joint type
  23198. */
  23199. static DistanceJoint: number;
  23200. /**
  23201. * Hinge-Joint type
  23202. */
  23203. static HingeJoint: number;
  23204. /**
  23205. * Ball-and-Socket joint type
  23206. */
  23207. static BallAndSocketJoint: number;
  23208. /**
  23209. * Wheel-Joint type
  23210. */
  23211. static WheelJoint: number;
  23212. /**
  23213. * Slider-Joint type
  23214. */
  23215. static SliderJoint: number;
  23216. /**
  23217. * Prismatic-Joint type
  23218. */
  23219. static PrismaticJoint: number;
  23220. /**
  23221. * Universal-Joint type
  23222. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23223. */
  23224. static UniversalJoint: number;
  23225. /**
  23226. * Hinge-Joint 2 type
  23227. */
  23228. static Hinge2Joint: number;
  23229. /**
  23230. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23231. */
  23232. static PointToPointJoint: number;
  23233. /**
  23234. * Spring-Joint type
  23235. */
  23236. static SpringJoint: number;
  23237. /**
  23238. * Lock-Joint type
  23239. */
  23240. static LockJoint: number;
  23241. }
  23242. /**
  23243. * A class representing a physics distance joint
  23244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23245. */
  23246. export class DistanceJoint extends PhysicsJoint {
  23247. /**
  23248. *
  23249. * @param jointData The data for the Distance-Joint
  23250. */
  23251. constructor(jointData: DistanceJointData);
  23252. /**
  23253. * Update the predefined distance.
  23254. * @param maxDistance The maximum preferred distance
  23255. * @param minDistance The minimum preferred distance
  23256. */
  23257. updateDistance(maxDistance: number, minDistance?: number): void;
  23258. }
  23259. /**
  23260. * Represents a Motor-Enabled Joint
  23261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23262. */
  23263. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23264. /**
  23265. * Initializes the Motor-Enabled Joint
  23266. * @param type The type of the joint
  23267. * @param jointData The physica joint data for the joint
  23268. */
  23269. constructor(type: number, jointData: PhysicsJointData);
  23270. /**
  23271. * Set the motor values.
  23272. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23273. * @param force the force to apply
  23274. * @param maxForce max force for this motor.
  23275. */
  23276. setMotor(force?: number, maxForce?: number): void;
  23277. /**
  23278. * Set the motor's limits.
  23279. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23280. * @param upperLimit The upper limit of the motor
  23281. * @param lowerLimit The lower limit of the motor
  23282. */
  23283. setLimit(upperLimit: number, lowerLimit?: number): void;
  23284. }
  23285. /**
  23286. * This class represents a single physics Hinge-Joint
  23287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23288. */
  23289. export class HingeJoint extends MotorEnabledJoint {
  23290. /**
  23291. * Initializes the Hinge-Joint
  23292. * @param jointData The joint data for the Hinge-Joint
  23293. */
  23294. constructor(jointData: PhysicsJointData);
  23295. /**
  23296. * Set the motor values.
  23297. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23298. * @param {number} force the force to apply
  23299. * @param {number} maxForce max force for this motor.
  23300. */
  23301. setMotor(force?: number, maxForce?: number): void;
  23302. /**
  23303. * Set the motor's limits.
  23304. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23305. * @param upperLimit The upper limit of the motor
  23306. * @param lowerLimit The lower limit of the motor
  23307. */
  23308. setLimit(upperLimit: number, lowerLimit?: number): void;
  23309. }
  23310. /**
  23311. * This class represents a dual hinge physics joint (same as wheel joint)
  23312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23313. */
  23314. export class Hinge2Joint extends MotorEnabledJoint {
  23315. /**
  23316. * Initializes the Hinge2-Joint
  23317. * @param jointData The joint data for the Hinge2-Joint
  23318. */
  23319. constructor(jointData: PhysicsJointData);
  23320. /**
  23321. * Set the motor values.
  23322. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23323. * @param {number} targetSpeed the speed the motor is to reach
  23324. * @param {number} maxForce max force for this motor.
  23325. * @param {motorIndex} the motor's index, 0 or 1.
  23326. */
  23327. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23328. /**
  23329. * Set the motor limits.
  23330. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23331. * @param {number} upperLimit the upper limit
  23332. * @param {number} lowerLimit lower limit
  23333. * @param {motorIndex} the motor's index, 0 or 1.
  23334. */
  23335. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23336. }
  23337. /**
  23338. * Interface for a motor enabled joint
  23339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23340. */
  23341. export interface IMotorEnabledJoint {
  23342. /**
  23343. * Physics joint
  23344. */
  23345. physicsJoint: any;
  23346. /**
  23347. * Sets the motor of the motor-enabled joint
  23348. * @param force The force of the motor
  23349. * @param maxForce The maximum force of the motor
  23350. * @param motorIndex The index of the motor
  23351. */
  23352. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23353. /**
  23354. * Sets the limit of the motor
  23355. * @param upperLimit The upper limit of the motor
  23356. * @param lowerLimit The lower limit of the motor
  23357. * @param motorIndex The index of the motor
  23358. */
  23359. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23360. }
  23361. /**
  23362. * Joint data for a Distance-Joint
  23363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23364. */
  23365. export interface DistanceJointData extends PhysicsJointData {
  23366. /**
  23367. * Max distance the 2 joint objects can be apart
  23368. */
  23369. maxDistance: number;
  23370. }
  23371. /**
  23372. * Joint data from a spring joint
  23373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23374. */
  23375. export interface SpringJointData extends PhysicsJointData {
  23376. /**
  23377. * Length of the spring
  23378. */
  23379. length: number;
  23380. /**
  23381. * Stiffness of the spring
  23382. */
  23383. stiffness: number;
  23384. /**
  23385. * Damping of the spring
  23386. */
  23387. damping: number;
  23388. /** this callback will be called when applying the force to the impostors. */
  23389. forceApplicationCallback: () => void;
  23390. }
  23391. }
  23392. declare module "babylonjs/Physics/physicsRaycastResult" {
  23393. import { Vector3 } from "babylonjs/Maths/math.vector";
  23394. /**
  23395. * Holds the data for the raycast result
  23396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23397. */
  23398. export class PhysicsRaycastResult {
  23399. private _hasHit;
  23400. private _hitDistance;
  23401. private _hitNormalWorld;
  23402. private _hitPointWorld;
  23403. private _rayFromWorld;
  23404. private _rayToWorld;
  23405. /**
  23406. * Gets if there was a hit
  23407. */
  23408. readonly hasHit: boolean;
  23409. /**
  23410. * Gets the distance from the hit
  23411. */
  23412. readonly hitDistance: number;
  23413. /**
  23414. * Gets the hit normal/direction in the world
  23415. */
  23416. readonly hitNormalWorld: Vector3;
  23417. /**
  23418. * Gets the hit point in the world
  23419. */
  23420. readonly hitPointWorld: Vector3;
  23421. /**
  23422. * Gets the ray "start point" of the ray in the world
  23423. */
  23424. readonly rayFromWorld: Vector3;
  23425. /**
  23426. * Gets the ray "end point" of the ray in the world
  23427. */
  23428. readonly rayToWorld: Vector3;
  23429. /**
  23430. * Sets the hit data (normal & point in world space)
  23431. * @param hitNormalWorld defines the normal in world space
  23432. * @param hitPointWorld defines the point in world space
  23433. */
  23434. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23435. /**
  23436. * Sets the distance from the start point to the hit point
  23437. * @param distance
  23438. */
  23439. setHitDistance(distance: number): void;
  23440. /**
  23441. * Calculates the distance manually
  23442. */
  23443. calculateHitDistance(): void;
  23444. /**
  23445. * Resets all the values to default
  23446. * @param from The from point on world space
  23447. * @param to The to point on world space
  23448. */
  23449. reset(from?: Vector3, to?: Vector3): void;
  23450. }
  23451. /**
  23452. * Interface for the size containing width and height
  23453. */
  23454. interface IXYZ {
  23455. /**
  23456. * X
  23457. */
  23458. x: number;
  23459. /**
  23460. * Y
  23461. */
  23462. y: number;
  23463. /**
  23464. * Z
  23465. */
  23466. z: number;
  23467. }
  23468. }
  23469. declare module "babylonjs/Physics/IPhysicsEngine" {
  23470. import { Nullable } from "babylonjs/types";
  23471. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23473. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23474. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23475. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23476. /**
  23477. * Interface used to describe a physics joint
  23478. */
  23479. export interface PhysicsImpostorJoint {
  23480. /** Defines the main impostor to which the joint is linked */
  23481. mainImpostor: PhysicsImpostor;
  23482. /** Defines the impostor that is connected to the main impostor using this joint */
  23483. connectedImpostor: PhysicsImpostor;
  23484. /** Defines the joint itself */
  23485. joint: PhysicsJoint;
  23486. }
  23487. /** @hidden */
  23488. export interface IPhysicsEnginePlugin {
  23489. world: any;
  23490. name: string;
  23491. setGravity(gravity: Vector3): void;
  23492. setTimeStep(timeStep: number): void;
  23493. getTimeStep(): number;
  23494. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23495. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23496. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23497. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23498. removePhysicsBody(impostor: PhysicsImpostor): void;
  23499. generateJoint(joint: PhysicsImpostorJoint): void;
  23500. removeJoint(joint: PhysicsImpostorJoint): void;
  23501. isSupported(): boolean;
  23502. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23503. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23504. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23505. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23507. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23508. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23509. getBodyMass(impostor: PhysicsImpostor): number;
  23510. getBodyFriction(impostor: PhysicsImpostor): number;
  23511. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23512. getBodyRestitution(impostor: PhysicsImpostor): number;
  23513. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23514. getBodyPressure?(impostor: PhysicsImpostor): number;
  23515. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23516. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23517. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23518. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23519. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23520. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23521. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23522. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23523. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23524. sleepBody(impostor: PhysicsImpostor): void;
  23525. wakeUpBody(impostor: PhysicsImpostor): void;
  23526. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23527. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23528. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23529. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23530. getRadius(impostor: PhysicsImpostor): number;
  23531. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23532. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23533. dispose(): void;
  23534. }
  23535. /**
  23536. * Interface used to define a physics engine
  23537. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23538. */
  23539. export interface IPhysicsEngine {
  23540. /**
  23541. * Gets the gravity vector used by the simulation
  23542. */
  23543. gravity: Vector3;
  23544. /**
  23545. * Sets the gravity vector used by the simulation
  23546. * @param gravity defines the gravity vector to use
  23547. */
  23548. setGravity(gravity: Vector3): void;
  23549. /**
  23550. * Set the time step of the physics engine.
  23551. * Default is 1/60.
  23552. * To slow it down, enter 1/600 for example.
  23553. * To speed it up, 1/30
  23554. * @param newTimeStep the new timestep to apply to this world.
  23555. */
  23556. setTimeStep(newTimeStep: number): void;
  23557. /**
  23558. * Get the time step of the physics engine.
  23559. * @returns the current time step
  23560. */
  23561. getTimeStep(): number;
  23562. /**
  23563. * Release all resources
  23564. */
  23565. dispose(): void;
  23566. /**
  23567. * Gets the name of the current physics plugin
  23568. * @returns the name of the plugin
  23569. */
  23570. getPhysicsPluginName(): string;
  23571. /**
  23572. * Adding a new impostor for the impostor tracking.
  23573. * This will be done by the impostor itself.
  23574. * @param impostor the impostor to add
  23575. */
  23576. addImpostor(impostor: PhysicsImpostor): void;
  23577. /**
  23578. * Remove an impostor from the engine.
  23579. * This impostor and its mesh will not longer be updated by the physics engine.
  23580. * @param impostor the impostor to remove
  23581. */
  23582. removeImpostor(impostor: PhysicsImpostor): void;
  23583. /**
  23584. * Add a joint to the physics engine
  23585. * @param mainImpostor defines the main impostor to which the joint is added.
  23586. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23587. * @param joint defines the joint that will connect both impostors.
  23588. */
  23589. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23590. /**
  23591. * Removes a joint from the simulation
  23592. * @param mainImpostor defines the impostor used with the joint
  23593. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23594. * @param joint defines the joint to remove
  23595. */
  23596. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23597. /**
  23598. * Gets the current plugin used to run the simulation
  23599. * @returns current plugin
  23600. */
  23601. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23602. /**
  23603. * Gets the list of physic impostors
  23604. * @returns an array of PhysicsImpostor
  23605. */
  23606. getImpostors(): Array<PhysicsImpostor>;
  23607. /**
  23608. * Gets the impostor for a physics enabled object
  23609. * @param object defines the object impersonated by the impostor
  23610. * @returns the PhysicsImpostor or null if not found
  23611. */
  23612. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23613. /**
  23614. * Gets the impostor for a physics body object
  23615. * @param body defines physics body used by the impostor
  23616. * @returns the PhysicsImpostor or null if not found
  23617. */
  23618. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23619. /**
  23620. * Does a raycast in the physics world
  23621. * @param from when should the ray start?
  23622. * @param to when should the ray end?
  23623. * @returns PhysicsRaycastResult
  23624. */
  23625. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23626. /**
  23627. * Called by the scene. No need to call it.
  23628. * @param delta defines the timespam between frames
  23629. */
  23630. _step(delta: number): void;
  23631. }
  23632. }
  23633. declare module "babylonjs/Physics/physicsImpostor" {
  23634. import { Nullable, IndicesArray } from "babylonjs/types";
  23635. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23636. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23638. import { Scene } from "babylonjs/scene";
  23639. import { Bone } from "babylonjs/Bones/bone";
  23640. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23641. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23642. import { Space } from "babylonjs/Maths/math.axis";
  23643. /**
  23644. * The interface for the physics imposter parameters
  23645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23646. */
  23647. export interface PhysicsImpostorParameters {
  23648. /**
  23649. * The mass of the physics imposter
  23650. */
  23651. mass: number;
  23652. /**
  23653. * The friction of the physics imposter
  23654. */
  23655. friction?: number;
  23656. /**
  23657. * The coefficient of restitution of the physics imposter
  23658. */
  23659. restitution?: number;
  23660. /**
  23661. * The native options of the physics imposter
  23662. */
  23663. nativeOptions?: any;
  23664. /**
  23665. * Specifies if the parent should be ignored
  23666. */
  23667. ignoreParent?: boolean;
  23668. /**
  23669. * Specifies if bi-directional transformations should be disabled
  23670. */
  23671. disableBidirectionalTransformation?: boolean;
  23672. /**
  23673. * The pressure inside the physics imposter, soft object only
  23674. */
  23675. pressure?: number;
  23676. /**
  23677. * The stiffness the physics imposter, soft object only
  23678. */
  23679. stiffness?: number;
  23680. /**
  23681. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23682. */
  23683. velocityIterations?: number;
  23684. /**
  23685. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23686. */
  23687. positionIterations?: number;
  23688. /**
  23689. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23690. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23691. * Add to fix multiple points
  23692. */
  23693. fixedPoints?: number;
  23694. /**
  23695. * The collision margin around a soft object
  23696. */
  23697. margin?: number;
  23698. /**
  23699. * The collision margin around a soft object
  23700. */
  23701. damping?: number;
  23702. /**
  23703. * The path for a rope based on an extrusion
  23704. */
  23705. path?: any;
  23706. /**
  23707. * The shape of an extrusion used for a rope based on an extrusion
  23708. */
  23709. shape?: any;
  23710. }
  23711. /**
  23712. * Interface for a physics-enabled object
  23713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23714. */
  23715. export interface IPhysicsEnabledObject {
  23716. /**
  23717. * The position of the physics-enabled object
  23718. */
  23719. position: Vector3;
  23720. /**
  23721. * The rotation of the physics-enabled object
  23722. */
  23723. rotationQuaternion: Nullable<Quaternion>;
  23724. /**
  23725. * The scale of the physics-enabled object
  23726. */
  23727. scaling: Vector3;
  23728. /**
  23729. * The rotation of the physics-enabled object
  23730. */
  23731. rotation?: Vector3;
  23732. /**
  23733. * The parent of the physics-enabled object
  23734. */
  23735. parent?: any;
  23736. /**
  23737. * The bounding info of the physics-enabled object
  23738. * @returns The bounding info of the physics-enabled object
  23739. */
  23740. getBoundingInfo(): BoundingInfo;
  23741. /**
  23742. * Computes the world matrix
  23743. * @param force Specifies if the world matrix should be computed by force
  23744. * @returns A world matrix
  23745. */
  23746. computeWorldMatrix(force: boolean): Matrix;
  23747. /**
  23748. * Gets the world matrix
  23749. * @returns A world matrix
  23750. */
  23751. getWorldMatrix?(): Matrix;
  23752. /**
  23753. * Gets the child meshes
  23754. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23755. * @returns An array of abstract meshes
  23756. */
  23757. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23758. /**
  23759. * Gets the vertex data
  23760. * @param kind The type of vertex data
  23761. * @returns A nullable array of numbers, or a float32 array
  23762. */
  23763. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23764. /**
  23765. * Gets the indices from the mesh
  23766. * @returns A nullable array of index arrays
  23767. */
  23768. getIndices?(): Nullable<IndicesArray>;
  23769. /**
  23770. * Gets the scene from the mesh
  23771. * @returns the indices array or null
  23772. */
  23773. getScene?(): Scene;
  23774. /**
  23775. * Gets the absolute position from the mesh
  23776. * @returns the absolute position
  23777. */
  23778. getAbsolutePosition(): Vector3;
  23779. /**
  23780. * Gets the absolute pivot point from the mesh
  23781. * @returns the absolute pivot point
  23782. */
  23783. getAbsolutePivotPoint(): Vector3;
  23784. /**
  23785. * Rotates the mesh
  23786. * @param axis The axis of rotation
  23787. * @param amount The amount of rotation
  23788. * @param space The space of the rotation
  23789. * @returns The rotation transform node
  23790. */
  23791. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23792. /**
  23793. * Translates the mesh
  23794. * @param axis The axis of translation
  23795. * @param distance The distance of translation
  23796. * @param space The space of the translation
  23797. * @returns The transform node
  23798. */
  23799. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23800. /**
  23801. * Sets the absolute position of the mesh
  23802. * @param absolutePosition The absolute position of the mesh
  23803. * @returns The transform node
  23804. */
  23805. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23806. /**
  23807. * Gets the class name of the mesh
  23808. * @returns The class name
  23809. */
  23810. getClassName(): string;
  23811. }
  23812. /**
  23813. * Represents a physics imposter
  23814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23815. */
  23816. export class PhysicsImpostor {
  23817. /**
  23818. * The physics-enabled object used as the physics imposter
  23819. */
  23820. object: IPhysicsEnabledObject;
  23821. /**
  23822. * The type of the physics imposter
  23823. */
  23824. type: number;
  23825. private _options;
  23826. private _scene?;
  23827. /**
  23828. * The default object size of the imposter
  23829. */
  23830. static DEFAULT_OBJECT_SIZE: Vector3;
  23831. /**
  23832. * The identity quaternion of the imposter
  23833. */
  23834. static IDENTITY_QUATERNION: Quaternion;
  23835. /** @hidden */
  23836. _pluginData: any;
  23837. private _physicsEngine;
  23838. private _physicsBody;
  23839. private _bodyUpdateRequired;
  23840. private _onBeforePhysicsStepCallbacks;
  23841. private _onAfterPhysicsStepCallbacks;
  23842. /** @hidden */
  23843. _onPhysicsCollideCallbacks: Array<{
  23844. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23845. otherImpostors: Array<PhysicsImpostor>;
  23846. }>;
  23847. private _deltaPosition;
  23848. private _deltaRotation;
  23849. private _deltaRotationConjugated;
  23850. /** @hidden */
  23851. _isFromLine: boolean;
  23852. private _parent;
  23853. private _isDisposed;
  23854. private static _tmpVecs;
  23855. private static _tmpQuat;
  23856. /**
  23857. * Specifies if the physics imposter is disposed
  23858. */
  23859. readonly isDisposed: boolean;
  23860. /**
  23861. * Gets the mass of the physics imposter
  23862. */
  23863. mass: number;
  23864. /**
  23865. * Gets the coefficient of friction
  23866. */
  23867. /**
  23868. * Sets the coefficient of friction
  23869. */
  23870. friction: number;
  23871. /**
  23872. * Gets the coefficient of restitution
  23873. */
  23874. /**
  23875. * Sets the coefficient of restitution
  23876. */
  23877. restitution: number;
  23878. /**
  23879. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23880. */
  23881. /**
  23882. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23883. */
  23884. pressure: number;
  23885. /**
  23886. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23887. */
  23888. /**
  23889. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23890. */
  23891. stiffness: number;
  23892. /**
  23893. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23894. */
  23895. /**
  23896. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23897. */
  23898. velocityIterations: number;
  23899. /**
  23900. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23901. */
  23902. /**
  23903. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23904. */
  23905. positionIterations: number;
  23906. /**
  23907. * The unique id of the physics imposter
  23908. * set by the physics engine when adding this impostor to the array
  23909. */
  23910. uniqueId: number;
  23911. /**
  23912. * @hidden
  23913. */
  23914. soft: boolean;
  23915. /**
  23916. * @hidden
  23917. */
  23918. segments: number;
  23919. private _joints;
  23920. /**
  23921. * Initializes the physics imposter
  23922. * @param object The physics-enabled object used as the physics imposter
  23923. * @param type The type of the physics imposter
  23924. * @param _options The options for the physics imposter
  23925. * @param _scene The Babylon scene
  23926. */
  23927. constructor(
  23928. /**
  23929. * The physics-enabled object used as the physics imposter
  23930. */
  23931. object: IPhysicsEnabledObject,
  23932. /**
  23933. * The type of the physics imposter
  23934. */
  23935. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23936. /**
  23937. * This function will completly initialize this impostor.
  23938. * It will create a new body - but only if this mesh has no parent.
  23939. * If it has, this impostor will not be used other than to define the impostor
  23940. * of the child mesh.
  23941. * @hidden
  23942. */
  23943. _init(): void;
  23944. private _getPhysicsParent;
  23945. /**
  23946. * Should a new body be generated.
  23947. * @returns boolean specifying if body initialization is required
  23948. */
  23949. isBodyInitRequired(): boolean;
  23950. /**
  23951. * Sets the updated scaling
  23952. * @param updated Specifies if the scaling is updated
  23953. */
  23954. setScalingUpdated(): void;
  23955. /**
  23956. * Force a regeneration of this or the parent's impostor's body.
  23957. * Use under cautious - This will remove all joints already implemented.
  23958. */
  23959. forceUpdate(): void;
  23960. /**
  23961. * Gets the body that holds this impostor. Either its own, or its parent.
  23962. */
  23963. /**
  23964. * Set the physics body. Used mainly by the physics engine/plugin
  23965. */
  23966. physicsBody: any;
  23967. /**
  23968. * Get the parent of the physics imposter
  23969. * @returns Physics imposter or null
  23970. */
  23971. /**
  23972. * Sets the parent of the physics imposter
  23973. */
  23974. parent: Nullable<PhysicsImpostor>;
  23975. /**
  23976. * Resets the update flags
  23977. */
  23978. resetUpdateFlags(): void;
  23979. /**
  23980. * Gets the object extend size
  23981. * @returns the object extend size
  23982. */
  23983. getObjectExtendSize(): Vector3;
  23984. /**
  23985. * Gets the object center
  23986. * @returns The object center
  23987. */
  23988. getObjectCenter(): Vector3;
  23989. /**
  23990. * Get a specific parametes from the options parameter
  23991. * @param paramName The object parameter name
  23992. * @returns The object parameter
  23993. */
  23994. getParam(paramName: string): any;
  23995. /**
  23996. * Sets a specific parameter in the options given to the physics plugin
  23997. * @param paramName The parameter name
  23998. * @param value The value of the parameter
  23999. */
  24000. setParam(paramName: string, value: number): void;
  24001. /**
  24002. * Specifically change the body's mass option. Won't recreate the physics body object
  24003. * @param mass The mass of the physics imposter
  24004. */
  24005. setMass(mass: number): void;
  24006. /**
  24007. * Gets the linear velocity
  24008. * @returns linear velocity or null
  24009. */
  24010. getLinearVelocity(): Nullable<Vector3>;
  24011. /**
  24012. * Sets the linear velocity
  24013. * @param velocity linear velocity or null
  24014. */
  24015. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24016. /**
  24017. * Gets the angular velocity
  24018. * @returns angular velocity or null
  24019. */
  24020. getAngularVelocity(): Nullable<Vector3>;
  24021. /**
  24022. * Sets the angular velocity
  24023. * @param velocity The velocity or null
  24024. */
  24025. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24026. /**
  24027. * Execute a function with the physics plugin native code
  24028. * Provide a function the will have two variables - the world object and the physics body object
  24029. * @param func The function to execute with the physics plugin native code
  24030. */
  24031. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24032. /**
  24033. * Register a function that will be executed before the physics world is stepping forward
  24034. * @param func The function to execute before the physics world is stepped forward
  24035. */
  24036. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24037. /**
  24038. * Unregister a function that will be executed before the physics world is stepping forward
  24039. * @param func The function to execute before the physics world is stepped forward
  24040. */
  24041. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24042. /**
  24043. * Register a function that will be executed after the physics step
  24044. * @param func The function to execute after physics step
  24045. */
  24046. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24047. /**
  24048. * Unregisters a function that will be executed after the physics step
  24049. * @param func The function to execute after physics step
  24050. */
  24051. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24052. /**
  24053. * register a function that will be executed when this impostor collides against a different body
  24054. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24055. * @param func Callback that is executed on collision
  24056. */
  24057. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24058. /**
  24059. * Unregisters the physics imposter on contact
  24060. * @param collideAgainst The physics object to collide against
  24061. * @param func Callback to execute on collision
  24062. */
  24063. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24064. private _tmpQuat;
  24065. private _tmpQuat2;
  24066. /**
  24067. * Get the parent rotation
  24068. * @returns The parent rotation
  24069. */
  24070. getParentsRotation(): Quaternion;
  24071. /**
  24072. * this function is executed by the physics engine.
  24073. */
  24074. beforeStep: () => void;
  24075. /**
  24076. * this function is executed by the physics engine
  24077. */
  24078. afterStep: () => void;
  24079. /**
  24080. * Legacy collision detection event support
  24081. */
  24082. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24083. /**
  24084. * event and body object due to cannon's event-based architecture.
  24085. */
  24086. onCollide: (e: {
  24087. body: any;
  24088. }) => void;
  24089. /**
  24090. * Apply a force
  24091. * @param force The force to apply
  24092. * @param contactPoint The contact point for the force
  24093. * @returns The physics imposter
  24094. */
  24095. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24096. /**
  24097. * Apply an impulse
  24098. * @param force The impulse force
  24099. * @param contactPoint The contact point for the impulse force
  24100. * @returns The physics imposter
  24101. */
  24102. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24103. /**
  24104. * A help function to create a joint
  24105. * @param otherImpostor A physics imposter used to create a joint
  24106. * @param jointType The type of joint
  24107. * @param jointData The data for the joint
  24108. * @returns The physics imposter
  24109. */
  24110. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24111. /**
  24112. * Add a joint to this impostor with a different impostor
  24113. * @param otherImpostor A physics imposter used to add a joint
  24114. * @param joint The joint to add
  24115. * @returns The physics imposter
  24116. */
  24117. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24118. /**
  24119. * Add an anchor to a cloth impostor
  24120. * @param otherImpostor rigid impostor to anchor to
  24121. * @param width ratio across width from 0 to 1
  24122. * @param height ratio up height from 0 to 1
  24123. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24124. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24125. * @returns impostor the soft imposter
  24126. */
  24127. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24128. /**
  24129. * Add a hook to a rope impostor
  24130. * @param otherImpostor rigid impostor to anchor to
  24131. * @param length ratio across rope from 0 to 1
  24132. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24133. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24134. * @returns impostor the rope imposter
  24135. */
  24136. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24137. /**
  24138. * Will keep this body still, in a sleep mode.
  24139. * @returns the physics imposter
  24140. */
  24141. sleep(): PhysicsImpostor;
  24142. /**
  24143. * Wake the body up.
  24144. * @returns The physics imposter
  24145. */
  24146. wakeUp(): PhysicsImpostor;
  24147. /**
  24148. * Clones the physics imposter
  24149. * @param newObject The physics imposter clones to this physics-enabled object
  24150. * @returns A nullable physics imposter
  24151. */
  24152. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24153. /**
  24154. * Disposes the physics imposter
  24155. */
  24156. dispose(): void;
  24157. /**
  24158. * Sets the delta position
  24159. * @param position The delta position amount
  24160. */
  24161. setDeltaPosition(position: Vector3): void;
  24162. /**
  24163. * Sets the delta rotation
  24164. * @param rotation The delta rotation amount
  24165. */
  24166. setDeltaRotation(rotation: Quaternion): void;
  24167. /**
  24168. * Gets the box size of the physics imposter and stores the result in the input parameter
  24169. * @param result Stores the box size
  24170. * @returns The physics imposter
  24171. */
  24172. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24173. /**
  24174. * Gets the radius of the physics imposter
  24175. * @returns Radius of the physics imposter
  24176. */
  24177. getRadius(): number;
  24178. /**
  24179. * Sync a bone with this impostor
  24180. * @param bone The bone to sync to the impostor.
  24181. * @param boneMesh The mesh that the bone is influencing.
  24182. * @param jointPivot The pivot of the joint / bone in local space.
  24183. * @param distToJoint Optional distance from the impostor to the joint.
  24184. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24185. */
  24186. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24187. /**
  24188. * Sync impostor to a bone
  24189. * @param bone The bone that the impostor will be synced to.
  24190. * @param boneMesh The mesh that the bone is influencing.
  24191. * @param jointPivot The pivot of the joint / bone in local space.
  24192. * @param distToJoint Optional distance from the impostor to the joint.
  24193. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24194. * @param boneAxis Optional vector3 axis the bone is aligned with
  24195. */
  24196. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24197. /**
  24198. * No-Imposter type
  24199. */
  24200. static NoImpostor: number;
  24201. /**
  24202. * Sphere-Imposter type
  24203. */
  24204. static SphereImpostor: number;
  24205. /**
  24206. * Box-Imposter type
  24207. */
  24208. static BoxImpostor: number;
  24209. /**
  24210. * Plane-Imposter type
  24211. */
  24212. static PlaneImpostor: number;
  24213. /**
  24214. * Mesh-imposter type
  24215. */
  24216. static MeshImpostor: number;
  24217. /**
  24218. * Capsule-Impostor type (Ammo.js plugin only)
  24219. */
  24220. static CapsuleImpostor: number;
  24221. /**
  24222. * Cylinder-Imposter type
  24223. */
  24224. static CylinderImpostor: number;
  24225. /**
  24226. * Particle-Imposter type
  24227. */
  24228. static ParticleImpostor: number;
  24229. /**
  24230. * Heightmap-Imposter type
  24231. */
  24232. static HeightmapImpostor: number;
  24233. /**
  24234. * ConvexHull-Impostor type (Ammo.js plugin only)
  24235. */
  24236. static ConvexHullImpostor: number;
  24237. /**
  24238. * Rope-Imposter type
  24239. */
  24240. static RopeImpostor: number;
  24241. /**
  24242. * Cloth-Imposter type
  24243. */
  24244. static ClothImpostor: number;
  24245. /**
  24246. * Softbody-Imposter type
  24247. */
  24248. static SoftbodyImpostor: number;
  24249. }
  24250. }
  24251. declare module "babylonjs/Meshes/mesh" {
  24252. import { Observable } from "babylonjs/Misc/observable";
  24253. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24254. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24255. import { Camera } from "babylonjs/Cameras/camera";
  24256. import { Scene } from "babylonjs/scene";
  24257. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24258. import { Color4 } from "babylonjs/Maths/math.color";
  24259. import { Engine } from "babylonjs/Engines/engine";
  24260. import { Node } from "babylonjs/node";
  24261. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24262. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24263. import { Buffer } from "babylonjs/Meshes/buffer";
  24264. import { Geometry } from "babylonjs/Meshes/geometry";
  24265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24266. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24267. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24268. import { Effect } from "babylonjs/Materials/effect";
  24269. import { Material } from "babylonjs/Materials/material";
  24270. import { Skeleton } from "babylonjs/Bones/skeleton";
  24271. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24272. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24273. import { Path3D } from "babylonjs/Maths/math.path";
  24274. import { Plane } from "babylonjs/Maths/math.plane";
  24275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24276. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24277. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24278. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24279. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24280. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24281. /**
  24282. * @hidden
  24283. **/
  24284. export class _CreationDataStorage {
  24285. closePath?: boolean;
  24286. closeArray?: boolean;
  24287. idx: number[];
  24288. dashSize: number;
  24289. gapSize: number;
  24290. path3D: Path3D;
  24291. pathArray: Vector3[][];
  24292. arc: number;
  24293. radius: number;
  24294. cap: number;
  24295. tessellation: number;
  24296. }
  24297. /**
  24298. * @hidden
  24299. **/
  24300. class _InstanceDataStorage {
  24301. visibleInstances: any;
  24302. batchCache: _InstancesBatch;
  24303. instancesBufferSize: number;
  24304. instancesBuffer: Nullable<Buffer>;
  24305. instancesData: Float32Array;
  24306. overridenInstanceCount: number;
  24307. isFrozen: boolean;
  24308. previousBatch: Nullable<_InstancesBatch>;
  24309. hardwareInstancedRendering: boolean;
  24310. sideOrientation: number;
  24311. }
  24312. /**
  24313. * @hidden
  24314. **/
  24315. export class _InstancesBatch {
  24316. mustReturn: boolean;
  24317. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24318. renderSelf: boolean[];
  24319. hardwareInstancedRendering: boolean[];
  24320. }
  24321. /**
  24322. * Class used to represent renderable models
  24323. */
  24324. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24325. /**
  24326. * Mesh side orientation : usually the external or front surface
  24327. */
  24328. static readonly FRONTSIDE: number;
  24329. /**
  24330. * Mesh side orientation : usually the internal or back surface
  24331. */
  24332. static readonly BACKSIDE: number;
  24333. /**
  24334. * Mesh side orientation : both internal and external or front and back surfaces
  24335. */
  24336. static readonly DOUBLESIDE: number;
  24337. /**
  24338. * Mesh side orientation : by default, `FRONTSIDE`
  24339. */
  24340. static readonly DEFAULTSIDE: number;
  24341. /**
  24342. * Mesh cap setting : no cap
  24343. */
  24344. static readonly NO_CAP: number;
  24345. /**
  24346. * Mesh cap setting : one cap at the beginning of the mesh
  24347. */
  24348. static readonly CAP_START: number;
  24349. /**
  24350. * Mesh cap setting : one cap at the end of the mesh
  24351. */
  24352. static readonly CAP_END: number;
  24353. /**
  24354. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24355. */
  24356. static readonly CAP_ALL: number;
  24357. /**
  24358. * Mesh pattern setting : no flip or rotate
  24359. */
  24360. static readonly NO_FLIP: number;
  24361. /**
  24362. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24363. */
  24364. static readonly FLIP_TILE: number;
  24365. /**
  24366. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24367. */
  24368. static readonly ROTATE_TILE: number;
  24369. /**
  24370. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24371. */
  24372. static readonly FLIP_ROW: number;
  24373. /**
  24374. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24375. */
  24376. static readonly ROTATE_ROW: number;
  24377. /**
  24378. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24379. */
  24380. static readonly FLIP_N_ROTATE_TILE: number;
  24381. /**
  24382. * Mesh pattern setting : rotate pattern and rotate
  24383. */
  24384. static readonly FLIP_N_ROTATE_ROW: number;
  24385. /**
  24386. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24387. */
  24388. static readonly CENTER: number;
  24389. /**
  24390. * Mesh tile positioning : part tiles on left
  24391. */
  24392. static readonly LEFT: number;
  24393. /**
  24394. * Mesh tile positioning : part tiles on right
  24395. */
  24396. static readonly RIGHT: number;
  24397. /**
  24398. * Mesh tile positioning : part tiles on top
  24399. */
  24400. static readonly TOP: number;
  24401. /**
  24402. * Mesh tile positioning : part tiles on bottom
  24403. */
  24404. static readonly BOTTOM: number;
  24405. /**
  24406. * Gets the default side orientation.
  24407. * @param orientation the orientation to value to attempt to get
  24408. * @returns the default orientation
  24409. * @hidden
  24410. */
  24411. static _GetDefaultSideOrientation(orientation?: number): number;
  24412. private _internalMeshDataInfo;
  24413. /**
  24414. * An event triggered before rendering the mesh
  24415. */
  24416. readonly onBeforeRenderObservable: Observable<Mesh>;
  24417. /**
  24418. * An event triggered before binding the mesh
  24419. */
  24420. readonly onBeforeBindObservable: Observable<Mesh>;
  24421. /**
  24422. * An event triggered after rendering the mesh
  24423. */
  24424. readonly onAfterRenderObservable: Observable<Mesh>;
  24425. /**
  24426. * An event triggered before drawing the mesh
  24427. */
  24428. readonly onBeforeDrawObservable: Observable<Mesh>;
  24429. private _onBeforeDrawObserver;
  24430. /**
  24431. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24432. */
  24433. onBeforeDraw: () => void;
  24434. readonly hasInstances: boolean;
  24435. /**
  24436. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24437. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24438. */
  24439. delayLoadState: number;
  24440. /**
  24441. * Gets the list of instances created from this mesh
  24442. * it is not supposed to be modified manually.
  24443. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24444. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24445. */
  24446. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24447. /**
  24448. * Gets the file containing delay loading data for this mesh
  24449. */
  24450. delayLoadingFile: string;
  24451. /** @hidden */
  24452. _binaryInfo: any;
  24453. /**
  24454. * User defined function used to change how LOD level selection is done
  24455. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24456. */
  24457. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24458. /**
  24459. * Gets or sets the morph target manager
  24460. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24461. */
  24462. morphTargetManager: Nullable<MorphTargetManager>;
  24463. /** @hidden */
  24464. _creationDataStorage: Nullable<_CreationDataStorage>;
  24465. /** @hidden */
  24466. _geometry: Nullable<Geometry>;
  24467. /** @hidden */
  24468. _delayInfo: Array<string>;
  24469. /** @hidden */
  24470. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24471. /** @hidden */
  24472. _instanceDataStorage: _InstanceDataStorage;
  24473. private _effectiveMaterial;
  24474. /** @hidden */
  24475. _shouldGenerateFlatShading: boolean;
  24476. /** @hidden */
  24477. _originalBuilderSideOrientation: number;
  24478. /**
  24479. * Use this property to change the original side orientation defined at construction time
  24480. */
  24481. overrideMaterialSideOrientation: Nullable<number>;
  24482. /**
  24483. * Gets the source mesh (the one used to clone this one from)
  24484. */
  24485. readonly source: Nullable<Mesh>;
  24486. /**
  24487. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24488. */
  24489. isUnIndexed: boolean;
  24490. /**
  24491. * @constructor
  24492. * @param name The value used by scene.getMeshByName() to do a lookup.
  24493. * @param scene The scene to add this mesh to.
  24494. * @param parent The parent of this mesh, if it has one
  24495. * @param source An optional Mesh from which geometry is shared, cloned.
  24496. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24497. * When false, achieved by calling a clone(), also passing False.
  24498. * This will make creation of children, recursive.
  24499. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24500. */
  24501. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24502. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24503. doNotInstantiate: boolean;
  24504. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24505. /**
  24506. * Gets the class name
  24507. * @returns the string "Mesh".
  24508. */
  24509. getClassName(): string;
  24510. /** @hidden */
  24511. readonly _isMesh: boolean;
  24512. /**
  24513. * Returns a description of this mesh
  24514. * @param fullDetails define if full details about this mesh must be used
  24515. * @returns a descriptive string representing this mesh
  24516. */
  24517. toString(fullDetails?: boolean): string;
  24518. /** @hidden */
  24519. _unBindEffect(): void;
  24520. /**
  24521. * Gets a boolean indicating if this mesh has LOD
  24522. */
  24523. readonly hasLODLevels: boolean;
  24524. /**
  24525. * Gets the list of MeshLODLevel associated with the current mesh
  24526. * @returns an array of MeshLODLevel
  24527. */
  24528. getLODLevels(): MeshLODLevel[];
  24529. private _sortLODLevels;
  24530. /**
  24531. * Add a mesh as LOD level triggered at the given distance.
  24532. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24533. * @param distance The distance from the center of the object to show this level
  24534. * @param mesh The mesh to be added as LOD level (can be null)
  24535. * @return This mesh (for chaining)
  24536. */
  24537. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24538. /**
  24539. * Returns the LOD level mesh at the passed distance or null if not found.
  24540. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24541. * @param distance The distance from the center of the object to show this level
  24542. * @returns a Mesh or `null`
  24543. */
  24544. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24545. /**
  24546. * Remove a mesh from the LOD array
  24547. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24548. * @param mesh defines the mesh to be removed
  24549. * @return This mesh (for chaining)
  24550. */
  24551. removeLODLevel(mesh: Mesh): Mesh;
  24552. /**
  24553. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24554. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24555. * @param camera defines the camera to use to compute distance
  24556. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24557. * @return This mesh (for chaining)
  24558. */
  24559. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24560. /**
  24561. * Gets the mesh internal Geometry object
  24562. */
  24563. readonly geometry: Nullable<Geometry>;
  24564. /**
  24565. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24566. * @returns the total number of vertices
  24567. */
  24568. getTotalVertices(): number;
  24569. /**
  24570. * Returns the content of an associated vertex buffer
  24571. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24572. * - VertexBuffer.PositionKind
  24573. * - VertexBuffer.UVKind
  24574. * - VertexBuffer.UV2Kind
  24575. * - VertexBuffer.UV3Kind
  24576. * - VertexBuffer.UV4Kind
  24577. * - VertexBuffer.UV5Kind
  24578. * - VertexBuffer.UV6Kind
  24579. * - VertexBuffer.ColorKind
  24580. * - VertexBuffer.MatricesIndicesKind
  24581. * - VertexBuffer.MatricesIndicesExtraKind
  24582. * - VertexBuffer.MatricesWeightsKind
  24583. * - VertexBuffer.MatricesWeightsExtraKind
  24584. * @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
  24585. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24586. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24587. */
  24588. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24589. /**
  24590. * Returns the mesh VertexBuffer object from the requested `kind`
  24591. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24592. * - VertexBuffer.PositionKind
  24593. * - VertexBuffer.NormalKind
  24594. * - VertexBuffer.UVKind
  24595. * - VertexBuffer.UV2Kind
  24596. * - VertexBuffer.UV3Kind
  24597. * - VertexBuffer.UV4Kind
  24598. * - VertexBuffer.UV5Kind
  24599. * - VertexBuffer.UV6Kind
  24600. * - VertexBuffer.ColorKind
  24601. * - VertexBuffer.MatricesIndicesKind
  24602. * - VertexBuffer.MatricesIndicesExtraKind
  24603. * - VertexBuffer.MatricesWeightsKind
  24604. * - VertexBuffer.MatricesWeightsExtraKind
  24605. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24606. */
  24607. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24608. /**
  24609. * Tests if a specific vertex buffer is associated with this mesh
  24610. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24611. * - VertexBuffer.PositionKind
  24612. * - VertexBuffer.NormalKind
  24613. * - VertexBuffer.UVKind
  24614. * - VertexBuffer.UV2Kind
  24615. * - VertexBuffer.UV3Kind
  24616. * - VertexBuffer.UV4Kind
  24617. * - VertexBuffer.UV5Kind
  24618. * - VertexBuffer.UV6Kind
  24619. * - VertexBuffer.ColorKind
  24620. * - VertexBuffer.MatricesIndicesKind
  24621. * - VertexBuffer.MatricesIndicesExtraKind
  24622. * - VertexBuffer.MatricesWeightsKind
  24623. * - VertexBuffer.MatricesWeightsExtraKind
  24624. * @returns a boolean
  24625. */
  24626. isVerticesDataPresent(kind: string): boolean;
  24627. /**
  24628. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24629. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24630. * - VertexBuffer.PositionKind
  24631. * - VertexBuffer.UVKind
  24632. * - VertexBuffer.UV2Kind
  24633. * - VertexBuffer.UV3Kind
  24634. * - VertexBuffer.UV4Kind
  24635. * - VertexBuffer.UV5Kind
  24636. * - VertexBuffer.UV6Kind
  24637. * - VertexBuffer.ColorKind
  24638. * - VertexBuffer.MatricesIndicesKind
  24639. * - VertexBuffer.MatricesIndicesExtraKind
  24640. * - VertexBuffer.MatricesWeightsKind
  24641. * - VertexBuffer.MatricesWeightsExtraKind
  24642. * @returns a boolean
  24643. */
  24644. isVertexBufferUpdatable(kind: string): boolean;
  24645. /**
  24646. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24647. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24648. * - VertexBuffer.PositionKind
  24649. * - VertexBuffer.NormalKind
  24650. * - VertexBuffer.UVKind
  24651. * - VertexBuffer.UV2Kind
  24652. * - VertexBuffer.UV3Kind
  24653. * - VertexBuffer.UV4Kind
  24654. * - VertexBuffer.UV5Kind
  24655. * - VertexBuffer.UV6Kind
  24656. * - VertexBuffer.ColorKind
  24657. * - VertexBuffer.MatricesIndicesKind
  24658. * - VertexBuffer.MatricesIndicesExtraKind
  24659. * - VertexBuffer.MatricesWeightsKind
  24660. * - VertexBuffer.MatricesWeightsExtraKind
  24661. * @returns an array of strings
  24662. */
  24663. getVerticesDataKinds(): string[];
  24664. /**
  24665. * Returns a positive integer : the total number of indices in this mesh geometry.
  24666. * @returns the numner of indices or zero if the mesh has no geometry.
  24667. */
  24668. getTotalIndices(): number;
  24669. /**
  24670. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24671. * @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.
  24672. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24673. * @returns the indices array or an empty array if the mesh has no geometry
  24674. */
  24675. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24676. readonly isBlocked: boolean;
  24677. /**
  24678. * Determine if the current mesh is ready to be rendered
  24679. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24680. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24681. * @returns true if all associated assets are ready (material, textures, shaders)
  24682. */
  24683. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24684. /**
  24685. * 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.
  24686. */
  24687. readonly areNormalsFrozen: boolean;
  24688. /**
  24689. * 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.
  24690. * @returns the current mesh
  24691. */
  24692. freezeNormals(): Mesh;
  24693. /**
  24694. * 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
  24695. * @returns the current mesh
  24696. */
  24697. unfreezeNormals(): Mesh;
  24698. /**
  24699. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24700. */
  24701. overridenInstanceCount: number;
  24702. /** @hidden */
  24703. _preActivate(): Mesh;
  24704. /** @hidden */
  24705. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24706. /** @hidden */
  24707. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24708. /**
  24709. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24710. * This means the mesh underlying bounding box and sphere are recomputed.
  24711. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24712. * @returns the current mesh
  24713. */
  24714. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24715. /** @hidden */
  24716. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24717. /**
  24718. * This function will subdivide the mesh into multiple submeshes
  24719. * @param count defines the expected number of submeshes
  24720. */
  24721. subdivide(count: number): void;
  24722. /**
  24723. * Copy a FloatArray into a specific associated vertex buffer
  24724. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24725. * - VertexBuffer.PositionKind
  24726. * - VertexBuffer.UVKind
  24727. * - VertexBuffer.UV2Kind
  24728. * - VertexBuffer.UV3Kind
  24729. * - VertexBuffer.UV4Kind
  24730. * - VertexBuffer.UV5Kind
  24731. * - VertexBuffer.UV6Kind
  24732. * - VertexBuffer.ColorKind
  24733. * - VertexBuffer.MatricesIndicesKind
  24734. * - VertexBuffer.MatricesIndicesExtraKind
  24735. * - VertexBuffer.MatricesWeightsKind
  24736. * - VertexBuffer.MatricesWeightsExtraKind
  24737. * @param data defines the data source
  24738. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24739. * @param stride defines the data stride size (can be null)
  24740. * @returns the current mesh
  24741. */
  24742. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24743. /**
  24744. * Delete a vertex buffer associated with this mesh
  24745. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24746. * - VertexBuffer.PositionKind
  24747. * - VertexBuffer.UVKind
  24748. * - VertexBuffer.UV2Kind
  24749. * - VertexBuffer.UV3Kind
  24750. * - VertexBuffer.UV4Kind
  24751. * - VertexBuffer.UV5Kind
  24752. * - VertexBuffer.UV6Kind
  24753. * - VertexBuffer.ColorKind
  24754. * - VertexBuffer.MatricesIndicesKind
  24755. * - VertexBuffer.MatricesIndicesExtraKind
  24756. * - VertexBuffer.MatricesWeightsKind
  24757. * - VertexBuffer.MatricesWeightsExtraKind
  24758. */
  24759. removeVerticesData(kind: string): void;
  24760. /**
  24761. * Flags an associated vertex buffer as updatable
  24762. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24763. * - VertexBuffer.PositionKind
  24764. * - VertexBuffer.UVKind
  24765. * - VertexBuffer.UV2Kind
  24766. * - VertexBuffer.UV3Kind
  24767. * - VertexBuffer.UV4Kind
  24768. * - VertexBuffer.UV5Kind
  24769. * - VertexBuffer.UV6Kind
  24770. * - VertexBuffer.ColorKind
  24771. * - VertexBuffer.MatricesIndicesKind
  24772. * - VertexBuffer.MatricesIndicesExtraKind
  24773. * - VertexBuffer.MatricesWeightsKind
  24774. * - VertexBuffer.MatricesWeightsExtraKind
  24775. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24776. */
  24777. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24778. /**
  24779. * Sets the mesh global Vertex Buffer
  24780. * @param buffer defines the buffer to use
  24781. * @returns the current mesh
  24782. */
  24783. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24784. /**
  24785. * Update a specific associated vertex buffer
  24786. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24787. * - VertexBuffer.PositionKind
  24788. * - VertexBuffer.UVKind
  24789. * - VertexBuffer.UV2Kind
  24790. * - VertexBuffer.UV3Kind
  24791. * - VertexBuffer.UV4Kind
  24792. * - VertexBuffer.UV5Kind
  24793. * - VertexBuffer.UV6Kind
  24794. * - VertexBuffer.ColorKind
  24795. * - VertexBuffer.MatricesIndicesKind
  24796. * - VertexBuffer.MatricesIndicesExtraKind
  24797. * - VertexBuffer.MatricesWeightsKind
  24798. * - VertexBuffer.MatricesWeightsExtraKind
  24799. * @param data defines the data source
  24800. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24801. * @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)
  24802. * @returns the current mesh
  24803. */
  24804. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24805. /**
  24806. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24807. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24808. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24809. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24810. * @returns the current mesh
  24811. */
  24812. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24813. /**
  24814. * Creates a un-shared specific occurence of the geometry for the mesh.
  24815. * @returns the current mesh
  24816. */
  24817. makeGeometryUnique(): Mesh;
  24818. /**
  24819. * Set the index buffer of this mesh
  24820. * @param indices defines the source data
  24821. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24822. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24823. * @returns the current mesh
  24824. */
  24825. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24826. /**
  24827. * Update the current index buffer
  24828. * @param indices defines the source data
  24829. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24830. * @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)
  24831. * @returns the current mesh
  24832. */
  24833. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24834. /**
  24835. * Invert the geometry to move from a right handed system to a left handed one.
  24836. * @returns the current mesh
  24837. */
  24838. toLeftHanded(): Mesh;
  24839. /** @hidden */
  24840. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24841. /** @hidden */
  24842. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24843. /**
  24844. * Registers for this mesh a javascript function called just before the rendering process
  24845. * @param func defines the function to call before rendering this mesh
  24846. * @returns the current mesh
  24847. */
  24848. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24849. /**
  24850. * Disposes a previously registered javascript function called before the rendering
  24851. * @param func defines the function to remove
  24852. * @returns the current mesh
  24853. */
  24854. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24855. /**
  24856. * Registers for this mesh a javascript function called just after the rendering is complete
  24857. * @param func defines the function to call after rendering this mesh
  24858. * @returns the current mesh
  24859. */
  24860. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24861. /**
  24862. * Disposes a previously registered javascript function called after the rendering.
  24863. * @param func defines the function to remove
  24864. * @returns the current mesh
  24865. */
  24866. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24867. /** @hidden */
  24868. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24869. /** @hidden */
  24870. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24871. /** @hidden */
  24872. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24873. /** @hidden */
  24874. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24875. /** @hidden */
  24876. _rebuild(): void;
  24877. /** @hidden */
  24878. _freeze(): void;
  24879. /** @hidden */
  24880. _unFreeze(): void;
  24881. /**
  24882. * 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
  24883. * @param subMesh defines the subMesh to render
  24884. * @param enableAlphaMode defines if alpha mode can be changed
  24885. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24886. * @returns the current mesh
  24887. */
  24888. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24889. private _onBeforeDraw;
  24890. /**
  24891. * Renormalize the mesh and patch it up if there are no weights
  24892. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24893. * However in the case of zero weights then we set just a single influence to 1.
  24894. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24895. */
  24896. cleanMatrixWeights(): void;
  24897. private normalizeSkinFourWeights;
  24898. private normalizeSkinWeightsAndExtra;
  24899. /**
  24900. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24901. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24902. * the user know there was an issue with importing the mesh
  24903. * @returns a validation object with skinned, valid and report string
  24904. */
  24905. validateSkinning(): {
  24906. skinned: boolean;
  24907. valid: boolean;
  24908. report: string;
  24909. };
  24910. /** @hidden */
  24911. _checkDelayState(): Mesh;
  24912. private _queueLoad;
  24913. /**
  24914. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24915. * A mesh is in the frustum if its bounding box intersects the frustum
  24916. * @param frustumPlanes defines the frustum to test
  24917. * @returns true if the mesh is in the frustum planes
  24918. */
  24919. isInFrustum(frustumPlanes: Plane[]): boolean;
  24920. /**
  24921. * Sets the mesh material by the material or multiMaterial `id` property
  24922. * @param id is a string identifying the material or the multiMaterial
  24923. * @returns the current mesh
  24924. */
  24925. setMaterialByID(id: string): Mesh;
  24926. /**
  24927. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24928. * @returns an array of IAnimatable
  24929. */
  24930. getAnimatables(): IAnimatable[];
  24931. /**
  24932. * Modifies the mesh geometry according to the passed transformation matrix.
  24933. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24934. * The mesh normals are modified using the same transformation.
  24935. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24936. * @param transform defines the transform matrix to use
  24937. * @see http://doc.babylonjs.com/resources/baking_transformations
  24938. * @returns the current mesh
  24939. */
  24940. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24941. /**
  24942. * Modifies the mesh geometry according to its own current World Matrix.
  24943. * The mesh World Matrix is then reset.
  24944. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24945. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24946. * @see http://doc.babylonjs.com/resources/baking_transformations
  24947. * @returns the current mesh
  24948. */
  24949. bakeCurrentTransformIntoVertices(): Mesh;
  24950. /** @hidden */
  24951. readonly _positions: Nullable<Vector3[]>;
  24952. /** @hidden */
  24953. _resetPointsArrayCache(): Mesh;
  24954. /** @hidden */
  24955. _generatePointsArray(): boolean;
  24956. /**
  24957. * Returns a new Mesh object generated from the current mesh properties.
  24958. * This method must not get confused with createInstance()
  24959. * @param name is a string, the name given to the new mesh
  24960. * @param newParent can be any Node object (default `null`)
  24961. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24962. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24963. * @returns a new mesh
  24964. */
  24965. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24966. /**
  24967. * Releases resources associated with this mesh.
  24968. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24969. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24970. */
  24971. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24972. /** @hidden */
  24973. _disposeInstanceSpecificData(): void;
  24974. /**
  24975. * Modifies the mesh geometry according to a displacement map.
  24976. * 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.
  24977. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24978. * @param url is a string, the URL from the image file is to be downloaded.
  24979. * @param minHeight is the lower limit of the displacement.
  24980. * @param maxHeight is the upper limit of the displacement.
  24981. * @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.
  24982. * @param uvOffset is an optional vector2 used to offset UV.
  24983. * @param uvScale is an optional vector2 used to scale UV.
  24984. * @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.
  24985. * @returns the Mesh.
  24986. */
  24987. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24988. /**
  24989. * Modifies the mesh geometry according to a displacementMap buffer.
  24990. * 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.
  24991. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24992. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24993. * @param heightMapWidth is the width of the buffer image.
  24994. * @param heightMapHeight is the height of the buffer image.
  24995. * @param minHeight is the lower limit of the displacement.
  24996. * @param maxHeight is the upper limit of the displacement.
  24997. * @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.
  24998. * @param uvOffset is an optional vector2 used to offset UV.
  24999. * @param uvScale is an optional vector2 used to scale UV.
  25000. * @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.
  25001. * @returns the Mesh.
  25002. */
  25003. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25004. /**
  25005. * Modify the mesh to get a flat shading rendering.
  25006. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25007. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25008. * @returns current mesh
  25009. */
  25010. convertToFlatShadedMesh(): Mesh;
  25011. /**
  25012. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25013. * In other words, more vertices, no more indices and a single bigger VBO.
  25014. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25015. * @returns current mesh
  25016. */
  25017. convertToUnIndexedMesh(): Mesh;
  25018. /**
  25019. * Inverses facet orientations.
  25020. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25021. * @param flipNormals will also inverts the normals
  25022. * @returns current mesh
  25023. */
  25024. flipFaces(flipNormals?: boolean): Mesh;
  25025. /**
  25026. * Increase the number of facets and hence vertices in a mesh
  25027. * Vertex normals are interpolated from existing vertex normals
  25028. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25029. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25030. */
  25031. increaseVertices(numberPerEdge: number): void;
  25032. /**
  25033. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25034. * This will undo any application of covertToFlatShadedMesh
  25035. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25036. */
  25037. forceSharedVertices(): void;
  25038. /** @hidden */
  25039. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25040. /** @hidden */
  25041. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25042. /**
  25043. * Creates a new InstancedMesh object from the mesh model.
  25044. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25045. * @param name defines the name of the new instance
  25046. * @returns a new InstancedMesh
  25047. */
  25048. createInstance(name: string): InstancedMesh;
  25049. /**
  25050. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25051. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25052. * @returns the current mesh
  25053. */
  25054. synchronizeInstances(): Mesh;
  25055. /**
  25056. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25057. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25058. * This should be used together with the simplification to avoid disappearing triangles.
  25059. * @param successCallback an optional success callback to be called after the optimization finished.
  25060. * @returns the current mesh
  25061. */
  25062. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25063. /**
  25064. * Serialize current mesh
  25065. * @param serializationObject defines the object which will receive the serialization data
  25066. */
  25067. serialize(serializationObject: any): void;
  25068. /** @hidden */
  25069. _syncGeometryWithMorphTargetManager(): void;
  25070. /** @hidden */
  25071. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25072. /**
  25073. * Returns a new Mesh object parsed from the source provided.
  25074. * @param parsedMesh is the source
  25075. * @param scene defines the hosting scene
  25076. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25077. * @returns a new Mesh
  25078. */
  25079. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25080. /**
  25081. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25082. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25083. * @param name defines the name of the mesh to create
  25084. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25085. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25086. * @param closePath creates a seam between the first and the last points of each path of the path array
  25087. * @param offset is taken in account only if the `pathArray` is containing a single path
  25088. * @param scene defines the hosting scene
  25089. * @param updatable defines if the mesh must be flagged as updatable
  25090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25091. * @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)
  25092. * @returns a new Mesh
  25093. */
  25094. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25095. /**
  25096. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25097. * @param name defines the name of the mesh to create
  25098. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25099. * @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
  25100. * @param scene defines the hosting scene
  25101. * @param updatable defines if the mesh must be flagged as updatable
  25102. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25103. * @returns a new Mesh
  25104. */
  25105. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25106. /**
  25107. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25108. * @param name defines the name of the mesh to create
  25109. * @param size sets the size (float) of each box side (default 1)
  25110. * @param scene defines the hosting scene
  25111. * @param updatable defines if the mesh must be flagged as updatable
  25112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25113. * @returns a new Mesh
  25114. */
  25115. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25116. /**
  25117. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25118. * @param name defines the name of the mesh to create
  25119. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25120. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25121. * @param scene defines the hosting scene
  25122. * @param updatable defines if the mesh must be flagged as updatable
  25123. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25124. * @returns a new Mesh
  25125. */
  25126. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25127. /**
  25128. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25129. * @param name defines the name of the mesh to create
  25130. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25131. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25132. * @param scene defines the hosting scene
  25133. * @returns a new Mesh
  25134. */
  25135. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25136. /**
  25137. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25138. * @param name defines the name of the mesh to create
  25139. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25140. * @param diameterTop set the top cap diameter (floats, default 1)
  25141. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25142. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25143. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25144. * @param scene defines the hosting scene
  25145. * @param updatable defines if the mesh must be flagged as updatable
  25146. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25147. * @returns a new Mesh
  25148. */
  25149. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25150. /**
  25151. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25152. * @param name defines the name of the mesh to create
  25153. * @param diameter sets the diameter size (float) of the torus (default 1)
  25154. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25155. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25156. * @param scene defines the hosting scene
  25157. * @param updatable defines if the mesh must be flagged as updatable
  25158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25159. * @returns a new Mesh
  25160. */
  25161. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25162. /**
  25163. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25164. * @param name defines the name of the mesh to create
  25165. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25166. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25167. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25168. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25169. * @param p the number of windings on X axis (positive integers, default 2)
  25170. * @param q the number of windings on Y axis (positive integers, default 3)
  25171. * @param scene defines the hosting scene
  25172. * @param updatable defines if the mesh must be flagged as updatable
  25173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25174. * @returns a new Mesh
  25175. */
  25176. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25177. /**
  25178. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25179. * @param name defines the name of the mesh to create
  25180. * @param points is an array successive Vector3
  25181. * @param scene defines the hosting scene
  25182. * @param updatable defines if the mesh must be flagged as updatable
  25183. * @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).
  25184. * @returns a new Mesh
  25185. */
  25186. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25187. /**
  25188. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25189. * @param name defines the name of the mesh to create
  25190. * @param points is an array successive Vector3
  25191. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25192. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25193. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25194. * @param scene defines the hosting scene
  25195. * @param updatable defines if the mesh must be flagged as updatable
  25196. * @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)
  25197. * @returns a new Mesh
  25198. */
  25199. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25200. /**
  25201. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25202. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25203. * 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.
  25204. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25205. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25206. * Remember you can only change the shape positions, not their number when updating a polygon.
  25207. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25208. * @param name defines the name of the mesh to create
  25209. * @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
  25210. * @param scene defines the hosting scene
  25211. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25212. * @param updatable defines if the mesh must be flagged as updatable
  25213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25214. * @param earcutInjection can be used to inject your own earcut reference
  25215. * @returns a new Mesh
  25216. */
  25217. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25218. /**
  25219. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25220. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25221. * @param name defines the name of the mesh to create
  25222. * @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
  25223. * @param depth defines the height of extrusion
  25224. * @param scene defines the hosting scene
  25225. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25226. * @param updatable defines if the mesh must be flagged as updatable
  25227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25228. * @param earcutInjection can be used to inject your own earcut reference
  25229. * @returns a new Mesh
  25230. */
  25231. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25232. /**
  25233. * Creates an extruded shape mesh.
  25234. * 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
  25235. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25236. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25237. * @param name defines the name of the mesh to create
  25238. * @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
  25239. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25240. * @param scale is the value to scale the shape
  25241. * @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
  25242. * @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
  25243. * @param scene defines the hosting scene
  25244. * @param updatable defines if the mesh must be flagged as updatable
  25245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25246. * @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)
  25247. * @returns a new Mesh
  25248. */
  25249. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25250. /**
  25251. * Creates an custom extruded shape mesh.
  25252. * The custom extrusion is a parametric shape.
  25253. * It has no predefined shape. Its final shape will depend on the input parameters.
  25254. * Please consider using the same method from the MeshBuilder class instead
  25255. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25256. * @param name defines the name of the mesh to create
  25257. * @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
  25258. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25259. * @param scaleFunction is a custom Javascript function called on each path point
  25260. * @param rotationFunction is a custom Javascript function called on each path point
  25261. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25262. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25263. * @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
  25264. * @param scene defines the hosting scene
  25265. * @param updatable defines if the mesh must be flagged as updatable
  25266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25267. * @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)
  25268. * @returns a new Mesh
  25269. */
  25270. 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;
  25271. /**
  25272. * Creates lathe mesh.
  25273. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25274. * Please consider using the same method from the MeshBuilder class instead
  25275. * @param name defines the name of the mesh to create
  25276. * @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
  25277. * @param radius is the radius value of the lathe
  25278. * @param tessellation is the side number of the lathe.
  25279. * @param scene defines the hosting scene
  25280. * @param updatable defines if the mesh must be flagged as updatable
  25281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25282. * @returns a new Mesh
  25283. */
  25284. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25285. /**
  25286. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25287. * @param name defines the name of the mesh to create
  25288. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25289. * @param scene defines the hosting scene
  25290. * @param updatable defines if the mesh must be flagged as updatable
  25291. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25292. * @returns a new Mesh
  25293. */
  25294. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25295. /**
  25296. * Creates a ground mesh.
  25297. * Please consider using the same method from the MeshBuilder class instead
  25298. * @param name defines the name of the mesh to create
  25299. * @param width set the width of the ground
  25300. * @param height set the height of the ground
  25301. * @param subdivisions sets the number of subdivisions per side
  25302. * @param scene defines the hosting scene
  25303. * @param updatable defines if the mesh must be flagged as updatable
  25304. * @returns a new Mesh
  25305. */
  25306. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25307. /**
  25308. * Creates a tiled ground mesh.
  25309. * Please consider using the same method from the MeshBuilder class instead
  25310. * @param name defines the name of the mesh to create
  25311. * @param xmin set the ground minimum X coordinate
  25312. * @param zmin set the ground minimum Y coordinate
  25313. * @param xmax set the ground maximum X coordinate
  25314. * @param zmax set the ground maximum Z coordinate
  25315. * @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
  25316. * @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
  25317. * @param scene defines the hosting scene
  25318. * @param updatable defines if the mesh must be flagged as updatable
  25319. * @returns a new Mesh
  25320. */
  25321. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25322. w: number;
  25323. h: number;
  25324. }, precision: {
  25325. w: number;
  25326. h: number;
  25327. }, scene: Scene, updatable?: boolean): Mesh;
  25328. /**
  25329. * Creates a ground mesh from a height map.
  25330. * Please consider using the same method from the MeshBuilder class instead
  25331. * @see http://doc.babylonjs.com/babylon101/height_map
  25332. * @param name defines the name of the mesh to create
  25333. * @param url sets the URL of the height map image resource
  25334. * @param width set the ground width size
  25335. * @param height set the ground height size
  25336. * @param subdivisions sets the number of subdivision per side
  25337. * @param minHeight is the minimum altitude on the ground
  25338. * @param maxHeight is the maximum altitude on the ground
  25339. * @param scene defines the hosting scene
  25340. * @param updatable defines if the mesh must be flagged as updatable
  25341. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25342. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25343. * @returns a new Mesh
  25344. */
  25345. 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;
  25346. /**
  25347. * Creates a tube mesh.
  25348. * The tube is a parametric shape.
  25349. * It has no predefined shape. Its final shape will depend on the input parameters.
  25350. * Please consider using the same method from the MeshBuilder class instead
  25351. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25352. * @param name defines the name of the mesh to create
  25353. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25354. * @param radius sets the tube radius size
  25355. * @param tessellation is the number of sides on the tubular surface
  25356. * @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
  25357. * @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
  25358. * @param scene defines the hosting scene
  25359. * @param updatable defines if the mesh must be flagged as updatable
  25360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25361. * @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)
  25362. * @returns a new Mesh
  25363. */
  25364. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25365. (i: number, distance: number): number;
  25366. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25367. /**
  25368. * Creates a polyhedron mesh.
  25369. * Please consider using the same method from the MeshBuilder class instead.
  25370. * * 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
  25371. * * The parameter `size` (positive float, default 1) sets the polygon size
  25372. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25373. * * 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`
  25374. * * 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
  25375. * * 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)`)
  25376. * * 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
  25377. * * 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
  25378. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25379. * * If you create a double-sided mesh, you can choose what parts of 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
  25380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25381. * @param name defines the name of the mesh to create
  25382. * @param options defines the options used to create the mesh
  25383. * @param scene defines the hosting scene
  25384. * @returns a new Mesh
  25385. */
  25386. static CreatePolyhedron(name: string, options: {
  25387. type?: number;
  25388. size?: number;
  25389. sizeX?: number;
  25390. sizeY?: number;
  25391. sizeZ?: number;
  25392. custom?: any;
  25393. faceUV?: Vector4[];
  25394. faceColors?: Color4[];
  25395. updatable?: boolean;
  25396. sideOrientation?: number;
  25397. }, scene: Scene): Mesh;
  25398. /**
  25399. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25400. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25401. * * 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`)
  25402. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25403. * * 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
  25404. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25405. * * If you create a double-sided mesh, you can choose what parts of 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
  25406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25407. * @param name defines the name of the mesh
  25408. * @param options defines the options used to create the mesh
  25409. * @param scene defines the hosting scene
  25410. * @returns a new Mesh
  25411. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25412. */
  25413. static CreateIcoSphere(name: string, options: {
  25414. radius?: number;
  25415. flat?: boolean;
  25416. subdivisions?: number;
  25417. sideOrientation?: number;
  25418. updatable?: boolean;
  25419. }, scene: Scene): Mesh;
  25420. /**
  25421. * Creates a decal mesh.
  25422. * Please consider using the same method from the MeshBuilder class instead.
  25423. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25424. * @param name defines the name of the mesh
  25425. * @param sourceMesh defines the mesh receiving the decal
  25426. * @param position sets the position of the decal in world coordinates
  25427. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25428. * @param size sets the decal scaling
  25429. * @param angle sets the angle to rotate the decal
  25430. * @returns a new Mesh
  25431. */
  25432. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25433. /**
  25434. * Prepare internal position array for software CPU skinning
  25435. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25436. */
  25437. setPositionsForCPUSkinning(): Float32Array;
  25438. /**
  25439. * Prepare internal normal array for software CPU skinning
  25440. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25441. */
  25442. setNormalsForCPUSkinning(): Float32Array;
  25443. /**
  25444. * Updates the vertex buffer by applying transformation from the bones
  25445. * @param skeleton defines the skeleton to apply to current mesh
  25446. * @returns the current mesh
  25447. */
  25448. applySkeleton(skeleton: Skeleton): Mesh;
  25449. /**
  25450. * 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
  25451. * @param meshes defines the list of meshes to scan
  25452. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25453. */
  25454. static MinMax(meshes: AbstractMesh[]): {
  25455. min: Vector3;
  25456. max: Vector3;
  25457. };
  25458. /**
  25459. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25460. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25461. * @returns a vector3
  25462. */
  25463. static Center(meshesOrMinMaxVector: {
  25464. min: Vector3;
  25465. max: Vector3;
  25466. } | AbstractMesh[]): Vector3;
  25467. /**
  25468. * Merge the array of meshes into a single mesh for performance reasons.
  25469. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25470. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25471. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25472. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25473. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25474. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25475. * @returns a new mesh
  25476. */
  25477. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25478. /** @hidden */
  25479. addInstance(instance: InstancedMesh): void;
  25480. /** @hidden */
  25481. removeInstance(instance: InstancedMesh): void;
  25482. }
  25483. }
  25484. declare module "babylonjs/Cameras/camera" {
  25485. import { SmartArray } from "babylonjs/Misc/smartArray";
  25486. import { Observable } from "babylonjs/Misc/observable";
  25487. import { Nullable } from "babylonjs/types";
  25488. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25489. import { Scene } from "babylonjs/scene";
  25490. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25491. import { Node } from "babylonjs/node";
  25492. import { Mesh } from "babylonjs/Meshes/mesh";
  25493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25494. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25495. import { Viewport } from "babylonjs/Maths/math.viewport";
  25496. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25497. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25498. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25499. import { Ray } from "babylonjs/Culling/ray";
  25500. /**
  25501. * This is the base class of all the camera used in the application.
  25502. * @see http://doc.babylonjs.com/features/cameras
  25503. */
  25504. export class Camera extends Node {
  25505. /** @hidden */
  25506. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25507. /**
  25508. * This is the default projection mode used by the cameras.
  25509. * It helps recreating a feeling of perspective and better appreciate depth.
  25510. * This is the best way to simulate real life cameras.
  25511. */
  25512. static readonly PERSPECTIVE_CAMERA: number;
  25513. /**
  25514. * This helps creating camera with an orthographic mode.
  25515. * 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.
  25516. */
  25517. static readonly ORTHOGRAPHIC_CAMERA: number;
  25518. /**
  25519. * This is the default FOV mode for perspective cameras.
  25520. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25521. */
  25522. static readonly FOVMODE_VERTICAL_FIXED: number;
  25523. /**
  25524. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25525. */
  25526. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25527. /**
  25528. * This specifies ther is no need for a camera rig.
  25529. * Basically only one eye is rendered corresponding to the camera.
  25530. */
  25531. static readonly RIG_MODE_NONE: number;
  25532. /**
  25533. * Simulates a camera Rig with one blue eye and one red eye.
  25534. * This can be use with 3d blue and red glasses.
  25535. */
  25536. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25537. /**
  25538. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25539. */
  25540. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25541. /**
  25542. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25543. */
  25544. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25545. /**
  25546. * Defines that both eyes of the camera will be rendered over under each other.
  25547. */
  25548. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25549. /**
  25550. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25551. */
  25552. static readonly RIG_MODE_VR: number;
  25553. /**
  25554. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25555. */
  25556. static readonly RIG_MODE_WEBVR: number;
  25557. /**
  25558. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25559. */
  25560. static readonly RIG_MODE_CUSTOM: number;
  25561. /**
  25562. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25563. */
  25564. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25565. /**
  25566. * Define the input manager associated with the camera.
  25567. */
  25568. inputs: CameraInputsManager<Camera>;
  25569. /** @hidden */
  25570. _position: Vector3;
  25571. /**
  25572. * Define the current local position of the camera in the scene
  25573. */
  25574. position: Vector3;
  25575. /**
  25576. * The vector the camera should consider as up.
  25577. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25578. */
  25579. upVector: Vector3;
  25580. /**
  25581. * Define the current limit on the left side for an orthographic camera
  25582. * In scene unit
  25583. */
  25584. orthoLeft: Nullable<number>;
  25585. /**
  25586. * Define the current limit on the right side for an orthographic camera
  25587. * In scene unit
  25588. */
  25589. orthoRight: Nullable<number>;
  25590. /**
  25591. * Define the current limit on the bottom side for an orthographic camera
  25592. * In scene unit
  25593. */
  25594. orthoBottom: Nullable<number>;
  25595. /**
  25596. * Define the current limit on the top side for an orthographic camera
  25597. * In scene unit
  25598. */
  25599. orthoTop: Nullable<number>;
  25600. /**
  25601. * Field Of View is set in Radians. (default is 0.8)
  25602. */
  25603. fov: number;
  25604. /**
  25605. * Define the minimum distance the camera can see from.
  25606. * This is important to note that the depth buffer are not infinite and the closer it starts
  25607. * the more your scene might encounter depth fighting issue.
  25608. */
  25609. minZ: number;
  25610. /**
  25611. * Define the maximum distance the camera can see to.
  25612. * This is important to note that the depth buffer are not infinite and the further it end
  25613. * the more your scene might encounter depth fighting issue.
  25614. */
  25615. maxZ: number;
  25616. /**
  25617. * Define the default inertia of the camera.
  25618. * This helps giving a smooth feeling to the camera movement.
  25619. */
  25620. inertia: number;
  25621. /**
  25622. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25623. */
  25624. mode: number;
  25625. /**
  25626. * Define wether the camera is intermediate.
  25627. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25628. */
  25629. isIntermediate: boolean;
  25630. /**
  25631. * Define the viewport of the camera.
  25632. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25633. */
  25634. viewport: Viewport;
  25635. /**
  25636. * Restricts the camera to viewing objects with the same layerMask.
  25637. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25638. */
  25639. layerMask: number;
  25640. /**
  25641. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25642. */
  25643. fovMode: number;
  25644. /**
  25645. * Rig mode of the camera.
  25646. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25647. * This is normally controlled byt the camera themselves as internal use.
  25648. */
  25649. cameraRigMode: number;
  25650. /**
  25651. * Defines the distance between both "eyes" in case of a RIG
  25652. */
  25653. interaxialDistance: number;
  25654. /**
  25655. * Defines if stereoscopic rendering is done side by side or over under.
  25656. */
  25657. isStereoscopicSideBySide: boolean;
  25658. /**
  25659. * 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
  25660. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25661. * else in the scene. (Eg. security camera)
  25662. *
  25663. * 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)
  25664. */
  25665. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25666. /**
  25667. * When set, the camera will render to this render target instead of the default canvas
  25668. *
  25669. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25670. */
  25671. outputRenderTarget: Nullable<RenderTargetTexture>;
  25672. /**
  25673. * Observable triggered when the camera view matrix has changed.
  25674. */
  25675. onViewMatrixChangedObservable: Observable<Camera>;
  25676. /**
  25677. * Observable triggered when the camera Projection matrix has changed.
  25678. */
  25679. onProjectionMatrixChangedObservable: Observable<Camera>;
  25680. /**
  25681. * Observable triggered when the inputs have been processed.
  25682. */
  25683. onAfterCheckInputsObservable: Observable<Camera>;
  25684. /**
  25685. * Observable triggered when reset has been called and applied to the camera.
  25686. */
  25687. onRestoreStateObservable: Observable<Camera>;
  25688. /** @hidden */
  25689. _cameraRigParams: any;
  25690. /** @hidden */
  25691. _rigCameras: Camera[];
  25692. /** @hidden */
  25693. _rigPostProcess: Nullable<PostProcess>;
  25694. protected _webvrViewMatrix: Matrix;
  25695. /** @hidden */
  25696. _skipRendering: boolean;
  25697. /** @hidden */
  25698. _projectionMatrix: Matrix;
  25699. /** @hidden */
  25700. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25701. /** @hidden */
  25702. _activeMeshes: SmartArray<AbstractMesh>;
  25703. protected _globalPosition: Vector3;
  25704. /** @hidden */
  25705. _computedViewMatrix: Matrix;
  25706. private _doNotComputeProjectionMatrix;
  25707. private _transformMatrix;
  25708. private _frustumPlanes;
  25709. private _refreshFrustumPlanes;
  25710. private _storedFov;
  25711. private _stateStored;
  25712. /**
  25713. * Instantiates a new camera object.
  25714. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25715. * @see http://doc.babylonjs.com/features/cameras
  25716. * @param name Defines the name of the camera in the scene
  25717. * @param position Defines the position of the camera
  25718. * @param scene Defines the scene the camera belongs too
  25719. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25720. */
  25721. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25722. /**
  25723. * Store current camera state (fov, position, etc..)
  25724. * @returns the camera
  25725. */
  25726. storeState(): Camera;
  25727. /**
  25728. * Restores the camera state values if it has been stored. You must call storeState() first
  25729. */
  25730. protected _restoreStateValues(): boolean;
  25731. /**
  25732. * Restored camera state. You must call storeState() first.
  25733. * @returns true if restored and false otherwise
  25734. */
  25735. restoreState(): boolean;
  25736. /**
  25737. * Gets the class name of the camera.
  25738. * @returns the class name
  25739. */
  25740. getClassName(): string;
  25741. /** @hidden */
  25742. readonly _isCamera: boolean;
  25743. /**
  25744. * Gets a string representation of the camera useful for debug purpose.
  25745. * @param fullDetails Defines that a more verboe level of logging is required
  25746. * @returns the string representation
  25747. */
  25748. toString(fullDetails?: boolean): string;
  25749. /**
  25750. * Gets the current world space position of the camera.
  25751. */
  25752. readonly globalPosition: Vector3;
  25753. /**
  25754. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25755. * @returns the active meshe list
  25756. */
  25757. getActiveMeshes(): SmartArray<AbstractMesh>;
  25758. /**
  25759. * Check wether a mesh is part of the current active mesh list of the camera
  25760. * @param mesh Defines the mesh to check
  25761. * @returns true if active, false otherwise
  25762. */
  25763. isActiveMesh(mesh: Mesh): boolean;
  25764. /**
  25765. * Is this camera ready to be used/rendered
  25766. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25767. * @return true if the camera is ready
  25768. */
  25769. isReady(completeCheck?: boolean): boolean;
  25770. /** @hidden */
  25771. _initCache(): void;
  25772. /** @hidden */
  25773. _updateCache(ignoreParentClass?: boolean): void;
  25774. /** @hidden */
  25775. _isSynchronized(): boolean;
  25776. /** @hidden */
  25777. _isSynchronizedViewMatrix(): boolean;
  25778. /** @hidden */
  25779. _isSynchronizedProjectionMatrix(): boolean;
  25780. /**
  25781. * Attach the input controls to a specific dom element to get the input from.
  25782. * @param element Defines the element the controls should be listened from
  25783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25784. */
  25785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25786. /**
  25787. * Detach the current controls from the specified dom element.
  25788. * @param element Defines the element to stop listening the inputs from
  25789. */
  25790. detachControl(element: HTMLElement): void;
  25791. /**
  25792. * Update the camera state according to the different inputs gathered during the frame.
  25793. */
  25794. update(): void;
  25795. /** @hidden */
  25796. _checkInputs(): void;
  25797. /** @hidden */
  25798. readonly rigCameras: Camera[];
  25799. /**
  25800. * Gets the post process used by the rig cameras
  25801. */
  25802. readonly rigPostProcess: Nullable<PostProcess>;
  25803. /**
  25804. * Internal, gets the first post proces.
  25805. * @returns the first post process to be run on this camera.
  25806. */
  25807. _getFirstPostProcess(): Nullable<PostProcess>;
  25808. private _cascadePostProcessesToRigCams;
  25809. /**
  25810. * Attach a post process to the camera.
  25811. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25812. * @param postProcess The post process to attach to the camera
  25813. * @param insertAt The position of the post process in case several of them are in use in the scene
  25814. * @returns the position the post process has been inserted at
  25815. */
  25816. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25817. /**
  25818. * Detach a post process to the camera.
  25819. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25820. * @param postProcess The post process to detach from the camera
  25821. */
  25822. detachPostProcess(postProcess: PostProcess): void;
  25823. /**
  25824. * Gets the current world matrix of the camera
  25825. */
  25826. getWorldMatrix(): Matrix;
  25827. /** @hidden */
  25828. _getViewMatrix(): Matrix;
  25829. /**
  25830. * Gets the current view matrix of the camera.
  25831. * @param force forces the camera to recompute the matrix without looking at the cached state
  25832. * @returns the view matrix
  25833. */
  25834. getViewMatrix(force?: boolean): Matrix;
  25835. /**
  25836. * Freeze the projection matrix.
  25837. * It will prevent the cache check of the camera projection compute and can speed up perf
  25838. * if no parameter of the camera are meant to change
  25839. * @param projection Defines manually a projection if necessary
  25840. */
  25841. freezeProjectionMatrix(projection?: Matrix): void;
  25842. /**
  25843. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25844. */
  25845. unfreezeProjectionMatrix(): void;
  25846. /**
  25847. * Gets the current projection matrix of the camera.
  25848. * @param force forces the camera to recompute the matrix without looking at the cached state
  25849. * @returns the projection matrix
  25850. */
  25851. getProjectionMatrix(force?: boolean): Matrix;
  25852. /**
  25853. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25854. * @returns a Matrix
  25855. */
  25856. getTransformationMatrix(): Matrix;
  25857. private _updateFrustumPlanes;
  25858. /**
  25859. * Checks if a cullable object (mesh...) is in the camera frustum
  25860. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25861. * @param target The object to check
  25862. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25863. * @returns true if the object is in frustum otherwise false
  25864. */
  25865. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25866. /**
  25867. * Checks if a cullable object (mesh...) is in the camera frustum
  25868. * Unlike isInFrustum this cheks the full bounding box
  25869. * @param target The object to check
  25870. * @returns true if the object is in frustum otherwise false
  25871. */
  25872. isCompletelyInFrustum(target: ICullable): boolean;
  25873. /**
  25874. * Gets a ray in the forward direction from the camera.
  25875. * @param length Defines the length of the ray to create
  25876. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25877. * @param origin Defines the start point of the ray which defaults to the camera position
  25878. * @returns the forward ray
  25879. */
  25880. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25881. /**
  25882. * Releases resources associated with this node.
  25883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25885. */
  25886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25887. /** @hidden */
  25888. _isLeftCamera: boolean;
  25889. /**
  25890. * Gets the left camera of a rig setup in case of Rigged Camera
  25891. */
  25892. readonly isLeftCamera: boolean;
  25893. /** @hidden */
  25894. _isRightCamera: boolean;
  25895. /**
  25896. * Gets the right camera of a rig setup in case of Rigged Camera
  25897. */
  25898. readonly isRightCamera: boolean;
  25899. /**
  25900. * Gets the left camera of a rig setup in case of Rigged Camera
  25901. */
  25902. readonly leftCamera: Nullable<FreeCamera>;
  25903. /**
  25904. * Gets the right camera of a rig setup in case of Rigged Camera
  25905. */
  25906. readonly rightCamera: Nullable<FreeCamera>;
  25907. /**
  25908. * Gets the left camera target of a rig setup in case of Rigged Camera
  25909. * @returns the target position
  25910. */
  25911. getLeftTarget(): Nullable<Vector3>;
  25912. /**
  25913. * Gets the right camera target of a rig setup in case of Rigged Camera
  25914. * @returns the target position
  25915. */
  25916. getRightTarget(): Nullable<Vector3>;
  25917. /**
  25918. * @hidden
  25919. */
  25920. setCameraRigMode(mode: number, rigParams: any): void;
  25921. /** @hidden */
  25922. static _setStereoscopicRigMode(camera: Camera): void;
  25923. /** @hidden */
  25924. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25925. /** @hidden */
  25926. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25927. /** @hidden */
  25928. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25929. /** @hidden */
  25930. _getVRProjectionMatrix(): Matrix;
  25931. protected _updateCameraRotationMatrix(): void;
  25932. protected _updateWebVRCameraRotationMatrix(): void;
  25933. /**
  25934. * This function MUST be overwritten by the different WebVR cameras available.
  25935. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25936. * @hidden
  25937. */
  25938. _getWebVRProjectionMatrix(): Matrix;
  25939. /**
  25940. * This function MUST be overwritten by the different WebVR cameras available.
  25941. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25942. * @hidden
  25943. */
  25944. _getWebVRViewMatrix(): Matrix;
  25945. /** @hidden */
  25946. setCameraRigParameter(name: string, value: any): void;
  25947. /**
  25948. * needs to be overridden by children so sub has required properties to be copied
  25949. * @hidden
  25950. */
  25951. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25952. /**
  25953. * May need to be overridden by children
  25954. * @hidden
  25955. */
  25956. _updateRigCameras(): void;
  25957. /** @hidden */
  25958. _setupInputs(): void;
  25959. /**
  25960. * Serialiaze the camera setup to a json represention
  25961. * @returns the JSON representation
  25962. */
  25963. serialize(): any;
  25964. /**
  25965. * Clones the current camera.
  25966. * @param name The cloned camera name
  25967. * @returns the cloned camera
  25968. */
  25969. clone(name: string): Camera;
  25970. /**
  25971. * Gets the direction of the camera relative to a given local axis.
  25972. * @param localAxis Defines the reference axis to provide a relative direction.
  25973. * @return the direction
  25974. */
  25975. getDirection(localAxis: Vector3): Vector3;
  25976. /**
  25977. * Returns the current camera absolute rotation
  25978. */
  25979. readonly absoluteRotation: Quaternion;
  25980. /**
  25981. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25982. * @param localAxis Defines the reference axis to provide a relative direction.
  25983. * @param result Defines the vector to store the result in
  25984. */
  25985. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25986. /**
  25987. * Gets a camera constructor for a given camera type
  25988. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25989. * @param name The name of the camera the result will be able to instantiate
  25990. * @param scene The scene the result will construct the camera in
  25991. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25992. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25993. * @returns a factory method to construc the camera
  25994. */
  25995. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25996. /**
  25997. * Compute the world matrix of the camera.
  25998. * @returns the camera world matrix
  25999. */
  26000. computeWorldMatrix(): Matrix;
  26001. /**
  26002. * Parse a JSON and creates the camera from the parsed information
  26003. * @param parsedCamera The JSON to parse
  26004. * @param scene The scene to instantiate the camera in
  26005. * @returns the newly constructed camera
  26006. */
  26007. static Parse(parsedCamera: any, scene: Scene): Camera;
  26008. }
  26009. }
  26010. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26011. import { Nullable } from "babylonjs/types";
  26012. import { Scene } from "babylonjs/scene";
  26013. import { Vector4 } from "babylonjs/Maths/math.vector";
  26014. import { Mesh } from "babylonjs/Meshes/mesh";
  26015. /**
  26016. * Class containing static functions to help procedurally build meshes
  26017. */
  26018. export class DiscBuilder {
  26019. /**
  26020. * Creates a plane polygonal mesh. By default, this is a disc
  26021. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26022. * * 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
  26023. * * 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
  26024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26027. * @param name defines the name of the mesh
  26028. * @param options defines the options used to create the mesh
  26029. * @param scene defines the hosting scene
  26030. * @returns the plane polygonal mesh
  26031. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26032. */
  26033. static CreateDisc(name: string, options: {
  26034. radius?: number;
  26035. tessellation?: number;
  26036. arc?: number;
  26037. updatable?: boolean;
  26038. sideOrientation?: number;
  26039. frontUVs?: Vector4;
  26040. backUVs?: Vector4;
  26041. }, scene?: Nullable<Scene>): Mesh;
  26042. }
  26043. }
  26044. declare module "babylonjs/Particles/solidParticleSystem" {
  26045. import { Vector3 } from "babylonjs/Maths/math.vector";
  26046. import { Mesh } from "babylonjs/Meshes/mesh";
  26047. import { Scene, IDisposable } from "babylonjs/scene";
  26048. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26049. /**
  26050. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26051. *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.
  26052. * The SPS is also a particle system. It provides some methods to manage the particles.
  26053. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26054. *
  26055. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26056. */
  26057. export class SolidParticleSystem implements IDisposable {
  26058. /**
  26059. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26060. * Example : var p = SPS.particles[i];
  26061. */
  26062. particles: SolidParticle[];
  26063. /**
  26064. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26065. */
  26066. nbParticles: number;
  26067. /**
  26068. * If the particles must ever face the camera (default false). Useful for planar particles.
  26069. */
  26070. billboard: boolean;
  26071. /**
  26072. * Recompute normals when adding a shape
  26073. */
  26074. recomputeNormals: boolean;
  26075. /**
  26076. * This a counter ofr your own usage. It's not set by any SPS functions.
  26077. */
  26078. counter: number;
  26079. /**
  26080. * The SPS name. This name is also given to the underlying mesh.
  26081. */
  26082. name: string;
  26083. /**
  26084. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26085. */
  26086. mesh: Mesh;
  26087. /**
  26088. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26089. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26090. */
  26091. vars: any;
  26092. /**
  26093. * This array is populated when the SPS is set as 'pickable'.
  26094. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26095. * Each element of this array is an object `{idx: int, faceId: int}`.
  26096. * `idx` is the picked particle index in the `SPS.particles` array
  26097. * `faceId` is the picked face index counted within this particle.
  26098. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26099. */
  26100. pickedParticles: {
  26101. idx: number;
  26102. faceId: number;
  26103. }[];
  26104. /**
  26105. * This array is populated when `enableDepthSort` is set to true.
  26106. * Each element of this array is an instance of the class DepthSortedParticle.
  26107. */
  26108. depthSortedParticles: DepthSortedParticle[];
  26109. /**
  26110. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26111. * @hidden
  26112. */
  26113. _bSphereOnly: boolean;
  26114. /**
  26115. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26116. * @hidden
  26117. */
  26118. _bSphereRadiusFactor: number;
  26119. private _scene;
  26120. private _positions;
  26121. private _indices;
  26122. private _normals;
  26123. private _colors;
  26124. private _uvs;
  26125. private _indices32;
  26126. private _positions32;
  26127. private _normals32;
  26128. private _fixedNormal32;
  26129. private _colors32;
  26130. private _uvs32;
  26131. private _index;
  26132. private _updatable;
  26133. private _pickable;
  26134. private _isVisibilityBoxLocked;
  26135. private _alwaysVisible;
  26136. private _depthSort;
  26137. private _expandable;
  26138. private _shapeCounter;
  26139. private _copy;
  26140. private _color;
  26141. private _computeParticleColor;
  26142. private _computeParticleTexture;
  26143. private _computeParticleRotation;
  26144. private _computeParticleVertex;
  26145. private _computeBoundingBox;
  26146. private _depthSortParticles;
  26147. private _camera;
  26148. private _mustUnrotateFixedNormals;
  26149. private _particlesIntersect;
  26150. private _needs32Bits;
  26151. private _isNotBuilt;
  26152. /**
  26153. * Creates a SPS (Solid Particle System) object.
  26154. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26155. * @param scene (Scene) is the scene in which the SPS is added.
  26156. * @param options defines the options of the sps e.g.
  26157. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26158. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26159. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26160. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26161. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26162. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26163. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26164. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26165. */
  26166. constructor(name: string, scene: Scene, options?: {
  26167. updatable?: boolean;
  26168. isPickable?: boolean;
  26169. enableDepthSort?: boolean;
  26170. particleIntersection?: boolean;
  26171. boundingSphereOnly?: boolean;
  26172. bSphereRadiusFactor?: number;
  26173. expandable?: boolean;
  26174. });
  26175. /**
  26176. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26177. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26178. * @returns the created mesh
  26179. */
  26180. buildMesh(): Mesh;
  26181. /**
  26182. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26183. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26184. * Thus the particles generated from `digest()` have their property `position` set yet.
  26185. * @param mesh ( Mesh ) is the mesh to be digested
  26186. * @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
  26187. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26188. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26189. * @returns the current SPS
  26190. */
  26191. digest(mesh: Mesh, options?: {
  26192. facetNb?: number;
  26193. number?: number;
  26194. delta?: number;
  26195. }): SolidParticleSystem;
  26196. private _unrotateFixedNormals;
  26197. private _resetCopy;
  26198. private _meshBuilder;
  26199. private _posToShape;
  26200. private _uvsToShapeUV;
  26201. private _addParticle;
  26202. /**
  26203. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26204. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26205. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26206. * @param nb (positive integer) the number of particles to be created from this model
  26207. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26208. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26209. * @returns the number of shapes in the system
  26210. */
  26211. addShape(mesh: Mesh, nb: number, options?: {
  26212. positionFunction?: any;
  26213. vertexFunction?: any;
  26214. }): number;
  26215. private _rebuildParticle;
  26216. /**
  26217. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26218. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  26219. * @returns the SPS.
  26220. */
  26221. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26222. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26223. * Returns an array with the removed particles.
  26224. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  26225. * The SPS can't be empty so at least one particle needs to remain in place.
  26226. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26227. * @param start index of the first particle to remove
  26228. * @param end index of the last particle to remove (included)
  26229. * @returns an array populated with the removed particles
  26230. */
  26231. removeParticles(start: number, end: number): SolidParticle[];
  26232. /**
  26233. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26234. * This method calls `updateParticle()` for each particle of the SPS.
  26235. * For an animated SPS, it is usually called within the render loop.
  26236. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  26237. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26238. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26239. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26240. * @returns the SPS.
  26241. */
  26242. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26243. /**
  26244. * Disposes the SPS.
  26245. */
  26246. dispose(): void;
  26247. /**
  26248. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26250. * @returns the SPS.
  26251. */
  26252. refreshVisibleSize(): SolidParticleSystem;
  26253. /**
  26254. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26255. * @param size the size (float) of the visibility box
  26256. * note : this doesn't lock the SPS mesh bounding box.
  26257. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26258. */
  26259. setVisibilityBox(size: number): void;
  26260. /**
  26261. * Gets whether the SPS as always visible or not
  26262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26263. */
  26264. /**
  26265. * Sets the SPS as always visible or not
  26266. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26267. */
  26268. isAlwaysVisible: boolean;
  26269. /**
  26270. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26271. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26272. */
  26273. /**
  26274. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26275. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26276. */
  26277. isVisibilityBoxLocked: boolean;
  26278. /**
  26279. * Tells to `setParticles()` to compute the particle rotations or not.
  26280. * Default value : true. The SPS is faster when it's set to false.
  26281. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26282. */
  26283. /**
  26284. * Gets if `setParticles()` computes the particle rotations or not.
  26285. * Default value : true. The SPS is faster when it's set to false.
  26286. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26287. */
  26288. computeParticleRotation: boolean;
  26289. /**
  26290. * Tells to `setParticles()` to compute the particle colors or not.
  26291. * Default value : true. The SPS is faster when it's set to false.
  26292. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26293. */
  26294. /**
  26295. * Gets if `setParticles()` computes the particle colors or not.
  26296. * Default value : true. The SPS is faster when it's set to false.
  26297. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26298. */
  26299. computeParticleColor: boolean;
  26300. /**
  26301. * Gets if `setParticles()` computes the particle textures or not.
  26302. * Default value : true. The SPS is faster when it's set to false.
  26303. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26304. */
  26305. computeParticleTexture: boolean;
  26306. /**
  26307. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26308. * Default value : false. The SPS is faster when it's set to false.
  26309. * Note : the particle custom vertex positions aren't stored values.
  26310. */
  26311. /**
  26312. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26313. * Default value : false. The SPS is faster when it's set to false.
  26314. * Note : the particle custom vertex positions aren't stored values.
  26315. */
  26316. computeParticleVertex: boolean;
  26317. /**
  26318. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26319. */
  26320. /**
  26321. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26322. */
  26323. computeBoundingBox: boolean;
  26324. /**
  26325. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26326. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26327. * Default : `true`
  26328. */
  26329. /**
  26330. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26331. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26332. * Default : `true`
  26333. */
  26334. depthSortParticles: boolean;
  26335. /**
  26336. * Gets if the SPS is created as expandable at construction time.
  26337. * Default : `false`
  26338. */
  26339. readonly expandable: boolean;
  26340. /**
  26341. * This function does nothing. It may be overwritten to set all the particle first values.
  26342. * The SPS doesn't call this function, you may have to call it by your own.
  26343. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26344. */
  26345. initParticles(): void;
  26346. /**
  26347. * This function does nothing. It may be overwritten to recycle a particle.
  26348. * The SPS doesn't call this function, you may have to call it by your own.
  26349. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26350. * @param particle The particle to recycle
  26351. * @returns the recycled particle
  26352. */
  26353. recycleParticle(particle: SolidParticle): SolidParticle;
  26354. /**
  26355. * Updates a particle : this function should be overwritten by the user.
  26356. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26357. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26358. * @example : just set a particle position or velocity and recycle conditions
  26359. * @param particle The particle to update
  26360. * @returns the updated particle
  26361. */
  26362. updateParticle(particle: SolidParticle): SolidParticle;
  26363. /**
  26364. * Updates a vertex of a particle : it can be overwritten by the user.
  26365. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26366. * @param particle the current particle
  26367. * @param vertex the current index of the current particle
  26368. * @param pt the index of the current vertex in the particle shape
  26369. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26370. * @example : just set a vertex particle position
  26371. * @returns the updated vertex
  26372. */
  26373. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26374. /**
  26375. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26376. * This does nothing and may be overwritten by the user.
  26377. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26378. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26379. * @param update the boolean update value actually passed to setParticles()
  26380. */
  26381. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26382. /**
  26383. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26384. * This will be passed three parameters.
  26385. * This does nothing and may be overwritten by the user.
  26386. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26387. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26388. * @param update the boolean update value actually passed to setParticles()
  26389. */
  26390. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26391. }
  26392. }
  26393. declare module "babylonjs/Particles/solidParticle" {
  26394. import { Nullable } from "babylonjs/types";
  26395. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26396. import { Color4 } from "babylonjs/Maths/math.color";
  26397. import { Mesh } from "babylonjs/Meshes/mesh";
  26398. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26399. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26400. import { Plane } from "babylonjs/Maths/math.plane";
  26401. /**
  26402. * Represents one particle of a solid particle system.
  26403. */
  26404. export class SolidParticle {
  26405. /**
  26406. * particle global index
  26407. */
  26408. idx: number;
  26409. /**
  26410. * The color of the particle
  26411. */
  26412. color: Nullable<Color4>;
  26413. /**
  26414. * The world space position of the particle.
  26415. */
  26416. position: Vector3;
  26417. /**
  26418. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26419. */
  26420. rotation: Vector3;
  26421. /**
  26422. * The world space rotation quaternion of the particle.
  26423. */
  26424. rotationQuaternion: Nullable<Quaternion>;
  26425. /**
  26426. * The scaling of the particle.
  26427. */
  26428. scaling: Vector3;
  26429. /**
  26430. * The uvs of the particle.
  26431. */
  26432. uvs: Vector4;
  26433. /**
  26434. * The current speed of the particle.
  26435. */
  26436. velocity: Vector3;
  26437. /**
  26438. * The pivot point in the particle local space.
  26439. */
  26440. pivot: Vector3;
  26441. /**
  26442. * Must the particle be translated from its pivot point in its local space ?
  26443. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26444. * Default : false
  26445. */
  26446. translateFromPivot: boolean;
  26447. /**
  26448. * Is the particle active or not ?
  26449. */
  26450. alive: boolean;
  26451. /**
  26452. * Is the particle visible or not ?
  26453. */
  26454. isVisible: boolean;
  26455. /**
  26456. * Index of this particle in the global "positions" array (Internal use)
  26457. * @hidden
  26458. */
  26459. _pos: number;
  26460. /**
  26461. * @hidden Index of this particle in the global "indices" array (Internal use)
  26462. */
  26463. _ind: number;
  26464. /**
  26465. * @hidden ModelShape of this particle (Internal use)
  26466. */
  26467. _model: ModelShape;
  26468. /**
  26469. * ModelShape id of this particle
  26470. */
  26471. shapeId: number;
  26472. /**
  26473. * Index of the particle in its shape id
  26474. */
  26475. idxInShape: number;
  26476. /**
  26477. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26478. */
  26479. _modelBoundingInfo: BoundingInfo;
  26480. /**
  26481. * @hidden Particle BoundingInfo object (Internal use)
  26482. */
  26483. _boundingInfo: BoundingInfo;
  26484. /**
  26485. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26486. */
  26487. _sps: SolidParticleSystem;
  26488. /**
  26489. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26490. */
  26491. _stillInvisible: boolean;
  26492. /**
  26493. * @hidden Last computed particle rotation matrix
  26494. */
  26495. _rotationMatrix: number[];
  26496. /**
  26497. * Parent particle Id, if any.
  26498. * Default null.
  26499. */
  26500. parentId: Nullable<number>;
  26501. /**
  26502. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26503. * The possible values are :
  26504. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26505. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26506. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26507. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26508. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26509. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26510. * */
  26511. cullingStrategy: number;
  26512. /**
  26513. * @hidden Internal global position in the SPS.
  26514. */
  26515. _globalPosition: Vector3;
  26516. /**
  26517. * Creates a Solid Particle object.
  26518. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26519. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26520. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26521. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26522. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26523. * @param shapeId (integer) is the model shape identifier in the SPS.
  26524. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26525. * @param sps defines the sps it is associated to
  26526. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26527. */
  26528. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26529. /**
  26530. * Legacy support, changed scale to scaling
  26531. */
  26532. /**
  26533. * Legacy support, changed scale to scaling
  26534. */
  26535. scale: Vector3;
  26536. /**
  26537. * Legacy support, changed quaternion to rotationQuaternion
  26538. */
  26539. /**
  26540. * Legacy support, changed quaternion to rotationQuaternion
  26541. */
  26542. quaternion: Nullable<Quaternion>;
  26543. /**
  26544. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26545. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26546. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26547. * @returns true if it intersects
  26548. */
  26549. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26550. /**
  26551. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26552. * A particle is in the frustum if its bounding box intersects the frustum
  26553. * @param frustumPlanes defines the frustum to test
  26554. * @returns true if the particle is in the frustum planes
  26555. */
  26556. isInFrustum(frustumPlanes: Plane[]): boolean;
  26557. /**
  26558. * get the rotation matrix of the particle
  26559. * @hidden
  26560. */
  26561. getRotationMatrix(m: Matrix): void;
  26562. }
  26563. /**
  26564. * Represents the shape of the model used by one particle of a solid particle system.
  26565. * SPS internal tool, don't use it manually.
  26566. */
  26567. export class ModelShape {
  26568. /**
  26569. * The shape id
  26570. * @hidden
  26571. */
  26572. shapeID: number;
  26573. /**
  26574. * flat array of model positions (internal use)
  26575. * @hidden
  26576. */
  26577. _shape: Vector3[];
  26578. /**
  26579. * flat array of model UVs (internal use)
  26580. * @hidden
  26581. */
  26582. _shapeUV: number[];
  26583. /**
  26584. * color array of the model
  26585. * @hidden
  26586. */
  26587. _shapeColors: number[];
  26588. /**
  26589. * indices array of the model
  26590. * @hidden
  26591. */
  26592. _indices: number[];
  26593. /**
  26594. * normals array of the model
  26595. * @hidden
  26596. */
  26597. _normals: number[];
  26598. /**
  26599. * length of the shape in the model indices array (internal use)
  26600. * @hidden
  26601. */
  26602. _indicesLength: number;
  26603. /**
  26604. * Custom position function (internal use)
  26605. * @hidden
  26606. */
  26607. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26608. /**
  26609. * Custom vertex function (internal use)
  26610. * @hidden
  26611. */
  26612. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26613. /**
  26614. * 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.
  26615. * SPS internal tool, don't use it manually.
  26616. * @hidden
  26617. */
  26618. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26619. }
  26620. /**
  26621. * Represents a Depth Sorted Particle in the solid particle system.
  26622. */
  26623. export class DepthSortedParticle {
  26624. /**
  26625. * Index of the particle in the "indices" array
  26626. */
  26627. ind: number;
  26628. /**
  26629. * Length of the particle shape in the "indices" array
  26630. */
  26631. indicesLength: number;
  26632. /**
  26633. * Squared distance from the particle to the camera
  26634. */
  26635. sqDistance: number;
  26636. }
  26637. }
  26638. declare module "babylonjs/Collisions/meshCollisionData" {
  26639. import { Collider } from "babylonjs/Collisions/collider";
  26640. import { Vector3 } from "babylonjs/Maths/math.vector";
  26641. import { Nullable } from "babylonjs/types";
  26642. import { Observer } from "babylonjs/Misc/observable";
  26643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26644. /**
  26645. * @hidden
  26646. */
  26647. export class _MeshCollisionData {
  26648. _checkCollisions: boolean;
  26649. _collisionMask: number;
  26650. _collisionGroup: number;
  26651. _collider: Nullable<Collider>;
  26652. _oldPositionForCollisions: Vector3;
  26653. _diffPositionForCollisions: Vector3;
  26654. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26655. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26656. }
  26657. }
  26658. declare module "babylonjs/Meshes/abstractMesh" {
  26659. import { Observable } from "babylonjs/Misc/observable";
  26660. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26661. import { Camera } from "babylonjs/Cameras/camera";
  26662. import { Scene, IDisposable } from "babylonjs/scene";
  26663. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26664. import { Node } from "babylonjs/node";
  26665. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26666. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26667. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26668. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26669. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26670. import { Material } from "babylonjs/Materials/material";
  26671. import { Light } from "babylonjs/Lights/light";
  26672. import { Skeleton } from "babylonjs/Bones/skeleton";
  26673. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26674. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26675. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26676. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26677. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26678. import { Plane } from "babylonjs/Maths/math.plane";
  26679. import { Ray } from "babylonjs/Culling/ray";
  26680. import { Collider } from "babylonjs/Collisions/collider";
  26681. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26682. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26683. /** @hidden */
  26684. class _FacetDataStorage {
  26685. facetPositions: Vector3[];
  26686. facetNormals: Vector3[];
  26687. facetPartitioning: number[][];
  26688. facetNb: number;
  26689. partitioningSubdivisions: number;
  26690. partitioningBBoxRatio: number;
  26691. facetDataEnabled: boolean;
  26692. facetParameters: any;
  26693. bbSize: Vector3;
  26694. subDiv: {
  26695. max: number;
  26696. X: number;
  26697. Y: number;
  26698. Z: number;
  26699. };
  26700. facetDepthSort: boolean;
  26701. facetDepthSortEnabled: boolean;
  26702. depthSortedIndices: IndicesArray;
  26703. depthSortedFacets: {
  26704. ind: number;
  26705. sqDistance: number;
  26706. }[];
  26707. facetDepthSortFunction: (f1: {
  26708. ind: number;
  26709. sqDistance: number;
  26710. }, f2: {
  26711. ind: number;
  26712. sqDistance: number;
  26713. }) => number;
  26714. facetDepthSortFrom: Vector3;
  26715. facetDepthSortOrigin: Vector3;
  26716. invertedMatrix: Matrix;
  26717. }
  26718. /**
  26719. * @hidden
  26720. **/
  26721. class _InternalAbstractMeshDataInfo {
  26722. _hasVertexAlpha: boolean;
  26723. _useVertexColors: boolean;
  26724. _numBoneInfluencers: number;
  26725. _applyFog: boolean;
  26726. _receiveShadows: boolean;
  26727. _facetData: _FacetDataStorage;
  26728. _visibility: number;
  26729. _skeleton: Nullable<Skeleton>;
  26730. _layerMask: number;
  26731. _computeBonesUsingShaders: boolean;
  26732. _isActive: boolean;
  26733. _onlyForInstances: boolean;
  26734. _isActiveIntermediate: boolean;
  26735. _onlyForInstancesIntermediate: boolean;
  26736. _actAsRegularMesh: boolean;
  26737. }
  26738. /**
  26739. * Class used to store all common mesh properties
  26740. */
  26741. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26742. /** No occlusion */
  26743. static OCCLUSION_TYPE_NONE: number;
  26744. /** Occlusion set to optimisitic */
  26745. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26746. /** Occlusion set to strict */
  26747. static OCCLUSION_TYPE_STRICT: number;
  26748. /** Use an accurante occlusion algorithm */
  26749. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26750. /** Use a conservative occlusion algorithm */
  26751. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26752. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26753. * Test order :
  26754. * Is the bounding sphere outside the frustum ?
  26755. * If not, are the bounding box vertices outside the frustum ?
  26756. * It not, then the cullable object is in the frustum.
  26757. */
  26758. static readonly CULLINGSTRATEGY_STANDARD: number;
  26759. /** Culling strategy : Bounding Sphere Only.
  26760. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26761. * It's also less accurate than the standard because some not visible objects can still be selected.
  26762. * Test : is the bounding sphere outside the frustum ?
  26763. * If not, then the cullable object is in the frustum.
  26764. */
  26765. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26766. /** Culling strategy : Optimistic Inclusion.
  26767. * This in an inclusion test first, then the standard exclusion test.
  26768. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26769. * 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.
  26770. * Anyway, it's as accurate as the standard strategy.
  26771. * Test :
  26772. * Is the cullable object bounding sphere center in the frustum ?
  26773. * If not, apply the default culling strategy.
  26774. */
  26775. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26776. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26777. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26778. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26779. * 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.
  26780. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26781. * Test :
  26782. * Is the cullable object bounding sphere center in the frustum ?
  26783. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26784. */
  26785. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26786. /**
  26787. * No billboard
  26788. */
  26789. static readonly BILLBOARDMODE_NONE: number;
  26790. /** Billboard on X axis */
  26791. static readonly BILLBOARDMODE_X: number;
  26792. /** Billboard on Y axis */
  26793. static readonly BILLBOARDMODE_Y: number;
  26794. /** Billboard on Z axis */
  26795. static readonly BILLBOARDMODE_Z: number;
  26796. /** Billboard on all axes */
  26797. static readonly BILLBOARDMODE_ALL: number;
  26798. /** Billboard on using position instead of orientation */
  26799. static readonly BILLBOARDMODE_USE_POSITION: number;
  26800. /** @hidden */
  26801. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26802. /**
  26803. * The culling strategy to use to check whether the mesh must be rendered or not.
  26804. * This value can be changed at any time and will be used on the next render mesh selection.
  26805. * The possible values are :
  26806. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26807. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26808. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26809. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26810. * Please read each static variable documentation to get details about the culling process.
  26811. * */
  26812. cullingStrategy: number;
  26813. /**
  26814. * Gets the number of facets in the mesh
  26815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26816. */
  26817. readonly facetNb: number;
  26818. /**
  26819. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26820. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26821. */
  26822. partitioningSubdivisions: number;
  26823. /**
  26824. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26825. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26827. */
  26828. partitioningBBoxRatio: number;
  26829. /**
  26830. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26831. * Works only for updatable meshes.
  26832. * Doesn't work with multi-materials
  26833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26834. */
  26835. mustDepthSortFacets: boolean;
  26836. /**
  26837. * The location (Vector3) where the facet depth sort must be computed from.
  26838. * By default, the active camera position.
  26839. * Used only when facet depth sort is enabled
  26840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26841. */
  26842. facetDepthSortFrom: Vector3;
  26843. /**
  26844. * gets a boolean indicating if facetData is enabled
  26845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26846. */
  26847. readonly isFacetDataEnabled: boolean;
  26848. /** @hidden */
  26849. _updateNonUniformScalingState(value: boolean): boolean;
  26850. /**
  26851. * An event triggered when this mesh collides with another one
  26852. */
  26853. onCollideObservable: Observable<AbstractMesh>;
  26854. /** Set a function to call when this mesh collides with another one */
  26855. onCollide: () => void;
  26856. /**
  26857. * An event triggered when the collision's position changes
  26858. */
  26859. onCollisionPositionChangeObservable: Observable<Vector3>;
  26860. /** Set a function to call when the collision's position changes */
  26861. onCollisionPositionChange: () => void;
  26862. /**
  26863. * An event triggered when material is changed
  26864. */
  26865. onMaterialChangedObservable: Observable<AbstractMesh>;
  26866. /**
  26867. * Gets or sets the orientation for POV movement & rotation
  26868. */
  26869. definedFacingForward: boolean;
  26870. /** @hidden */
  26871. _occlusionQuery: Nullable<WebGLQuery>;
  26872. /** @hidden */
  26873. _renderingGroup: Nullable<RenderingGroup>;
  26874. /**
  26875. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26876. */
  26877. /**
  26878. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26879. */
  26880. visibility: number;
  26881. /** Gets or sets the alpha index used to sort transparent meshes
  26882. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26883. */
  26884. alphaIndex: number;
  26885. /**
  26886. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26887. */
  26888. isVisible: boolean;
  26889. /**
  26890. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26891. */
  26892. isPickable: boolean;
  26893. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26894. showSubMeshesBoundingBox: boolean;
  26895. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26896. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26897. */
  26898. isBlocker: boolean;
  26899. /**
  26900. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26901. */
  26902. enablePointerMoveEvents: boolean;
  26903. /**
  26904. * Specifies the rendering group id for this mesh (0 by default)
  26905. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26906. */
  26907. renderingGroupId: number;
  26908. private _material;
  26909. /** Gets or sets current material */
  26910. material: Nullable<Material>;
  26911. /**
  26912. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26913. * @see http://doc.babylonjs.com/babylon101/shadows
  26914. */
  26915. receiveShadows: boolean;
  26916. /** Defines color to use when rendering outline */
  26917. outlineColor: Color3;
  26918. /** Define width to use when rendering outline */
  26919. outlineWidth: number;
  26920. /** Defines color to use when rendering overlay */
  26921. overlayColor: Color3;
  26922. /** Defines alpha to use when rendering overlay */
  26923. overlayAlpha: number;
  26924. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26925. hasVertexAlpha: boolean;
  26926. /** 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) */
  26927. useVertexColors: boolean;
  26928. /**
  26929. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26930. */
  26931. computeBonesUsingShaders: boolean;
  26932. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26933. numBoneInfluencers: number;
  26934. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26935. applyFog: boolean;
  26936. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26937. useOctreeForRenderingSelection: boolean;
  26938. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26939. useOctreeForPicking: boolean;
  26940. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26941. useOctreeForCollisions: boolean;
  26942. /**
  26943. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26944. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26945. */
  26946. layerMask: number;
  26947. /**
  26948. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26949. */
  26950. alwaysSelectAsActiveMesh: boolean;
  26951. /**
  26952. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26953. */
  26954. doNotSyncBoundingInfo: boolean;
  26955. /**
  26956. * Gets or sets the current action manager
  26957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26958. */
  26959. actionManager: Nullable<AbstractActionManager>;
  26960. private _meshCollisionData;
  26961. /**
  26962. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26964. */
  26965. ellipsoid: Vector3;
  26966. /**
  26967. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26969. */
  26970. ellipsoidOffset: Vector3;
  26971. /**
  26972. * Gets or sets a collision mask used to mask collisions (default is -1).
  26973. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26974. */
  26975. collisionMask: number;
  26976. /**
  26977. * Gets or sets the current collision group mask (-1 by default).
  26978. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26979. */
  26980. collisionGroup: number;
  26981. /**
  26982. * Defines edge width used when edgesRenderer is enabled
  26983. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26984. */
  26985. edgesWidth: number;
  26986. /**
  26987. * Defines edge color used when edgesRenderer is enabled
  26988. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26989. */
  26990. edgesColor: Color4;
  26991. /** @hidden */
  26992. _edgesRenderer: Nullable<IEdgesRenderer>;
  26993. /** @hidden */
  26994. _masterMesh: Nullable<AbstractMesh>;
  26995. /** @hidden */
  26996. _boundingInfo: Nullable<BoundingInfo>;
  26997. /** @hidden */
  26998. _renderId: number;
  26999. /**
  27000. * Gets or sets the list of subMeshes
  27001. * @see http://doc.babylonjs.com/how_to/multi_materials
  27002. */
  27003. subMeshes: SubMesh[];
  27004. /** @hidden */
  27005. _intersectionsInProgress: AbstractMesh[];
  27006. /** @hidden */
  27007. _unIndexed: boolean;
  27008. /** @hidden */
  27009. _lightSources: Light[];
  27010. /** Gets the list of lights affecting that mesh */
  27011. readonly lightSources: Light[];
  27012. /** @hidden */
  27013. readonly _positions: Nullable<Vector3[]>;
  27014. /** @hidden */
  27015. _waitingData: {
  27016. lods: Nullable<any>;
  27017. actions: Nullable<any>;
  27018. freezeWorldMatrix: Nullable<boolean>;
  27019. };
  27020. /** @hidden */
  27021. _bonesTransformMatrices: Nullable<Float32Array>;
  27022. /** @hidden */
  27023. _transformMatrixTexture: Nullable<RawTexture>;
  27024. /**
  27025. * Gets or sets a skeleton to apply skining transformations
  27026. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27027. */
  27028. skeleton: Nullable<Skeleton>;
  27029. /**
  27030. * An event triggered when the mesh is rebuilt.
  27031. */
  27032. onRebuildObservable: Observable<AbstractMesh>;
  27033. /**
  27034. * Creates a new AbstractMesh
  27035. * @param name defines the name of the mesh
  27036. * @param scene defines the hosting scene
  27037. */
  27038. constructor(name: string, scene?: Nullable<Scene>);
  27039. /**
  27040. * Returns the string "AbstractMesh"
  27041. * @returns "AbstractMesh"
  27042. */
  27043. getClassName(): string;
  27044. /**
  27045. * Gets a string representation of the current mesh
  27046. * @param fullDetails defines a boolean indicating if full details must be included
  27047. * @returns a string representation of the current mesh
  27048. */
  27049. toString(fullDetails?: boolean): string;
  27050. /**
  27051. * @hidden
  27052. */
  27053. protected _getEffectiveParent(): Nullable<Node>;
  27054. /** @hidden */
  27055. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27056. /** @hidden */
  27057. _rebuild(): void;
  27058. /** @hidden */
  27059. _resyncLightSources(): void;
  27060. /** @hidden */
  27061. _resyncLighSource(light: Light): void;
  27062. /** @hidden */
  27063. _unBindEffect(): void;
  27064. /** @hidden */
  27065. _removeLightSource(light: Light, dispose: boolean): void;
  27066. private _markSubMeshesAsDirty;
  27067. /** @hidden */
  27068. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27069. /** @hidden */
  27070. _markSubMeshesAsAttributesDirty(): void;
  27071. /** @hidden */
  27072. _markSubMeshesAsMiscDirty(): void;
  27073. /**
  27074. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27075. */
  27076. scaling: Vector3;
  27077. /**
  27078. * Returns true if the mesh is blocked. Implemented by child classes
  27079. */
  27080. readonly isBlocked: boolean;
  27081. /**
  27082. * Returns the mesh itself by default. Implemented by child classes
  27083. * @param camera defines the camera to use to pick the right LOD level
  27084. * @returns the currentAbstractMesh
  27085. */
  27086. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27087. /**
  27088. * Returns 0 by default. Implemented by child classes
  27089. * @returns an integer
  27090. */
  27091. getTotalVertices(): number;
  27092. /**
  27093. * Returns a positive integer : the total number of indices in this mesh geometry.
  27094. * @returns the numner of indices or zero if the mesh has no geometry.
  27095. */
  27096. getTotalIndices(): number;
  27097. /**
  27098. * Returns null by default. Implemented by child classes
  27099. * @returns null
  27100. */
  27101. getIndices(): Nullable<IndicesArray>;
  27102. /**
  27103. * Returns the array of the requested vertex data kind. Implemented by child classes
  27104. * @param kind defines the vertex data kind to use
  27105. * @returns null
  27106. */
  27107. getVerticesData(kind: string): Nullable<FloatArray>;
  27108. /**
  27109. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27110. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27111. * Note that a new underlying VertexBuffer object is created each call.
  27112. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27113. * @param kind defines vertex data kind:
  27114. * * VertexBuffer.PositionKind
  27115. * * VertexBuffer.UVKind
  27116. * * VertexBuffer.UV2Kind
  27117. * * VertexBuffer.UV3Kind
  27118. * * VertexBuffer.UV4Kind
  27119. * * VertexBuffer.UV5Kind
  27120. * * VertexBuffer.UV6Kind
  27121. * * VertexBuffer.ColorKind
  27122. * * VertexBuffer.MatricesIndicesKind
  27123. * * VertexBuffer.MatricesIndicesExtraKind
  27124. * * VertexBuffer.MatricesWeightsKind
  27125. * * VertexBuffer.MatricesWeightsExtraKind
  27126. * @param data defines the data source
  27127. * @param updatable defines if the data must be flagged as updatable (or static)
  27128. * @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
  27129. * @returns the current mesh
  27130. */
  27131. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27132. /**
  27133. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27134. * If the mesh has no geometry, it is simply returned as it is.
  27135. * @param kind defines vertex data kind:
  27136. * * VertexBuffer.PositionKind
  27137. * * VertexBuffer.UVKind
  27138. * * VertexBuffer.UV2Kind
  27139. * * VertexBuffer.UV3Kind
  27140. * * VertexBuffer.UV4Kind
  27141. * * VertexBuffer.UV5Kind
  27142. * * VertexBuffer.UV6Kind
  27143. * * VertexBuffer.ColorKind
  27144. * * VertexBuffer.MatricesIndicesKind
  27145. * * VertexBuffer.MatricesIndicesExtraKind
  27146. * * VertexBuffer.MatricesWeightsKind
  27147. * * VertexBuffer.MatricesWeightsExtraKind
  27148. * @param data defines the data source
  27149. * @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
  27150. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27151. * @returns the current mesh
  27152. */
  27153. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27154. /**
  27155. * Sets the mesh indices,
  27156. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27157. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27158. * @param totalVertices Defines the total number of vertices
  27159. * @returns the current mesh
  27160. */
  27161. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27162. /**
  27163. * Gets a boolean indicating if specific vertex data is present
  27164. * @param kind defines the vertex data kind to use
  27165. * @returns true is data kind is present
  27166. */
  27167. isVerticesDataPresent(kind: string): boolean;
  27168. /**
  27169. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27170. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27171. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27172. * @returns a BoundingInfo
  27173. */
  27174. getBoundingInfo(): BoundingInfo;
  27175. /**
  27176. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27177. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27178. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27179. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27180. * @returns the current mesh
  27181. */
  27182. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27183. /**
  27184. * Overwrite the current bounding info
  27185. * @param boundingInfo defines the new bounding info
  27186. * @returns the current mesh
  27187. */
  27188. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27189. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27190. readonly useBones: boolean;
  27191. /** @hidden */
  27192. _preActivate(): void;
  27193. /** @hidden */
  27194. _preActivateForIntermediateRendering(renderId: number): void;
  27195. /** @hidden */
  27196. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27197. /** @hidden */
  27198. _postActivate(): void;
  27199. /** @hidden */
  27200. _freeze(): void;
  27201. /** @hidden */
  27202. _unFreeze(): void;
  27203. /**
  27204. * Gets the current world matrix
  27205. * @returns a Matrix
  27206. */
  27207. getWorldMatrix(): Matrix;
  27208. /** @hidden */
  27209. _getWorldMatrixDeterminant(): number;
  27210. /**
  27211. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27212. */
  27213. readonly isAnInstance: boolean;
  27214. /**
  27215. * Gets a boolean indicating if this mesh has instances
  27216. */
  27217. readonly hasInstances: boolean;
  27218. /**
  27219. * Perform relative position change from the point of view of behind the front of the mesh.
  27220. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27221. * Supports definition of mesh facing forward or backward
  27222. * @param amountRight defines the distance on the right axis
  27223. * @param amountUp defines the distance on the up axis
  27224. * @param amountForward defines the distance on the forward axis
  27225. * @returns the current mesh
  27226. */
  27227. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27228. /**
  27229. * Calculate relative position change from the point of view of behind the front of the mesh.
  27230. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27231. * Supports definition of mesh facing forward or backward
  27232. * @param amountRight defines the distance on the right axis
  27233. * @param amountUp defines the distance on the up axis
  27234. * @param amountForward defines the distance on the forward axis
  27235. * @returns the new displacement vector
  27236. */
  27237. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27238. /**
  27239. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27240. * Supports definition of mesh facing forward or backward
  27241. * @param flipBack defines the flip
  27242. * @param twirlClockwise defines the twirl
  27243. * @param tiltRight defines the tilt
  27244. * @returns the current mesh
  27245. */
  27246. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27247. /**
  27248. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27249. * Supports definition of mesh facing forward or backward.
  27250. * @param flipBack defines the flip
  27251. * @param twirlClockwise defines the twirl
  27252. * @param tiltRight defines the tilt
  27253. * @returns the new rotation vector
  27254. */
  27255. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27256. /**
  27257. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27258. * This means the mesh underlying bounding box and sphere are recomputed.
  27259. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27260. * @returns the current mesh
  27261. */
  27262. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27263. /** @hidden */
  27264. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27265. /** @hidden */
  27266. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27267. /** @hidden */
  27268. _updateBoundingInfo(): AbstractMesh;
  27269. /** @hidden */
  27270. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27271. /** @hidden */
  27272. protected _afterComputeWorldMatrix(): void;
  27273. /** @hidden */
  27274. readonly _effectiveMesh: AbstractMesh;
  27275. /**
  27276. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27277. * A mesh is in the frustum if its bounding box intersects the frustum
  27278. * @param frustumPlanes defines the frustum to test
  27279. * @returns true if the mesh is in the frustum planes
  27280. */
  27281. isInFrustum(frustumPlanes: Plane[]): boolean;
  27282. /**
  27283. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27284. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27285. * @param frustumPlanes defines the frustum to test
  27286. * @returns true if the mesh is completely in the frustum planes
  27287. */
  27288. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27289. /**
  27290. * True if the mesh intersects another mesh or a SolidParticle object
  27291. * @param mesh defines a target mesh or SolidParticle to test
  27292. * @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)
  27293. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27294. * @returns true if there is an intersection
  27295. */
  27296. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27297. /**
  27298. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27299. * @param point defines the point to test
  27300. * @returns true if there is an intersection
  27301. */
  27302. intersectsPoint(point: Vector3): boolean;
  27303. /**
  27304. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27305. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27306. */
  27307. checkCollisions: boolean;
  27308. /**
  27309. * Gets Collider object used to compute collisions (not physics)
  27310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27311. */
  27312. readonly collider: Nullable<Collider>;
  27313. /**
  27314. * Move the mesh using collision engine
  27315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27316. * @param displacement defines the requested displacement vector
  27317. * @returns the current mesh
  27318. */
  27319. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27320. private _onCollisionPositionChange;
  27321. /** @hidden */
  27322. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27323. /** @hidden */
  27324. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27325. /** @hidden */
  27326. _checkCollision(collider: Collider): AbstractMesh;
  27327. /** @hidden */
  27328. _generatePointsArray(): boolean;
  27329. /**
  27330. * Checks if the passed Ray intersects with the mesh
  27331. * @param ray defines the ray to use
  27332. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27333. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27334. * @returns the picking info
  27335. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27336. */
  27337. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27338. /**
  27339. * Clones the current mesh
  27340. * @param name defines the mesh name
  27341. * @param newParent defines the new mesh parent
  27342. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27343. * @returns the new mesh
  27344. */
  27345. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27346. /**
  27347. * Disposes all the submeshes of the current meshnp
  27348. * @returns the current mesh
  27349. */
  27350. releaseSubMeshes(): AbstractMesh;
  27351. /**
  27352. * Releases resources associated with this abstract mesh.
  27353. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27354. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27355. */
  27356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27357. /**
  27358. * Adds the passed mesh as a child to the current mesh
  27359. * @param mesh defines the child mesh
  27360. * @returns the current mesh
  27361. */
  27362. addChild(mesh: AbstractMesh): AbstractMesh;
  27363. /**
  27364. * Removes the passed mesh from the current mesh children list
  27365. * @param mesh defines the child mesh
  27366. * @returns the current mesh
  27367. */
  27368. removeChild(mesh: AbstractMesh): AbstractMesh;
  27369. /** @hidden */
  27370. private _initFacetData;
  27371. /**
  27372. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27373. * This method can be called within the render loop.
  27374. * 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
  27375. * @returns the current mesh
  27376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27377. */
  27378. updateFacetData(): AbstractMesh;
  27379. /**
  27380. * Returns the facetLocalNormals array.
  27381. * The normals are expressed in the mesh local spac
  27382. * @returns an array of Vector3
  27383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27384. */
  27385. getFacetLocalNormals(): Vector3[];
  27386. /**
  27387. * Returns the facetLocalPositions array.
  27388. * The facet positions are expressed in the mesh local space
  27389. * @returns an array of Vector3
  27390. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27391. */
  27392. getFacetLocalPositions(): Vector3[];
  27393. /**
  27394. * Returns the facetLocalPartioning array
  27395. * @returns an array of array of numbers
  27396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27397. */
  27398. getFacetLocalPartitioning(): number[][];
  27399. /**
  27400. * Returns the i-th facet position in the world system.
  27401. * This method allocates a new Vector3 per call
  27402. * @param i defines the facet index
  27403. * @returns a new Vector3
  27404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27405. */
  27406. getFacetPosition(i: number): Vector3;
  27407. /**
  27408. * Sets the reference Vector3 with the i-th facet position in the world system
  27409. * @param i defines the facet index
  27410. * @param ref defines the target vector
  27411. * @returns the current mesh
  27412. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27413. */
  27414. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27415. /**
  27416. * Returns the i-th facet normal in the world system.
  27417. * This method allocates a new Vector3 per call
  27418. * @param i defines the facet index
  27419. * @returns a new Vector3
  27420. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27421. */
  27422. getFacetNormal(i: number): Vector3;
  27423. /**
  27424. * Sets the reference Vector3 with the i-th facet normal in the world system
  27425. * @param i defines the facet index
  27426. * @param ref defines the target vector
  27427. * @returns the current mesh
  27428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27429. */
  27430. getFacetNormalToRef(i: number, ref: Vector3): this;
  27431. /**
  27432. * 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)
  27433. * @param x defines x coordinate
  27434. * @param y defines y coordinate
  27435. * @param z defines z coordinate
  27436. * @returns the array of facet indexes
  27437. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27438. */
  27439. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27440. /**
  27441. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27442. * @param projected sets as the (x,y,z) world projection on the facet
  27443. * @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
  27444. * @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
  27445. * @param x defines x coordinate
  27446. * @param y defines y coordinate
  27447. * @param z defines z coordinate
  27448. * @returns the face index if found (or null instead)
  27449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27450. */
  27451. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27452. /**
  27453. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27454. * @param projected sets as the (x,y,z) local projection on the facet
  27455. * @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
  27456. * @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
  27457. * @param x defines x coordinate
  27458. * @param y defines y coordinate
  27459. * @param z defines z coordinate
  27460. * @returns the face index if found (or null instead)
  27461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27462. */
  27463. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27464. /**
  27465. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27466. * @returns the parameters
  27467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27468. */
  27469. getFacetDataParameters(): any;
  27470. /**
  27471. * Disables the feature FacetData and frees the related memory
  27472. * @returns the current mesh
  27473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27474. */
  27475. disableFacetData(): AbstractMesh;
  27476. /**
  27477. * Updates the AbstractMesh indices array
  27478. * @param indices defines the data source
  27479. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27480. * @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)
  27481. * @returns the current mesh
  27482. */
  27483. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27484. /**
  27485. * Creates new normals data for the mesh
  27486. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27487. * @returns the current mesh
  27488. */
  27489. createNormals(updatable: boolean): AbstractMesh;
  27490. /**
  27491. * Align the mesh with a normal
  27492. * @param normal defines the normal to use
  27493. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27494. * @returns the current mesh
  27495. */
  27496. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27497. /** @hidden */
  27498. _checkOcclusionQuery(): boolean;
  27499. /**
  27500. * Disables the mesh edge rendering mode
  27501. * @returns the currentAbstractMesh
  27502. */
  27503. disableEdgesRendering(): AbstractMesh;
  27504. /**
  27505. * Enables the edge rendering mode on the mesh.
  27506. * This mode makes the mesh edges visible
  27507. * @param epsilon defines the maximal distance between two angles to detect a face
  27508. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27509. * @returns the currentAbstractMesh
  27510. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27511. */
  27512. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27513. }
  27514. }
  27515. declare module "babylonjs/Actions/actionEvent" {
  27516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27517. import { Nullable } from "babylonjs/types";
  27518. import { Sprite } from "babylonjs/Sprites/sprite";
  27519. import { Scene } from "babylonjs/scene";
  27520. import { Vector2 } from "babylonjs/Maths/math.vector";
  27521. /**
  27522. * Interface used to define ActionEvent
  27523. */
  27524. export interface IActionEvent {
  27525. /** The mesh or sprite that triggered the action */
  27526. source: any;
  27527. /** The X mouse cursor position at the time of the event */
  27528. pointerX: number;
  27529. /** The Y mouse cursor position at the time of the event */
  27530. pointerY: number;
  27531. /** The mesh that is currently pointed at (can be null) */
  27532. meshUnderPointer: Nullable<AbstractMesh>;
  27533. /** the original (browser) event that triggered the ActionEvent */
  27534. sourceEvent?: any;
  27535. /** additional data for the event */
  27536. additionalData?: any;
  27537. }
  27538. /**
  27539. * ActionEvent is the event being sent when an action is triggered.
  27540. */
  27541. export class ActionEvent implements IActionEvent {
  27542. /** The mesh or sprite that triggered the action */
  27543. source: any;
  27544. /** The X mouse cursor position at the time of the event */
  27545. pointerX: number;
  27546. /** The Y mouse cursor position at the time of the event */
  27547. pointerY: number;
  27548. /** The mesh that is currently pointed at (can be null) */
  27549. meshUnderPointer: Nullable<AbstractMesh>;
  27550. /** the original (browser) event that triggered the ActionEvent */
  27551. sourceEvent?: any;
  27552. /** additional data for the event */
  27553. additionalData?: any;
  27554. /**
  27555. * Creates a new ActionEvent
  27556. * @param source The mesh or sprite that triggered the action
  27557. * @param pointerX The X mouse cursor position at the time of the event
  27558. * @param pointerY The Y mouse cursor position at the time of the event
  27559. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27560. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27561. * @param additionalData additional data for the event
  27562. */
  27563. constructor(
  27564. /** The mesh or sprite that triggered the action */
  27565. source: any,
  27566. /** The X mouse cursor position at the time of the event */
  27567. pointerX: number,
  27568. /** The Y mouse cursor position at the time of the event */
  27569. pointerY: number,
  27570. /** The mesh that is currently pointed at (can be null) */
  27571. meshUnderPointer: Nullable<AbstractMesh>,
  27572. /** the original (browser) event that triggered the ActionEvent */
  27573. sourceEvent?: any,
  27574. /** additional data for the event */
  27575. additionalData?: any);
  27576. /**
  27577. * Helper function to auto-create an ActionEvent from a source mesh.
  27578. * @param source The source mesh that triggered the event
  27579. * @param evt The original (browser) event
  27580. * @param additionalData additional data for the event
  27581. * @returns the new ActionEvent
  27582. */
  27583. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27584. /**
  27585. * Helper function to auto-create an ActionEvent from a source sprite
  27586. * @param source The source sprite that triggered the event
  27587. * @param scene Scene associated with the sprite
  27588. * @param evt The original (browser) event
  27589. * @param additionalData additional data for the event
  27590. * @returns the new ActionEvent
  27591. */
  27592. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27593. /**
  27594. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27595. * @param scene the scene where the event occurred
  27596. * @param evt The original (browser) event
  27597. * @returns the new ActionEvent
  27598. */
  27599. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27600. /**
  27601. * Helper function to auto-create an ActionEvent from a primitive
  27602. * @param prim defines the target primitive
  27603. * @param pointerPos defines the pointer position
  27604. * @param evt The original (browser) event
  27605. * @param additionalData additional data for the event
  27606. * @returns the new ActionEvent
  27607. */
  27608. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27609. }
  27610. }
  27611. declare module "babylonjs/Actions/abstractActionManager" {
  27612. import { IDisposable } from "babylonjs/scene";
  27613. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27614. import { IAction } from "babylonjs/Actions/action";
  27615. import { Nullable } from "babylonjs/types";
  27616. /**
  27617. * Abstract class used to decouple action Manager from scene and meshes.
  27618. * Do not instantiate.
  27619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27620. */
  27621. export abstract class AbstractActionManager implements IDisposable {
  27622. /** Gets the list of active triggers */
  27623. static Triggers: {
  27624. [key: string]: number;
  27625. };
  27626. /** Gets the cursor to use when hovering items */
  27627. hoverCursor: string;
  27628. /** Gets the list of actions */
  27629. actions: IAction[];
  27630. /**
  27631. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27632. */
  27633. isRecursive: boolean;
  27634. /**
  27635. * Releases all associated resources
  27636. */
  27637. abstract dispose(): void;
  27638. /**
  27639. * Does this action manager has pointer triggers
  27640. */
  27641. abstract readonly hasPointerTriggers: boolean;
  27642. /**
  27643. * Does this action manager has pick triggers
  27644. */
  27645. abstract readonly hasPickTriggers: boolean;
  27646. /**
  27647. * Process a specific trigger
  27648. * @param trigger defines the trigger to process
  27649. * @param evt defines the event details to be processed
  27650. */
  27651. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27652. /**
  27653. * Does this action manager handles actions of any of the given triggers
  27654. * @param triggers defines the triggers to be tested
  27655. * @return a boolean indicating whether one (or more) of the triggers is handled
  27656. */
  27657. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27658. /**
  27659. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27660. * speed.
  27661. * @param triggerA defines the trigger to be tested
  27662. * @param triggerB defines the trigger to be tested
  27663. * @return a boolean indicating whether one (or more) of the triggers is handled
  27664. */
  27665. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27666. /**
  27667. * Does this action manager handles actions of a given trigger
  27668. * @param trigger defines the trigger to be tested
  27669. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27670. * @return whether the trigger is handled
  27671. */
  27672. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27673. /**
  27674. * Serialize this manager to a JSON object
  27675. * @param name defines the property name to store this manager
  27676. * @returns a JSON representation of this manager
  27677. */
  27678. abstract serialize(name: string): any;
  27679. /**
  27680. * Registers an action to this action manager
  27681. * @param action defines the action to be registered
  27682. * @return the action amended (prepared) after registration
  27683. */
  27684. abstract registerAction(action: IAction): Nullable<IAction>;
  27685. /**
  27686. * Unregisters an action to this action manager
  27687. * @param action defines the action to be unregistered
  27688. * @return a boolean indicating whether the action has been unregistered
  27689. */
  27690. abstract unregisterAction(action: IAction): Boolean;
  27691. /**
  27692. * Does exist one action manager with at least one trigger
  27693. **/
  27694. static readonly HasTriggers: boolean;
  27695. /**
  27696. * Does exist one action manager with at least one pick trigger
  27697. **/
  27698. static readonly HasPickTriggers: boolean;
  27699. /**
  27700. * Does exist one action manager that handles actions of a given trigger
  27701. * @param trigger defines the trigger to be tested
  27702. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27703. **/
  27704. static HasSpecificTrigger(trigger: number): boolean;
  27705. }
  27706. }
  27707. declare module "babylonjs/node" {
  27708. import { Scene } from "babylonjs/scene";
  27709. import { Nullable } from "babylonjs/types";
  27710. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27711. import { Engine } from "babylonjs/Engines/engine";
  27712. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27713. import { Observable } from "babylonjs/Misc/observable";
  27714. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27715. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27716. import { Animatable } from "babylonjs/Animations/animatable";
  27717. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27718. import { Animation } from "babylonjs/Animations/animation";
  27719. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27721. /**
  27722. * Defines how a node can be built from a string name.
  27723. */
  27724. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27725. /**
  27726. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27727. */
  27728. export class Node implements IBehaviorAware<Node> {
  27729. /** @hidden */
  27730. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27731. private static _NodeConstructors;
  27732. /**
  27733. * Add a new node constructor
  27734. * @param type defines the type name of the node to construct
  27735. * @param constructorFunc defines the constructor function
  27736. */
  27737. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27738. /**
  27739. * Returns a node constructor based on type name
  27740. * @param type defines the type name
  27741. * @param name defines the new node name
  27742. * @param scene defines the hosting scene
  27743. * @param options defines optional options to transmit to constructors
  27744. * @returns the new constructor or null
  27745. */
  27746. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27747. /**
  27748. * Gets or sets the name of the node
  27749. */
  27750. name: string;
  27751. /**
  27752. * Gets or sets the id of the node
  27753. */
  27754. id: string;
  27755. /**
  27756. * Gets or sets the unique id of the node
  27757. */
  27758. uniqueId: number;
  27759. /**
  27760. * Gets or sets a string used to store user defined state for the node
  27761. */
  27762. state: string;
  27763. /**
  27764. * Gets or sets an object used to store user defined information for the node
  27765. */
  27766. metadata: any;
  27767. /**
  27768. * For internal use only. Please do not use.
  27769. */
  27770. reservedDataStore: any;
  27771. /**
  27772. * List of inspectable custom properties (used by the Inspector)
  27773. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27774. */
  27775. inspectableCustomProperties: IInspectable[];
  27776. private _doNotSerialize;
  27777. /**
  27778. * Gets or sets a boolean used to define if the node must be serialized
  27779. */
  27780. doNotSerialize: boolean;
  27781. /** @hidden */
  27782. _isDisposed: boolean;
  27783. /**
  27784. * Gets a list of Animations associated with the node
  27785. */
  27786. animations: import("babylonjs/Animations/animation").Animation[];
  27787. protected _ranges: {
  27788. [name: string]: Nullable<AnimationRange>;
  27789. };
  27790. /**
  27791. * Callback raised when the node is ready to be used
  27792. */
  27793. onReady: Nullable<(node: Node) => void>;
  27794. private _isEnabled;
  27795. private _isParentEnabled;
  27796. private _isReady;
  27797. /** @hidden */
  27798. _currentRenderId: number;
  27799. private _parentUpdateId;
  27800. /** @hidden */
  27801. _childUpdateId: number;
  27802. /** @hidden */
  27803. _waitingParentId: Nullable<string>;
  27804. /** @hidden */
  27805. _scene: Scene;
  27806. /** @hidden */
  27807. _cache: any;
  27808. private _parentNode;
  27809. private _children;
  27810. /** @hidden */
  27811. _worldMatrix: Matrix;
  27812. /** @hidden */
  27813. _worldMatrixDeterminant: number;
  27814. /** @hidden */
  27815. _worldMatrixDeterminantIsDirty: boolean;
  27816. /** @hidden */
  27817. private _sceneRootNodesIndex;
  27818. /**
  27819. * Gets a boolean indicating if the node has been disposed
  27820. * @returns true if the node was disposed
  27821. */
  27822. isDisposed(): boolean;
  27823. /**
  27824. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27825. * @see https://doc.babylonjs.com/how_to/parenting
  27826. */
  27827. parent: Nullable<Node>;
  27828. private addToSceneRootNodes;
  27829. private removeFromSceneRootNodes;
  27830. private _animationPropertiesOverride;
  27831. /**
  27832. * Gets or sets the animation properties override
  27833. */
  27834. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27835. /**
  27836. * Gets a string idenfifying the name of the class
  27837. * @returns "Node" string
  27838. */
  27839. getClassName(): string;
  27840. /** @hidden */
  27841. readonly _isNode: boolean;
  27842. /**
  27843. * An event triggered when the mesh is disposed
  27844. */
  27845. onDisposeObservable: Observable<Node>;
  27846. private _onDisposeObserver;
  27847. /**
  27848. * Sets a callback that will be raised when the node will be disposed
  27849. */
  27850. onDispose: () => void;
  27851. /**
  27852. * Creates a new Node
  27853. * @param name the name and id to be given to this node
  27854. * @param scene the scene this node will be added to
  27855. * @param addToRootNodes the node will be added to scene.rootNodes
  27856. */
  27857. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27858. /**
  27859. * Gets the scene of the node
  27860. * @returns a scene
  27861. */
  27862. getScene(): Scene;
  27863. /**
  27864. * Gets the engine of the node
  27865. * @returns a Engine
  27866. */
  27867. getEngine(): Engine;
  27868. private _behaviors;
  27869. /**
  27870. * Attach a behavior to the node
  27871. * @see http://doc.babylonjs.com/features/behaviour
  27872. * @param behavior defines the behavior to attach
  27873. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27874. * @returns the current Node
  27875. */
  27876. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27877. /**
  27878. * Remove an attached behavior
  27879. * @see http://doc.babylonjs.com/features/behaviour
  27880. * @param behavior defines the behavior to attach
  27881. * @returns the current Node
  27882. */
  27883. removeBehavior(behavior: Behavior<Node>): Node;
  27884. /**
  27885. * Gets the list of attached behaviors
  27886. * @see http://doc.babylonjs.com/features/behaviour
  27887. */
  27888. readonly behaviors: Behavior<Node>[];
  27889. /**
  27890. * Gets an attached behavior by name
  27891. * @param name defines the name of the behavior to look for
  27892. * @see http://doc.babylonjs.com/features/behaviour
  27893. * @returns null if behavior was not found else the requested behavior
  27894. */
  27895. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27896. /**
  27897. * Returns the latest update of the World matrix
  27898. * @returns a Matrix
  27899. */
  27900. getWorldMatrix(): Matrix;
  27901. /** @hidden */
  27902. _getWorldMatrixDeterminant(): number;
  27903. /**
  27904. * Returns directly the latest state of the mesh World matrix.
  27905. * A Matrix is returned.
  27906. */
  27907. readonly worldMatrixFromCache: Matrix;
  27908. /** @hidden */
  27909. _initCache(): void;
  27910. /** @hidden */
  27911. updateCache(force?: boolean): void;
  27912. /** @hidden */
  27913. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27914. /** @hidden */
  27915. _updateCache(ignoreParentClass?: boolean): void;
  27916. /** @hidden */
  27917. _isSynchronized(): boolean;
  27918. /** @hidden */
  27919. _markSyncedWithParent(): void;
  27920. /** @hidden */
  27921. isSynchronizedWithParent(): boolean;
  27922. /** @hidden */
  27923. isSynchronized(): boolean;
  27924. /**
  27925. * Is this node ready to be used/rendered
  27926. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27927. * @return true if the node is ready
  27928. */
  27929. isReady(completeCheck?: boolean): boolean;
  27930. /**
  27931. * Is this node enabled?
  27932. * 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
  27933. * @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
  27934. * @return whether this node (and its parent) is enabled
  27935. */
  27936. isEnabled(checkAncestors?: boolean): boolean;
  27937. /** @hidden */
  27938. protected _syncParentEnabledState(): void;
  27939. /**
  27940. * Set the enabled state of this node
  27941. * @param value defines the new enabled state
  27942. */
  27943. setEnabled(value: boolean): void;
  27944. /**
  27945. * Is this node a descendant of the given node?
  27946. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27947. * @param ancestor defines the parent node to inspect
  27948. * @returns a boolean indicating if this node is a descendant of the given node
  27949. */
  27950. isDescendantOf(ancestor: Node): boolean;
  27951. /** @hidden */
  27952. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27953. /**
  27954. * Will return all nodes that have this node as ascendant
  27955. * @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
  27956. * @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
  27957. * @return all children nodes of all types
  27958. */
  27959. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27960. /**
  27961. * Get all child-meshes of this node
  27962. * @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)
  27963. * @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
  27964. * @returns an array of AbstractMesh
  27965. */
  27966. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27967. /**
  27968. * Get all direct children of this node
  27969. * @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
  27970. * @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)
  27971. * @returns an array of Node
  27972. */
  27973. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27974. /** @hidden */
  27975. _setReady(state: boolean): void;
  27976. /**
  27977. * Get an animation by name
  27978. * @param name defines the name of the animation to look for
  27979. * @returns null if not found else the requested animation
  27980. */
  27981. getAnimationByName(name: string): Nullable<Animation>;
  27982. /**
  27983. * Creates an animation range for this node
  27984. * @param name defines the name of the range
  27985. * @param from defines the starting key
  27986. * @param to defines the end key
  27987. */
  27988. createAnimationRange(name: string, from: number, to: number): void;
  27989. /**
  27990. * Delete a specific animation range
  27991. * @param name defines the name of the range to delete
  27992. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27993. */
  27994. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27995. /**
  27996. * Get an animation range by name
  27997. * @param name defines the name of the animation range to look for
  27998. * @returns null if not found else the requested animation range
  27999. */
  28000. getAnimationRange(name: string): Nullable<AnimationRange>;
  28001. /**
  28002. * Gets the list of all animation ranges defined on this node
  28003. * @returns an array
  28004. */
  28005. getAnimationRanges(): Nullable<AnimationRange>[];
  28006. /**
  28007. * Will start the animation sequence
  28008. * @param name defines the range frames for animation sequence
  28009. * @param loop defines if the animation should loop (false by default)
  28010. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28011. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28012. * @returns the object created for this animation. If range does not exist, it will return null
  28013. */
  28014. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28015. /**
  28016. * Serialize animation ranges into a JSON compatible object
  28017. * @returns serialization object
  28018. */
  28019. serializeAnimationRanges(): any;
  28020. /**
  28021. * Computes the world matrix of the node
  28022. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28023. * @returns the world matrix
  28024. */
  28025. computeWorldMatrix(force?: boolean): Matrix;
  28026. /**
  28027. * Releases resources associated with this node.
  28028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28030. */
  28031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28032. /**
  28033. * Parse animation range data from a serialization object and store them into a given node
  28034. * @param node defines where to store the animation ranges
  28035. * @param parsedNode defines the serialization object to read data from
  28036. * @param scene defines the hosting scene
  28037. */
  28038. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28039. /**
  28040. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28041. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28042. * @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
  28043. * @returns the new bounding vectors
  28044. */
  28045. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28046. min: Vector3;
  28047. max: Vector3;
  28048. };
  28049. }
  28050. }
  28051. declare module "babylonjs/Animations/animation" {
  28052. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28053. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28054. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28055. import { Nullable } from "babylonjs/types";
  28056. import { Scene } from "babylonjs/scene";
  28057. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28058. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28059. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28060. import { Node } from "babylonjs/node";
  28061. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28062. import { Size } from "babylonjs/Maths/math.size";
  28063. import { Animatable } from "babylonjs/Animations/animatable";
  28064. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28065. /**
  28066. * @hidden
  28067. */
  28068. export class _IAnimationState {
  28069. key: number;
  28070. repeatCount: number;
  28071. workValue?: any;
  28072. loopMode?: number;
  28073. offsetValue?: any;
  28074. highLimitValue?: any;
  28075. }
  28076. /**
  28077. * Class used to store any kind of animation
  28078. */
  28079. export class Animation {
  28080. /**Name of the animation */
  28081. name: string;
  28082. /**Property to animate */
  28083. targetProperty: string;
  28084. /**The frames per second of the animation */
  28085. framePerSecond: number;
  28086. /**The data type of the animation */
  28087. dataType: number;
  28088. /**The loop mode of the animation */
  28089. loopMode?: number | undefined;
  28090. /**Specifies if blending should be enabled */
  28091. enableBlending?: boolean | undefined;
  28092. /**
  28093. * Use matrix interpolation instead of using direct key value when animating matrices
  28094. */
  28095. static AllowMatricesInterpolation: boolean;
  28096. /**
  28097. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28098. */
  28099. static AllowMatrixDecomposeForInterpolation: boolean;
  28100. /**
  28101. * Stores the key frames of the animation
  28102. */
  28103. private _keys;
  28104. /**
  28105. * Stores the easing function of the animation
  28106. */
  28107. private _easingFunction;
  28108. /**
  28109. * @hidden Internal use only
  28110. */
  28111. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28112. /**
  28113. * The set of event that will be linked to this animation
  28114. */
  28115. private _events;
  28116. /**
  28117. * Stores an array of target property paths
  28118. */
  28119. targetPropertyPath: string[];
  28120. /**
  28121. * Stores the blending speed of the animation
  28122. */
  28123. blendingSpeed: number;
  28124. /**
  28125. * Stores the animation ranges for the animation
  28126. */
  28127. private _ranges;
  28128. /**
  28129. * @hidden Internal use
  28130. */
  28131. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28132. /**
  28133. * Sets up an animation
  28134. * @param property The property to animate
  28135. * @param animationType The animation type to apply
  28136. * @param framePerSecond The frames per second of the animation
  28137. * @param easingFunction The easing function used in the animation
  28138. * @returns The created animation
  28139. */
  28140. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28141. /**
  28142. * Create and start an animation on a node
  28143. * @param name defines the name of the global animation that will be run on all nodes
  28144. * @param node defines the root node where the animation will take place
  28145. * @param targetProperty defines property to animate
  28146. * @param framePerSecond defines the number of frame per second yo use
  28147. * @param totalFrame defines the number of frames in total
  28148. * @param from defines the initial value
  28149. * @param to defines the final value
  28150. * @param loopMode defines which loop mode you want to use (off by default)
  28151. * @param easingFunction defines the easing function to use (linear by default)
  28152. * @param onAnimationEnd defines the callback to call when animation end
  28153. * @returns the animatable created for this animation
  28154. */
  28155. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28156. /**
  28157. * Create and start an animation on a node and its descendants
  28158. * @param name defines the name of the global animation that will be run on all nodes
  28159. * @param node defines the root node where the animation will take place
  28160. * @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
  28161. * @param targetProperty defines property to animate
  28162. * @param framePerSecond defines the number of frame per second to use
  28163. * @param totalFrame defines the number of frames in total
  28164. * @param from defines the initial value
  28165. * @param to defines the final value
  28166. * @param loopMode defines which loop mode you want to use (off by default)
  28167. * @param easingFunction defines the easing function to use (linear by default)
  28168. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28169. * @returns the list of animatables created for all nodes
  28170. * @example https://www.babylonjs-playground.com/#MH0VLI
  28171. */
  28172. 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[]>;
  28173. /**
  28174. * Creates a new animation, merges it with the existing animations and starts it
  28175. * @param name Name of the animation
  28176. * @param node Node which contains the scene that begins the animations
  28177. * @param targetProperty Specifies which property to animate
  28178. * @param framePerSecond The frames per second of the animation
  28179. * @param totalFrame The total number of frames
  28180. * @param from The frame at the beginning of the animation
  28181. * @param to The frame at the end of the animation
  28182. * @param loopMode Specifies the loop mode of the animation
  28183. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28184. * @param onAnimationEnd Callback to run once the animation is complete
  28185. * @returns Nullable animation
  28186. */
  28187. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28188. /**
  28189. * Transition property of an host to the target Value
  28190. * @param property The property to transition
  28191. * @param targetValue The target Value of the property
  28192. * @param host The object where the property to animate belongs
  28193. * @param scene Scene used to run the animation
  28194. * @param frameRate Framerate (in frame/s) to use
  28195. * @param transition The transition type we want to use
  28196. * @param duration The duration of the animation, in milliseconds
  28197. * @param onAnimationEnd Callback trigger at the end of the animation
  28198. * @returns Nullable animation
  28199. */
  28200. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28201. /**
  28202. * Return the array of runtime animations currently using this animation
  28203. */
  28204. readonly runtimeAnimations: RuntimeAnimation[];
  28205. /**
  28206. * Specifies if any of the runtime animations are currently running
  28207. */
  28208. readonly hasRunningRuntimeAnimations: boolean;
  28209. /**
  28210. * Initializes the animation
  28211. * @param name Name of the animation
  28212. * @param targetProperty Property to animate
  28213. * @param framePerSecond The frames per second of the animation
  28214. * @param dataType The data type of the animation
  28215. * @param loopMode The loop mode of the animation
  28216. * @param enableBlending Specifies if blending should be enabled
  28217. */
  28218. constructor(
  28219. /**Name of the animation */
  28220. name: string,
  28221. /**Property to animate */
  28222. targetProperty: string,
  28223. /**The frames per second of the animation */
  28224. framePerSecond: number,
  28225. /**The data type of the animation */
  28226. dataType: number,
  28227. /**The loop mode of the animation */
  28228. loopMode?: number | undefined,
  28229. /**Specifies if blending should be enabled */
  28230. enableBlending?: boolean | undefined);
  28231. /**
  28232. * Converts the animation to a string
  28233. * @param fullDetails support for multiple levels of logging within scene loading
  28234. * @returns String form of the animation
  28235. */
  28236. toString(fullDetails?: boolean): string;
  28237. /**
  28238. * Add an event to this animation
  28239. * @param event Event to add
  28240. */
  28241. addEvent(event: AnimationEvent): void;
  28242. /**
  28243. * Remove all events found at the given frame
  28244. * @param frame The frame to remove events from
  28245. */
  28246. removeEvents(frame: number): void;
  28247. /**
  28248. * Retrieves all the events from the animation
  28249. * @returns Events from the animation
  28250. */
  28251. getEvents(): AnimationEvent[];
  28252. /**
  28253. * Creates an animation range
  28254. * @param name Name of the animation range
  28255. * @param from Starting frame of the animation range
  28256. * @param to Ending frame of the animation
  28257. */
  28258. createRange(name: string, from: number, to: number): void;
  28259. /**
  28260. * Deletes an animation range by name
  28261. * @param name Name of the animation range to delete
  28262. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28263. */
  28264. deleteRange(name: string, deleteFrames?: boolean): void;
  28265. /**
  28266. * Gets the animation range by name, or null if not defined
  28267. * @param name Name of the animation range
  28268. * @returns Nullable animation range
  28269. */
  28270. getRange(name: string): Nullable<AnimationRange>;
  28271. /**
  28272. * Gets the key frames from the animation
  28273. * @returns The key frames of the animation
  28274. */
  28275. getKeys(): Array<IAnimationKey>;
  28276. /**
  28277. * Gets the highest frame rate of the animation
  28278. * @returns Highest frame rate of the animation
  28279. */
  28280. getHighestFrame(): number;
  28281. /**
  28282. * Gets the easing function of the animation
  28283. * @returns Easing function of the animation
  28284. */
  28285. getEasingFunction(): IEasingFunction;
  28286. /**
  28287. * Sets the easing function of the animation
  28288. * @param easingFunction A custom mathematical formula for animation
  28289. */
  28290. setEasingFunction(easingFunction: EasingFunction): void;
  28291. /**
  28292. * Interpolates a scalar linearly
  28293. * @param startValue Start value of the animation curve
  28294. * @param endValue End value of the animation curve
  28295. * @param gradient Scalar amount to interpolate
  28296. * @returns Interpolated scalar value
  28297. */
  28298. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28299. /**
  28300. * Interpolates a scalar cubically
  28301. * @param startValue Start value of the animation curve
  28302. * @param outTangent End tangent of the animation
  28303. * @param endValue End value of the animation curve
  28304. * @param inTangent Start tangent of the animation curve
  28305. * @param gradient Scalar amount to interpolate
  28306. * @returns Interpolated scalar value
  28307. */
  28308. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28309. /**
  28310. * Interpolates a quaternion using a spherical linear interpolation
  28311. * @param startValue Start value of the animation curve
  28312. * @param endValue End value of the animation curve
  28313. * @param gradient Scalar amount to interpolate
  28314. * @returns Interpolated quaternion value
  28315. */
  28316. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28317. /**
  28318. * Interpolates a quaternion cubically
  28319. * @param startValue Start value of the animation curve
  28320. * @param outTangent End tangent of the animation curve
  28321. * @param endValue End value of the animation curve
  28322. * @param inTangent Start tangent of the animation curve
  28323. * @param gradient Scalar amount to interpolate
  28324. * @returns Interpolated quaternion value
  28325. */
  28326. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28327. /**
  28328. * Interpolates a Vector3 linearl
  28329. * @param startValue Start value of the animation curve
  28330. * @param endValue End value of the animation curve
  28331. * @param gradient Scalar amount to interpolate
  28332. * @returns Interpolated scalar value
  28333. */
  28334. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28335. /**
  28336. * Interpolates a Vector3 cubically
  28337. * @param startValue Start value of the animation curve
  28338. * @param outTangent End tangent of the animation
  28339. * @param endValue End value of the animation curve
  28340. * @param inTangent Start tangent of the animation curve
  28341. * @param gradient Scalar amount to interpolate
  28342. * @returns InterpolatedVector3 value
  28343. */
  28344. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28345. /**
  28346. * Interpolates a Vector2 linearly
  28347. * @param startValue Start value of the animation curve
  28348. * @param endValue End value of the animation curve
  28349. * @param gradient Scalar amount to interpolate
  28350. * @returns Interpolated Vector2 value
  28351. */
  28352. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28353. /**
  28354. * Interpolates a Vector2 cubically
  28355. * @param startValue Start value of the animation curve
  28356. * @param outTangent End tangent of the animation
  28357. * @param endValue End value of the animation curve
  28358. * @param inTangent Start tangent of the animation curve
  28359. * @param gradient Scalar amount to interpolate
  28360. * @returns Interpolated Vector2 value
  28361. */
  28362. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28363. /**
  28364. * Interpolates a size linearly
  28365. * @param startValue Start value of the animation curve
  28366. * @param endValue End value of the animation curve
  28367. * @param gradient Scalar amount to interpolate
  28368. * @returns Interpolated Size value
  28369. */
  28370. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28371. /**
  28372. * Interpolates a Color3 linearly
  28373. * @param startValue Start value of the animation curve
  28374. * @param endValue End value of the animation curve
  28375. * @param gradient Scalar amount to interpolate
  28376. * @returns Interpolated Color3 value
  28377. */
  28378. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28379. /**
  28380. * Interpolates a Color4 linearly
  28381. * @param startValue Start value of the animation curve
  28382. * @param endValue End value of the animation curve
  28383. * @param gradient Scalar amount to interpolate
  28384. * @returns Interpolated Color3 value
  28385. */
  28386. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28387. /**
  28388. * @hidden Internal use only
  28389. */
  28390. _getKeyValue(value: any): any;
  28391. /**
  28392. * @hidden Internal use only
  28393. */
  28394. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28395. /**
  28396. * Defines the function to use to interpolate matrices
  28397. * @param startValue defines the start matrix
  28398. * @param endValue defines the end matrix
  28399. * @param gradient defines the gradient between both matrices
  28400. * @param result defines an optional target matrix where to store the interpolation
  28401. * @returns the interpolated matrix
  28402. */
  28403. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28404. /**
  28405. * Makes a copy of the animation
  28406. * @returns Cloned animation
  28407. */
  28408. clone(): Animation;
  28409. /**
  28410. * Sets the key frames of the animation
  28411. * @param values The animation key frames to set
  28412. */
  28413. setKeys(values: Array<IAnimationKey>): void;
  28414. /**
  28415. * Serializes the animation to an object
  28416. * @returns Serialized object
  28417. */
  28418. serialize(): any;
  28419. /**
  28420. * Float animation type
  28421. */
  28422. static readonly ANIMATIONTYPE_FLOAT: number;
  28423. /**
  28424. * Vector3 animation type
  28425. */
  28426. static readonly ANIMATIONTYPE_VECTOR3: number;
  28427. /**
  28428. * Quaternion animation type
  28429. */
  28430. static readonly ANIMATIONTYPE_QUATERNION: number;
  28431. /**
  28432. * Matrix animation type
  28433. */
  28434. static readonly ANIMATIONTYPE_MATRIX: number;
  28435. /**
  28436. * Color3 animation type
  28437. */
  28438. static readonly ANIMATIONTYPE_COLOR3: number;
  28439. /**
  28440. * Color3 animation type
  28441. */
  28442. static readonly ANIMATIONTYPE_COLOR4: number;
  28443. /**
  28444. * Vector2 animation type
  28445. */
  28446. static readonly ANIMATIONTYPE_VECTOR2: number;
  28447. /**
  28448. * Size animation type
  28449. */
  28450. static readonly ANIMATIONTYPE_SIZE: number;
  28451. /**
  28452. * Relative Loop Mode
  28453. */
  28454. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28455. /**
  28456. * Cycle Loop Mode
  28457. */
  28458. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28459. /**
  28460. * Constant Loop Mode
  28461. */
  28462. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28463. /** @hidden */
  28464. static _UniversalLerp(left: any, right: any, amount: number): any;
  28465. /**
  28466. * Parses an animation object and creates an animation
  28467. * @param parsedAnimation Parsed animation object
  28468. * @returns Animation object
  28469. */
  28470. static Parse(parsedAnimation: any): Animation;
  28471. /**
  28472. * Appends the serialized animations from the source animations
  28473. * @param source Source containing the animations
  28474. * @param destination Target to store the animations
  28475. */
  28476. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28477. }
  28478. }
  28479. declare module "babylonjs/Animations/animatable.interface" {
  28480. import { Nullable } from "babylonjs/types";
  28481. import { Animation } from "babylonjs/Animations/animation";
  28482. /**
  28483. * Interface containing an array of animations
  28484. */
  28485. export interface IAnimatable {
  28486. /**
  28487. * Array of animations
  28488. */
  28489. animations: Nullable<Array<Animation>>;
  28490. }
  28491. }
  28492. declare module "babylonjs/Materials/fresnelParameters" {
  28493. import { Color3 } from "babylonjs/Maths/math.color";
  28494. /**
  28495. * This represents all the required information to add a fresnel effect on a material:
  28496. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28497. */
  28498. export class FresnelParameters {
  28499. private _isEnabled;
  28500. /**
  28501. * Define if the fresnel effect is enable or not.
  28502. */
  28503. isEnabled: boolean;
  28504. /**
  28505. * Define the color used on edges (grazing angle)
  28506. */
  28507. leftColor: Color3;
  28508. /**
  28509. * Define the color used on center
  28510. */
  28511. rightColor: Color3;
  28512. /**
  28513. * Define bias applied to computed fresnel term
  28514. */
  28515. bias: number;
  28516. /**
  28517. * Defined the power exponent applied to fresnel term
  28518. */
  28519. power: number;
  28520. /**
  28521. * Clones the current fresnel and its valuues
  28522. * @returns a clone fresnel configuration
  28523. */
  28524. clone(): FresnelParameters;
  28525. /**
  28526. * Serializes the current fresnel parameters to a JSON representation.
  28527. * @return the JSON serialization
  28528. */
  28529. serialize(): any;
  28530. /**
  28531. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28532. * @param parsedFresnelParameters Define the JSON representation
  28533. * @returns the parsed parameters
  28534. */
  28535. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28536. }
  28537. }
  28538. declare module "babylonjs/Misc/decorators" {
  28539. import { Nullable } from "babylonjs/types";
  28540. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28541. import { Scene } from "babylonjs/scene";
  28542. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28543. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28544. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28545. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28546. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28547. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28548. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28549. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28550. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28551. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28552. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28553. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28554. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28555. /**
  28556. * Decorator used to define property that can be serialized as reference to a camera
  28557. * @param sourceName defines the name of the property to decorate
  28558. */
  28559. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28560. /**
  28561. * Class used to help serialization objects
  28562. */
  28563. export class SerializationHelper {
  28564. /** @hidden */
  28565. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28566. /** @hidden */
  28567. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28568. /** @hidden */
  28569. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28570. /** @hidden */
  28571. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28572. /**
  28573. * Appends the serialized animations from the source animations
  28574. * @param source Source containing the animations
  28575. * @param destination Target to store the animations
  28576. */
  28577. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28578. /**
  28579. * Static function used to serialized a specific entity
  28580. * @param entity defines the entity to serialize
  28581. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28582. * @returns a JSON compatible object representing the serialization of the entity
  28583. */
  28584. static Serialize<T>(entity: T, serializationObject?: any): any;
  28585. /**
  28586. * Creates a new entity from a serialization data object
  28587. * @param creationFunction defines a function used to instanciated the new entity
  28588. * @param source defines the source serialization data
  28589. * @param scene defines the hosting scene
  28590. * @param rootUrl defines the root url for resources
  28591. * @returns a new entity
  28592. */
  28593. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28594. /**
  28595. * Clones an object
  28596. * @param creationFunction defines the function used to instanciate the new object
  28597. * @param source defines the source object
  28598. * @returns the cloned object
  28599. */
  28600. static Clone<T>(creationFunction: () => T, source: T): T;
  28601. /**
  28602. * Instanciates a new object based on a source one (some data will be shared between both object)
  28603. * @param creationFunction defines the function used to instanciate the new object
  28604. * @param source defines the source object
  28605. * @returns the new object
  28606. */
  28607. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28608. }
  28609. }
  28610. declare module "babylonjs/Misc/guid" {
  28611. /**
  28612. * Class used to manipulate GUIDs
  28613. */
  28614. export class GUID {
  28615. /**
  28616. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28617. * Be aware Math.random() could cause collisions, but:
  28618. * "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"
  28619. * @returns a pseudo random id
  28620. */
  28621. static RandomId(): string;
  28622. }
  28623. }
  28624. declare module "babylonjs/Materials/Textures/baseTexture" {
  28625. import { Observable } from "babylonjs/Misc/observable";
  28626. import { Nullable } from "babylonjs/types";
  28627. import { Scene } from "babylonjs/scene";
  28628. import { Matrix } from "babylonjs/Maths/math.vector";
  28629. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28630. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28631. import { ISize } from "babylonjs/Maths/math.size";
  28632. /**
  28633. * Base class of all the textures in babylon.
  28634. * It groups all the common properties the materials, post process, lights... might need
  28635. * in order to make a correct use of the texture.
  28636. */
  28637. export class BaseTexture implements IAnimatable {
  28638. /**
  28639. * Default anisotropic filtering level for the application.
  28640. * It is set to 4 as a good tradeoff between perf and quality.
  28641. */
  28642. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28643. /**
  28644. * Gets or sets the unique id of the texture
  28645. */
  28646. uniqueId: number;
  28647. /**
  28648. * Define the name of the texture.
  28649. */
  28650. name: string;
  28651. /**
  28652. * Gets or sets an object used to store user defined information.
  28653. */
  28654. metadata: any;
  28655. /**
  28656. * For internal use only. Please do not use.
  28657. */
  28658. reservedDataStore: any;
  28659. private _hasAlpha;
  28660. /**
  28661. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28662. */
  28663. hasAlpha: boolean;
  28664. /**
  28665. * Defines if the alpha value should be determined via the rgb values.
  28666. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28667. */
  28668. getAlphaFromRGB: boolean;
  28669. /**
  28670. * Intensity or strength of the texture.
  28671. * It is commonly used by materials to fine tune the intensity of the texture
  28672. */
  28673. level: number;
  28674. /**
  28675. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28676. * This is part of the texture as textures usually maps to one uv set.
  28677. */
  28678. coordinatesIndex: number;
  28679. private _coordinatesMode;
  28680. /**
  28681. * How a texture is mapped.
  28682. *
  28683. * | Value | Type | Description |
  28684. * | ----- | ----------------------------------- | ----------- |
  28685. * | 0 | EXPLICIT_MODE | |
  28686. * | 1 | SPHERICAL_MODE | |
  28687. * | 2 | PLANAR_MODE | |
  28688. * | 3 | CUBIC_MODE | |
  28689. * | 4 | PROJECTION_MODE | |
  28690. * | 5 | SKYBOX_MODE | |
  28691. * | 6 | INVCUBIC_MODE | |
  28692. * | 7 | EQUIRECTANGULAR_MODE | |
  28693. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28694. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28695. */
  28696. coordinatesMode: number;
  28697. /**
  28698. * | Value | Type | Description |
  28699. * | ----- | ------------------ | ----------- |
  28700. * | 0 | CLAMP_ADDRESSMODE | |
  28701. * | 1 | WRAP_ADDRESSMODE | |
  28702. * | 2 | MIRROR_ADDRESSMODE | |
  28703. */
  28704. wrapU: number;
  28705. /**
  28706. * | Value | Type | Description |
  28707. * | ----- | ------------------ | ----------- |
  28708. * | 0 | CLAMP_ADDRESSMODE | |
  28709. * | 1 | WRAP_ADDRESSMODE | |
  28710. * | 2 | MIRROR_ADDRESSMODE | |
  28711. */
  28712. wrapV: number;
  28713. /**
  28714. * | Value | Type | Description |
  28715. * | ----- | ------------------ | ----------- |
  28716. * | 0 | CLAMP_ADDRESSMODE | |
  28717. * | 1 | WRAP_ADDRESSMODE | |
  28718. * | 2 | MIRROR_ADDRESSMODE | |
  28719. */
  28720. wrapR: number;
  28721. /**
  28722. * With compliant hardware and browser (supporting anisotropic filtering)
  28723. * this defines the level of anisotropic filtering in the texture.
  28724. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28725. */
  28726. anisotropicFilteringLevel: number;
  28727. /**
  28728. * Define if the texture is a cube texture or if false a 2d texture.
  28729. */
  28730. isCube: boolean;
  28731. /**
  28732. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28733. */
  28734. is3D: boolean;
  28735. /**
  28736. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28737. * HDR texture are usually stored in linear space.
  28738. * This only impacts the PBR and Background materials
  28739. */
  28740. gammaSpace: boolean;
  28741. /**
  28742. * Gets or sets whether or not the texture contains RGBD data.
  28743. */
  28744. isRGBD: boolean;
  28745. /**
  28746. * Is Z inverted in the texture (useful in a cube texture).
  28747. */
  28748. invertZ: boolean;
  28749. /**
  28750. * Are mip maps generated for this texture or not.
  28751. */
  28752. readonly noMipmap: boolean;
  28753. /**
  28754. * @hidden
  28755. */
  28756. lodLevelInAlpha: boolean;
  28757. /**
  28758. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28759. */
  28760. lodGenerationOffset: number;
  28761. /**
  28762. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28763. */
  28764. lodGenerationScale: number;
  28765. /**
  28766. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28767. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28768. * average roughness values.
  28769. */
  28770. linearSpecularLOD: boolean;
  28771. /**
  28772. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28773. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28774. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28775. */
  28776. irradianceTexture: Nullable<BaseTexture>;
  28777. /**
  28778. * Define if the texture is a render target.
  28779. */
  28780. isRenderTarget: boolean;
  28781. /**
  28782. * Define the unique id of the texture in the scene.
  28783. */
  28784. readonly uid: string;
  28785. /**
  28786. * Return a string representation of the texture.
  28787. * @returns the texture as a string
  28788. */
  28789. toString(): string;
  28790. /**
  28791. * Get the class name of the texture.
  28792. * @returns "BaseTexture"
  28793. */
  28794. getClassName(): string;
  28795. /**
  28796. * Define the list of animation attached to the texture.
  28797. */
  28798. animations: import("babylonjs/Animations/animation").Animation[];
  28799. /**
  28800. * An event triggered when the texture is disposed.
  28801. */
  28802. onDisposeObservable: Observable<BaseTexture>;
  28803. private _onDisposeObserver;
  28804. /**
  28805. * Callback triggered when the texture has been disposed.
  28806. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28807. */
  28808. onDispose: () => void;
  28809. /**
  28810. * Define the current state of the loading sequence when in delayed load mode.
  28811. */
  28812. delayLoadState: number;
  28813. private _scene;
  28814. /** @hidden */
  28815. _texture: Nullable<InternalTexture>;
  28816. private _uid;
  28817. /**
  28818. * Define if the texture is preventinga material to render or not.
  28819. * If not and the texture is not ready, the engine will use a default black texture instead.
  28820. */
  28821. readonly isBlocking: boolean;
  28822. /**
  28823. * Instantiates a new BaseTexture.
  28824. * Base class of all the textures in babylon.
  28825. * It groups all the common properties the materials, post process, lights... might need
  28826. * in order to make a correct use of the texture.
  28827. * @param scene Define the scene the texture blongs to
  28828. */
  28829. constructor(scene: Nullable<Scene>);
  28830. /**
  28831. * Get the scene the texture belongs to.
  28832. * @returns the scene or null if undefined
  28833. */
  28834. getScene(): Nullable<Scene>;
  28835. /**
  28836. * Get the texture transform matrix used to offset tile the texture for istance.
  28837. * @returns the transformation matrix
  28838. */
  28839. getTextureMatrix(): Matrix;
  28840. /**
  28841. * Get the texture reflection matrix used to rotate/transform the reflection.
  28842. * @returns the reflection matrix
  28843. */
  28844. getReflectionTextureMatrix(): Matrix;
  28845. /**
  28846. * Get the underlying lower level texture from Babylon.
  28847. * @returns the insternal texture
  28848. */
  28849. getInternalTexture(): Nullable<InternalTexture>;
  28850. /**
  28851. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28852. * @returns true if ready or not blocking
  28853. */
  28854. isReadyOrNotBlocking(): boolean;
  28855. /**
  28856. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28857. * @returns true if fully ready
  28858. */
  28859. isReady(): boolean;
  28860. private _cachedSize;
  28861. /**
  28862. * Get the size of the texture.
  28863. * @returns the texture size.
  28864. */
  28865. getSize(): ISize;
  28866. /**
  28867. * Get the base size of the texture.
  28868. * It can be different from the size if the texture has been resized for POT for instance
  28869. * @returns the base size
  28870. */
  28871. getBaseSize(): ISize;
  28872. /**
  28873. * Update the sampling mode of the texture.
  28874. * Default is Trilinear mode.
  28875. *
  28876. * | Value | Type | Description |
  28877. * | ----- | ------------------ | ----------- |
  28878. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28879. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28880. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28881. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28882. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28883. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28884. * | 7 | NEAREST_LINEAR | |
  28885. * | 8 | NEAREST_NEAREST | |
  28886. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28887. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28888. * | 11 | LINEAR_LINEAR | |
  28889. * | 12 | LINEAR_NEAREST | |
  28890. *
  28891. * > _mag_: magnification filter (close to the viewer)
  28892. * > _min_: minification filter (far from the viewer)
  28893. * > _mip_: filter used between mip map levels
  28894. *@param samplingMode Define the new sampling mode of the texture
  28895. */
  28896. updateSamplingMode(samplingMode: number): void;
  28897. /**
  28898. * Scales the texture if is `canRescale()`
  28899. * @param ratio the resize factor we want to use to rescale
  28900. */
  28901. scale(ratio: number): void;
  28902. /**
  28903. * Get if the texture can rescale.
  28904. */
  28905. readonly canRescale: boolean;
  28906. /** @hidden */
  28907. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28908. /** @hidden */
  28909. _rebuild(): void;
  28910. /**
  28911. * Triggers the load sequence in delayed load mode.
  28912. */
  28913. delayLoad(): void;
  28914. /**
  28915. * Clones the texture.
  28916. * @returns the cloned texture
  28917. */
  28918. clone(): Nullable<BaseTexture>;
  28919. /**
  28920. * Get the texture underlying type (INT, FLOAT...)
  28921. */
  28922. readonly textureType: number;
  28923. /**
  28924. * Get the texture underlying format (RGB, RGBA...)
  28925. */
  28926. readonly textureFormat: number;
  28927. /**
  28928. * Indicates that textures need to be re-calculated for all materials
  28929. */
  28930. protected _markAllSubMeshesAsTexturesDirty(): void;
  28931. /**
  28932. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28933. * This will returns an RGBA array buffer containing either in values (0-255) or
  28934. * float values (0-1) depending of the underlying buffer type.
  28935. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28936. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28937. * @param buffer defines a user defined buffer to fill with data (can be null)
  28938. * @returns The Array buffer containing the pixels data.
  28939. */
  28940. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28941. /**
  28942. * Release and destroy the underlying lower level texture aka internalTexture.
  28943. */
  28944. releaseInternalTexture(): void;
  28945. /** @hidden */
  28946. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28947. /** @hidden */
  28948. readonly _lodTextureMid: Nullable<BaseTexture>;
  28949. /** @hidden */
  28950. readonly _lodTextureLow: Nullable<BaseTexture>;
  28951. /**
  28952. * Dispose the texture and release its associated resources.
  28953. */
  28954. dispose(): void;
  28955. /**
  28956. * Serialize the texture into a JSON representation that can be parsed later on.
  28957. * @returns the JSON representation of the texture
  28958. */
  28959. serialize(): any;
  28960. /**
  28961. * Helper function to be called back once a list of texture contains only ready textures.
  28962. * @param textures Define the list of textures to wait for
  28963. * @param callback Define the callback triggered once the entire list will be ready
  28964. */
  28965. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28966. }
  28967. }
  28968. declare module "babylonjs/Materials/effect" {
  28969. import { Observable } from "babylonjs/Misc/observable";
  28970. import { Nullable } from "babylonjs/types";
  28971. import { IDisposable } from "babylonjs/scene";
  28972. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28973. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28974. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28975. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28976. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28977. import { Engine } from "babylonjs/Engines/engine";
  28978. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28979. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28980. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28981. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28982. /**
  28983. * Options to be used when creating an effect.
  28984. */
  28985. export interface IEffectCreationOptions {
  28986. /**
  28987. * Atrributes that will be used in the shader.
  28988. */
  28989. attributes: string[];
  28990. /**
  28991. * Uniform varible names that will be set in the shader.
  28992. */
  28993. uniformsNames: string[];
  28994. /**
  28995. * Uniform buffer varible names that will be set in the shader.
  28996. */
  28997. uniformBuffersNames: string[];
  28998. /**
  28999. * Sampler texture variable names that will be set in the shader.
  29000. */
  29001. samplers: string[];
  29002. /**
  29003. * Define statements that will be set in the shader.
  29004. */
  29005. defines: any;
  29006. /**
  29007. * Possible fallbacks for this effect to improve performance when needed.
  29008. */
  29009. fallbacks: Nullable<IEffectFallbacks>;
  29010. /**
  29011. * Callback that will be called when the shader is compiled.
  29012. */
  29013. onCompiled: Nullable<(effect: Effect) => void>;
  29014. /**
  29015. * Callback that will be called if an error occurs during shader compilation.
  29016. */
  29017. onError: Nullable<(effect: Effect, errors: string) => void>;
  29018. /**
  29019. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29020. */
  29021. indexParameters?: any;
  29022. /**
  29023. * Max number of lights that can be used in the shader.
  29024. */
  29025. maxSimultaneousLights?: number;
  29026. /**
  29027. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29028. */
  29029. transformFeedbackVaryings?: Nullable<string[]>;
  29030. }
  29031. /**
  29032. * Effect containing vertex and fragment shader that can be executed on an object.
  29033. */
  29034. export class Effect implements IDisposable {
  29035. /**
  29036. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29037. */
  29038. static ShadersRepository: string;
  29039. /**
  29040. * Name of the effect.
  29041. */
  29042. name: any;
  29043. /**
  29044. * String container all the define statements that should be set on the shader.
  29045. */
  29046. defines: string;
  29047. /**
  29048. * Callback that will be called when the shader is compiled.
  29049. */
  29050. onCompiled: Nullable<(effect: Effect) => void>;
  29051. /**
  29052. * Callback that will be called if an error occurs during shader compilation.
  29053. */
  29054. onError: Nullable<(effect: Effect, errors: string) => void>;
  29055. /**
  29056. * Callback that will be called when effect is bound.
  29057. */
  29058. onBind: Nullable<(effect: Effect) => void>;
  29059. /**
  29060. * Unique ID of the effect.
  29061. */
  29062. uniqueId: number;
  29063. /**
  29064. * Observable that will be called when the shader is compiled.
  29065. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29066. */
  29067. onCompileObservable: Observable<Effect>;
  29068. /**
  29069. * Observable that will be called if an error occurs during shader compilation.
  29070. */
  29071. onErrorObservable: Observable<Effect>;
  29072. /** @hidden */
  29073. _onBindObservable: Nullable<Observable<Effect>>;
  29074. /**
  29075. * Observable that will be called when effect is bound.
  29076. */
  29077. readonly onBindObservable: Observable<Effect>;
  29078. /** @hidden */
  29079. _bonesComputationForcedToCPU: boolean;
  29080. private static _uniqueIdSeed;
  29081. private _engine;
  29082. private _uniformBuffersNames;
  29083. private _uniformsNames;
  29084. private _samplerList;
  29085. private _samplers;
  29086. private _isReady;
  29087. private _compilationError;
  29088. private _allFallbacksProcessed;
  29089. private _attributesNames;
  29090. private _attributes;
  29091. private _uniforms;
  29092. /**
  29093. * Key for the effect.
  29094. * @hidden
  29095. */
  29096. _key: string;
  29097. private _indexParameters;
  29098. private _fallbacks;
  29099. private _vertexSourceCode;
  29100. private _fragmentSourceCode;
  29101. private _vertexSourceCodeOverride;
  29102. private _fragmentSourceCodeOverride;
  29103. private _transformFeedbackVaryings;
  29104. /**
  29105. * Compiled shader to webGL program.
  29106. * @hidden
  29107. */
  29108. _pipelineContext: Nullable<IPipelineContext>;
  29109. private _valueCache;
  29110. private static _baseCache;
  29111. /**
  29112. * Instantiates an effect.
  29113. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29114. * @param baseName Name of the effect.
  29115. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29116. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29117. * @param samplers List of sampler variables that will be passed to the shader.
  29118. * @param engine Engine to be used to render the effect
  29119. * @param defines Define statements to be added to the shader.
  29120. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29121. * @param onCompiled Callback that will be called when the shader is compiled.
  29122. * @param onError Callback that will be called if an error occurs during shader compilation.
  29123. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29124. */
  29125. 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);
  29126. private _useFinalCode;
  29127. /**
  29128. * Unique key for this effect
  29129. */
  29130. readonly key: string;
  29131. /**
  29132. * If the effect has been compiled and prepared.
  29133. * @returns if the effect is compiled and prepared.
  29134. */
  29135. isReady(): boolean;
  29136. private _isReadyInternal;
  29137. /**
  29138. * The engine the effect was initialized with.
  29139. * @returns the engine.
  29140. */
  29141. getEngine(): Engine;
  29142. /**
  29143. * The pipeline context for this effect
  29144. * @returns the associated pipeline context
  29145. */
  29146. getPipelineContext(): Nullable<IPipelineContext>;
  29147. /**
  29148. * The set of names of attribute variables for the shader.
  29149. * @returns An array of attribute names.
  29150. */
  29151. getAttributesNames(): string[];
  29152. /**
  29153. * Returns the attribute at the given index.
  29154. * @param index The index of the attribute.
  29155. * @returns The location of the attribute.
  29156. */
  29157. getAttributeLocation(index: number): number;
  29158. /**
  29159. * Returns the attribute based on the name of the variable.
  29160. * @param name of the attribute to look up.
  29161. * @returns the attribute location.
  29162. */
  29163. getAttributeLocationByName(name: string): number;
  29164. /**
  29165. * The number of attributes.
  29166. * @returns the numnber of attributes.
  29167. */
  29168. getAttributesCount(): number;
  29169. /**
  29170. * Gets the index of a uniform variable.
  29171. * @param uniformName of the uniform to look up.
  29172. * @returns the index.
  29173. */
  29174. getUniformIndex(uniformName: string): number;
  29175. /**
  29176. * Returns the attribute based on the name of the variable.
  29177. * @param uniformName of the uniform to look up.
  29178. * @returns the location of the uniform.
  29179. */
  29180. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29181. /**
  29182. * Returns an array of sampler variable names
  29183. * @returns The array of sampler variable neames.
  29184. */
  29185. getSamplers(): string[];
  29186. /**
  29187. * The error from the last compilation.
  29188. * @returns the error string.
  29189. */
  29190. getCompilationError(): string;
  29191. /**
  29192. * Gets a boolean indicating that all fallbacks were used during compilation
  29193. * @returns true if all fallbacks were used
  29194. */
  29195. allFallbacksProcessed(): boolean;
  29196. /**
  29197. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29198. * @param func The callback to be used.
  29199. */
  29200. executeWhenCompiled(func: (effect: Effect) => void): void;
  29201. private _checkIsReady;
  29202. private _loadShader;
  29203. /**
  29204. * Recompiles the webGL program
  29205. * @param vertexSourceCode The source code for the vertex shader.
  29206. * @param fragmentSourceCode The source code for the fragment shader.
  29207. * @param onCompiled Callback called when completed.
  29208. * @param onError Callback called on error.
  29209. * @hidden
  29210. */
  29211. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29212. /**
  29213. * Prepares the effect
  29214. * @hidden
  29215. */
  29216. _prepareEffect(): void;
  29217. private _processCompilationErrors;
  29218. /**
  29219. * Checks if the effect is supported. (Must be called after compilation)
  29220. */
  29221. readonly isSupported: boolean;
  29222. /**
  29223. * Binds a texture to the engine to be used as output of the shader.
  29224. * @param channel Name of the output variable.
  29225. * @param texture Texture to bind.
  29226. * @hidden
  29227. */
  29228. _bindTexture(channel: string, texture: InternalTexture): void;
  29229. /**
  29230. * Sets a texture on the engine to be used in the shader.
  29231. * @param channel Name of the sampler variable.
  29232. * @param texture Texture to set.
  29233. */
  29234. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29235. /**
  29236. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29237. * @param channel Name of the sampler variable.
  29238. * @param texture Texture to set.
  29239. */
  29240. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29241. /**
  29242. * Sets an array of textures on the engine to be used in the shader.
  29243. * @param channel Name of the variable.
  29244. * @param textures Textures to set.
  29245. */
  29246. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29247. /**
  29248. * 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)
  29249. * @param channel Name of the sampler variable.
  29250. * @param postProcess Post process to get the input texture from.
  29251. */
  29252. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29253. /**
  29254. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29255. * 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)
  29256. * @param channel Name of the sampler variable.
  29257. * @param postProcess Post process to get the output texture from.
  29258. */
  29259. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29260. /** @hidden */
  29261. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29262. /** @hidden */
  29263. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29264. /** @hidden */
  29265. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29266. /** @hidden */
  29267. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29268. /**
  29269. * Binds a buffer to a uniform.
  29270. * @param buffer Buffer to bind.
  29271. * @param name Name of the uniform variable to bind to.
  29272. */
  29273. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29274. /**
  29275. * Binds block to a uniform.
  29276. * @param blockName Name of the block to bind.
  29277. * @param index Index to bind.
  29278. */
  29279. bindUniformBlock(blockName: string, index: number): void;
  29280. /**
  29281. * Sets an interger value on a uniform variable.
  29282. * @param uniformName Name of the variable.
  29283. * @param value Value to be set.
  29284. * @returns this effect.
  29285. */
  29286. setInt(uniformName: string, value: number): Effect;
  29287. /**
  29288. * Sets an int array on a uniform variable.
  29289. * @param uniformName Name of the variable.
  29290. * @param array array to be set.
  29291. * @returns this effect.
  29292. */
  29293. setIntArray(uniformName: string, array: Int32Array): Effect;
  29294. /**
  29295. * 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)
  29296. * @param uniformName Name of the variable.
  29297. * @param array array to be set.
  29298. * @returns this effect.
  29299. */
  29300. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29301. /**
  29302. * 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)
  29303. * @param uniformName Name of the variable.
  29304. * @param array array to be set.
  29305. * @returns this effect.
  29306. */
  29307. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29308. /**
  29309. * 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)
  29310. * @param uniformName Name of the variable.
  29311. * @param array array to be set.
  29312. * @returns this effect.
  29313. */
  29314. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29315. /**
  29316. * Sets an float array on a uniform variable.
  29317. * @param uniformName Name of the variable.
  29318. * @param array array to be set.
  29319. * @returns this effect.
  29320. */
  29321. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29322. /**
  29323. * 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)
  29324. * @param uniformName Name of the variable.
  29325. * @param array array to be set.
  29326. * @returns this effect.
  29327. */
  29328. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29329. /**
  29330. * 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)
  29331. * @param uniformName Name of the variable.
  29332. * @param array array to be set.
  29333. * @returns this effect.
  29334. */
  29335. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29336. /**
  29337. * 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)
  29338. * @param uniformName Name of the variable.
  29339. * @param array array to be set.
  29340. * @returns this effect.
  29341. */
  29342. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29343. /**
  29344. * Sets an array on a uniform variable.
  29345. * @param uniformName Name of the variable.
  29346. * @param array array to be set.
  29347. * @returns this effect.
  29348. */
  29349. setArray(uniformName: string, array: number[]): Effect;
  29350. /**
  29351. * 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)
  29352. * @param uniformName Name of the variable.
  29353. * @param array array to be set.
  29354. * @returns this effect.
  29355. */
  29356. setArray2(uniformName: string, array: number[]): Effect;
  29357. /**
  29358. * 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)
  29359. * @param uniformName Name of the variable.
  29360. * @param array array to be set.
  29361. * @returns this effect.
  29362. */
  29363. setArray3(uniformName: string, array: number[]): Effect;
  29364. /**
  29365. * 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)
  29366. * @param uniformName Name of the variable.
  29367. * @param array array to be set.
  29368. * @returns this effect.
  29369. */
  29370. setArray4(uniformName: string, array: number[]): Effect;
  29371. /**
  29372. * Sets matrices on a uniform variable.
  29373. * @param uniformName Name of the variable.
  29374. * @param matrices matrices to be set.
  29375. * @returns this effect.
  29376. */
  29377. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29378. /**
  29379. * Sets matrix on a uniform variable.
  29380. * @param uniformName Name of the variable.
  29381. * @param matrix matrix to be set.
  29382. * @returns this effect.
  29383. */
  29384. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param matrix matrix to be set.
  29389. * @returns this effect.
  29390. */
  29391. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29392. /**
  29393. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29394. * @param uniformName Name of the variable.
  29395. * @param matrix matrix to be set.
  29396. * @returns this effect.
  29397. */
  29398. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29399. /**
  29400. * Sets a float on a uniform variable.
  29401. * @param uniformName Name of the variable.
  29402. * @param value value to be set.
  29403. * @returns this effect.
  29404. */
  29405. setFloat(uniformName: string, value: number): Effect;
  29406. /**
  29407. * Sets a boolean on a uniform variable.
  29408. * @param uniformName Name of the variable.
  29409. * @param bool value to be set.
  29410. * @returns this effect.
  29411. */
  29412. setBool(uniformName: string, bool: boolean): Effect;
  29413. /**
  29414. * Sets a Vector2 on a uniform variable.
  29415. * @param uniformName Name of the variable.
  29416. * @param vector2 vector2 to be set.
  29417. * @returns this effect.
  29418. */
  29419. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29420. /**
  29421. * Sets a float2 on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param x First float in float2.
  29424. * @param y Second float in float2.
  29425. * @returns this effect.
  29426. */
  29427. setFloat2(uniformName: string, x: number, y: number): Effect;
  29428. /**
  29429. * Sets a Vector3 on a uniform variable.
  29430. * @param uniformName Name of the variable.
  29431. * @param vector3 Value to be set.
  29432. * @returns this effect.
  29433. */
  29434. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29435. /**
  29436. * Sets a float3 on a uniform variable.
  29437. * @param uniformName Name of the variable.
  29438. * @param x First float in float3.
  29439. * @param y Second float in float3.
  29440. * @param z Third float in float3.
  29441. * @returns this effect.
  29442. */
  29443. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29444. /**
  29445. * Sets a Vector4 on a uniform variable.
  29446. * @param uniformName Name of the variable.
  29447. * @param vector4 Value to be set.
  29448. * @returns this effect.
  29449. */
  29450. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29451. /**
  29452. * Sets a float4 on a uniform variable.
  29453. * @param uniformName Name of the variable.
  29454. * @param x First float in float4.
  29455. * @param y Second float in float4.
  29456. * @param z Third float in float4.
  29457. * @param w Fourth float in float4.
  29458. * @returns this effect.
  29459. */
  29460. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29461. /**
  29462. * Sets a Color3 on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param color3 Value to be set.
  29465. * @returns this effect.
  29466. */
  29467. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29468. /**
  29469. * Sets a Color4 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param color3 Value to be set.
  29472. * @param alpha Alpha value to be set.
  29473. * @returns this effect.
  29474. */
  29475. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29476. /**
  29477. * Sets a Color4 on a uniform variable
  29478. * @param uniformName defines the name of the variable
  29479. * @param color4 defines the value to be set
  29480. * @returns this effect.
  29481. */
  29482. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29483. /** Release all associated resources */
  29484. dispose(): void;
  29485. /**
  29486. * This function will add a new shader to the shader store
  29487. * @param name the name of the shader
  29488. * @param pixelShader optional pixel shader content
  29489. * @param vertexShader optional vertex shader content
  29490. */
  29491. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29492. /**
  29493. * Store of each shader (The can be looked up using effect.key)
  29494. */
  29495. static ShadersStore: {
  29496. [key: string]: string;
  29497. };
  29498. /**
  29499. * Store of each included file for a shader (The can be looked up using effect.key)
  29500. */
  29501. static IncludesShadersStore: {
  29502. [key: string]: string;
  29503. };
  29504. /**
  29505. * Resets the cache of effects.
  29506. */
  29507. static ResetCache(): void;
  29508. }
  29509. }
  29510. declare module "babylonjs/Engines/engineCapabilities" {
  29511. /**
  29512. * Interface used to describe the capabilities of the engine relatively to the current browser
  29513. */
  29514. export interface EngineCapabilities {
  29515. /** Maximum textures units per fragment shader */
  29516. maxTexturesImageUnits: number;
  29517. /** Maximum texture units per vertex shader */
  29518. maxVertexTextureImageUnits: number;
  29519. /** Maximum textures units in the entire pipeline */
  29520. maxCombinedTexturesImageUnits: number;
  29521. /** Maximum texture size */
  29522. maxTextureSize: number;
  29523. /** Maximum cube texture size */
  29524. maxCubemapTextureSize: number;
  29525. /** Maximum render texture size */
  29526. maxRenderTextureSize: number;
  29527. /** Maximum number of vertex attributes */
  29528. maxVertexAttribs: number;
  29529. /** Maximum number of varyings */
  29530. maxVaryingVectors: number;
  29531. /** Maximum number of uniforms per vertex shader */
  29532. maxVertexUniformVectors: number;
  29533. /** Maximum number of uniforms per fragment shader */
  29534. maxFragmentUniformVectors: number;
  29535. /** Defines if standard derivates (dx/dy) are supported */
  29536. standardDerivatives: boolean;
  29537. /** Defines if s3tc texture compression is supported */
  29538. s3tc?: WEBGL_compressed_texture_s3tc;
  29539. /** Defines if pvrtc texture compression is supported */
  29540. pvrtc: any;
  29541. /** Defines if etc1 texture compression is supported */
  29542. etc1: any;
  29543. /** Defines if etc2 texture compression is supported */
  29544. etc2: any;
  29545. /** Defines if astc texture compression is supported */
  29546. astc: any;
  29547. /** Defines if float textures are supported */
  29548. textureFloat: boolean;
  29549. /** Defines if vertex array objects are supported */
  29550. vertexArrayObject: boolean;
  29551. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29552. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29553. /** Gets the maximum level of anisotropy supported */
  29554. maxAnisotropy: number;
  29555. /** Defines if instancing is supported */
  29556. instancedArrays: boolean;
  29557. /** Defines if 32 bits indices are supported */
  29558. uintIndices: boolean;
  29559. /** Defines if high precision shaders are supported */
  29560. highPrecisionShaderSupported: boolean;
  29561. /** Defines if depth reading in the fragment shader is supported */
  29562. fragmentDepthSupported: boolean;
  29563. /** Defines if float texture linear filtering is supported*/
  29564. textureFloatLinearFiltering: boolean;
  29565. /** Defines if rendering to float textures is supported */
  29566. textureFloatRender: boolean;
  29567. /** Defines if half float textures are supported*/
  29568. textureHalfFloat: boolean;
  29569. /** Defines if half float texture linear filtering is supported*/
  29570. textureHalfFloatLinearFiltering: boolean;
  29571. /** Defines if rendering to half float textures is supported */
  29572. textureHalfFloatRender: boolean;
  29573. /** Defines if textureLOD shader command is supported */
  29574. textureLOD: boolean;
  29575. /** Defines if draw buffers extension is supported */
  29576. drawBuffersExtension: boolean;
  29577. /** Defines if depth textures are supported */
  29578. depthTextureExtension: boolean;
  29579. /** Defines if float color buffer are supported */
  29580. colorBufferFloat: boolean;
  29581. /** Gets disjoint timer query extension (null if not supported) */
  29582. timerQuery?: EXT_disjoint_timer_query;
  29583. /** Defines if timestamp can be used with timer query */
  29584. canUseTimestampForTimerQuery: boolean;
  29585. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29586. multiview?: any;
  29587. /** Function used to let the system compiles shaders in background */
  29588. parallelShaderCompile?: {
  29589. COMPLETION_STATUS_KHR: number;
  29590. };
  29591. /** Max number of texture samples for MSAA */
  29592. maxMSAASamples: number;
  29593. /** Defines if the blend min max extension is supported */
  29594. blendMinMax: boolean;
  29595. }
  29596. }
  29597. declare module "babylonjs/States/depthCullingState" {
  29598. import { Nullable } from "babylonjs/types";
  29599. /**
  29600. * @hidden
  29601. **/
  29602. export class DepthCullingState {
  29603. private _isDepthTestDirty;
  29604. private _isDepthMaskDirty;
  29605. private _isDepthFuncDirty;
  29606. private _isCullFaceDirty;
  29607. private _isCullDirty;
  29608. private _isZOffsetDirty;
  29609. private _isFrontFaceDirty;
  29610. private _depthTest;
  29611. private _depthMask;
  29612. private _depthFunc;
  29613. private _cull;
  29614. private _cullFace;
  29615. private _zOffset;
  29616. private _frontFace;
  29617. /**
  29618. * Initializes the state.
  29619. */
  29620. constructor();
  29621. readonly isDirty: boolean;
  29622. zOffset: number;
  29623. cullFace: Nullable<number>;
  29624. cull: Nullable<boolean>;
  29625. depthFunc: Nullable<number>;
  29626. depthMask: boolean;
  29627. depthTest: boolean;
  29628. frontFace: Nullable<number>;
  29629. reset(): void;
  29630. apply(gl: WebGLRenderingContext): void;
  29631. }
  29632. }
  29633. declare module "babylonjs/States/stencilState" {
  29634. /**
  29635. * @hidden
  29636. **/
  29637. export class StencilState {
  29638. /** 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 */
  29639. static readonly ALWAYS: number;
  29640. /** Passed to stencilOperation to specify that stencil value must be kept */
  29641. static readonly KEEP: number;
  29642. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29643. static readonly REPLACE: number;
  29644. private _isStencilTestDirty;
  29645. private _isStencilMaskDirty;
  29646. private _isStencilFuncDirty;
  29647. private _isStencilOpDirty;
  29648. private _stencilTest;
  29649. private _stencilMask;
  29650. private _stencilFunc;
  29651. private _stencilFuncRef;
  29652. private _stencilFuncMask;
  29653. private _stencilOpStencilFail;
  29654. private _stencilOpDepthFail;
  29655. private _stencilOpStencilDepthPass;
  29656. readonly isDirty: boolean;
  29657. stencilFunc: number;
  29658. stencilFuncRef: number;
  29659. stencilFuncMask: number;
  29660. stencilOpStencilFail: number;
  29661. stencilOpDepthFail: number;
  29662. stencilOpStencilDepthPass: number;
  29663. stencilMask: number;
  29664. stencilTest: boolean;
  29665. constructor();
  29666. reset(): void;
  29667. apply(gl: WebGLRenderingContext): void;
  29668. }
  29669. }
  29670. declare module "babylonjs/States/alphaCullingState" {
  29671. /**
  29672. * @hidden
  29673. **/
  29674. export class AlphaState {
  29675. private _isAlphaBlendDirty;
  29676. private _isBlendFunctionParametersDirty;
  29677. private _isBlendEquationParametersDirty;
  29678. private _isBlendConstantsDirty;
  29679. private _alphaBlend;
  29680. private _blendFunctionParameters;
  29681. private _blendEquationParameters;
  29682. private _blendConstants;
  29683. /**
  29684. * Initializes the state.
  29685. */
  29686. constructor();
  29687. readonly isDirty: boolean;
  29688. alphaBlend: boolean;
  29689. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29690. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29691. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29692. reset(): void;
  29693. apply(gl: WebGLRenderingContext): void;
  29694. }
  29695. }
  29696. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29697. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29698. /** @hidden */
  29699. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29700. attributeProcessor(attribute: string): string;
  29701. varyingProcessor(varying: string, isFragment: boolean): string;
  29702. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29703. }
  29704. }
  29705. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29706. /**
  29707. * Interface for attribute information associated with buffer instanciation
  29708. */
  29709. export interface InstancingAttributeInfo {
  29710. /**
  29711. * Index/offset of the attribute in the vertex shader
  29712. */
  29713. index: number;
  29714. /**
  29715. * size of the attribute, 1, 2, 3 or 4
  29716. */
  29717. attributeSize: number;
  29718. /**
  29719. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29720. * default is FLOAT
  29721. */
  29722. attributeType: number;
  29723. /**
  29724. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29725. */
  29726. normalized: boolean;
  29727. /**
  29728. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29729. */
  29730. offset: number;
  29731. /**
  29732. * Name of the GLSL attribute, for debugging purpose only
  29733. */
  29734. attributeName: string;
  29735. }
  29736. }
  29737. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29739. import { Nullable } from "babylonjs/types";
  29740. module "babylonjs/Engines/thinEngine" {
  29741. interface ThinEngine {
  29742. /**
  29743. * Update a video texture
  29744. * @param texture defines the texture to update
  29745. * @param video defines the video element to use
  29746. * @param invertY defines if data must be stored with Y axis inverted
  29747. */
  29748. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29749. }
  29750. }
  29751. }
  29752. declare module "babylonjs/Materials/Textures/videoTexture" {
  29753. import { Observable } from "babylonjs/Misc/observable";
  29754. import { Nullable } from "babylonjs/types";
  29755. import { Scene } from "babylonjs/scene";
  29756. import { Texture } from "babylonjs/Materials/Textures/texture";
  29757. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29758. /**
  29759. * Settings for finer control over video usage
  29760. */
  29761. export interface VideoTextureSettings {
  29762. /**
  29763. * Applies `autoplay` to video, if specified
  29764. */
  29765. autoPlay?: boolean;
  29766. /**
  29767. * Applies `loop` to video, if specified
  29768. */
  29769. loop?: boolean;
  29770. /**
  29771. * Automatically updates internal texture from video at every frame in the render loop
  29772. */
  29773. autoUpdateTexture: boolean;
  29774. /**
  29775. * Image src displayed during the video loading or until the user interacts with the video.
  29776. */
  29777. poster?: string;
  29778. }
  29779. /**
  29780. * If you want to display a video in your scene, this is the special texture for that.
  29781. * This special texture works similar to other textures, with the exception of a few parameters.
  29782. * @see https://doc.babylonjs.com/how_to/video_texture
  29783. */
  29784. export class VideoTexture extends Texture {
  29785. /**
  29786. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29787. */
  29788. readonly autoUpdateTexture: boolean;
  29789. /**
  29790. * The video instance used by the texture internally
  29791. */
  29792. readonly video: HTMLVideoElement;
  29793. private _onUserActionRequestedObservable;
  29794. /**
  29795. * Event triggerd when a dom action is required by the user to play the video.
  29796. * This happens due to recent changes in browser policies preventing video to auto start.
  29797. */
  29798. readonly onUserActionRequestedObservable: Observable<Texture>;
  29799. private _generateMipMaps;
  29800. private _engine;
  29801. private _stillImageCaptured;
  29802. private _displayingPosterTexture;
  29803. private _settings;
  29804. private _createInternalTextureOnEvent;
  29805. private _frameId;
  29806. /**
  29807. * Creates a video texture.
  29808. * If you want to display a video in your scene, this is the special texture for that.
  29809. * This special texture works similar to other textures, with the exception of a few parameters.
  29810. * @see https://doc.babylonjs.com/how_to/video_texture
  29811. * @param name optional name, will detect from video source, if not defined
  29812. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29813. * @param scene is obviously the current scene.
  29814. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29815. * @param invertY is false by default but can be used to invert video on Y axis
  29816. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29817. * @param settings allows finer control over video usage
  29818. */
  29819. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29820. private _getName;
  29821. private _getVideo;
  29822. private _createInternalTexture;
  29823. private reset;
  29824. /**
  29825. * @hidden Internal method to initiate `update`.
  29826. */
  29827. _rebuild(): void;
  29828. /**
  29829. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29830. */
  29831. update(): void;
  29832. /**
  29833. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29834. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29835. */
  29836. updateTexture(isVisible: boolean): void;
  29837. protected _updateInternalTexture: () => void;
  29838. /**
  29839. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29840. * @param url New url.
  29841. */
  29842. updateURL(url: string): void;
  29843. /**
  29844. * Dispose the texture and release its associated resources.
  29845. */
  29846. dispose(): void;
  29847. /**
  29848. * Creates a video texture straight from a stream.
  29849. * @param scene Define the scene the texture should be created in
  29850. * @param stream Define the stream the texture should be created from
  29851. * @returns The created video texture as a promise
  29852. */
  29853. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29854. /**
  29855. * Creates a video texture straight from your WebCam video feed.
  29856. * @param scene Define the scene the texture should be created in
  29857. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29858. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29859. * @returns The created video texture as a promise
  29860. */
  29861. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29862. minWidth: number;
  29863. maxWidth: number;
  29864. minHeight: number;
  29865. maxHeight: number;
  29866. deviceId: string;
  29867. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29868. /**
  29869. * Creates a video texture straight from your WebCam video feed.
  29870. * @param scene Define the scene the texture should be created in
  29871. * @param onReady Define a callback to triggered once the texture will be ready
  29872. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29873. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29874. */
  29875. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29876. minWidth: number;
  29877. maxWidth: number;
  29878. minHeight: number;
  29879. maxHeight: number;
  29880. deviceId: string;
  29881. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29882. }
  29883. }
  29884. declare module "babylonjs/Engines/thinEngine" {
  29885. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29886. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29887. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29888. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29889. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29890. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29891. import { Observable } from "babylonjs/Misc/observable";
  29892. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29893. import { StencilState } from "babylonjs/States/stencilState";
  29894. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29895. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29896. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29897. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29898. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29899. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29900. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29901. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29902. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29904. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29905. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29906. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29907. /**
  29908. * Defines the interface used by objects working like Scene
  29909. * @hidden
  29910. */
  29911. interface ISceneLike {
  29912. _addPendingData(data: any): void;
  29913. _removePendingData(data: any): void;
  29914. offlineProvider: IOfflineProvider;
  29915. }
  29916. /** Interface defining initialization parameters for Engine class */
  29917. export interface EngineOptions extends WebGLContextAttributes {
  29918. /**
  29919. * Defines if the engine should no exceed a specified device ratio
  29920. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29921. */
  29922. limitDeviceRatio?: number;
  29923. /**
  29924. * Defines if webvr should be enabled automatically
  29925. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29926. */
  29927. autoEnableWebVR?: boolean;
  29928. /**
  29929. * Defines if webgl2 should be turned off even if supported
  29930. * @see http://doc.babylonjs.com/features/webgl2
  29931. */
  29932. disableWebGL2Support?: boolean;
  29933. /**
  29934. * Defines if webaudio should be initialized as well
  29935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29936. */
  29937. audioEngine?: boolean;
  29938. /**
  29939. * Defines if animations should run using a deterministic lock step
  29940. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29941. */
  29942. deterministicLockstep?: boolean;
  29943. /** Defines the maximum steps to use with deterministic lock step mode */
  29944. lockstepMaxSteps?: number;
  29945. /**
  29946. * Defines that engine should ignore context lost events
  29947. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29948. */
  29949. doNotHandleContextLost?: boolean;
  29950. /**
  29951. * Defines that engine should ignore modifying touch action attribute and style
  29952. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29953. */
  29954. doNotHandleTouchAction?: boolean;
  29955. /**
  29956. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29957. */
  29958. useHighPrecisionFloats?: boolean;
  29959. }
  29960. /**
  29961. * The base engine class (root of all engines)
  29962. */
  29963. export class ThinEngine {
  29964. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29965. static ExceptionList: ({
  29966. key: string;
  29967. capture: string;
  29968. captureConstraint: number;
  29969. targets: string[];
  29970. } | {
  29971. key: string;
  29972. capture: null;
  29973. captureConstraint: null;
  29974. targets: string[];
  29975. })[];
  29976. /** @hidden */
  29977. static _TextureLoaders: IInternalTextureLoader[];
  29978. /**
  29979. * Returns the current npm package of the sdk
  29980. */
  29981. static readonly NpmPackage: string;
  29982. /**
  29983. * Returns the current version of the framework
  29984. */
  29985. static readonly Version: string;
  29986. /**
  29987. * Returns a string describing the current engine
  29988. */
  29989. readonly description: string;
  29990. /**
  29991. * Gets or sets the epsilon value used by collision engine
  29992. */
  29993. static CollisionsEpsilon: number;
  29994. /**
  29995. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29996. */
  29997. static ShadersRepository: string;
  29998. /** @hidden */
  29999. _shaderProcessor: IShaderProcessor;
  30000. /**
  30001. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30002. */
  30003. forcePOTTextures: boolean;
  30004. /**
  30005. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30006. */
  30007. isFullscreen: boolean;
  30008. /**
  30009. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30010. */
  30011. cullBackFaces: boolean;
  30012. /**
  30013. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30014. */
  30015. renderEvenInBackground: boolean;
  30016. /**
  30017. * Gets or sets a boolean indicating that cache can be kept between frames
  30018. */
  30019. preventCacheWipeBetweenFrames: boolean;
  30020. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30021. validateShaderPrograms: boolean;
  30022. /**
  30023. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30024. */
  30025. disableUniformBuffers: boolean;
  30026. /** @hidden */
  30027. _uniformBuffers: UniformBuffer[];
  30028. /**
  30029. * Gets a boolean indicating that the engine supports uniform buffers
  30030. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30031. */
  30032. readonly supportsUniformBuffers: boolean;
  30033. /** @hidden */
  30034. _gl: WebGLRenderingContext;
  30035. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30036. protected _windowIsBackground: boolean;
  30037. protected _webGLVersion: number;
  30038. protected _creationOptions: EngineOptions;
  30039. protected _highPrecisionShadersAllowed: boolean;
  30040. /** @hidden */
  30041. readonly _shouldUseHighPrecisionShader: boolean;
  30042. /**
  30043. * Gets a boolean indicating that only power of 2 textures are supported
  30044. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30045. */
  30046. readonly needPOTTextures: boolean;
  30047. /** @hidden */
  30048. _badOS: boolean;
  30049. /** @hidden */
  30050. _badDesktopOS: boolean;
  30051. private _hardwareScalingLevel;
  30052. /** @hidden */
  30053. _caps: EngineCapabilities;
  30054. private _isStencilEnable;
  30055. protected _colorWrite: boolean;
  30056. private _glVersion;
  30057. private _glRenderer;
  30058. private _glVendor;
  30059. /** @hidden */
  30060. _videoTextureSupported: boolean;
  30061. protected _renderingQueueLaunched: boolean;
  30062. protected _activeRenderLoops: (() => void)[];
  30063. /**
  30064. * Observable signaled when a context lost event is raised
  30065. */
  30066. onContextLostObservable: Observable<ThinEngine>;
  30067. /**
  30068. * Observable signaled when a context restored event is raised
  30069. */
  30070. onContextRestoredObservable: Observable<ThinEngine>;
  30071. private _onContextLost;
  30072. private _onContextRestored;
  30073. protected _contextWasLost: boolean;
  30074. /** @hidden */
  30075. _doNotHandleContextLost: boolean;
  30076. /**
  30077. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30079. */
  30080. doNotHandleContextLost: boolean;
  30081. /**
  30082. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30083. */
  30084. disableVertexArrayObjects: boolean;
  30085. /** @hidden */
  30086. protected _depthCullingState: DepthCullingState;
  30087. /** @hidden */
  30088. protected _stencilState: StencilState;
  30089. /** @hidden */
  30090. protected _alphaState: AlphaState;
  30091. /** @hidden */
  30092. _internalTexturesCache: InternalTexture[];
  30093. /** @hidden */
  30094. protected _activeChannel: number;
  30095. private _currentTextureChannel;
  30096. /** @hidden */
  30097. protected _boundTexturesCache: {
  30098. [key: string]: Nullable<InternalTexture>;
  30099. };
  30100. /** @hidden */
  30101. protected _currentEffect: Nullable<Effect>;
  30102. /** @hidden */
  30103. protected _currentProgram: Nullable<WebGLProgram>;
  30104. private _compiledEffects;
  30105. private _vertexAttribArraysEnabled;
  30106. /** @hidden */
  30107. protected _cachedViewport: Nullable<IViewportLike>;
  30108. private _cachedVertexArrayObject;
  30109. /** @hidden */
  30110. protected _cachedVertexBuffers: any;
  30111. /** @hidden */
  30112. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30113. /** @hidden */
  30114. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30115. /** @hidden */
  30116. _currentRenderTarget: Nullable<InternalTexture>;
  30117. private _uintIndicesCurrentlySet;
  30118. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30119. /** @hidden */
  30120. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30121. private _currentBufferPointers;
  30122. private _currentInstanceLocations;
  30123. private _currentInstanceBuffers;
  30124. private _textureUnits;
  30125. /** @hidden */
  30126. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30127. /** @hidden */
  30128. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30129. /** @hidden */
  30130. _bindedRenderFunction: any;
  30131. private _vaoRecordInProgress;
  30132. private _mustWipeVertexAttributes;
  30133. private _emptyTexture;
  30134. private _emptyCubeTexture;
  30135. private _emptyTexture3D;
  30136. /** @hidden */
  30137. _frameHandler: number;
  30138. private _nextFreeTextureSlots;
  30139. private _maxSimultaneousTextures;
  30140. private _activeRequests;
  30141. protected _texturesSupported: string[];
  30142. /** @hidden */
  30143. _textureFormatInUse: Nullable<string>;
  30144. protected readonly _supportsHardwareTextureRescaling: boolean;
  30145. /**
  30146. * Gets the list of texture formats supported
  30147. */
  30148. readonly texturesSupported: Array<string>;
  30149. /**
  30150. * Gets the list of texture formats in use
  30151. */
  30152. readonly textureFormatInUse: Nullable<string>;
  30153. /**
  30154. * Gets the current viewport
  30155. */
  30156. readonly currentViewport: Nullable<IViewportLike>;
  30157. /**
  30158. * Gets the default empty texture
  30159. */
  30160. readonly emptyTexture: InternalTexture;
  30161. /**
  30162. * Gets the default empty 3D texture
  30163. */
  30164. readonly emptyTexture3D: InternalTexture;
  30165. /**
  30166. * Gets the default empty cube texture
  30167. */
  30168. readonly emptyCubeTexture: InternalTexture;
  30169. /**
  30170. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30171. */
  30172. readonly premultipliedAlpha: boolean;
  30173. /**
  30174. * Observable event triggered before each texture is initialized
  30175. */
  30176. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30177. /**
  30178. * Creates a new engine
  30179. * @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
  30180. * @param antialias defines enable antialiasing (default: false)
  30181. * @param options defines further options to be sent to the getContext() function
  30182. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30183. */
  30184. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30185. private _rebuildInternalTextures;
  30186. private _rebuildEffects;
  30187. /**
  30188. * Gets a boolean indicating if all created effects are ready
  30189. * @returns true if all effects are ready
  30190. */
  30191. areAllEffectsReady(): boolean;
  30192. protected _rebuildBuffers(): void;
  30193. private _initGLContext;
  30194. /**
  30195. * Gets version of the current webGL context
  30196. */
  30197. readonly webGLVersion: number;
  30198. /**
  30199. * Gets a string idenfifying the name of the class
  30200. * @returns "Engine" string
  30201. */
  30202. getClassName(): string;
  30203. /**
  30204. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30205. */
  30206. readonly isStencilEnable: boolean;
  30207. /** @hidden */
  30208. _prepareWorkingCanvas(): void;
  30209. /**
  30210. * Reset the texture cache to empty state
  30211. */
  30212. resetTextureCache(): void;
  30213. /**
  30214. * Gets an object containing information about the current webGL context
  30215. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30216. */
  30217. getGlInfo(): {
  30218. vendor: string;
  30219. renderer: string;
  30220. version: string;
  30221. };
  30222. /**
  30223. * Defines the hardware scaling level.
  30224. * By default the hardware scaling level is computed from the window device ratio.
  30225. * 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.
  30226. * @param level defines the level to use
  30227. */
  30228. setHardwareScalingLevel(level: number): void;
  30229. /**
  30230. * Gets the current hardware scaling level.
  30231. * By default the hardware scaling level is computed from the window device ratio.
  30232. * 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.
  30233. * @returns a number indicating the current hardware scaling level
  30234. */
  30235. getHardwareScalingLevel(): number;
  30236. /**
  30237. * Gets the list of loaded textures
  30238. * @returns an array containing all loaded textures
  30239. */
  30240. getLoadedTexturesCache(): InternalTexture[];
  30241. /**
  30242. * Gets the object containing all engine capabilities
  30243. * @returns the EngineCapabilities object
  30244. */
  30245. getCaps(): EngineCapabilities;
  30246. /**
  30247. * stop executing a render loop function and remove it from the execution array
  30248. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30249. */
  30250. stopRenderLoop(renderFunction?: () => void): void;
  30251. /** @hidden */
  30252. _renderLoop(): void;
  30253. /**
  30254. * Gets the HTML canvas attached with the current webGL context
  30255. * @returns a HTML canvas
  30256. */
  30257. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30258. /**
  30259. * Gets host window
  30260. * @returns the host window object
  30261. */
  30262. getHostWindow(): Nullable<Window>;
  30263. /**
  30264. * Gets the current render width
  30265. * @param useScreen defines if screen size must be used (or the current render target if any)
  30266. * @returns a number defining the current render width
  30267. */
  30268. getRenderWidth(useScreen?: boolean): number;
  30269. /**
  30270. * Gets the current render height
  30271. * @param useScreen defines if screen size must be used (or the current render target if any)
  30272. * @returns a number defining the current render height
  30273. */
  30274. getRenderHeight(useScreen?: boolean): number;
  30275. /**
  30276. * Can be used to override the current requestAnimationFrame requester.
  30277. * @hidden
  30278. */
  30279. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30280. /**
  30281. * Register and execute a render loop. The engine can have more than one render function
  30282. * @param renderFunction defines the function to continuously execute
  30283. */
  30284. runRenderLoop(renderFunction: () => void): void;
  30285. /**
  30286. * Clear the current render buffer or the current render target (if any is set up)
  30287. * @param color defines the color to use
  30288. * @param backBuffer defines if the back buffer must be cleared
  30289. * @param depth defines if the depth buffer must be cleared
  30290. * @param stencil defines if the stencil buffer must be cleared
  30291. */
  30292. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30293. private _viewportCached;
  30294. /** @hidden */
  30295. _viewport(x: number, y: number, width: number, height: number): void;
  30296. /**
  30297. * Set the WebGL's viewport
  30298. * @param viewport defines the viewport element to be used
  30299. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30300. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30301. */
  30302. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30303. /**
  30304. * Begin a new frame
  30305. */
  30306. beginFrame(): void;
  30307. /**
  30308. * Enf the current frame
  30309. */
  30310. endFrame(): void;
  30311. /**
  30312. * Resize the view according to the canvas' size
  30313. */
  30314. resize(): void;
  30315. /**
  30316. * Force a specific size of the canvas
  30317. * @param width defines the new canvas' width
  30318. * @param height defines the new canvas' height
  30319. */
  30320. setSize(width: number, height: number): void;
  30321. /**
  30322. * Binds the frame buffer to the specified texture.
  30323. * @param texture The texture to render to or null for the default canvas
  30324. * @param faceIndex The face of the texture to render to in case of cube texture
  30325. * @param requiredWidth The width of the target to render to
  30326. * @param requiredHeight The height of the target to render to
  30327. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30328. * @param depthStencilTexture The depth stencil texture to use to render
  30329. * @param lodLevel defines le lod level to bind to the frame buffer
  30330. */
  30331. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30332. /** @hidden */
  30333. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30334. /**
  30335. * Unbind the current render target texture from the webGL context
  30336. * @param texture defines the render target texture to unbind
  30337. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30338. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30339. */
  30340. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30341. /**
  30342. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30343. */
  30344. flushFramebuffer(): void;
  30345. /**
  30346. * Unbind the current render target and bind the default framebuffer
  30347. */
  30348. restoreDefaultFramebuffer(): void;
  30349. /** @hidden */
  30350. protected _resetVertexBufferBinding(): void;
  30351. /**
  30352. * Creates a vertex buffer
  30353. * @param data the data for the vertex buffer
  30354. * @returns the new WebGL static buffer
  30355. */
  30356. createVertexBuffer(data: DataArray): DataBuffer;
  30357. private _createVertexBuffer;
  30358. /**
  30359. * Creates a dynamic vertex buffer
  30360. * @param data the data for the dynamic vertex buffer
  30361. * @returns the new WebGL dynamic buffer
  30362. */
  30363. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30364. protected _resetIndexBufferBinding(): void;
  30365. /**
  30366. * Creates a new index buffer
  30367. * @param indices defines the content of the index buffer
  30368. * @param updatable defines if the index buffer must be updatable
  30369. * @returns a new webGL buffer
  30370. */
  30371. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30372. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30373. /**
  30374. * Bind a webGL buffer to the webGL context
  30375. * @param buffer defines the buffer to bind
  30376. */
  30377. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30378. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30379. private bindBuffer;
  30380. /**
  30381. * update the bound buffer with the given data
  30382. * @param data defines the data to update
  30383. */
  30384. updateArrayBuffer(data: Float32Array): void;
  30385. private _vertexAttribPointer;
  30386. private _bindIndexBufferWithCache;
  30387. private _bindVertexBuffersAttributes;
  30388. /**
  30389. * Records a vertex array object
  30390. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30391. * @param vertexBuffers defines the list of vertex buffers to store
  30392. * @param indexBuffer defines the index buffer to store
  30393. * @param effect defines the effect to store
  30394. * @returns the new vertex array object
  30395. */
  30396. recordVertexArrayObject(vertexBuffers: {
  30397. [key: string]: VertexBuffer;
  30398. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30399. /**
  30400. * Bind a specific vertex array object
  30401. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30402. * @param vertexArrayObject defines the vertex array object to bind
  30403. * @param indexBuffer defines the index buffer to bind
  30404. */
  30405. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30406. /**
  30407. * Bind webGl buffers directly to the webGL context
  30408. * @param vertexBuffer defines the vertex buffer to bind
  30409. * @param indexBuffer defines the index buffer to bind
  30410. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30411. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30412. * @param effect defines the effect associated with the vertex buffer
  30413. */
  30414. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30415. private _unbindVertexArrayObject;
  30416. /**
  30417. * Bind a list of vertex buffers to the webGL context
  30418. * @param vertexBuffers defines the list of vertex buffers to bind
  30419. * @param indexBuffer defines the index buffer to bind
  30420. * @param effect defines the effect associated with the vertex buffers
  30421. */
  30422. bindBuffers(vertexBuffers: {
  30423. [key: string]: Nullable<VertexBuffer>;
  30424. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30425. /**
  30426. * Unbind all instance attributes
  30427. */
  30428. unbindInstanceAttributes(): void;
  30429. /**
  30430. * Release and free the memory of a vertex array object
  30431. * @param vao defines the vertex array object to delete
  30432. */
  30433. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30434. /** @hidden */
  30435. _releaseBuffer(buffer: DataBuffer): boolean;
  30436. protected _deleteBuffer(buffer: DataBuffer): void;
  30437. /**
  30438. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30439. * @param instancesBuffer defines the webGL buffer to update and bind
  30440. * @param data defines the data to store in the buffer
  30441. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30442. */
  30443. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30444. /**
  30445. * Apply all cached states (depth, culling, stencil and alpha)
  30446. */
  30447. applyStates(): void;
  30448. /**
  30449. * Send a draw order
  30450. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30451. * @param indexStart defines the starting index
  30452. * @param indexCount defines the number of index to draw
  30453. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30454. */
  30455. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30456. /**
  30457. * Draw a list of points
  30458. * @param verticesStart defines the index of first vertex to draw
  30459. * @param verticesCount defines the count of vertices to draw
  30460. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30461. */
  30462. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30463. /**
  30464. * Draw a list of unindexed primitives
  30465. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30466. * @param verticesStart defines the index of first vertex to draw
  30467. * @param verticesCount defines the count of vertices to draw
  30468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30469. */
  30470. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30471. /**
  30472. * Draw a list of indexed primitives
  30473. * @param fillMode defines the primitive to use
  30474. * @param indexStart defines the starting index
  30475. * @param indexCount defines the number of index to draw
  30476. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30477. */
  30478. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30479. /**
  30480. * Draw a list of unindexed primitives
  30481. * @param fillMode defines the primitive to use
  30482. * @param verticesStart defines the index of first vertex to draw
  30483. * @param verticesCount defines the count of vertices to draw
  30484. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30485. */
  30486. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30487. private _drawMode;
  30488. /** @hidden */
  30489. protected _reportDrawCall(): void;
  30490. /** @hidden */
  30491. _releaseEffect(effect: Effect): void;
  30492. /** @hidden */
  30493. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30494. /**
  30495. * Create a new effect (used to store vertex/fragment shaders)
  30496. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30497. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30498. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30499. * @param samplers defines an array of string used to represent textures
  30500. * @param defines defines the string containing the defines to use to compile the shaders
  30501. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30502. * @param onCompiled defines a function to call when the effect creation is successful
  30503. * @param onError defines a function to call when the effect creation has failed
  30504. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30505. * @returns the new Effect
  30506. */
  30507. 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;
  30508. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30509. private _compileShader;
  30510. private _compileRawShader;
  30511. /**
  30512. * Directly creates a webGL program
  30513. * @param pipelineContext defines the pipeline context to attach to
  30514. * @param vertexCode defines the vertex shader code to use
  30515. * @param fragmentCode defines the fragment shader code to use
  30516. * @param context defines the webGL context to use (if not set, the current one will be used)
  30517. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30518. * @returns the new webGL program
  30519. */
  30520. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30521. /**
  30522. * Creates a webGL program
  30523. * @param pipelineContext defines the pipeline context to attach to
  30524. * @param vertexCode defines the vertex shader code to use
  30525. * @param fragmentCode defines the fragment shader code to use
  30526. * @param defines defines the string containing the defines to use to compile the shaders
  30527. * @param context defines the webGL context to use (if not set, the current one will be used)
  30528. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30529. * @returns the new webGL program
  30530. */
  30531. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30532. /**
  30533. * Creates a new pipeline context
  30534. * @returns the new pipeline
  30535. */
  30536. createPipelineContext(): IPipelineContext;
  30537. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30538. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30539. /** @hidden */
  30540. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30541. /** @hidden */
  30542. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30543. /** @hidden */
  30544. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30545. /**
  30546. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30547. * @param pipelineContext defines the pipeline context to use
  30548. * @param uniformsNames defines the list of uniform names
  30549. * @returns an array of webGL uniform locations
  30550. */
  30551. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30552. /**
  30553. * Gets the lsit of active attributes for a given webGL program
  30554. * @param pipelineContext defines the pipeline context to use
  30555. * @param attributesNames defines the list of attribute names to get
  30556. * @returns an array of indices indicating the offset of each attribute
  30557. */
  30558. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30559. /**
  30560. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30561. * @param effect defines the effect to activate
  30562. */
  30563. enableEffect(effect: Nullable<Effect>): void;
  30564. /**
  30565. * Set the value of an uniform to a number (int)
  30566. * @param uniform defines the webGL uniform location where to store the value
  30567. * @param value defines the int number to store
  30568. */
  30569. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30570. /**
  30571. * Set the value of an uniform to an array of int32
  30572. * @param uniform defines the webGL uniform location where to store the value
  30573. * @param array defines the array of int32 to store
  30574. */
  30575. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30576. /**
  30577. * Set the value of an uniform to an array of int32 (stored as vec2)
  30578. * @param uniform defines the webGL uniform location where to store the value
  30579. * @param array defines the array of int32 to store
  30580. */
  30581. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30582. /**
  30583. * Set the value of an uniform to an array of int32 (stored as vec3)
  30584. * @param uniform defines the webGL uniform location where to store the value
  30585. * @param array defines the array of int32 to store
  30586. */
  30587. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30588. /**
  30589. * Set the value of an uniform to an array of int32 (stored as vec4)
  30590. * @param uniform defines the webGL uniform location where to store the value
  30591. * @param array defines the array of int32 to store
  30592. */
  30593. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30594. /**
  30595. * Set the value of an uniform to an array of number
  30596. * @param uniform defines the webGL uniform location where to store the value
  30597. * @param array defines the array of number to store
  30598. */
  30599. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30600. /**
  30601. * Set the value of an uniform to an array of number (stored as vec2)
  30602. * @param uniform defines the webGL uniform location where to store the value
  30603. * @param array defines the array of number to store
  30604. */
  30605. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30606. /**
  30607. * Set the value of an uniform to an array of number (stored as vec3)
  30608. * @param uniform defines the webGL uniform location where to store the value
  30609. * @param array defines the array of number to store
  30610. */
  30611. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30612. /**
  30613. * Set the value of an uniform to an array of number (stored as vec4)
  30614. * @param uniform defines the webGL uniform location where to store the value
  30615. * @param array defines the array of number to store
  30616. */
  30617. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30618. /**
  30619. * Set the value of an uniform to an array of float32 (stored as matrices)
  30620. * @param uniform defines the webGL uniform location where to store the value
  30621. * @param matrices defines the array of float32 to store
  30622. */
  30623. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30624. /**
  30625. * Set the value of an uniform to a matrix (3x3)
  30626. * @param uniform defines the webGL uniform location where to store the value
  30627. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30628. */
  30629. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30630. /**
  30631. * Set the value of an uniform to a matrix (2x2)
  30632. * @param uniform defines the webGL uniform location where to store the value
  30633. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30634. */
  30635. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30636. /**
  30637. * Set the value of an uniform to a number (float)
  30638. * @param uniform defines the webGL uniform location where to store the value
  30639. * @param value defines the float number to store
  30640. */
  30641. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30642. /**
  30643. * Set the value of an uniform to a vec2
  30644. * @param uniform defines the webGL uniform location where to store the value
  30645. * @param x defines the 1st component of the value
  30646. * @param y defines the 2nd component of the value
  30647. */
  30648. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30649. /**
  30650. * Set the value of an uniform to a vec3
  30651. * @param uniform defines the webGL uniform location where to store the value
  30652. * @param x defines the 1st component of the value
  30653. * @param y defines the 2nd component of the value
  30654. * @param z defines the 3rd component of the value
  30655. */
  30656. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30657. /**
  30658. * Set the value of an uniform to a vec4
  30659. * @param uniform defines the webGL uniform location where to store the value
  30660. * @param x defines the 1st component of the value
  30661. * @param y defines the 2nd component of the value
  30662. * @param z defines the 3rd component of the value
  30663. * @param w defines the 4th component of the value
  30664. */
  30665. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30666. /**
  30667. * Gets the depth culling state manager
  30668. */
  30669. readonly depthCullingState: DepthCullingState;
  30670. /**
  30671. * Gets the alpha state manager
  30672. */
  30673. readonly alphaState: AlphaState;
  30674. /**
  30675. * Gets the stencil state manager
  30676. */
  30677. readonly stencilState: StencilState;
  30678. /**
  30679. * Clears the list of texture accessible through engine.
  30680. * This can help preventing texture load conflict due to name collision.
  30681. */
  30682. clearInternalTexturesCache(): void;
  30683. /**
  30684. * Force the entire cache to be cleared
  30685. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30686. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30687. */
  30688. wipeCaches(bruteForce?: boolean): void;
  30689. /** @hidden */
  30690. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30691. min: number;
  30692. mag: number;
  30693. };
  30694. /** @hidden */
  30695. _createTexture(): WebGLTexture;
  30696. /**
  30697. * Usually called from Texture.ts.
  30698. * Passed information to create a WebGLTexture
  30699. * @param urlArg defines a value which contains one of the following:
  30700. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30701. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30702. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30703. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30704. * @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)
  30705. * @param scene needed for loading to the correct scene
  30706. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30707. * @param onLoad optional callback to be called upon successful completion
  30708. * @param onError optional callback to be called upon failure
  30709. * @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
  30710. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30711. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30712. * @param forcedExtension defines the extension to use to pick the right loader
  30713. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30714. * @param mimeType defines an optional mime type
  30715. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30716. */
  30717. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30718. /**
  30719. * @hidden
  30720. */
  30721. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30722. /**
  30723. * Creates a raw texture
  30724. * @param data defines the data to store in the texture
  30725. * @param width defines the width of the texture
  30726. * @param height defines the height of the texture
  30727. * @param format defines the format of the data
  30728. * @param generateMipMaps defines if the engine should generate the mip levels
  30729. * @param invertY defines if data must be stored with Y axis inverted
  30730. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30731. * @param compression defines the compression used (null by default)
  30732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30733. * @returns the raw texture inside an InternalTexture
  30734. */
  30735. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30736. /**
  30737. * Creates a new raw cube texture
  30738. * @param data defines the array of data to use to create each face
  30739. * @param size defines the size of the textures
  30740. * @param format defines the format of the data
  30741. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30742. * @param generateMipMaps defines if the engine should generate the mip levels
  30743. * @param invertY defines if data must be stored with Y axis inverted
  30744. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30745. * @param compression defines the compression used (null by default)
  30746. * @returns the cube texture as an InternalTexture
  30747. */
  30748. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30749. /**
  30750. * Creates a new raw 3D texture
  30751. * @param data defines the data used to create the texture
  30752. * @param width defines the width of the texture
  30753. * @param height defines the height of the texture
  30754. * @param depth defines the depth of the texture
  30755. * @param format defines the format of the texture
  30756. * @param generateMipMaps defines if the engine must generate mip levels
  30757. * @param invertY defines if data must be stored with Y axis inverted
  30758. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30759. * @param compression defines the compressed used (can be null)
  30760. * @param textureType defines the compressed used (can be null)
  30761. * @returns a new raw 3D texture (stored in an InternalTexture)
  30762. */
  30763. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30764. private _unpackFlipYCached;
  30765. /**
  30766. * In case you are sharing the context with other applications, it might
  30767. * be interested to not cache the unpack flip y state to ensure a consistent
  30768. * value would be set.
  30769. */
  30770. enableUnpackFlipYCached: boolean;
  30771. /** @hidden */
  30772. _unpackFlipY(value: boolean): void;
  30773. /** @hidden */
  30774. _getUnpackAlignement(): number;
  30775. /**
  30776. * Update the sampling mode of a given texture
  30777. * @param samplingMode defines the required sampling mode
  30778. * @param texture defines the texture to update
  30779. */
  30780. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30781. /** @hidden */
  30782. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30783. width: number;
  30784. height: number;
  30785. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30786. /** @hidden */
  30787. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30788. /** @hidden */
  30789. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30790. /** @hidden */
  30791. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30792. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30793. private _prepareWebGLTexture;
  30794. /** @hidden */
  30795. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30796. /** @hidden */
  30797. _releaseFramebufferObjects(texture: InternalTexture): void;
  30798. /** @hidden */
  30799. _releaseTexture(texture: InternalTexture): void;
  30800. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30801. protected _setProgram(program: WebGLProgram): void;
  30802. protected _boundUniforms: {
  30803. [key: number]: WebGLUniformLocation;
  30804. };
  30805. /**
  30806. * Binds an effect to the webGL context
  30807. * @param effect defines the effect to bind
  30808. */
  30809. bindSamplers(effect: Effect): void;
  30810. private _activateCurrentTexture;
  30811. /** @hidden */
  30812. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30813. /** @hidden */
  30814. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30815. /**
  30816. * Unbind all textures from the webGL context
  30817. */
  30818. unbindAllTextures(): void;
  30819. /**
  30820. * Sets a texture to the according uniform.
  30821. * @param channel The texture channel
  30822. * @param uniform The uniform to set
  30823. * @param texture The texture to apply
  30824. */
  30825. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30826. private _bindSamplerUniformToChannel;
  30827. private _getTextureWrapMode;
  30828. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30829. /**
  30830. * Sets an array of texture to the webGL context
  30831. * @param channel defines the channel where the texture array must be set
  30832. * @param uniform defines the associated uniform location
  30833. * @param textures defines the array of textures to bind
  30834. */
  30835. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30836. /** @hidden */
  30837. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30838. private _setTextureParameterFloat;
  30839. private _setTextureParameterInteger;
  30840. /**
  30841. * Unbind all vertex attributes from the webGL context
  30842. */
  30843. unbindAllAttributes(): void;
  30844. /**
  30845. * 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
  30846. */
  30847. releaseEffects(): void;
  30848. /**
  30849. * Dispose and release all associated resources
  30850. */
  30851. dispose(): void;
  30852. /**
  30853. * Attach a new callback raised when context lost event is fired
  30854. * @param callback defines the callback to call
  30855. */
  30856. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30857. /**
  30858. * Attach a new callback raised when context restored event is fired
  30859. * @param callback defines the callback to call
  30860. */
  30861. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30862. /**
  30863. * Get the current error code of the webGL context
  30864. * @returns the error code
  30865. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30866. */
  30867. getError(): number;
  30868. private _canRenderToFloatFramebuffer;
  30869. private _canRenderToHalfFloatFramebuffer;
  30870. private _canRenderToFramebuffer;
  30871. /** @hidden */
  30872. _getWebGLTextureType(type: number): number;
  30873. /** @hidden */
  30874. _getInternalFormat(format: number): number;
  30875. /** @hidden */
  30876. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30877. /** @hidden */
  30878. _getRGBAMultiSampleBufferFormat(type: number): number;
  30879. /** @hidden */
  30880. _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;
  30881. /**
  30882. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30883. * @returns true if the engine can be created
  30884. * @ignorenaming
  30885. */
  30886. static isSupported(): boolean;
  30887. /**
  30888. * Find the next highest power of two.
  30889. * @param x Number to start search from.
  30890. * @return Next highest power of two.
  30891. */
  30892. static CeilingPOT(x: number): number;
  30893. /**
  30894. * Find the next lowest power of two.
  30895. * @param x Number to start search from.
  30896. * @return Next lowest power of two.
  30897. */
  30898. static FloorPOT(x: number): number;
  30899. /**
  30900. * Find the nearest power of two.
  30901. * @param x Number to start search from.
  30902. * @return Next nearest power of two.
  30903. */
  30904. static NearestPOT(x: number): number;
  30905. /**
  30906. * Get the closest exponent of two
  30907. * @param value defines the value to approximate
  30908. * @param max defines the maximum value to return
  30909. * @param mode defines how to define the closest value
  30910. * @returns closest exponent of two of the given value
  30911. */
  30912. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30913. /**
  30914. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30915. * @param func - the function to be called
  30916. * @param requester - the object that will request the next frame. Falls back to window.
  30917. * @returns frame number
  30918. */
  30919. static QueueNewFrame(func: () => void, requester?: any): number;
  30920. }
  30921. }
  30922. declare module "babylonjs/Maths/sphericalPolynomial" {
  30923. import { Vector3 } from "babylonjs/Maths/math.vector";
  30924. import { Color3 } from "babylonjs/Maths/math.color";
  30925. /**
  30926. * Class representing spherical harmonics coefficients to the 3rd degree
  30927. */
  30928. export class SphericalHarmonics {
  30929. /**
  30930. * Defines whether or not the harmonics have been prescaled for rendering.
  30931. */
  30932. preScaled: boolean;
  30933. /**
  30934. * The l0,0 coefficients of the spherical harmonics
  30935. */
  30936. l00: Vector3;
  30937. /**
  30938. * The l1,-1 coefficients of the spherical harmonics
  30939. */
  30940. l1_1: Vector3;
  30941. /**
  30942. * The l1,0 coefficients of the spherical harmonics
  30943. */
  30944. l10: Vector3;
  30945. /**
  30946. * The l1,1 coefficients of the spherical harmonics
  30947. */
  30948. l11: Vector3;
  30949. /**
  30950. * The l2,-2 coefficients of the spherical harmonics
  30951. */
  30952. l2_2: Vector3;
  30953. /**
  30954. * The l2,-1 coefficients of the spherical harmonics
  30955. */
  30956. l2_1: Vector3;
  30957. /**
  30958. * The l2,0 coefficients of the spherical harmonics
  30959. */
  30960. l20: Vector3;
  30961. /**
  30962. * The l2,1 coefficients of the spherical harmonics
  30963. */
  30964. l21: Vector3;
  30965. /**
  30966. * The l2,2 coefficients of the spherical harmonics
  30967. */
  30968. l22: Vector3;
  30969. /**
  30970. * Adds a light to the spherical harmonics
  30971. * @param direction the direction of the light
  30972. * @param color the color of the light
  30973. * @param deltaSolidAngle the delta solid angle of the light
  30974. */
  30975. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30976. /**
  30977. * Scales the spherical harmonics by the given amount
  30978. * @param scale the amount to scale
  30979. */
  30980. scaleInPlace(scale: number): void;
  30981. /**
  30982. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30983. *
  30984. * ```
  30985. * E_lm = A_l * L_lm
  30986. * ```
  30987. *
  30988. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30989. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30990. * the scaling factors are given in equation 9.
  30991. */
  30992. convertIncidentRadianceToIrradiance(): void;
  30993. /**
  30994. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30995. *
  30996. * ```
  30997. * L = (1/pi) * E * rho
  30998. * ```
  30999. *
  31000. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31001. */
  31002. convertIrradianceToLambertianRadiance(): void;
  31003. /**
  31004. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31005. * required operations at run time.
  31006. *
  31007. * This is simply done by scaling back the SH with Ylm constants parameter.
  31008. * The trigonometric part being applied by the shader at run time.
  31009. */
  31010. preScaleForRendering(): void;
  31011. /**
  31012. * Constructs a spherical harmonics from an array.
  31013. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31014. * @returns the spherical harmonics
  31015. */
  31016. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31017. /**
  31018. * Gets the spherical harmonics from polynomial
  31019. * @param polynomial the spherical polynomial
  31020. * @returns the spherical harmonics
  31021. */
  31022. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31023. }
  31024. /**
  31025. * Class representing spherical polynomial coefficients to the 3rd degree
  31026. */
  31027. export class SphericalPolynomial {
  31028. private _harmonics;
  31029. /**
  31030. * The spherical harmonics used to create the polynomials.
  31031. */
  31032. readonly preScaledHarmonics: SphericalHarmonics;
  31033. /**
  31034. * The x coefficients of the spherical polynomial
  31035. */
  31036. x: Vector3;
  31037. /**
  31038. * The y coefficients of the spherical polynomial
  31039. */
  31040. y: Vector3;
  31041. /**
  31042. * The z coefficients of the spherical polynomial
  31043. */
  31044. z: Vector3;
  31045. /**
  31046. * The xx coefficients of the spherical polynomial
  31047. */
  31048. xx: Vector3;
  31049. /**
  31050. * The yy coefficients of the spherical polynomial
  31051. */
  31052. yy: Vector3;
  31053. /**
  31054. * The zz coefficients of the spherical polynomial
  31055. */
  31056. zz: Vector3;
  31057. /**
  31058. * The xy coefficients of the spherical polynomial
  31059. */
  31060. xy: Vector3;
  31061. /**
  31062. * The yz coefficients of the spherical polynomial
  31063. */
  31064. yz: Vector3;
  31065. /**
  31066. * The zx coefficients of the spherical polynomial
  31067. */
  31068. zx: Vector3;
  31069. /**
  31070. * Adds an ambient color to the spherical polynomial
  31071. * @param color the color to add
  31072. */
  31073. addAmbient(color: Color3): void;
  31074. /**
  31075. * Scales the spherical polynomial by the given amount
  31076. * @param scale the amount to scale
  31077. */
  31078. scaleInPlace(scale: number): void;
  31079. /**
  31080. * Gets the spherical polynomial from harmonics
  31081. * @param harmonics the spherical harmonics
  31082. * @returns the spherical polynomial
  31083. */
  31084. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31085. /**
  31086. * Constructs a spherical polynomial from an array.
  31087. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31088. * @returns the spherical polynomial
  31089. */
  31090. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31091. }
  31092. }
  31093. declare module "babylonjs/Materials/Textures/internalTexture" {
  31094. import { Observable } from "babylonjs/Misc/observable";
  31095. import { Nullable, int } from "babylonjs/types";
  31096. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31098. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31099. /**
  31100. * Defines the source of the internal texture
  31101. */
  31102. export enum InternalTextureSource {
  31103. /**
  31104. * The source of the texture data is unknown
  31105. */
  31106. Unknown = 0,
  31107. /**
  31108. * Texture data comes from an URL
  31109. */
  31110. Url = 1,
  31111. /**
  31112. * Texture data is only used for temporary storage
  31113. */
  31114. Temp = 2,
  31115. /**
  31116. * Texture data comes from raw data (ArrayBuffer)
  31117. */
  31118. Raw = 3,
  31119. /**
  31120. * Texture content is dynamic (video or dynamic texture)
  31121. */
  31122. Dynamic = 4,
  31123. /**
  31124. * Texture content is generated by rendering to it
  31125. */
  31126. RenderTarget = 5,
  31127. /**
  31128. * Texture content is part of a multi render target process
  31129. */
  31130. MultiRenderTarget = 6,
  31131. /**
  31132. * Texture data comes from a cube data file
  31133. */
  31134. Cube = 7,
  31135. /**
  31136. * Texture data comes from a raw cube data
  31137. */
  31138. CubeRaw = 8,
  31139. /**
  31140. * Texture data come from a prefiltered cube data file
  31141. */
  31142. CubePrefiltered = 9,
  31143. /**
  31144. * Texture content is raw 3D data
  31145. */
  31146. Raw3D = 10,
  31147. /**
  31148. * Texture content is a depth texture
  31149. */
  31150. Depth = 11,
  31151. /**
  31152. * Texture data comes from a raw cube data encoded with RGBD
  31153. */
  31154. CubeRawRGBD = 12
  31155. }
  31156. /**
  31157. * Class used to store data associated with WebGL texture data for the engine
  31158. * This class should not be used directly
  31159. */
  31160. export class InternalTexture {
  31161. /** @hidden */
  31162. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31163. /**
  31164. * Defines if the texture is ready
  31165. */
  31166. isReady: boolean;
  31167. /**
  31168. * Defines if the texture is a cube texture
  31169. */
  31170. isCube: boolean;
  31171. /**
  31172. * Defines if the texture contains 3D data
  31173. */
  31174. is3D: boolean;
  31175. /**
  31176. * Defines if the texture contains multiview data
  31177. */
  31178. isMultiview: boolean;
  31179. /**
  31180. * Gets the URL used to load this texture
  31181. */
  31182. url: string;
  31183. /**
  31184. * Gets the sampling mode of the texture
  31185. */
  31186. samplingMode: number;
  31187. /**
  31188. * Gets a boolean indicating if the texture needs mipmaps generation
  31189. */
  31190. generateMipMaps: boolean;
  31191. /**
  31192. * Gets the number of samples used by the texture (WebGL2+ only)
  31193. */
  31194. samples: number;
  31195. /**
  31196. * Gets the type of the texture (int, float...)
  31197. */
  31198. type: number;
  31199. /**
  31200. * Gets the format of the texture (RGB, RGBA...)
  31201. */
  31202. format: number;
  31203. /**
  31204. * Observable called when the texture is loaded
  31205. */
  31206. onLoadedObservable: Observable<InternalTexture>;
  31207. /**
  31208. * Gets the width of the texture
  31209. */
  31210. width: number;
  31211. /**
  31212. * Gets the height of the texture
  31213. */
  31214. height: number;
  31215. /**
  31216. * Gets the depth of the texture
  31217. */
  31218. depth: number;
  31219. /**
  31220. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31221. */
  31222. baseWidth: number;
  31223. /**
  31224. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31225. */
  31226. baseHeight: number;
  31227. /**
  31228. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31229. */
  31230. baseDepth: number;
  31231. /**
  31232. * Gets a boolean indicating if the texture is inverted on Y axis
  31233. */
  31234. invertY: boolean;
  31235. /** @hidden */
  31236. _invertVScale: boolean;
  31237. /** @hidden */
  31238. _associatedChannel: number;
  31239. /** @hidden */
  31240. _source: InternalTextureSource;
  31241. /** @hidden */
  31242. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31243. /** @hidden */
  31244. _bufferView: Nullable<ArrayBufferView>;
  31245. /** @hidden */
  31246. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31247. /** @hidden */
  31248. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31249. /** @hidden */
  31250. _size: number;
  31251. /** @hidden */
  31252. _extension: string;
  31253. /** @hidden */
  31254. _files: Nullable<string[]>;
  31255. /** @hidden */
  31256. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31257. /** @hidden */
  31258. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31259. /** @hidden */
  31260. _framebuffer: Nullable<WebGLFramebuffer>;
  31261. /** @hidden */
  31262. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31263. /** @hidden */
  31264. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31265. /** @hidden */
  31266. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31267. /** @hidden */
  31268. _attachments: Nullable<number[]>;
  31269. /** @hidden */
  31270. _cachedCoordinatesMode: Nullable<number>;
  31271. /** @hidden */
  31272. _cachedWrapU: Nullable<number>;
  31273. /** @hidden */
  31274. _cachedWrapV: Nullable<number>;
  31275. /** @hidden */
  31276. _cachedWrapR: Nullable<number>;
  31277. /** @hidden */
  31278. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31279. /** @hidden */
  31280. _isDisabled: boolean;
  31281. /** @hidden */
  31282. _compression: Nullable<string>;
  31283. /** @hidden */
  31284. _generateStencilBuffer: boolean;
  31285. /** @hidden */
  31286. _generateDepthBuffer: boolean;
  31287. /** @hidden */
  31288. _comparisonFunction: number;
  31289. /** @hidden */
  31290. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31291. /** @hidden */
  31292. _lodGenerationScale: number;
  31293. /** @hidden */
  31294. _lodGenerationOffset: number;
  31295. /** @hidden */
  31296. _colorTextureArray: Nullable<WebGLTexture>;
  31297. /** @hidden */
  31298. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31299. /** @hidden */
  31300. _lodTextureHigh: Nullable<BaseTexture>;
  31301. /** @hidden */
  31302. _lodTextureMid: Nullable<BaseTexture>;
  31303. /** @hidden */
  31304. _lodTextureLow: Nullable<BaseTexture>;
  31305. /** @hidden */
  31306. _isRGBD: boolean;
  31307. /** @hidden */
  31308. _linearSpecularLOD: boolean;
  31309. /** @hidden */
  31310. _irradianceTexture: Nullable<BaseTexture>;
  31311. /** @hidden */
  31312. _webGLTexture: Nullable<WebGLTexture>;
  31313. /** @hidden */
  31314. _references: number;
  31315. private _engine;
  31316. /**
  31317. * Gets the Engine the texture belongs to.
  31318. * @returns The babylon engine
  31319. */
  31320. getEngine(): ThinEngine;
  31321. /**
  31322. * Gets the data source type of the texture
  31323. */
  31324. readonly source: InternalTextureSource;
  31325. /**
  31326. * Creates a new InternalTexture
  31327. * @param engine defines the engine to use
  31328. * @param source defines the type of data that will be used
  31329. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31330. */
  31331. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31332. /**
  31333. * Increments the number of references (ie. the number of Texture that point to it)
  31334. */
  31335. incrementReferences(): void;
  31336. /**
  31337. * Change the size of the texture (not the size of the content)
  31338. * @param width defines the new width
  31339. * @param height defines the new height
  31340. * @param depth defines the new depth (1 by default)
  31341. */
  31342. updateSize(width: int, height: int, depth?: int): void;
  31343. /** @hidden */
  31344. _rebuild(): void;
  31345. /** @hidden */
  31346. _swapAndDie(target: InternalTexture): void;
  31347. /**
  31348. * Dispose the current allocated resources
  31349. */
  31350. dispose(): void;
  31351. }
  31352. }
  31353. declare module "babylonjs/Audio/analyser" {
  31354. import { Scene } from "babylonjs/scene";
  31355. /**
  31356. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31358. */
  31359. export class Analyser {
  31360. /**
  31361. * Gets or sets the smoothing
  31362. * @ignorenaming
  31363. */
  31364. SMOOTHING: number;
  31365. /**
  31366. * Gets or sets the FFT table size
  31367. * @ignorenaming
  31368. */
  31369. FFT_SIZE: number;
  31370. /**
  31371. * Gets or sets the bar graph amplitude
  31372. * @ignorenaming
  31373. */
  31374. BARGRAPHAMPLITUDE: number;
  31375. /**
  31376. * Gets or sets the position of the debug canvas
  31377. * @ignorenaming
  31378. */
  31379. DEBUGCANVASPOS: {
  31380. x: number;
  31381. y: number;
  31382. };
  31383. /**
  31384. * Gets or sets the debug canvas size
  31385. * @ignorenaming
  31386. */
  31387. DEBUGCANVASSIZE: {
  31388. width: number;
  31389. height: number;
  31390. };
  31391. private _byteFreqs;
  31392. private _byteTime;
  31393. private _floatFreqs;
  31394. private _webAudioAnalyser;
  31395. private _debugCanvas;
  31396. private _debugCanvasContext;
  31397. private _scene;
  31398. private _registerFunc;
  31399. private _audioEngine;
  31400. /**
  31401. * Creates a new analyser
  31402. * @param scene defines hosting scene
  31403. */
  31404. constructor(scene: Scene);
  31405. /**
  31406. * Get the number of data values you will have to play with for the visualization
  31407. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31408. * @returns a number
  31409. */
  31410. getFrequencyBinCount(): number;
  31411. /**
  31412. * Gets the current frequency data as a byte array
  31413. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31414. * @returns a Uint8Array
  31415. */
  31416. getByteFrequencyData(): Uint8Array;
  31417. /**
  31418. * Gets the current waveform as a byte array
  31419. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31420. * @returns a Uint8Array
  31421. */
  31422. getByteTimeDomainData(): Uint8Array;
  31423. /**
  31424. * Gets the current frequency data as a float array
  31425. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31426. * @returns a Float32Array
  31427. */
  31428. getFloatFrequencyData(): Float32Array;
  31429. /**
  31430. * Renders the debug canvas
  31431. */
  31432. drawDebugCanvas(): void;
  31433. /**
  31434. * Stops rendering the debug canvas and removes it
  31435. */
  31436. stopDebugCanvas(): void;
  31437. /**
  31438. * Connects two audio nodes
  31439. * @param inputAudioNode defines first node to connect
  31440. * @param outputAudioNode defines second node to connect
  31441. */
  31442. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31443. /**
  31444. * Releases all associated resources
  31445. */
  31446. dispose(): void;
  31447. }
  31448. }
  31449. declare module "babylonjs/Audio/audioEngine" {
  31450. import { IDisposable } from "babylonjs/scene";
  31451. import { Analyser } from "babylonjs/Audio/analyser";
  31452. import { Nullable } from "babylonjs/types";
  31453. import { Observable } from "babylonjs/Misc/observable";
  31454. /**
  31455. * This represents an audio engine and it is responsible
  31456. * to play, synchronize and analyse sounds throughout the application.
  31457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31458. */
  31459. export interface IAudioEngine extends IDisposable {
  31460. /**
  31461. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31462. */
  31463. readonly canUseWebAudio: boolean;
  31464. /**
  31465. * Gets the current AudioContext if available.
  31466. */
  31467. readonly audioContext: Nullable<AudioContext>;
  31468. /**
  31469. * The master gain node defines the global audio volume of your audio engine.
  31470. */
  31471. readonly masterGain: GainNode;
  31472. /**
  31473. * Gets whether or not mp3 are supported by your browser.
  31474. */
  31475. readonly isMP3supported: boolean;
  31476. /**
  31477. * Gets whether or not ogg are supported by your browser.
  31478. */
  31479. readonly isOGGsupported: boolean;
  31480. /**
  31481. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31482. * @ignoreNaming
  31483. */
  31484. WarnedWebAudioUnsupported: boolean;
  31485. /**
  31486. * Defines if the audio engine relies on a custom unlocked button.
  31487. * In this case, the embedded button will not be displayed.
  31488. */
  31489. useCustomUnlockedButton: boolean;
  31490. /**
  31491. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31492. */
  31493. readonly unlocked: boolean;
  31494. /**
  31495. * Event raised when audio has been unlocked on the browser.
  31496. */
  31497. onAudioUnlockedObservable: Observable<AudioEngine>;
  31498. /**
  31499. * Event raised when audio has been locked on the browser.
  31500. */
  31501. onAudioLockedObservable: Observable<AudioEngine>;
  31502. /**
  31503. * Flags the audio engine in Locked state.
  31504. * This happens due to new browser policies preventing audio to autoplay.
  31505. */
  31506. lock(): void;
  31507. /**
  31508. * Unlocks the audio engine once a user action has been done on the dom.
  31509. * This is helpful to resume play once browser policies have been satisfied.
  31510. */
  31511. unlock(): void;
  31512. }
  31513. /**
  31514. * This represents the default audio engine used in babylon.
  31515. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31517. */
  31518. export class AudioEngine implements IAudioEngine {
  31519. private _audioContext;
  31520. private _audioContextInitialized;
  31521. private _muteButton;
  31522. private _hostElement;
  31523. /**
  31524. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31525. */
  31526. canUseWebAudio: boolean;
  31527. /**
  31528. * The master gain node defines the global audio volume of your audio engine.
  31529. */
  31530. masterGain: GainNode;
  31531. /**
  31532. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31533. * @ignoreNaming
  31534. */
  31535. WarnedWebAudioUnsupported: boolean;
  31536. /**
  31537. * Gets whether or not mp3 are supported by your browser.
  31538. */
  31539. isMP3supported: boolean;
  31540. /**
  31541. * Gets whether or not ogg are supported by your browser.
  31542. */
  31543. isOGGsupported: boolean;
  31544. /**
  31545. * Gets whether audio has been unlocked on the device.
  31546. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31547. * a user interaction has happened.
  31548. */
  31549. unlocked: boolean;
  31550. /**
  31551. * Defines if the audio engine relies on a custom unlocked button.
  31552. * In this case, the embedded button will not be displayed.
  31553. */
  31554. useCustomUnlockedButton: boolean;
  31555. /**
  31556. * Event raised when audio has been unlocked on the browser.
  31557. */
  31558. onAudioUnlockedObservable: Observable<AudioEngine>;
  31559. /**
  31560. * Event raised when audio has been locked on the browser.
  31561. */
  31562. onAudioLockedObservable: Observable<AudioEngine>;
  31563. /**
  31564. * Gets the current AudioContext if available.
  31565. */
  31566. readonly audioContext: Nullable<AudioContext>;
  31567. private _connectedAnalyser;
  31568. /**
  31569. * Instantiates a new audio engine.
  31570. *
  31571. * There should be only one per page as some browsers restrict the number
  31572. * of audio contexts you can create.
  31573. * @param hostElement defines the host element where to display the mute icon if necessary
  31574. */
  31575. constructor(hostElement?: Nullable<HTMLElement>);
  31576. /**
  31577. * Flags the audio engine in Locked state.
  31578. * This happens due to new browser policies preventing audio to autoplay.
  31579. */
  31580. lock(): void;
  31581. /**
  31582. * Unlocks the audio engine once a user action has been done on the dom.
  31583. * This is helpful to resume play once browser policies have been satisfied.
  31584. */
  31585. unlock(): void;
  31586. private _resumeAudioContext;
  31587. private _initializeAudioContext;
  31588. private _tryToRun;
  31589. private _triggerRunningState;
  31590. private _triggerSuspendedState;
  31591. private _displayMuteButton;
  31592. private _moveButtonToTopLeft;
  31593. private _onResize;
  31594. private _hideMuteButton;
  31595. /**
  31596. * Destroy and release the resources associated with the audio ccontext.
  31597. */
  31598. dispose(): void;
  31599. /**
  31600. * Gets the global volume sets on the master gain.
  31601. * @returns the global volume if set or -1 otherwise
  31602. */
  31603. getGlobalVolume(): number;
  31604. /**
  31605. * Sets the global volume of your experience (sets on the master gain).
  31606. * @param newVolume Defines the new global volume of the application
  31607. */
  31608. setGlobalVolume(newVolume: number): void;
  31609. /**
  31610. * Connect the audio engine to an audio analyser allowing some amazing
  31611. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31613. * @param analyser The analyser to connect to the engine
  31614. */
  31615. connectToAnalyser(analyser: Analyser): void;
  31616. }
  31617. }
  31618. declare module "babylonjs/Loading/loadingScreen" {
  31619. /**
  31620. * Interface used to present a loading screen while loading a scene
  31621. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31622. */
  31623. export interface ILoadingScreen {
  31624. /**
  31625. * Function called to display the loading screen
  31626. */
  31627. displayLoadingUI: () => void;
  31628. /**
  31629. * Function called to hide the loading screen
  31630. */
  31631. hideLoadingUI: () => void;
  31632. /**
  31633. * Gets or sets the color to use for the background
  31634. */
  31635. loadingUIBackgroundColor: string;
  31636. /**
  31637. * Gets or sets the text to display while loading
  31638. */
  31639. loadingUIText: string;
  31640. }
  31641. /**
  31642. * Class used for the default loading screen
  31643. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31644. */
  31645. export class DefaultLoadingScreen implements ILoadingScreen {
  31646. private _renderingCanvas;
  31647. private _loadingText;
  31648. private _loadingDivBackgroundColor;
  31649. private _loadingDiv;
  31650. private _loadingTextDiv;
  31651. /** Gets or sets the logo url to use for the default loading screen */
  31652. static DefaultLogoUrl: string;
  31653. /** Gets or sets the spinner url to use for the default loading screen */
  31654. static DefaultSpinnerUrl: string;
  31655. /**
  31656. * Creates a new default loading screen
  31657. * @param _renderingCanvas defines the canvas used to render the scene
  31658. * @param _loadingText defines the default text to display
  31659. * @param _loadingDivBackgroundColor defines the default background color
  31660. */
  31661. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31662. /**
  31663. * Function called to display the loading screen
  31664. */
  31665. displayLoadingUI(): void;
  31666. /**
  31667. * Function called to hide the loading screen
  31668. */
  31669. hideLoadingUI(): void;
  31670. /**
  31671. * Gets or sets the text to display while loading
  31672. */
  31673. loadingUIText: string;
  31674. /**
  31675. * Gets or sets the color to use for the background
  31676. */
  31677. loadingUIBackgroundColor: string;
  31678. private _resizeLoadingUI;
  31679. }
  31680. }
  31681. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31682. /**
  31683. * Interface for any object that can request an animation frame
  31684. */
  31685. export interface ICustomAnimationFrameRequester {
  31686. /**
  31687. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31688. */
  31689. renderFunction?: Function;
  31690. /**
  31691. * Called to request the next frame to render to
  31692. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31693. */
  31694. requestAnimationFrame: Function;
  31695. /**
  31696. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31697. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31698. */
  31699. requestID?: number;
  31700. }
  31701. }
  31702. declare module "babylonjs/Misc/performanceMonitor" {
  31703. /**
  31704. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31705. */
  31706. export class PerformanceMonitor {
  31707. private _enabled;
  31708. private _rollingFrameTime;
  31709. private _lastFrameTimeMs;
  31710. /**
  31711. * constructor
  31712. * @param frameSampleSize The number of samples required to saturate the sliding window
  31713. */
  31714. constructor(frameSampleSize?: number);
  31715. /**
  31716. * Samples current frame
  31717. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31718. */
  31719. sampleFrame(timeMs?: number): void;
  31720. /**
  31721. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31722. */
  31723. readonly averageFrameTime: number;
  31724. /**
  31725. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31726. */
  31727. readonly averageFrameTimeVariance: number;
  31728. /**
  31729. * Returns the frame time of the most recent frame
  31730. */
  31731. readonly instantaneousFrameTime: number;
  31732. /**
  31733. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31734. */
  31735. readonly averageFPS: number;
  31736. /**
  31737. * Returns the average framerate in frames per second using the most recent frame time
  31738. */
  31739. readonly instantaneousFPS: number;
  31740. /**
  31741. * Returns true if enough samples have been taken to completely fill the sliding window
  31742. */
  31743. readonly isSaturated: boolean;
  31744. /**
  31745. * Enables contributions to the sliding window sample set
  31746. */
  31747. enable(): void;
  31748. /**
  31749. * Disables contributions to the sliding window sample set
  31750. * Samples will not be interpolated over the disabled period
  31751. */
  31752. disable(): void;
  31753. /**
  31754. * Returns true if sampling is enabled
  31755. */
  31756. readonly isEnabled: boolean;
  31757. /**
  31758. * Resets performance monitor
  31759. */
  31760. reset(): void;
  31761. }
  31762. /**
  31763. * RollingAverage
  31764. *
  31765. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31766. */
  31767. export class RollingAverage {
  31768. /**
  31769. * Current average
  31770. */
  31771. average: number;
  31772. /**
  31773. * Current variance
  31774. */
  31775. variance: number;
  31776. protected _samples: Array<number>;
  31777. protected _sampleCount: number;
  31778. protected _pos: number;
  31779. protected _m2: number;
  31780. /**
  31781. * constructor
  31782. * @param length The number of samples required to saturate the sliding window
  31783. */
  31784. constructor(length: number);
  31785. /**
  31786. * Adds a sample to the sample set
  31787. * @param v The sample value
  31788. */
  31789. add(v: number): void;
  31790. /**
  31791. * Returns previously added values or null if outside of history or outside the sliding window domain
  31792. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31793. * @return Value previously recorded with add() or null if outside of range
  31794. */
  31795. history(i: number): number;
  31796. /**
  31797. * Returns true if enough samples have been taken to completely fill the sliding window
  31798. * @return true if sample-set saturated
  31799. */
  31800. isSaturated(): boolean;
  31801. /**
  31802. * Resets the rolling average (equivalent to 0 samples taken so far)
  31803. */
  31804. reset(): void;
  31805. /**
  31806. * Wraps a value around the sample range boundaries
  31807. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31808. * @return Wrapped position in sample range
  31809. */
  31810. protected _wrapPosition(i: number): number;
  31811. }
  31812. }
  31813. declare module "babylonjs/Misc/perfCounter" {
  31814. /**
  31815. * This class is used to track a performance counter which is number based.
  31816. * The user has access to many properties which give statistics of different nature.
  31817. *
  31818. * The implementer can track two kinds of Performance Counter: time and count.
  31819. * 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.
  31820. * 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.
  31821. */
  31822. export class PerfCounter {
  31823. /**
  31824. * Gets or sets a global boolean to turn on and off all the counters
  31825. */
  31826. static Enabled: boolean;
  31827. /**
  31828. * Returns the smallest value ever
  31829. */
  31830. readonly min: number;
  31831. /**
  31832. * Returns the biggest value ever
  31833. */
  31834. readonly max: number;
  31835. /**
  31836. * Returns the average value since the performance counter is running
  31837. */
  31838. readonly average: number;
  31839. /**
  31840. * Returns the average value of the last second the counter was monitored
  31841. */
  31842. readonly lastSecAverage: number;
  31843. /**
  31844. * Returns the current value
  31845. */
  31846. readonly current: number;
  31847. /**
  31848. * Gets the accumulated total
  31849. */
  31850. readonly total: number;
  31851. /**
  31852. * Gets the total value count
  31853. */
  31854. readonly count: number;
  31855. /**
  31856. * Creates a new counter
  31857. */
  31858. constructor();
  31859. /**
  31860. * Call this method to start monitoring a new frame.
  31861. * 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.
  31862. */
  31863. fetchNewFrame(): void;
  31864. /**
  31865. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31866. * @param newCount the count value to add to the monitored count
  31867. * @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.
  31868. */
  31869. addCount(newCount: number, fetchResult: boolean): void;
  31870. /**
  31871. * Start monitoring this performance counter
  31872. */
  31873. beginMonitoring(): void;
  31874. /**
  31875. * Compute the time lapsed since the previous beginMonitoring() call.
  31876. * @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
  31877. */
  31878. endMonitoring(newFrame?: boolean): void;
  31879. private _fetchResult;
  31880. private _startMonitoringTime;
  31881. private _min;
  31882. private _max;
  31883. private _average;
  31884. private _current;
  31885. private _totalValueCount;
  31886. private _totalAccumulated;
  31887. private _lastSecAverage;
  31888. private _lastSecAccumulated;
  31889. private _lastSecTime;
  31890. private _lastSecValueCount;
  31891. }
  31892. }
  31893. declare module "babylonjs/Engines/engine" {
  31894. import { Observable } from "babylonjs/Misc/observable";
  31895. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  31896. import { Scene } from "babylonjs/scene";
  31897. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31898. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31899. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31900. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31901. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31902. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31903. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31904. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31905. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31907. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31908. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31909. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31910. import { Material } from "babylonjs/Materials/material";
  31911. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31912. /**
  31913. * Defines the interface used by display changed events
  31914. */
  31915. export interface IDisplayChangedEventArgs {
  31916. /** Gets the vrDisplay object (if any) */
  31917. vrDisplay: Nullable<any>;
  31918. /** Gets a boolean indicating if webVR is supported */
  31919. vrSupported: boolean;
  31920. }
  31921. /**
  31922. * Defines the interface used by objects containing a viewport (like a camera)
  31923. */
  31924. interface IViewportOwnerLike {
  31925. /**
  31926. * Gets or sets the viewport
  31927. */
  31928. viewport: IViewportLike;
  31929. }
  31930. /**
  31931. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31932. */
  31933. export class Engine extends ThinEngine {
  31934. /** Defines that alpha blending is disabled */
  31935. static readonly ALPHA_DISABLE: number;
  31936. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31937. static readonly ALPHA_ADD: number;
  31938. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31939. static readonly ALPHA_COMBINE: number;
  31940. /** Defines that alpha blending to DEST - SRC * DEST */
  31941. static readonly ALPHA_SUBTRACT: number;
  31942. /** Defines that alpha blending to SRC * DEST */
  31943. static readonly ALPHA_MULTIPLY: number;
  31944. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31945. static readonly ALPHA_MAXIMIZED: number;
  31946. /** Defines that alpha blending to SRC + DEST */
  31947. static readonly ALPHA_ONEONE: number;
  31948. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31949. static readonly ALPHA_PREMULTIPLIED: number;
  31950. /**
  31951. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31952. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31953. */
  31954. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31955. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31956. static readonly ALPHA_INTERPOLATE: number;
  31957. /**
  31958. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31959. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31960. */
  31961. static readonly ALPHA_SCREENMODE: number;
  31962. /** Defines that the ressource is not delayed*/
  31963. static readonly DELAYLOADSTATE_NONE: number;
  31964. /** Defines that the ressource was successfully delay loaded */
  31965. static readonly DELAYLOADSTATE_LOADED: number;
  31966. /** Defines that the ressource is currently delay loading */
  31967. static readonly DELAYLOADSTATE_LOADING: number;
  31968. /** Defines that the ressource is delayed and has not started loading */
  31969. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31970. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31971. static readonly NEVER: number;
  31972. /** 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 */
  31973. static readonly ALWAYS: number;
  31974. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31975. static readonly LESS: number;
  31976. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31977. static readonly EQUAL: number;
  31978. /** 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 */
  31979. static readonly LEQUAL: number;
  31980. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31981. static readonly GREATER: number;
  31982. /** 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 */
  31983. static readonly GEQUAL: number;
  31984. /** 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 */
  31985. static readonly NOTEQUAL: number;
  31986. /** Passed to stencilOperation to specify that stencil value must be kept */
  31987. static readonly KEEP: number;
  31988. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31989. static readonly REPLACE: number;
  31990. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31991. static readonly INCR: number;
  31992. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31993. static readonly DECR: number;
  31994. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31995. static readonly INVERT: number;
  31996. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31997. static readonly INCR_WRAP: number;
  31998. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31999. static readonly DECR_WRAP: number;
  32000. /** Texture is not repeating outside of 0..1 UVs */
  32001. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32002. /** Texture is repeating outside of 0..1 UVs */
  32003. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32004. /** Texture is repeating and mirrored */
  32005. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32006. /** ALPHA */
  32007. static readonly TEXTUREFORMAT_ALPHA: number;
  32008. /** LUMINANCE */
  32009. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32010. /** LUMINANCE_ALPHA */
  32011. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32012. /** RGB */
  32013. static readonly TEXTUREFORMAT_RGB: number;
  32014. /** RGBA */
  32015. static readonly TEXTUREFORMAT_RGBA: number;
  32016. /** RED */
  32017. static readonly TEXTUREFORMAT_RED: number;
  32018. /** RED (2nd reference) */
  32019. static readonly TEXTUREFORMAT_R: number;
  32020. /** RG */
  32021. static readonly TEXTUREFORMAT_RG: number;
  32022. /** RED_INTEGER */
  32023. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32024. /** RED_INTEGER (2nd reference) */
  32025. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32026. /** RG_INTEGER */
  32027. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32028. /** RGB_INTEGER */
  32029. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32030. /** RGBA_INTEGER */
  32031. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32032. /** UNSIGNED_BYTE */
  32033. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32034. /** UNSIGNED_BYTE (2nd reference) */
  32035. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32036. /** FLOAT */
  32037. static readonly TEXTURETYPE_FLOAT: number;
  32038. /** HALF_FLOAT */
  32039. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32040. /** BYTE */
  32041. static readonly TEXTURETYPE_BYTE: number;
  32042. /** SHORT */
  32043. static readonly TEXTURETYPE_SHORT: number;
  32044. /** UNSIGNED_SHORT */
  32045. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32046. /** INT */
  32047. static readonly TEXTURETYPE_INT: number;
  32048. /** UNSIGNED_INT */
  32049. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32050. /** UNSIGNED_SHORT_4_4_4_4 */
  32051. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32052. /** UNSIGNED_SHORT_5_5_5_1 */
  32053. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32054. /** UNSIGNED_SHORT_5_6_5 */
  32055. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32056. /** UNSIGNED_INT_2_10_10_10_REV */
  32057. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32058. /** UNSIGNED_INT_24_8 */
  32059. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32060. /** UNSIGNED_INT_10F_11F_11F_REV */
  32061. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32062. /** UNSIGNED_INT_5_9_9_9_REV */
  32063. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32064. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32065. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32066. /** nearest is mag = nearest and min = nearest and mip = linear */
  32067. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32068. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32069. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32070. /** Trilinear is mag = linear and min = linear and mip = linear */
  32071. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32072. /** nearest is mag = nearest and min = nearest and mip = linear */
  32073. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32074. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32075. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32076. /** Trilinear is mag = linear and min = linear and mip = linear */
  32077. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32078. /** mag = nearest and min = nearest and mip = nearest */
  32079. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32080. /** mag = nearest and min = linear and mip = nearest */
  32081. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32082. /** mag = nearest and min = linear and mip = linear */
  32083. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32084. /** mag = nearest and min = linear and mip = none */
  32085. static readonly TEXTURE_NEAREST_LINEAR: number;
  32086. /** mag = nearest and min = nearest and mip = none */
  32087. static readonly TEXTURE_NEAREST_NEAREST: number;
  32088. /** mag = linear and min = nearest and mip = nearest */
  32089. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32090. /** mag = linear and min = nearest and mip = linear */
  32091. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32092. /** mag = linear and min = linear and mip = none */
  32093. static readonly TEXTURE_LINEAR_LINEAR: number;
  32094. /** mag = linear and min = nearest and mip = none */
  32095. static readonly TEXTURE_LINEAR_NEAREST: number;
  32096. /** Explicit coordinates mode */
  32097. static readonly TEXTURE_EXPLICIT_MODE: number;
  32098. /** Spherical coordinates mode */
  32099. static readonly TEXTURE_SPHERICAL_MODE: number;
  32100. /** Planar coordinates mode */
  32101. static readonly TEXTURE_PLANAR_MODE: number;
  32102. /** Cubic coordinates mode */
  32103. static readonly TEXTURE_CUBIC_MODE: number;
  32104. /** Projection coordinates mode */
  32105. static readonly TEXTURE_PROJECTION_MODE: number;
  32106. /** Skybox coordinates mode */
  32107. static readonly TEXTURE_SKYBOX_MODE: number;
  32108. /** Inverse Cubic coordinates mode */
  32109. static readonly TEXTURE_INVCUBIC_MODE: number;
  32110. /** Equirectangular coordinates mode */
  32111. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32112. /** Equirectangular Fixed coordinates mode */
  32113. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32114. /** Equirectangular Fixed Mirrored coordinates mode */
  32115. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32116. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32117. static readonly SCALEMODE_FLOOR: number;
  32118. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32119. static readonly SCALEMODE_NEAREST: number;
  32120. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32121. static readonly SCALEMODE_CEILING: number;
  32122. /**
  32123. * Returns the current npm package of the sdk
  32124. */
  32125. static readonly NpmPackage: string;
  32126. /**
  32127. * Returns the current version of the framework
  32128. */
  32129. static readonly Version: string;
  32130. /** Gets the list of created engines */
  32131. static readonly Instances: Engine[];
  32132. /**
  32133. * Gets the latest created engine
  32134. */
  32135. static readonly LastCreatedEngine: Nullable<Engine>;
  32136. /**
  32137. * Gets the latest created scene
  32138. */
  32139. static readonly LastCreatedScene: Nullable<Scene>;
  32140. /**
  32141. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32142. * @param flag defines which part of the materials must be marked as dirty
  32143. * @param predicate defines a predicate used to filter which materials should be affected
  32144. */
  32145. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32146. /**
  32147. * Method called to create the default loading screen.
  32148. * This can be overriden in your own app.
  32149. * @param canvas The rendering canvas element
  32150. * @returns The loading screen
  32151. */
  32152. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32153. /**
  32154. * Method called to create the default rescale post process on each engine.
  32155. */
  32156. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32157. /**
  32158. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32159. **/
  32160. enableOfflineSupport: boolean;
  32161. /**
  32162. * 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)
  32163. **/
  32164. disableManifestCheck: boolean;
  32165. /**
  32166. * Gets the list of created scenes
  32167. */
  32168. scenes: Scene[];
  32169. /**
  32170. * Event raised when a new scene is created
  32171. */
  32172. onNewSceneAddedObservable: Observable<Scene>;
  32173. /**
  32174. * Gets the list of created postprocesses
  32175. */
  32176. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32177. /**
  32178. * Gets a boolean indicating if the pointer is currently locked
  32179. */
  32180. isPointerLock: boolean;
  32181. /**
  32182. * Observable event triggered each time the rendering canvas is resized
  32183. */
  32184. onResizeObservable: Observable<Engine>;
  32185. /**
  32186. * Observable event triggered each time the canvas loses focus
  32187. */
  32188. onCanvasBlurObservable: Observable<Engine>;
  32189. /**
  32190. * Observable event triggered each time the canvas gains focus
  32191. */
  32192. onCanvasFocusObservable: Observable<Engine>;
  32193. /**
  32194. * Observable event triggered each time the canvas receives pointerout event
  32195. */
  32196. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32197. /**
  32198. * Observable raised when the engine begins a new frame
  32199. */
  32200. onBeginFrameObservable: Observable<Engine>;
  32201. /**
  32202. * If set, will be used to request the next animation frame for the render loop
  32203. */
  32204. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32205. /**
  32206. * Observable raised when the engine ends the current frame
  32207. */
  32208. onEndFrameObservable: Observable<Engine>;
  32209. /**
  32210. * Observable raised when the engine is about to compile a shader
  32211. */
  32212. onBeforeShaderCompilationObservable: Observable<Engine>;
  32213. /**
  32214. * Observable raised when the engine has jsut compiled a shader
  32215. */
  32216. onAfterShaderCompilationObservable: Observable<Engine>;
  32217. /**
  32218. * Gets the audio engine
  32219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32220. * @ignorenaming
  32221. */
  32222. static audioEngine: IAudioEngine;
  32223. /**
  32224. * Default AudioEngine factory responsible of creating the Audio Engine.
  32225. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32226. */
  32227. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32228. /**
  32229. * Default offline support factory responsible of creating a tool used to store data locally.
  32230. * By default, this will create a Database object if the workload has been embedded.
  32231. */
  32232. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32233. private _loadingScreen;
  32234. private _pointerLockRequested;
  32235. private _dummyFramebuffer;
  32236. private _rescalePostProcess;
  32237. /** @hidden */
  32238. protected _alphaMode: number;
  32239. /** @hidden */
  32240. protected _alphaEquation: number;
  32241. private _deterministicLockstep;
  32242. private _lockstepMaxSteps;
  32243. protected readonly _supportsHardwareTextureRescaling: boolean;
  32244. private _fps;
  32245. private _deltaTime;
  32246. /** @hidden */
  32247. _drawCalls: PerfCounter;
  32248. /**
  32249. * Turn this value on if you want to pause FPS computation when in background
  32250. */
  32251. disablePerformanceMonitorInBackground: boolean;
  32252. private _performanceMonitor;
  32253. /**
  32254. * Gets the performance monitor attached to this engine
  32255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32256. */
  32257. readonly performanceMonitor: PerformanceMonitor;
  32258. private _onFocus;
  32259. private _onBlur;
  32260. private _onCanvasPointerOut;
  32261. private _onCanvasBlur;
  32262. private _onCanvasFocus;
  32263. private _onFullscreenChange;
  32264. private _onPointerLockChange;
  32265. /**
  32266. * Creates a new engine
  32267. * @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
  32268. * @param antialias defines enable antialiasing (default: false)
  32269. * @param options defines further options to be sent to the getContext() function
  32270. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32271. */
  32272. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32273. /**
  32274. * Gets current aspect ratio
  32275. * @param viewportOwner defines the camera to use to get the aspect ratio
  32276. * @param useScreen defines if screen size must be used (or the current render target if any)
  32277. * @returns a number defining the aspect ratio
  32278. */
  32279. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32280. /**
  32281. * Gets current screen aspect ratio
  32282. * @returns a number defining the aspect ratio
  32283. */
  32284. getScreenAspectRatio(): number;
  32285. /**
  32286. * Gets host document
  32287. * @returns the host document object
  32288. */
  32289. getHostDocument(): Document;
  32290. /**
  32291. * Gets the client rect of the HTML canvas attached with the current webGL context
  32292. * @returns a client rectanglee
  32293. */
  32294. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32295. /**
  32296. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32298. * @returns true if engine is in deterministic lock step mode
  32299. */
  32300. isDeterministicLockStep(): boolean;
  32301. /**
  32302. * Gets the max steps when engine is running in deterministic lock step
  32303. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32304. * @returns the max steps
  32305. */
  32306. getLockstepMaxSteps(): number;
  32307. /**
  32308. * Force the mipmap generation for the given render target texture
  32309. * @param texture defines the render target texture to use
  32310. */
  32311. generateMipMapsForCubemap(texture: InternalTexture): void;
  32312. /** States */
  32313. /**
  32314. * Set various states to the webGL context
  32315. * @param culling defines backface culling state
  32316. * @param zOffset defines the value to apply to zOffset (0 by default)
  32317. * @param force defines if states must be applied even if cache is up to date
  32318. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32319. */
  32320. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32321. /**
  32322. * Set the z offset to apply to current rendering
  32323. * @param value defines the offset to apply
  32324. */
  32325. setZOffset(value: number): void;
  32326. /**
  32327. * Gets the current value of the zOffset
  32328. * @returns the current zOffset state
  32329. */
  32330. getZOffset(): number;
  32331. /**
  32332. * Enable or disable depth buffering
  32333. * @param enable defines the state to set
  32334. */
  32335. setDepthBuffer(enable: boolean): void;
  32336. /**
  32337. * Gets a boolean indicating if depth writing is enabled
  32338. * @returns the current depth writing state
  32339. */
  32340. getDepthWrite(): boolean;
  32341. /**
  32342. * Enable or disable depth writing
  32343. * @param enable defines the state to set
  32344. */
  32345. setDepthWrite(enable: boolean): void;
  32346. /**
  32347. * Enable or disable color writing
  32348. * @param enable defines the state to set
  32349. */
  32350. setColorWrite(enable: boolean): void;
  32351. /**
  32352. * Gets a boolean indicating if color writing is enabled
  32353. * @returns the current color writing state
  32354. */
  32355. getColorWrite(): boolean;
  32356. /**
  32357. * Sets alpha constants used by some alpha blending modes
  32358. * @param r defines the red component
  32359. * @param g defines the green component
  32360. * @param b defines the blue component
  32361. * @param a defines the alpha component
  32362. */
  32363. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32364. /**
  32365. * Sets the current alpha mode
  32366. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32367. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32368. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32369. */
  32370. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32371. /**
  32372. * Gets the current alpha mode
  32373. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32374. * @returns the current alpha mode
  32375. */
  32376. getAlphaMode(): number;
  32377. /**
  32378. * Sets the current alpha equation
  32379. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32380. */
  32381. setAlphaEquation(equation: number): void;
  32382. /**
  32383. * Gets the current alpha equation.
  32384. * @returns the current alpha equation
  32385. */
  32386. getAlphaEquation(): number;
  32387. /**
  32388. * Gets a boolean indicating if stencil buffer is enabled
  32389. * @returns the current stencil buffer state
  32390. */
  32391. getStencilBuffer(): boolean;
  32392. /**
  32393. * Enable or disable the stencil buffer
  32394. * @param enable defines if the stencil buffer must be enabled or disabled
  32395. */
  32396. setStencilBuffer(enable: boolean): void;
  32397. /**
  32398. * Gets the current stencil mask
  32399. * @returns a number defining the new stencil mask to use
  32400. */
  32401. getStencilMask(): number;
  32402. /**
  32403. * Sets the current stencil mask
  32404. * @param mask defines the new stencil mask to use
  32405. */
  32406. setStencilMask(mask: number): void;
  32407. /**
  32408. * Gets the current stencil function
  32409. * @returns a number defining the stencil function to use
  32410. */
  32411. getStencilFunction(): number;
  32412. /**
  32413. * Gets the current stencil reference value
  32414. * @returns a number defining the stencil reference value to use
  32415. */
  32416. getStencilFunctionReference(): number;
  32417. /**
  32418. * Gets the current stencil mask
  32419. * @returns a number defining the stencil mask to use
  32420. */
  32421. getStencilFunctionMask(): number;
  32422. /**
  32423. * Sets the current stencil function
  32424. * @param stencilFunc defines the new stencil function to use
  32425. */
  32426. setStencilFunction(stencilFunc: number): void;
  32427. /**
  32428. * Sets the current stencil reference
  32429. * @param reference defines the new stencil reference to use
  32430. */
  32431. setStencilFunctionReference(reference: number): void;
  32432. /**
  32433. * Sets the current stencil mask
  32434. * @param mask defines the new stencil mask to use
  32435. */
  32436. setStencilFunctionMask(mask: number): void;
  32437. /**
  32438. * Gets the current stencil operation when stencil fails
  32439. * @returns a number defining stencil operation to use when stencil fails
  32440. */
  32441. getStencilOperationFail(): number;
  32442. /**
  32443. * Gets the current stencil operation when depth fails
  32444. * @returns a number defining stencil operation to use when depth fails
  32445. */
  32446. getStencilOperationDepthFail(): number;
  32447. /**
  32448. * Gets the current stencil operation when stencil passes
  32449. * @returns a number defining stencil operation to use when stencil passes
  32450. */
  32451. getStencilOperationPass(): number;
  32452. /**
  32453. * Sets the stencil operation to use when stencil fails
  32454. * @param operation defines the stencil operation to use when stencil fails
  32455. */
  32456. setStencilOperationFail(operation: number): void;
  32457. /**
  32458. * Sets the stencil operation to use when depth fails
  32459. * @param operation defines the stencil operation to use when depth fails
  32460. */
  32461. setStencilOperationDepthFail(operation: number): void;
  32462. /**
  32463. * Sets the stencil operation to use when stencil passes
  32464. * @param operation defines the stencil operation to use when stencil passes
  32465. */
  32466. setStencilOperationPass(operation: number): void;
  32467. /**
  32468. * Sets a boolean indicating if the dithering state is enabled or disabled
  32469. * @param value defines the dithering state
  32470. */
  32471. setDitheringState(value: boolean): void;
  32472. /**
  32473. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32474. * @param value defines the rasterizer state
  32475. */
  32476. setRasterizerState(value: boolean): void;
  32477. /**
  32478. * Gets the current depth function
  32479. * @returns a number defining the depth function
  32480. */
  32481. getDepthFunction(): Nullable<number>;
  32482. /**
  32483. * Sets the current depth function
  32484. * @param depthFunc defines the function to use
  32485. */
  32486. setDepthFunction(depthFunc: number): void;
  32487. /**
  32488. * Sets the current depth function to GREATER
  32489. */
  32490. setDepthFunctionToGreater(): void;
  32491. /**
  32492. * Sets the current depth function to GEQUAL
  32493. */
  32494. setDepthFunctionToGreaterOrEqual(): void;
  32495. /**
  32496. * Sets the current depth function to LESS
  32497. */
  32498. setDepthFunctionToLess(): void;
  32499. /**
  32500. * Sets the current depth function to LEQUAL
  32501. */
  32502. setDepthFunctionToLessOrEqual(): void;
  32503. private _cachedStencilBuffer;
  32504. private _cachedStencilFunction;
  32505. private _cachedStencilMask;
  32506. private _cachedStencilOperationPass;
  32507. private _cachedStencilOperationFail;
  32508. private _cachedStencilOperationDepthFail;
  32509. private _cachedStencilReference;
  32510. /**
  32511. * Caches the the state of the stencil buffer
  32512. */
  32513. cacheStencilState(): void;
  32514. /**
  32515. * Restores the state of the stencil buffer
  32516. */
  32517. restoreStencilState(): void;
  32518. /**
  32519. * Directly set the WebGL Viewport
  32520. * @param x defines the x coordinate of the viewport (in screen space)
  32521. * @param y defines the y coordinate of the viewport (in screen space)
  32522. * @param width defines the width of the viewport (in screen space)
  32523. * @param height defines the height of the viewport (in screen space)
  32524. * @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
  32525. */
  32526. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32527. /**
  32528. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32529. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32530. * @param y defines the y-coordinate of the corner of the clear rectangle
  32531. * @param width defines the width of the clear rectangle
  32532. * @param height defines the height of the clear rectangle
  32533. * @param clearColor defines the clear color
  32534. */
  32535. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32536. /**
  32537. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32538. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32539. * @param y defines the y-coordinate of the corner of the clear rectangle
  32540. * @param width defines the width of the clear rectangle
  32541. * @param height defines the height of the clear rectangle
  32542. */
  32543. enableScissor(x: number, y: number, width: number, height: number): void;
  32544. /**
  32545. * Disable previously set scissor test rectangle
  32546. */
  32547. disableScissor(): void;
  32548. protected _reportDrawCall(): void;
  32549. /**
  32550. * Initializes a webVR display and starts listening to display change events
  32551. * The onVRDisplayChangedObservable will be notified upon these changes
  32552. * @returns The onVRDisplayChangedObservable
  32553. */
  32554. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32555. /** @hidden */
  32556. _prepareVRComponent(): void;
  32557. /** @hidden */
  32558. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32559. /** @hidden */
  32560. _submitVRFrame(): void;
  32561. /**
  32562. * Call this function to leave webVR mode
  32563. * Will do nothing if webVR is not supported or if there is no webVR device
  32564. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32565. */
  32566. disableVR(): void;
  32567. /**
  32568. * Gets a boolean indicating that the system is in VR mode and is presenting
  32569. * @returns true if VR mode is engaged
  32570. */
  32571. isVRPresenting(): boolean;
  32572. /** @hidden */
  32573. _requestVRFrame(): void;
  32574. /** @hidden */
  32575. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32576. /**
  32577. * Gets the source code of the vertex shader associated with a specific webGL program
  32578. * @param program defines the program to use
  32579. * @returns a string containing the source code of the vertex shader associated with the program
  32580. */
  32581. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32582. /**
  32583. * Gets the source code of the fragment shader associated with a specific webGL program
  32584. * @param program defines the program to use
  32585. * @returns a string containing the source code of the fragment shader associated with the program
  32586. */
  32587. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32588. /**
  32589. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32590. * @param x defines the x coordinate of the rectangle where pixels must be read
  32591. * @param y defines the y coordinate of the rectangle where pixels must be read
  32592. * @param width defines the width of the rectangle where pixels must be read
  32593. * @param height defines the height of the rectangle where pixels must be read
  32594. * @returns a Uint8Array containing RGBA colors
  32595. */
  32596. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32597. /**
  32598. * Sets a depth stencil texture from a render target to the according uniform.
  32599. * @param channel The texture channel
  32600. * @param uniform The uniform to set
  32601. * @param texture The render target texture containing the depth stencil texture to apply
  32602. */
  32603. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32604. /**
  32605. * Sets a texture to the webGL context from a postprocess
  32606. * @param channel defines the channel to use
  32607. * @param postProcess defines the source postprocess
  32608. */
  32609. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32610. /**
  32611. * Binds the output of the passed in post process to the texture channel specified
  32612. * @param channel The channel the texture should be bound to
  32613. * @param postProcess The post process which's output should be bound
  32614. */
  32615. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32616. /** @hidden */
  32617. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32618. protected _rebuildBuffers(): void;
  32619. _renderLoop(): void;
  32620. /**
  32621. * Toggle full screen mode
  32622. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32623. */
  32624. switchFullscreen(requestPointerLock: boolean): void;
  32625. /**
  32626. * Enters full screen mode
  32627. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32628. */
  32629. enterFullscreen(requestPointerLock: boolean): void;
  32630. /**
  32631. * Exits full screen mode
  32632. */
  32633. exitFullscreen(): void;
  32634. /**
  32635. * Enters Pointerlock mode
  32636. */
  32637. enterPointerlock(): void;
  32638. /**
  32639. * Exits Pointerlock mode
  32640. */
  32641. exitPointerlock(): void;
  32642. /**
  32643. * Begin a new frame
  32644. */
  32645. beginFrame(): void;
  32646. /**
  32647. * Enf the current frame
  32648. */
  32649. endFrame(): void;
  32650. resize(): void;
  32651. /**
  32652. * Set the compressed texture format to use, based on the formats you have, and the formats
  32653. * supported by the hardware / browser.
  32654. *
  32655. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32656. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32657. * to API arguments needed to compressed textures. This puts the burden on the container
  32658. * generator to house the arcane code for determining these for current & future formats.
  32659. *
  32660. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32661. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32662. *
  32663. * Note: The result of this call is not taken into account when a texture is base64.
  32664. *
  32665. * @param formatsAvailable defines the list of those format families you have created
  32666. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32667. *
  32668. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32669. * @returns The extension selected.
  32670. */
  32671. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32672. /**
  32673. * Force a specific size of the canvas
  32674. * @param width defines the new canvas' width
  32675. * @param height defines the new canvas' height
  32676. */
  32677. setSize(width: number, height: number): void;
  32678. /**
  32679. * Updates a dynamic vertex buffer.
  32680. * @param vertexBuffer the vertex buffer to update
  32681. * @param data the data used to update the vertex buffer
  32682. * @param byteOffset the byte offset of the data
  32683. * @param byteLength the byte length of the data
  32684. */
  32685. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  32686. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32687. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32688. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32689. _releaseTexture(texture: InternalTexture): void;
  32690. /**
  32691. * @hidden
  32692. * Rescales a texture
  32693. * @param source input texutre
  32694. * @param destination destination texture
  32695. * @param scene scene to use to render the resize
  32696. * @param internalFormat format to use when resizing
  32697. * @param onComplete callback to be called when resize has completed
  32698. */
  32699. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32700. /**
  32701. * Gets the current framerate
  32702. * @returns a number representing the framerate
  32703. */
  32704. getFps(): number;
  32705. /**
  32706. * Gets the time spent between current and previous frame
  32707. * @returns a number representing the delta time in ms
  32708. */
  32709. getDeltaTime(): number;
  32710. private _measureFps;
  32711. /** @hidden */
  32712. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  32713. /**
  32714. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32715. * @param renderTarget The render target to set the frame buffer for
  32716. */
  32717. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32718. /**
  32719. * Update a dynamic index buffer
  32720. * @param indexBuffer defines the target index buffer
  32721. * @param indices defines the data to update
  32722. * @param offset defines the offset in the target index buffer where update should start
  32723. */
  32724. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32725. /**
  32726. * Updates the sample count of a render target texture
  32727. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32728. * @param texture defines the texture to update
  32729. * @param samples defines the sample count to set
  32730. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32731. */
  32732. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32733. /**
  32734. * Updates a depth texture Comparison Mode and Function.
  32735. * If the comparison Function is equal to 0, the mode will be set to none.
  32736. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32737. * @param texture The texture to set the comparison function for
  32738. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32739. */
  32740. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32741. /**
  32742. * Creates a webGL buffer to use with instanciation
  32743. * @param capacity defines the size of the buffer
  32744. * @returns the webGL buffer
  32745. */
  32746. createInstancesBuffer(capacity: number): DataBuffer;
  32747. /**
  32748. * Delete a webGL buffer used with instanciation
  32749. * @param buffer defines the webGL buffer to delete
  32750. */
  32751. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  32752. /** @hidden */
  32753. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32754. dispose(): void;
  32755. private _disableTouchAction;
  32756. /**
  32757. * Display the loading screen
  32758. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32759. */
  32760. displayLoadingUI(): void;
  32761. /**
  32762. * Hide the loading screen
  32763. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32764. */
  32765. hideLoadingUI(): void;
  32766. /**
  32767. * Gets the current loading screen object
  32768. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32769. */
  32770. /**
  32771. * Sets the current loading screen object
  32772. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32773. */
  32774. loadingScreen: ILoadingScreen;
  32775. /**
  32776. * Sets the current loading screen text
  32777. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32778. */
  32779. loadingUIText: string;
  32780. /**
  32781. * Sets the current loading screen background color
  32782. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32783. */
  32784. loadingUIBackgroundColor: string;
  32785. /** Pointerlock and fullscreen */
  32786. /**
  32787. * Ask the browser to promote the current element to pointerlock mode
  32788. * @param element defines the DOM element to promote
  32789. */
  32790. static _RequestPointerlock(element: HTMLElement): void;
  32791. /**
  32792. * Asks the browser to exit pointerlock mode
  32793. */
  32794. static _ExitPointerlock(): void;
  32795. /**
  32796. * Ask the browser to promote the current element to fullscreen rendering mode
  32797. * @param element defines the DOM element to promote
  32798. */
  32799. static _RequestFullscreen(element: HTMLElement): void;
  32800. /**
  32801. * Asks the browser to exit fullscreen mode
  32802. */
  32803. static _ExitFullscreen(): void;
  32804. }
  32805. }
  32806. declare module "babylonjs/Engines/engineStore" {
  32807. import { Nullable } from "babylonjs/types";
  32808. import { Engine } from "babylonjs/Engines/engine";
  32809. import { Scene } from "babylonjs/scene";
  32810. /**
  32811. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32812. * during the life time of the application.
  32813. */
  32814. export class EngineStore {
  32815. /** Gets the list of created engines */
  32816. static Instances: import("babylonjs/Engines/engine").Engine[];
  32817. /** @hidden */
  32818. static _LastCreatedScene: Nullable<Scene>;
  32819. /**
  32820. * Gets the latest created engine
  32821. */
  32822. static readonly LastCreatedEngine: Nullable<Engine>;
  32823. /**
  32824. * Gets the latest created scene
  32825. */
  32826. static readonly LastCreatedScene: Nullable<Scene>;
  32827. /**
  32828. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32829. * @ignorenaming
  32830. */
  32831. static UseFallbackTexture: boolean;
  32832. /**
  32833. * Texture content used if a texture cannot loaded
  32834. * @ignorenaming
  32835. */
  32836. static FallbackTexture: string;
  32837. }
  32838. }
  32839. declare module "babylonjs/Misc/promise" {
  32840. /**
  32841. * Helper class that provides a small promise polyfill
  32842. */
  32843. export class PromisePolyfill {
  32844. /**
  32845. * Static function used to check if the polyfill is required
  32846. * If this is the case then the function will inject the polyfill to window.Promise
  32847. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32848. */
  32849. static Apply(force?: boolean): void;
  32850. }
  32851. }
  32852. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32853. /**
  32854. * Interface for screenshot methods with describe argument called `size` as object with options
  32855. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32856. */
  32857. export interface IScreenshotSize {
  32858. /**
  32859. * number in pixels for canvas height
  32860. */
  32861. height?: number;
  32862. /**
  32863. * multiplier allowing render at a higher or lower resolution
  32864. * If value is defined then height and width will be ignored and taken from camera
  32865. */
  32866. precision?: number;
  32867. /**
  32868. * number in pixels for canvas width
  32869. */
  32870. width?: number;
  32871. }
  32872. }
  32873. declare module "babylonjs/Misc/tools" {
  32874. import { Nullable, float } from "babylonjs/types";
  32875. import { DomManagement } from "babylonjs/Misc/domManagement";
  32876. import { WebRequest } from "babylonjs/Misc/webRequest";
  32877. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32878. import { ReadFileError } from "babylonjs/Misc/fileTools";
  32879. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32880. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32881. import { Camera } from "babylonjs/Cameras/camera";
  32882. import { Engine } from "babylonjs/Engines/engine";
  32883. interface IColor4Like {
  32884. r: float;
  32885. g: float;
  32886. b: float;
  32887. a: float;
  32888. }
  32889. /**
  32890. * Class containing a set of static utilities functions
  32891. */
  32892. export class Tools {
  32893. /**
  32894. * Gets or sets the base URL to use to load assets
  32895. */
  32896. static BaseUrl: string;
  32897. /**
  32898. * Enable/Disable Custom HTTP Request Headers globally.
  32899. * default = false
  32900. * @see CustomRequestHeaders
  32901. */
  32902. static UseCustomRequestHeaders: boolean;
  32903. /**
  32904. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32905. * i.e. when loading files, where the server/service expects an Authorization header
  32906. */
  32907. static CustomRequestHeaders: {
  32908. [key: string]: string;
  32909. };
  32910. /**
  32911. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32912. */
  32913. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32914. /**
  32915. * Default behaviour for cors in the application.
  32916. * It can be a string if the expected behavior is identical in the entire app.
  32917. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32918. */
  32919. static CorsBehavior: string | ((url: string | string[]) => string);
  32920. /**
  32921. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32922. * @ignorenaming
  32923. */
  32924. static UseFallbackTexture: boolean;
  32925. /**
  32926. * Use this object to register external classes like custom textures or material
  32927. * to allow the laoders to instantiate them
  32928. */
  32929. static RegisteredExternalClasses: {
  32930. [key: string]: Object;
  32931. };
  32932. /**
  32933. * Texture content used if a texture cannot loaded
  32934. * @ignorenaming
  32935. */
  32936. static fallbackTexture: string;
  32937. /**
  32938. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32939. * @param u defines the coordinate on X axis
  32940. * @param v defines the coordinate on Y axis
  32941. * @param width defines the width of the source data
  32942. * @param height defines the height of the source data
  32943. * @param pixels defines the source byte array
  32944. * @param color defines the output color
  32945. */
  32946. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32947. /**
  32948. * Interpolates between a and b via alpha
  32949. * @param a The lower value (returned when alpha = 0)
  32950. * @param b The upper value (returned when alpha = 1)
  32951. * @param alpha The interpolation-factor
  32952. * @return The mixed value
  32953. */
  32954. static Mix(a: number, b: number, alpha: number): number;
  32955. /**
  32956. * Tries to instantiate a new object from a given class name
  32957. * @param className defines the class name to instantiate
  32958. * @returns the new object or null if the system was not able to do the instantiation
  32959. */
  32960. static Instantiate(className: string): any;
  32961. /**
  32962. * Provides a slice function that will work even on IE
  32963. * @param data defines the array to slice
  32964. * @param start defines the start of the data (optional)
  32965. * @param end defines the end of the data (optional)
  32966. * @returns the new sliced array
  32967. */
  32968. static Slice<T>(data: T, start?: number, end?: number): T;
  32969. /**
  32970. * Polyfill for setImmediate
  32971. * @param action defines the action to execute after the current execution block
  32972. */
  32973. static SetImmediate(action: () => void): void;
  32974. /**
  32975. * Function indicating if a number is an exponent of 2
  32976. * @param value defines the value to test
  32977. * @returns true if the value is an exponent of 2
  32978. */
  32979. static IsExponentOfTwo(value: number): boolean;
  32980. private static _tmpFloatArray;
  32981. /**
  32982. * Returns the nearest 32-bit single precision float representation of a Number
  32983. * @param value A Number. If the parameter is of a different type, it will get converted
  32984. * to a number or to NaN if it cannot be converted
  32985. * @returns number
  32986. */
  32987. static FloatRound(value: number): number;
  32988. /**
  32989. * Extracts the filename from a path
  32990. * @param path defines the path to use
  32991. * @returns the filename
  32992. */
  32993. static GetFilename(path: string): string;
  32994. /**
  32995. * Extracts the "folder" part of a path (everything before the filename).
  32996. * @param uri The URI to extract the info from
  32997. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32998. * @returns The "folder" part of the path
  32999. */
  33000. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33001. /**
  33002. * Extracts text content from a DOM element hierarchy
  33003. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33004. */
  33005. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33006. /**
  33007. * Convert an angle in radians to degrees
  33008. * @param angle defines the angle to convert
  33009. * @returns the angle in degrees
  33010. */
  33011. static ToDegrees(angle: number): number;
  33012. /**
  33013. * Convert an angle in degrees to radians
  33014. * @param angle defines the angle to convert
  33015. * @returns the angle in radians
  33016. */
  33017. static ToRadians(angle: number): number;
  33018. /**
  33019. * Returns an array if obj is not an array
  33020. * @param obj defines the object to evaluate as an array
  33021. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33022. * @returns either obj directly if obj is an array or a new array containing obj
  33023. */
  33024. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33025. /**
  33026. * Gets the pointer prefix to use
  33027. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33028. */
  33029. static GetPointerPrefix(): string;
  33030. /**
  33031. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33032. * @param url define the url we are trying
  33033. * @param element define the dom element where to configure the cors policy
  33034. */
  33035. static SetCorsBehavior(url: string | string[], element: {
  33036. crossOrigin: string | null;
  33037. }): void;
  33038. /**
  33039. * Removes unwanted characters from an url
  33040. * @param url defines the url to clean
  33041. * @returns the cleaned url
  33042. */
  33043. static CleanUrl(url: string): string;
  33044. /**
  33045. * Gets or sets a function used to pre-process url before using them to load assets
  33046. */
  33047. static PreprocessUrl: (url: string) => string;
  33048. /**
  33049. * Loads an image as an HTMLImageElement.
  33050. * @param input url string, ArrayBuffer, or Blob to load
  33051. * @param onLoad callback called when the image successfully loads
  33052. * @param onError callback called when the image fails to load
  33053. * @param offlineProvider offline provider for caching
  33054. * @param mimeType optional mime type
  33055. * @returns the HTMLImageElement of the loaded image
  33056. */
  33057. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33058. /**
  33059. * Loads a file from a url
  33060. * @param url url string, ArrayBuffer, or Blob to load
  33061. * @param onSuccess callback called when the file successfully loads
  33062. * @param onProgress callback called while file is loading (if the server supports this mode)
  33063. * @param offlineProvider defines the offline provider for caching
  33064. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33065. * @param onError callback called when the file fails to load
  33066. * @returns a file request object
  33067. */
  33068. 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;
  33069. /**
  33070. * Loads a file from a url
  33071. * @param url the file url to load
  33072. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33073. */
  33074. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33075. /**
  33076. * Load a script (identified by an url). When the url returns, the
  33077. * content of this file is added into a new script element, attached to the DOM (body element)
  33078. * @param scriptUrl defines the url of the script to laod
  33079. * @param onSuccess defines the callback called when the script is loaded
  33080. * @param onError defines the callback to call if an error occurs
  33081. * @param scriptId defines the id of the script element
  33082. */
  33083. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33084. /**
  33085. * Load an asynchronous script (identified by an url). When the url returns, the
  33086. * content of this file is added into a new script element, attached to the DOM (body element)
  33087. * @param scriptUrl defines the url of the script to laod
  33088. * @param scriptId defines the id of the script element
  33089. * @returns a promise request object
  33090. */
  33091. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33092. /**
  33093. * Loads a file from a blob
  33094. * @param fileToLoad defines the blob to use
  33095. * @param callback defines the callback to call when data is loaded
  33096. * @param progressCallback defines the callback to call during loading process
  33097. * @returns a file request object
  33098. */
  33099. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33100. /**
  33101. * Reads a file from a File object
  33102. * @param file defines the file to load
  33103. * @param onSuccess defines the callback to call when data is loaded
  33104. * @param onProgress defines the callback to call during loading process
  33105. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33106. * @param onError defines the callback to call when an error occurs
  33107. * @returns a file request object
  33108. */
  33109. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33110. /**
  33111. * Creates a data url from a given string content
  33112. * @param content defines the content to convert
  33113. * @returns the new data url link
  33114. */
  33115. static FileAsURL(content: string): string;
  33116. /**
  33117. * Format the given number to a specific decimal format
  33118. * @param value defines the number to format
  33119. * @param decimals defines the number of decimals to use
  33120. * @returns the formatted string
  33121. */
  33122. static Format(value: number, decimals?: number): string;
  33123. /**
  33124. * Tries to copy an object by duplicating every property
  33125. * @param source defines the source object
  33126. * @param destination defines the target object
  33127. * @param doNotCopyList defines a list of properties to avoid
  33128. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33129. */
  33130. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33131. /**
  33132. * Gets a boolean indicating if the given object has no own property
  33133. * @param obj defines the object to test
  33134. * @returns true if object has no own property
  33135. */
  33136. static IsEmpty(obj: any): boolean;
  33137. /**
  33138. * Function used to register events at window level
  33139. * @param windowElement defines the Window object to use
  33140. * @param events defines the events to register
  33141. */
  33142. static RegisterTopRootEvents(windowElement: Window, events: {
  33143. name: string;
  33144. handler: Nullable<(e: FocusEvent) => any>;
  33145. }[]): void;
  33146. /**
  33147. * Function used to unregister events from window level
  33148. * @param windowElement defines the Window object to use
  33149. * @param events defines the events to unregister
  33150. */
  33151. static UnregisterTopRootEvents(windowElement: Window, events: {
  33152. name: string;
  33153. handler: Nullable<(e: FocusEvent) => any>;
  33154. }[]): void;
  33155. /**
  33156. * @ignore
  33157. */
  33158. static _ScreenshotCanvas: HTMLCanvasElement;
  33159. /**
  33160. * Dumps the current bound framebuffer
  33161. * @param width defines the rendering width
  33162. * @param height defines the rendering height
  33163. * @param engine defines the hosting engine
  33164. * @param successCallback defines the callback triggered once the data are available
  33165. * @param mimeType defines the mime type of the result
  33166. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33167. */
  33168. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33169. /**
  33170. * Converts the canvas data to blob.
  33171. * This acts as a polyfill for browsers not supporting the to blob function.
  33172. * @param canvas Defines the canvas to extract the data from
  33173. * @param successCallback Defines the callback triggered once the data are available
  33174. * @param mimeType Defines the mime type of the result
  33175. */
  33176. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33177. /**
  33178. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33179. * @param successCallback defines the callback triggered once the data are available
  33180. * @param mimeType defines the mime type of the result
  33181. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33182. */
  33183. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33184. /**
  33185. * Downloads a blob in the browser
  33186. * @param blob defines the blob to download
  33187. * @param fileName defines the name of the downloaded file
  33188. */
  33189. static Download(blob: Blob, fileName: string): void;
  33190. /**
  33191. * Captures a screenshot of the current rendering
  33192. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33193. * @param engine defines the rendering engine
  33194. * @param camera defines the source camera
  33195. * @param size This parameter can be set to a single number or to an object with the
  33196. * following (optional) properties: precision, width, height. If a single number is passed,
  33197. * it will be used for both width and height. If an object is passed, the screenshot size
  33198. * will be derived from the parameters. The precision property is a multiplier allowing
  33199. * rendering at a higher or lower resolution
  33200. * @param successCallback defines the callback receives a single parameter which contains the
  33201. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33202. * src parameter of an <img> to display it
  33203. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33204. * Check your browser for supported MIME types
  33205. */
  33206. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33207. /**
  33208. * Captures a screenshot of the current rendering
  33209. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33210. * @param engine defines the rendering engine
  33211. * @param camera defines the source camera
  33212. * @param size This parameter can be set to a single number or to an object with the
  33213. * following (optional) properties: precision, width, height. If a single number is passed,
  33214. * it will be used for both width and height. If an object is passed, the screenshot size
  33215. * will be derived from the parameters. The precision property is a multiplier allowing
  33216. * rendering at a higher or lower resolution
  33217. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33218. * Check your browser for supported MIME types
  33219. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33220. * to the src parameter of an <img> to display it
  33221. */
  33222. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33223. /**
  33224. * Generates an image screenshot from the specified camera.
  33225. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33226. * @param engine The engine to use for rendering
  33227. * @param camera The camera to use for rendering
  33228. * @param size This parameter can be set to a single number or to an object with the
  33229. * following (optional) properties: precision, width, height. If a single number is passed,
  33230. * it will be used for both width and height. If an object is passed, the screenshot size
  33231. * will be derived from the parameters. The precision property is a multiplier allowing
  33232. * rendering at a higher or lower resolution
  33233. * @param successCallback The callback receives a single parameter which contains the
  33234. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33235. * src parameter of an <img> to display it
  33236. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33237. * Check your browser for supported MIME types
  33238. * @param samples Texture samples (default: 1)
  33239. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33240. * @param fileName A name for for the downloaded file.
  33241. */
  33242. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33243. /**
  33244. * Generates an image screenshot from the specified camera.
  33245. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33246. * @param engine The engine to use for rendering
  33247. * @param camera The camera to use for rendering
  33248. * @param size This parameter can be set to a single number or to an object with the
  33249. * following (optional) properties: precision, width, height. If a single number is passed,
  33250. * it will be used for both width and height. If an object is passed, the screenshot size
  33251. * will be derived from the parameters. The precision property is a multiplier allowing
  33252. * rendering at a higher or lower resolution
  33253. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33254. * Check your browser for supported MIME types
  33255. * @param samples Texture samples (default: 1)
  33256. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33257. * @param fileName A name for for the downloaded file.
  33258. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33259. * to the src parameter of an <img> to display it
  33260. */
  33261. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33262. /**
  33263. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33264. * Be aware Math.random() could cause collisions, but:
  33265. * "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"
  33266. * @returns a pseudo random id
  33267. */
  33268. static RandomId(): string;
  33269. /**
  33270. * Test if the given uri is a base64 string
  33271. * @param uri The uri to test
  33272. * @return True if the uri is a base64 string or false otherwise
  33273. */
  33274. static IsBase64(uri: string): boolean;
  33275. /**
  33276. * Decode the given base64 uri.
  33277. * @param uri The uri to decode
  33278. * @return The decoded base64 data.
  33279. */
  33280. static DecodeBase64(uri: string): ArrayBuffer;
  33281. /**
  33282. * Gets the absolute url.
  33283. * @param url the input url
  33284. * @return the absolute url
  33285. */
  33286. static GetAbsoluteUrl(url: string): string;
  33287. /**
  33288. * No log
  33289. */
  33290. static readonly NoneLogLevel: number;
  33291. /**
  33292. * Only message logs
  33293. */
  33294. static readonly MessageLogLevel: number;
  33295. /**
  33296. * Only warning logs
  33297. */
  33298. static readonly WarningLogLevel: number;
  33299. /**
  33300. * Only error logs
  33301. */
  33302. static readonly ErrorLogLevel: number;
  33303. /**
  33304. * All logs
  33305. */
  33306. static readonly AllLogLevel: number;
  33307. /**
  33308. * Gets a value indicating the number of loading errors
  33309. * @ignorenaming
  33310. */
  33311. static readonly errorsCount: number;
  33312. /**
  33313. * Callback called when a new log is added
  33314. */
  33315. static OnNewCacheEntry: (entry: string) => void;
  33316. /**
  33317. * Log a message to the console
  33318. * @param message defines the message to log
  33319. */
  33320. static Log(message: string): void;
  33321. /**
  33322. * Write a warning message to the console
  33323. * @param message defines the message to log
  33324. */
  33325. static Warn(message: string): void;
  33326. /**
  33327. * Write an error message to the console
  33328. * @param message defines the message to log
  33329. */
  33330. static Error(message: string): void;
  33331. /**
  33332. * Gets current log cache (list of logs)
  33333. */
  33334. static readonly LogCache: string;
  33335. /**
  33336. * Clears the log cache
  33337. */
  33338. static ClearLogCache(): void;
  33339. /**
  33340. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33341. */
  33342. static LogLevels: number;
  33343. /**
  33344. * Checks if the window object exists
  33345. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33346. */
  33347. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33348. /**
  33349. * No performance log
  33350. */
  33351. static readonly PerformanceNoneLogLevel: number;
  33352. /**
  33353. * Use user marks to log performance
  33354. */
  33355. static readonly PerformanceUserMarkLogLevel: number;
  33356. /**
  33357. * Log performance to the console
  33358. */
  33359. static readonly PerformanceConsoleLogLevel: number;
  33360. private static _performance;
  33361. /**
  33362. * Sets the current performance log level
  33363. */
  33364. static PerformanceLogLevel: number;
  33365. private static _StartPerformanceCounterDisabled;
  33366. private static _EndPerformanceCounterDisabled;
  33367. private static _StartUserMark;
  33368. private static _EndUserMark;
  33369. private static _StartPerformanceConsole;
  33370. private static _EndPerformanceConsole;
  33371. /**
  33372. * Starts a performance counter
  33373. */
  33374. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33375. /**
  33376. * Ends a specific performance coutner
  33377. */
  33378. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33379. /**
  33380. * Gets either window.performance.now() if supported or Date.now() else
  33381. */
  33382. static readonly Now: number;
  33383. /**
  33384. * This method will return the name of the class used to create the instance of the given object.
  33385. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33386. * @param object the object to get the class name from
  33387. * @param isType defines if the object is actually a type
  33388. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33389. */
  33390. static GetClassName(object: any, isType?: boolean): string;
  33391. /**
  33392. * Gets the first element of an array satisfying a given predicate
  33393. * @param array defines the array to browse
  33394. * @param predicate defines the predicate to use
  33395. * @returns null if not found or the element
  33396. */
  33397. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33398. /**
  33399. * This method will return the name of the full name of the class, including its owning module (if any).
  33400. * 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).
  33401. * @param object the object to get the class name from
  33402. * @param isType defines if the object is actually a type
  33403. * @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.
  33404. * @ignorenaming
  33405. */
  33406. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33407. /**
  33408. * Returns a promise that resolves after the given amount of time.
  33409. * @param delay Number of milliseconds to delay
  33410. * @returns Promise that resolves after the given amount of time
  33411. */
  33412. static DelayAsync(delay: number): Promise<void>;
  33413. }
  33414. /**
  33415. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33416. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33417. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33418. * @param name The name of the class, case should be preserved
  33419. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33420. */
  33421. export function className(name: string, module?: string): (target: Object) => void;
  33422. /**
  33423. * An implementation of a loop for asynchronous functions.
  33424. */
  33425. export class AsyncLoop {
  33426. /**
  33427. * Defines the number of iterations for the loop
  33428. */
  33429. iterations: number;
  33430. /**
  33431. * Defines the current index of the loop.
  33432. */
  33433. index: number;
  33434. private _done;
  33435. private _fn;
  33436. private _successCallback;
  33437. /**
  33438. * Constructor.
  33439. * @param iterations the number of iterations.
  33440. * @param func the function to run each iteration
  33441. * @param successCallback the callback that will be called upon succesful execution
  33442. * @param offset starting offset.
  33443. */
  33444. constructor(
  33445. /**
  33446. * Defines the number of iterations for the loop
  33447. */
  33448. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33449. /**
  33450. * Execute the next iteration. Must be called after the last iteration was finished.
  33451. */
  33452. executeNext(): void;
  33453. /**
  33454. * Break the loop and run the success callback.
  33455. */
  33456. breakLoop(): void;
  33457. /**
  33458. * Create and run an async loop.
  33459. * @param iterations the number of iterations.
  33460. * @param fn the function to run each iteration
  33461. * @param successCallback the callback that will be called upon succesful execution
  33462. * @param offset starting offset.
  33463. * @returns the created async loop object
  33464. */
  33465. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33466. /**
  33467. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33468. * @param iterations total number of iterations
  33469. * @param syncedIterations number of synchronous iterations in each async iteration.
  33470. * @param fn the function to call each iteration.
  33471. * @param callback a success call back that will be called when iterating stops.
  33472. * @param breakFunction a break condition (optional)
  33473. * @param timeout timeout settings for the setTimeout function. default - 0.
  33474. * @returns the created async loop object
  33475. */
  33476. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33477. }
  33478. }
  33479. declare module "babylonjs/Misc/stringDictionary" {
  33480. import { Nullable } from "babylonjs/types";
  33481. /**
  33482. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33483. * The underlying implementation relies on an associative array to ensure the best performances.
  33484. * The value can be anything including 'null' but except 'undefined'
  33485. */
  33486. export class StringDictionary<T> {
  33487. /**
  33488. * This will clear this dictionary and copy the content from the 'source' one.
  33489. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33490. * @param source the dictionary to take the content from and copy to this dictionary
  33491. */
  33492. copyFrom(source: StringDictionary<T>): void;
  33493. /**
  33494. * Get a value based from its key
  33495. * @param key the given key to get the matching value from
  33496. * @return the value if found, otherwise undefined is returned
  33497. */
  33498. get(key: string): T | undefined;
  33499. /**
  33500. * Get a value from its key or add it if it doesn't exist.
  33501. * This method will ensure you that a given key/data will be present in the dictionary.
  33502. * @param key the given key to get the matching value from
  33503. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33504. * The factory will only be invoked if there's no data for the given key.
  33505. * @return the value corresponding to the key.
  33506. */
  33507. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33508. /**
  33509. * Get a value from its key if present in the dictionary otherwise add it
  33510. * @param key the key to get the value from
  33511. * @param val if there's no such key/value pair in the dictionary add it with this value
  33512. * @return the value corresponding to the key
  33513. */
  33514. getOrAdd(key: string, val: T): T;
  33515. /**
  33516. * Check if there's a given key in the dictionary
  33517. * @param key the key to check for
  33518. * @return true if the key is present, false otherwise
  33519. */
  33520. contains(key: string): boolean;
  33521. /**
  33522. * Add a new key and its corresponding value
  33523. * @param key the key to add
  33524. * @param value the value corresponding to the key
  33525. * @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
  33526. */
  33527. add(key: string, value: T): boolean;
  33528. /**
  33529. * Update a specific value associated to a key
  33530. * @param key defines the key to use
  33531. * @param value defines the value to store
  33532. * @returns true if the value was updated (or false if the key was not found)
  33533. */
  33534. set(key: string, value: T): boolean;
  33535. /**
  33536. * Get the element of the given key and remove it from the dictionary
  33537. * @param key defines the key to search
  33538. * @returns the value associated with the key or null if not found
  33539. */
  33540. getAndRemove(key: string): Nullable<T>;
  33541. /**
  33542. * Remove a key/value from the dictionary.
  33543. * @param key the key to remove
  33544. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33545. */
  33546. remove(key: string): boolean;
  33547. /**
  33548. * Clear the whole content of the dictionary
  33549. */
  33550. clear(): void;
  33551. /**
  33552. * Gets the current count
  33553. */
  33554. readonly count: number;
  33555. /**
  33556. * Execute a callback on each key/val of the dictionary.
  33557. * Note that you can remove any element in this dictionary in the callback implementation
  33558. * @param callback the callback to execute on a given key/value pair
  33559. */
  33560. forEach(callback: (key: string, val: T) => void): void;
  33561. /**
  33562. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33563. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33564. * Note that you can remove any element in this dictionary in the callback implementation
  33565. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33566. * @returns the first item
  33567. */
  33568. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33569. private _count;
  33570. private _data;
  33571. }
  33572. }
  33573. declare module "babylonjs/Collisions/collisionCoordinator" {
  33574. import { Nullable } from "babylonjs/types";
  33575. import { Scene } from "babylonjs/scene";
  33576. import { Vector3 } from "babylonjs/Maths/math.vector";
  33577. import { Collider } from "babylonjs/Collisions/collider";
  33578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33579. /** @hidden */
  33580. export interface ICollisionCoordinator {
  33581. createCollider(): Collider;
  33582. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33583. init(scene: Scene): void;
  33584. }
  33585. /** @hidden */
  33586. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33587. private _scene;
  33588. private _scaledPosition;
  33589. private _scaledVelocity;
  33590. private _finalPosition;
  33591. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33592. createCollider(): Collider;
  33593. init(scene: Scene): void;
  33594. private _collideWithWorld;
  33595. }
  33596. }
  33597. declare module "babylonjs/Inputs/scene.inputManager" {
  33598. import { Nullable } from "babylonjs/types";
  33599. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33600. import { Vector2 } from "babylonjs/Maths/math.vector";
  33601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33602. import { Scene } from "babylonjs/scene";
  33603. /**
  33604. * Class used to manage all inputs for the scene.
  33605. */
  33606. export class InputManager {
  33607. /** The distance in pixel that you have to move to prevent some events */
  33608. static DragMovementThreshold: number;
  33609. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33610. static LongPressDelay: number;
  33611. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33612. static DoubleClickDelay: number;
  33613. /** If you need to check double click without raising a single click at first click, enable this flag */
  33614. static ExclusiveDoubleClickMode: boolean;
  33615. private _wheelEventName;
  33616. private _onPointerMove;
  33617. private _onPointerDown;
  33618. private _onPointerUp;
  33619. private _initClickEvent;
  33620. private _initActionManager;
  33621. private _delayedSimpleClick;
  33622. private _delayedSimpleClickTimeout;
  33623. private _previousDelayedSimpleClickTimeout;
  33624. private _meshPickProceed;
  33625. private _previousButtonPressed;
  33626. private _currentPickResult;
  33627. private _previousPickResult;
  33628. private _totalPointersPressed;
  33629. private _doubleClickOccured;
  33630. private _pointerOverMesh;
  33631. private _pickedDownMesh;
  33632. private _pickedUpMesh;
  33633. private _pointerX;
  33634. private _pointerY;
  33635. private _unTranslatedPointerX;
  33636. private _unTranslatedPointerY;
  33637. private _startingPointerPosition;
  33638. private _previousStartingPointerPosition;
  33639. private _startingPointerTime;
  33640. private _previousStartingPointerTime;
  33641. private _pointerCaptures;
  33642. private _onKeyDown;
  33643. private _onKeyUp;
  33644. private _onCanvasFocusObserver;
  33645. private _onCanvasBlurObserver;
  33646. private _scene;
  33647. /**
  33648. * Creates a new InputManager
  33649. * @param scene defines the hosting scene
  33650. */
  33651. constructor(scene: Scene);
  33652. /**
  33653. * Gets the mesh that is currently under the pointer
  33654. */
  33655. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33656. /**
  33657. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33658. */
  33659. readonly unTranslatedPointer: Vector2;
  33660. /**
  33661. * Gets or sets the current on-screen X position of the pointer
  33662. */
  33663. pointerX: number;
  33664. /**
  33665. * Gets or sets the current on-screen Y position of the pointer
  33666. */
  33667. pointerY: number;
  33668. private _updatePointerPosition;
  33669. private _processPointerMove;
  33670. private _setRayOnPointerInfo;
  33671. private _checkPrePointerObservable;
  33672. /**
  33673. * Use this method to simulate a pointer move on a mesh
  33674. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33675. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33676. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33677. */
  33678. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33679. /**
  33680. * Use this method to simulate a pointer down on a mesh
  33681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33684. */
  33685. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33686. private _processPointerDown;
  33687. /** @hidden */
  33688. _isPointerSwiping(): boolean;
  33689. /**
  33690. * Use this method to simulate a pointer up on a mesh
  33691. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33692. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33693. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33694. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33695. */
  33696. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33697. private _processPointerUp;
  33698. /**
  33699. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33700. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33701. * @returns true if the pointer was captured
  33702. */
  33703. isPointerCaptured(pointerId?: number): boolean;
  33704. /**
  33705. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33706. * @param attachUp defines if you want to attach events to pointerup
  33707. * @param attachDown defines if you want to attach events to pointerdown
  33708. * @param attachMove defines if you want to attach events to pointermove
  33709. */
  33710. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33711. /**
  33712. * Detaches all event handlers
  33713. */
  33714. detachControl(): void;
  33715. /**
  33716. * Force the value of meshUnderPointer
  33717. * @param mesh defines the mesh to use
  33718. */
  33719. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33720. /**
  33721. * Gets the mesh under the pointer
  33722. * @returns a Mesh or null if no mesh is under the pointer
  33723. */
  33724. getPointerOverMesh(): Nullable<AbstractMesh>;
  33725. }
  33726. }
  33727. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33728. /**
  33729. * Helper class used to generate session unique ID
  33730. */
  33731. export class UniqueIdGenerator {
  33732. private static _UniqueIdCounter;
  33733. /**
  33734. * Gets an unique (relatively to the current scene) Id
  33735. */
  33736. static readonly UniqueId: number;
  33737. }
  33738. }
  33739. declare module "babylonjs/Animations/animationGroup" {
  33740. import { Animatable } from "babylonjs/Animations/animatable";
  33741. import { Animation } from "babylonjs/Animations/animation";
  33742. import { Scene, IDisposable } from "babylonjs/scene";
  33743. import { Observable } from "babylonjs/Misc/observable";
  33744. import { Nullable } from "babylonjs/types";
  33745. import "babylonjs/Animations/animatable";
  33746. /**
  33747. * This class defines the direct association between an animation and a target
  33748. */
  33749. export class TargetedAnimation {
  33750. /**
  33751. * Animation to perform
  33752. */
  33753. animation: Animation;
  33754. /**
  33755. * Target to animate
  33756. */
  33757. target: any;
  33758. /**
  33759. * Serialize the object
  33760. * @returns the JSON object representing the current entity
  33761. */
  33762. serialize(): any;
  33763. }
  33764. /**
  33765. * Use this class to create coordinated animations on multiple targets
  33766. */
  33767. export class AnimationGroup implements IDisposable {
  33768. /** The name of the animation group */
  33769. name: string;
  33770. private _scene;
  33771. private _targetedAnimations;
  33772. private _animatables;
  33773. private _from;
  33774. private _to;
  33775. private _isStarted;
  33776. private _isPaused;
  33777. private _speedRatio;
  33778. private _loopAnimation;
  33779. /**
  33780. * Gets or sets the unique id of the node
  33781. */
  33782. uniqueId: number;
  33783. /**
  33784. * This observable will notify when one animation have ended
  33785. */
  33786. onAnimationEndObservable: Observable<TargetedAnimation>;
  33787. /**
  33788. * Observer raised when one animation loops
  33789. */
  33790. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33791. /**
  33792. * Observer raised when all animations have looped
  33793. */
  33794. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  33795. /**
  33796. * This observable will notify when all animations have ended.
  33797. */
  33798. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33799. /**
  33800. * This observable will notify when all animations have paused.
  33801. */
  33802. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33803. /**
  33804. * This observable will notify when all animations are playing.
  33805. */
  33806. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33807. /**
  33808. * Gets the first frame
  33809. */
  33810. readonly from: number;
  33811. /**
  33812. * Gets the last frame
  33813. */
  33814. readonly to: number;
  33815. /**
  33816. * Define if the animations are started
  33817. */
  33818. readonly isStarted: boolean;
  33819. /**
  33820. * Gets a value indicating that the current group is playing
  33821. */
  33822. readonly isPlaying: boolean;
  33823. /**
  33824. * Gets or sets the speed ratio to use for all animations
  33825. */
  33826. /**
  33827. * Gets or sets the speed ratio to use for all animations
  33828. */
  33829. speedRatio: number;
  33830. /**
  33831. * Gets or sets if all animations should loop or not
  33832. */
  33833. loopAnimation: boolean;
  33834. /**
  33835. * Gets the targeted animations for this animation group
  33836. */
  33837. readonly targetedAnimations: Array<TargetedAnimation>;
  33838. /**
  33839. * returning the list of animatables controlled by this animation group.
  33840. */
  33841. readonly animatables: Array<Animatable>;
  33842. /**
  33843. * Instantiates a new Animation Group.
  33844. * This helps managing several animations at once.
  33845. * @see http://doc.babylonjs.com/how_to/group
  33846. * @param name Defines the name of the group
  33847. * @param scene Defines the scene the group belongs to
  33848. */
  33849. constructor(
  33850. /** The name of the animation group */
  33851. name: string, scene?: Nullable<Scene>);
  33852. /**
  33853. * Add an animation (with its target) in the group
  33854. * @param animation defines the animation we want to add
  33855. * @param target defines the target of the animation
  33856. * @returns the TargetedAnimation object
  33857. */
  33858. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33859. /**
  33860. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33861. * It can add constant keys at begin or end
  33862. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33863. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33864. * @returns the animation group
  33865. */
  33866. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33867. private _animationLoopCount;
  33868. private _animationLoopFlags;
  33869. private _processLoop;
  33870. /**
  33871. * Start all animations on given targets
  33872. * @param loop defines if animations must loop
  33873. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33874. * @param from defines the from key (optional)
  33875. * @param to defines the to key (optional)
  33876. * @returns the current animation group
  33877. */
  33878. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33879. /**
  33880. * Pause all animations
  33881. * @returns the animation group
  33882. */
  33883. pause(): AnimationGroup;
  33884. /**
  33885. * Play all animations to initial state
  33886. * This function will start() the animations if they were not started or will restart() them if they were paused
  33887. * @param loop defines if animations must loop
  33888. * @returns the animation group
  33889. */
  33890. play(loop?: boolean): AnimationGroup;
  33891. /**
  33892. * Reset all animations to initial state
  33893. * @returns the animation group
  33894. */
  33895. reset(): AnimationGroup;
  33896. /**
  33897. * Restart animations from key 0
  33898. * @returns the animation group
  33899. */
  33900. restart(): AnimationGroup;
  33901. /**
  33902. * Stop all animations
  33903. * @returns the animation group
  33904. */
  33905. stop(): AnimationGroup;
  33906. /**
  33907. * Set animation weight for all animatables
  33908. * @param weight defines the weight to use
  33909. * @return the animationGroup
  33910. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33911. */
  33912. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33913. /**
  33914. * Synchronize and normalize all animatables with a source animatable
  33915. * @param root defines the root animatable to synchronize with
  33916. * @return the animationGroup
  33917. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33918. */
  33919. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33920. /**
  33921. * Goes to a specific frame in this animation group
  33922. * @param frame the frame number to go to
  33923. * @return the animationGroup
  33924. */
  33925. goToFrame(frame: number): AnimationGroup;
  33926. /**
  33927. * Dispose all associated resources
  33928. */
  33929. dispose(): void;
  33930. private _checkAnimationGroupEnded;
  33931. /**
  33932. * Clone the current animation group and returns a copy
  33933. * @param newName defines the name of the new group
  33934. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33935. * @returns the new aniamtion group
  33936. */
  33937. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33938. /**
  33939. * Serializes the animationGroup to an object
  33940. * @returns Serialized object
  33941. */
  33942. serialize(): any;
  33943. /**
  33944. * Returns a new AnimationGroup object parsed from the source provided.
  33945. * @param parsedAnimationGroup defines the source
  33946. * @param scene defines the scene that will receive the animationGroup
  33947. * @returns a new AnimationGroup
  33948. */
  33949. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33950. /**
  33951. * Returns the string "AnimationGroup"
  33952. * @returns "AnimationGroup"
  33953. */
  33954. getClassName(): string;
  33955. /**
  33956. * Creates a detailled string about the object
  33957. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33958. * @returns a string representing the object
  33959. */
  33960. toString(fullDetails?: boolean): string;
  33961. }
  33962. }
  33963. declare module "babylonjs/scene" {
  33964. import { Nullable } from "babylonjs/types";
  33965. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33966. import { Observable } from "babylonjs/Misc/observable";
  33967. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33968. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33969. import { Geometry } from "babylonjs/Meshes/geometry";
  33970. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33971. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33973. import { Mesh } from "babylonjs/Meshes/mesh";
  33974. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33975. import { Bone } from "babylonjs/Bones/bone";
  33976. import { Skeleton } from "babylonjs/Bones/skeleton";
  33977. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33978. import { Camera } from "babylonjs/Cameras/camera";
  33979. import { AbstractScene } from "babylonjs/abstractScene";
  33980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33981. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33982. import { Material } from "babylonjs/Materials/material";
  33983. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33984. import { Effect } from "babylonjs/Materials/effect";
  33985. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33986. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33987. import { Light } from "babylonjs/Lights/light";
  33988. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33989. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33990. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33991. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33993. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33994. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33995. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33996. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33997. import { Engine } from "babylonjs/Engines/engine";
  33998. import { Node } from "babylonjs/node";
  33999. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34000. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34001. import { WebRequest } from "babylonjs/Misc/webRequest";
  34002. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34003. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34004. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34005. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34006. import { Plane } from "babylonjs/Maths/math.plane";
  34007. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34008. import { Ray } from "babylonjs/Culling/ray";
  34009. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34010. import { Animation } from "babylonjs/Animations/animation";
  34011. import { Animatable } from "babylonjs/Animations/animatable";
  34012. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34013. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34014. import { Collider } from "babylonjs/Collisions/collider";
  34015. /**
  34016. * Define an interface for all classes that will hold resources
  34017. */
  34018. export interface IDisposable {
  34019. /**
  34020. * Releases all held resources
  34021. */
  34022. dispose(): void;
  34023. }
  34024. /** Interface defining initialization parameters for Scene class */
  34025. export interface SceneOptions {
  34026. /**
  34027. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34028. * It will improve performance when the number of geometries becomes important.
  34029. */
  34030. useGeometryUniqueIdsMap?: boolean;
  34031. /**
  34032. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34033. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34034. */
  34035. useMaterialMeshMap?: boolean;
  34036. /**
  34037. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34038. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34039. */
  34040. useClonedMeshhMap?: boolean;
  34041. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34042. virtual?: boolean;
  34043. }
  34044. /**
  34045. * Represents a scene to be rendered by the engine.
  34046. * @see http://doc.babylonjs.com/features/scene
  34047. */
  34048. export class Scene extends AbstractScene implements IAnimatable {
  34049. /** The fog is deactivated */
  34050. static readonly FOGMODE_NONE: number;
  34051. /** The fog density is following an exponential function */
  34052. static readonly FOGMODE_EXP: number;
  34053. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34054. static readonly FOGMODE_EXP2: number;
  34055. /** The fog density is following a linear function. */
  34056. static readonly FOGMODE_LINEAR: number;
  34057. /**
  34058. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34059. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34060. */
  34061. static MinDeltaTime: number;
  34062. /**
  34063. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34065. */
  34066. static MaxDeltaTime: number;
  34067. /**
  34068. * Factory used to create the default material.
  34069. * @param name The name of the material to create
  34070. * @param scene The scene to create the material for
  34071. * @returns The default material
  34072. */
  34073. static DefaultMaterialFactory(scene: Scene): Material;
  34074. /**
  34075. * Factory used to create the a collision coordinator.
  34076. * @returns The collision coordinator
  34077. */
  34078. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34079. /** @hidden */
  34080. _inputManager: InputManager;
  34081. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34082. cameraToUseForPointers: Nullable<Camera>;
  34083. /** @hidden */
  34084. readonly _isScene: boolean;
  34085. /**
  34086. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34087. */
  34088. autoClear: boolean;
  34089. /**
  34090. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34091. */
  34092. autoClearDepthAndStencil: boolean;
  34093. /**
  34094. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34095. */
  34096. clearColor: Color4;
  34097. /**
  34098. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34099. */
  34100. ambientColor: Color3;
  34101. /**
  34102. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34103. * It should only be one of the following (if not the default embedded one):
  34104. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34105. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34106. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34107. * The material properties need to be setup according to the type of texture in use.
  34108. */
  34109. environmentBRDFTexture: BaseTexture;
  34110. /** @hidden */
  34111. protected _environmentTexture: Nullable<BaseTexture>;
  34112. /**
  34113. * Texture used in all pbr material as the reflection texture.
  34114. * As in the majority of the scene they are the same (exception for multi room and so on),
  34115. * this is easier to reference from here than from all the materials.
  34116. */
  34117. /**
  34118. * Texture used in all pbr material as the reflection texture.
  34119. * As in the majority of the scene they are the same (exception for multi room and so on),
  34120. * this is easier to set here than in all the materials.
  34121. */
  34122. environmentTexture: Nullable<BaseTexture>;
  34123. /** @hidden */
  34124. protected _environmentIntensity: number;
  34125. /**
  34126. * Intensity of the environment in all pbr material.
  34127. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34128. * As in the majority of the scene they are the same (exception for multi room and so on),
  34129. * this is easier to reference from here than from all the materials.
  34130. */
  34131. /**
  34132. * Intensity of the environment in all pbr material.
  34133. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34134. * As in the majority of the scene they are the same (exception for multi room and so on),
  34135. * this is easier to set here than in all the materials.
  34136. */
  34137. environmentIntensity: number;
  34138. /** @hidden */
  34139. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34140. /**
  34141. * Default image processing configuration used either in the rendering
  34142. * Forward main pass or through the imageProcessingPostProcess if present.
  34143. * As in the majority of the scene they are the same (exception for multi camera),
  34144. * this is easier to reference from here than from all the materials and post process.
  34145. *
  34146. * No setter as we it is a shared configuration, you can set the values instead.
  34147. */
  34148. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34149. private _forceWireframe;
  34150. /**
  34151. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34152. */
  34153. forceWireframe: boolean;
  34154. private _forcePointsCloud;
  34155. /**
  34156. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34157. */
  34158. forcePointsCloud: boolean;
  34159. /**
  34160. * Gets or sets the active clipplane 1
  34161. */
  34162. clipPlane: Nullable<Plane>;
  34163. /**
  34164. * Gets or sets the active clipplane 2
  34165. */
  34166. clipPlane2: Nullable<Plane>;
  34167. /**
  34168. * Gets or sets the active clipplane 3
  34169. */
  34170. clipPlane3: Nullable<Plane>;
  34171. /**
  34172. * Gets or sets the active clipplane 4
  34173. */
  34174. clipPlane4: Nullable<Plane>;
  34175. /**
  34176. * Gets or sets a boolean indicating if animations are enabled
  34177. */
  34178. animationsEnabled: boolean;
  34179. private _animationPropertiesOverride;
  34180. /**
  34181. * Gets or sets the animation properties override
  34182. */
  34183. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34184. /**
  34185. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34186. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34187. */
  34188. useConstantAnimationDeltaTime: boolean;
  34189. /**
  34190. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34191. * Please note that it requires to run a ray cast through the scene on every frame
  34192. */
  34193. constantlyUpdateMeshUnderPointer: boolean;
  34194. /**
  34195. * Defines the HTML cursor to use when hovering over interactive elements
  34196. */
  34197. hoverCursor: string;
  34198. /**
  34199. * Defines the HTML default cursor to use (empty by default)
  34200. */
  34201. defaultCursor: string;
  34202. /**
  34203. * Defines wether cursors are handled by the scene.
  34204. */
  34205. doNotHandleCursors: boolean;
  34206. /**
  34207. * This is used to call preventDefault() on pointer down
  34208. * in order to block unwanted artifacts like system double clicks
  34209. */
  34210. preventDefaultOnPointerDown: boolean;
  34211. /**
  34212. * This is used to call preventDefault() on pointer up
  34213. * in order to block unwanted artifacts like system double clicks
  34214. */
  34215. preventDefaultOnPointerUp: boolean;
  34216. /**
  34217. * Gets or sets user defined metadata
  34218. */
  34219. metadata: any;
  34220. /**
  34221. * For internal use only. Please do not use.
  34222. */
  34223. reservedDataStore: any;
  34224. /**
  34225. * Gets the name of the plugin used to load this scene (null by default)
  34226. */
  34227. loadingPluginName: string;
  34228. /**
  34229. * Use this array to add regular expressions used to disable offline support for specific urls
  34230. */
  34231. disableOfflineSupportExceptionRules: RegExp[];
  34232. /**
  34233. * An event triggered when the scene is disposed.
  34234. */
  34235. onDisposeObservable: Observable<Scene>;
  34236. private _onDisposeObserver;
  34237. /** Sets a function to be executed when this scene is disposed. */
  34238. onDispose: () => void;
  34239. /**
  34240. * An event triggered before rendering the scene (right after animations and physics)
  34241. */
  34242. onBeforeRenderObservable: Observable<Scene>;
  34243. private _onBeforeRenderObserver;
  34244. /** Sets a function to be executed before rendering this scene */
  34245. beforeRender: Nullable<() => void>;
  34246. /**
  34247. * An event triggered after rendering the scene
  34248. */
  34249. onAfterRenderObservable: Observable<Scene>;
  34250. /**
  34251. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34252. */
  34253. onAfterRenderCameraObservable: Observable<Camera>;
  34254. private _onAfterRenderObserver;
  34255. /** Sets a function to be executed after rendering this scene */
  34256. afterRender: Nullable<() => void>;
  34257. /**
  34258. * An event triggered before animating the scene
  34259. */
  34260. onBeforeAnimationsObservable: Observable<Scene>;
  34261. /**
  34262. * An event triggered after animations processing
  34263. */
  34264. onAfterAnimationsObservable: Observable<Scene>;
  34265. /**
  34266. * An event triggered before draw calls are ready to be sent
  34267. */
  34268. onBeforeDrawPhaseObservable: Observable<Scene>;
  34269. /**
  34270. * An event triggered after draw calls have been sent
  34271. */
  34272. onAfterDrawPhaseObservable: Observable<Scene>;
  34273. /**
  34274. * An event triggered when the scene is ready
  34275. */
  34276. onReadyObservable: Observable<Scene>;
  34277. /**
  34278. * An event triggered before rendering a camera
  34279. */
  34280. onBeforeCameraRenderObservable: Observable<Camera>;
  34281. private _onBeforeCameraRenderObserver;
  34282. /** Sets a function to be executed before rendering a camera*/
  34283. beforeCameraRender: () => void;
  34284. /**
  34285. * An event triggered after rendering a camera
  34286. */
  34287. onAfterCameraRenderObservable: Observable<Camera>;
  34288. private _onAfterCameraRenderObserver;
  34289. /** Sets a function to be executed after rendering a camera*/
  34290. afterCameraRender: () => void;
  34291. /**
  34292. * An event triggered when active meshes evaluation is about to start
  34293. */
  34294. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34295. /**
  34296. * An event triggered when active meshes evaluation is done
  34297. */
  34298. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34299. /**
  34300. * An event triggered when particles rendering is about to start
  34301. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34302. */
  34303. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34304. /**
  34305. * An event triggered when particles rendering is done
  34306. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34307. */
  34308. onAfterParticlesRenderingObservable: Observable<Scene>;
  34309. /**
  34310. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34311. */
  34312. onDataLoadedObservable: Observable<Scene>;
  34313. /**
  34314. * An event triggered when a camera is created
  34315. */
  34316. onNewCameraAddedObservable: Observable<Camera>;
  34317. /**
  34318. * An event triggered when a camera is removed
  34319. */
  34320. onCameraRemovedObservable: Observable<Camera>;
  34321. /**
  34322. * An event triggered when a light is created
  34323. */
  34324. onNewLightAddedObservable: Observable<Light>;
  34325. /**
  34326. * An event triggered when a light is removed
  34327. */
  34328. onLightRemovedObservable: Observable<Light>;
  34329. /**
  34330. * An event triggered when a geometry is created
  34331. */
  34332. onNewGeometryAddedObservable: Observable<Geometry>;
  34333. /**
  34334. * An event triggered when a geometry is removed
  34335. */
  34336. onGeometryRemovedObservable: Observable<Geometry>;
  34337. /**
  34338. * An event triggered when a transform node is created
  34339. */
  34340. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34341. /**
  34342. * An event triggered when a transform node is removed
  34343. */
  34344. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34345. /**
  34346. * An event triggered when a mesh is created
  34347. */
  34348. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34349. /**
  34350. * An event triggered when a mesh is removed
  34351. */
  34352. onMeshRemovedObservable: Observable<AbstractMesh>;
  34353. /**
  34354. * An event triggered when a skeleton is created
  34355. */
  34356. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34357. /**
  34358. * An event triggered when a skeleton is removed
  34359. */
  34360. onSkeletonRemovedObservable: Observable<Skeleton>;
  34361. /**
  34362. * An event triggered when a material is created
  34363. */
  34364. onNewMaterialAddedObservable: Observable<Material>;
  34365. /**
  34366. * An event triggered when a material is removed
  34367. */
  34368. onMaterialRemovedObservable: Observable<Material>;
  34369. /**
  34370. * An event triggered when a texture is created
  34371. */
  34372. onNewTextureAddedObservable: Observable<BaseTexture>;
  34373. /**
  34374. * An event triggered when a texture is removed
  34375. */
  34376. onTextureRemovedObservable: Observable<BaseTexture>;
  34377. /**
  34378. * An event triggered when render targets are about to be rendered
  34379. * Can happen multiple times per frame.
  34380. */
  34381. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34382. /**
  34383. * An event triggered when render targets were rendered.
  34384. * Can happen multiple times per frame.
  34385. */
  34386. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34387. /**
  34388. * An event triggered before calculating deterministic simulation step
  34389. */
  34390. onBeforeStepObservable: Observable<Scene>;
  34391. /**
  34392. * An event triggered after calculating deterministic simulation step
  34393. */
  34394. onAfterStepObservable: Observable<Scene>;
  34395. /**
  34396. * An event triggered when the activeCamera property is updated
  34397. */
  34398. onActiveCameraChanged: Observable<Scene>;
  34399. /**
  34400. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34401. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34402. * 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)
  34403. */
  34404. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34405. /**
  34406. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34407. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34408. * 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)
  34409. */
  34410. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34411. /**
  34412. * This Observable will when a mesh has been imported into the scene.
  34413. */
  34414. onMeshImportedObservable: Observable<AbstractMesh>;
  34415. /**
  34416. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34417. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34418. */
  34419. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34420. /** @hidden */
  34421. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34422. /**
  34423. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34424. */
  34425. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34426. /**
  34427. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34428. */
  34429. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34430. /**
  34431. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34432. */
  34433. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34434. /** Callback called when a pointer move is detected */
  34435. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34436. /** Callback called when a pointer down is detected */
  34437. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34438. /** Callback called when a pointer up is detected */
  34439. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34440. /** Callback called when a pointer pick is detected */
  34441. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34442. /**
  34443. * 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).
  34444. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34445. */
  34446. onPrePointerObservable: Observable<PointerInfoPre>;
  34447. /**
  34448. * Observable event triggered each time an input event is received from the rendering canvas
  34449. */
  34450. onPointerObservable: Observable<PointerInfo>;
  34451. /**
  34452. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34453. */
  34454. readonly unTranslatedPointer: Vector2;
  34455. /**
  34456. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34457. */
  34458. static DragMovementThreshold: number;
  34459. /**
  34460. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34461. */
  34462. static LongPressDelay: number;
  34463. /**
  34464. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34465. */
  34466. static DoubleClickDelay: number;
  34467. /** If you need to check double click without raising a single click at first click, enable this flag */
  34468. static ExclusiveDoubleClickMode: boolean;
  34469. /** @hidden */
  34470. _mirroredCameraPosition: Nullable<Vector3>;
  34471. /**
  34472. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34473. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34474. */
  34475. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34476. /**
  34477. * Observable event triggered each time an keyboard event is received from the hosting window
  34478. */
  34479. onKeyboardObservable: Observable<KeyboardInfo>;
  34480. private _useRightHandedSystem;
  34481. /**
  34482. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34483. */
  34484. useRightHandedSystem: boolean;
  34485. private _timeAccumulator;
  34486. private _currentStepId;
  34487. private _currentInternalStep;
  34488. /**
  34489. * Sets the step Id used by deterministic lock step
  34490. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34491. * @param newStepId defines the step Id
  34492. */
  34493. setStepId(newStepId: number): void;
  34494. /**
  34495. * Gets the step Id used by deterministic lock step
  34496. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34497. * @returns the step Id
  34498. */
  34499. getStepId(): number;
  34500. /**
  34501. * Gets the internal step used by deterministic lock step
  34502. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34503. * @returns the internal step
  34504. */
  34505. getInternalStep(): number;
  34506. private _fogEnabled;
  34507. /**
  34508. * Gets or sets a boolean indicating if fog is enabled on this scene
  34509. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34510. * (Default is true)
  34511. */
  34512. fogEnabled: boolean;
  34513. private _fogMode;
  34514. /**
  34515. * Gets or sets the fog mode to use
  34516. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34517. * | mode | value |
  34518. * | --- | --- |
  34519. * | FOGMODE_NONE | 0 |
  34520. * | FOGMODE_EXP | 1 |
  34521. * | FOGMODE_EXP2 | 2 |
  34522. * | FOGMODE_LINEAR | 3 |
  34523. */
  34524. fogMode: number;
  34525. /**
  34526. * Gets or sets the fog color to use
  34527. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34528. * (Default is Color3(0.2, 0.2, 0.3))
  34529. */
  34530. fogColor: Color3;
  34531. /**
  34532. * Gets or sets the fog density to use
  34533. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34534. * (Default is 0.1)
  34535. */
  34536. fogDensity: number;
  34537. /**
  34538. * Gets or sets the fog start distance to use
  34539. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34540. * (Default is 0)
  34541. */
  34542. fogStart: number;
  34543. /**
  34544. * Gets or sets the fog end distance to use
  34545. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34546. * (Default is 1000)
  34547. */
  34548. fogEnd: number;
  34549. private _shadowsEnabled;
  34550. /**
  34551. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34552. */
  34553. shadowsEnabled: boolean;
  34554. private _lightsEnabled;
  34555. /**
  34556. * Gets or sets a boolean indicating if lights are enabled on this scene
  34557. */
  34558. lightsEnabled: boolean;
  34559. /** All of the active cameras added to this scene. */
  34560. activeCameras: Camera[];
  34561. /** @hidden */
  34562. _activeCamera: Nullable<Camera>;
  34563. /** Gets or sets the current active camera */
  34564. activeCamera: Nullable<Camera>;
  34565. private _defaultMaterial;
  34566. /** The default material used on meshes when no material is affected */
  34567. /** The default material used on meshes when no material is affected */
  34568. defaultMaterial: Material;
  34569. private _texturesEnabled;
  34570. /**
  34571. * Gets or sets a boolean indicating if textures are enabled on this scene
  34572. */
  34573. texturesEnabled: boolean;
  34574. /**
  34575. * Gets or sets a boolean indicating if particles are enabled on this scene
  34576. */
  34577. particlesEnabled: boolean;
  34578. /**
  34579. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34580. */
  34581. spritesEnabled: boolean;
  34582. private _skeletonsEnabled;
  34583. /**
  34584. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34585. */
  34586. skeletonsEnabled: boolean;
  34587. /**
  34588. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34589. */
  34590. lensFlaresEnabled: boolean;
  34591. /**
  34592. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34594. */
  34595. collisionsEnabled: boolean;
  34596. private _collisionCoordinator;
  34597. /** @hidden */
  34598. readonly collisionCoordinator: ICollisionCoordinator;
  34599. /**
  34600. * Defines the gravity applied to this scene (used only for collisions)
  34601. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34602. */
  34603. gravity: Vector3;
  34604. /**
  34605. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34606. */
  34607. postProcessesEnabled: boolean;
  34608. /**
  34609. * The list of postprocesses added to the scene
  34610. */
  34611. postProcesses: PostProcess[];
  34612. /**
  34613. * Gets the current postprocess manager
  34614. */
  34615. postProcessManager: PostProcessManager;
  34616. /**
  34617. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34618. */
  34619. renderTargetsEnabled: boolean;
  34620. /**
  34621. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34622. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34623. */
  34624. dumpNextRenderTargets: boolean;
  34625. /**
  34626. * The list of user defined render targets added to the scene
  34627. */
  34628. customRenderTargets: RenderTargetTexture[];
  34629. /**
  34630. * Defines if texture loading must be delayed
  34631. * If true, textures will only be loaded when they need to be rendered
  34632. */
  34633. useDelayedTextureLoading: boolean;
  34634. /**
  34635. * Gets the list of meshes imported to the scene through SceneLoader
  34636. */
  34637. importedMeshesFiles: String[];
  34638. /**
  34639. * Gets or sets a boolean indicating if probes are enabled on this scene
  34640. */
  34641. probesEnabled: boolean;
  34642. /**
  34643. * Gets or sets the current offline provider to use to store scene data
  34644. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34645. */
  34646. offlineProvider: IOfflineProvider;
  34647. /**
  34648. * Gets or sets the action manager associated with the scene
  34649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34650. */
  34651. actionManager: AbstractActionManager;
  34652. private _meshesForIntersections;
  34653. /**
  34654. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34655. */
  34656. proceduralTexturesEnabled: boolean;
  34657. private _engine;
  34658. private _totalVertices;
  34659. /** @hidden */
  34660. _activeIndices: PerfCounter;
  34661. /** @hidden */
  34662. _activeParticles: PerfCounter;
  34663. /** @hidden */
  34664. _activeBones: PerfCounter;
  34665. private _animationRatio;
  34666. /** @hidden */
  34667. _animationTimeLast: number;
  34668. /** @hidden */
  34669. _animationTime: number;
  34670. /**
  34671. * Gets or sets a general scale for animation speed
  34672. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34673. */
  34674. animationTimeScale: number;
  34675. /** @hidden */
  34676. _cachedMaterial: Nullable<Material>;
  34677. /** @hidden */
  34678. _cachedEffect: Nullable<Effect>;
  34679. /** @hidden */
  34680. _cachedVisibility: Nullable<number>;
  34681. private _renderId;
  34682. private _frameId;
  34683. private _executeWhenReadyTimeoutId;
  34684. private _intermediateRendering;
  34685. private _viewUpdateFlag;
  34686. private _projectionUpdateFlag;
  34687. /** @hidden */
  34688. _toBeDisposed: Nullable<IDisposable>[];
  34689. private _activeRequests;
  34690. /** @hidden */
  34691. _pendingData: any[];
  34692. private _isDisposed;
  34693. /**
  34694. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34695. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34696. */
  34697. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34698. private _activeMeshes;
  34699. private _processedMaterials;
  34700. private _renderTargets;
  34701. /** @hidden */
  34702. _activeParticleSystems: SmartArray<IParticleSystem>;
  34703. private _activeSkeletons;
  34704. private _softwareSkinnedMeshes;
  34705. private _renderingManager;
  34706. /** @hidden */
  34707. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34708. private _transformMatrix;
  34709. private _sceneUbo;
  34710. /** @hidden */
  34711. _viewMatrix: Matrix;
  34712. private _projectionMatrix;
  34713. /** @hidden */
  34714. _forcedViewPosition: Nullable<Vector3>;
  34715. /** @hidden */
  34716. _frustumPlanes: Plane[];
  34717. /**
  34718. * Gets the list of frustum planes (built from the active camera)
  34719. */
  34720. readonly frustumPlanes: Plane[];
  34721. /**
  34722. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34723. * This is useful if there are more lights that the maximum simulteanous authorized
  34724. */
  34725. requireLightSorting: boolean;
  34726. /** @hidden */
  34727. readonly useMaterialMeshMap: boolean;
  34728. /** @hidden */
  34729. readonly useClonedMeshhMap: boolean;
  34730. private _externalData;
  34731. private _uid;
  34732. /**
  34733. * @hidden
  34734. * Backing store of defined scene components.
  34735. */
  34736. _components: ISceneComponent[];
  34737. /**
  34738. * @hidden
  34739. * Backing store of defined scene components.
  34740. */
  34741. _serializableComponents: ISceneSerializableComponent[];
  34742. /**
  34743. * List of components to register on the next registration step.
  34744. */
  34745. private _transientComponents;
  34746. /**
  34747. * Registers the transient components if needed.
  34748. */
  34749. private _registerTransientComponents;
  34750. /**
  34751. * @hidden
  34752. * Add a component to the scene.
  34753. * Note that the ccomponent could be registered on th next frame if this is called after
  34754. * the register component stage.
  34755. * @param component Defines the component to add to the scene
  34756. */
  34757. _addComponent(component: ISceneComponent): void;
  34758. /**
  34759. * @hidden
  34760. * Gets a component from the scene.
  34761. * @param name defines the name of the component to retrieve
  34762. * @returns the component or null if not present
  34763. */
  34764. _getComponent(name: string): Nullable<ISceneComponent>;
  34765. /**
  34766. * @hidden
  34767. * Defines the actions happening before camera updates.
  34768. */
  34769. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34770. /**
  34771. * @hidden
  34772. * Defines the actions happening before clear the canvas.
  34773. */
  34774. _beforeClearStage: Stage<SimpleStageAction>;
  34775. /**
  34776. * @hidden
  34777. * Defines the actions when collecting render targets for the frame.
  34778. */
  34779. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34780. /**
  34781. * @hidden
  34782. * Defines the actions happening for one camera in the frame.
  34783. */
  34784. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34785. /**
  34786. * @hidden
  34787. * Defines the actions happening during the per mesh ready checks.
  34788. */
  34789. _isReadyForMeshStage: Stage<MeshStageAction>;
  34790. /**
  34791. * @hidden
  34792. * Defines the actions happening before evaluate active mesh checks.
  34793. */
  34794. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34795. /**
  34796. * @hidden
  34797. * Defines the actions happening during the evaluate sub mesh checks.
  34798. */
  34799. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34800. /**
  34801. * @hidden
  34802. * Defines the actions happening during the active mesh stage.
  34803. */
  34804. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34805. /**
  34806. * @hidden
  34807. * Defines the actions happening during the per camera render target step.
  34808. */
  34809. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34810. /**
  34811. * @hidden
  34812. * Defines the actions happening just before the active camera is drawing.
  34813. */
  34814. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34815. /**
  34816. * @hidden
  34817. * Defines the actions happening just before a render target is drawing.
  34818. */
  34819. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34820. /**
  34821. * @hidden
  34822. * Defines the actions happening just before a rendering group is drawing.
  34823. */
  34824. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34825. /**
  34826. * @hidden
  34827. * Defines the actions happening just before a mesh is drawing.
  34828. */
  34829. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34830. /**
  34831. * @hidden
  34832. * Defines the actions happening just after a mesh has been drawn.
  34833. */
  34834. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34835. /**
  34836. * @hidden
  34837. * Defines the actions happening just after a rendering group has been drawn.
  34838. */
  34839. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34840. /**
  34841. * @hidden
  34842. * Defines the actions happening just after the active camera has been drawn.
  34843. */
  34844. _afterCameraDrawStage: Stage<CameraStageAction>;
  34845. /**
  34846. * @hidden
  34847. * Defines the actions happening just after a render target has been drawn.
  34848. */
  34849. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34850. /**
  34851. * @hidden
  34852. * Defines the actions happening just after rendering all cameras and computing intersections.
  34853. */
  34854. _afterRenderStage: Stage<SimpleStageAction>;
  34855. /**
  34856. * @hidden
  34857. * Defines the actions happening when a pointer move event happens.
  34858. */
  34859. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34860. /**
  34861. * @hidden
  34862. * Defines the actions happening when a pointer down event happens.
  34863. */
  34864. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34865. /**
  34866. * @hidden
  34867. * Defines the actions happening when a pointer up event happens.
  34868. */
  34869. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34870. /**
  34871. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34872. */
  34873. private geometriesByUniqueId;
  34874. /**
  34875. * Creates a new Scene
  34876. * @param engine defines the engine to use to render this scene
  34877. * @param options defines the scene options
  34878. */
  34879. constructor(engine: Engine, options?: SceneOptions);
  34880. /**
  34881. * Gets a string idenfifying the name of the class
  34882. * @returns "Scene" string
  34883. */
  34884. getClassName(): string;
  34885. private _defaultMeshCandidates;
  34886. /**
  34887. * @hidden
  34888. */
  34889. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34890. private _defaultSubMeshCandidates;
  34891. /**
  34892. * @hidden
  34893. */
  34894. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34895. /**
  34896. * Sets the default candidate providers for the scene.
  34897. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34898. * and getCollidingSubMeshCandidates to their default function
  34899. */
  34900. setDefaultCandidateProviders(): void;
  34901. /**
  34902. * Gets the mesh that is currently under the pointer
  34903. */
  34904. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34905. /**
  34906. * Gets or sets the current on-screen X position of the pointer
  34907. */
  34908. pointerX: number;
  34909. /**
  34910. * Gets or sets the current on-screen Y position of the pointer
  34911. */
  34912. pointerY: number;
  34913. /**
  34914. * Gets the cached material (ie. the latest rendered one)
  34915. * @returns the cached material
  34916. */
  34917. getCachedMaterial(): Nullable<Material>;
  34918. /**
  34919. * Gets the cached effect (ie. the latest rendered one)
  34920. * @returns the cached effect
  34921. */
  34922. getCachedEffect(): Nullable<Effect>;
  34923. /**
  34924. * Gets the cached visibility state (ie. the latest rendered one)
  34925. * @returns the cached visibility state
  34926. */
  34927. getCachedVisibility(): Nullable<number>;
  34928. /**
  34929. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34930. * @param material defines the current material
  34931. * @param effect defines the current effect
  34932. * @param visibility defines the current visibility state
  34933. * @returns true if one parameter is not cached
  34934. */
  34935. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34936. /**
  34937. * Gets the engine associated with the scene
  34938. * @returns an Engine
  34939. */
  34940. getEngine(): Engine;
  34941. /**
  34942. * Gets the total number of vertices rendered per frame
  34943. * @returns the total number of vertices rendered per frame
  34944. */
  34945. getTotalVertices(): number;
  34946. /**
  34947. * Gets the performance counter for total vertices
  34948. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34949. */
  34950. readonly totalVerticesPerfCounter: PerfCounter;
  34951. /**
  34952. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34953. * @returns the total number of active indices rendered per frame
  34954. */
  34955. getActiveIndices(): number;
  34956. /**
  34957. * Gets the performance counter for active indices
  34958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34959. */
  34960. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34961. /**
  34962. * Gets the total number of active particles rendered per frame
  34963. * @returns the total number of active particles rendered per frame
  34964. */
  34965. getActiveParticles(): number;
  34966. /**
  34967. * Gets the performance counter for active particles
  34968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34969. */
  34970. readonly activeParticlesPerfCounter: PerfCounter;
  34971. /**
  34972. * Gets the total number of active bones rendered per frame
  34973. * @returns the total number of active bones rendered per frame
  34974. */
  34975. getActiveBones(): number;
  34976. /**
  34977. * Gets the performance counter for active bones
  34978. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34979. */
  34980. readonly activeBonesPerfCounter: PerfCounter;
  34981. /**
  34982. * Gets the array of active meshes
  34983. * @returns an array of AbstractMesh
  34984. */
  34985. getActiveMeshes(): SmartArray<AbstractMesh>;
  34986. /**
  34987. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34988. * @returns a number
  34989. */
  34990. getAnimationRatio(): number;
  34991. /**
  34992. * Gets an unique Id for the current render phase
  34993. * @returns a number
  34994. */
  34995. getRenderId(): number;
  34996. /**
  34997. * Gets an unique Id for the current frame
  34998. * @returns a number
  34999. */
  35000. getFrameId(): number;
  35001. /** Call this function if you want to manually increment the render Id*/
  35002. incrementRenderId(): void;
  35003. private _createUbo;
  35004. /**
  35005. * Use this method to simulate a pointer move on a mesh
  35006. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35007. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35008. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35009. * @returns the current scene
  35010. */
  35011. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35012. /**
  35013. * Use this method to simulate a pointer down on a mesh
  35014. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35015. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35016. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35017. * @returns the current scene
  35018. */
  35019. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35020. /**
  35021. * Use this method to simulate a pointer up on a mesh
  35022. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35023. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35024. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35025. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35026. * @returns the current scene
  35027. */
  35028. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35029. /**
  35030. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35031. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35032. * @returns true if the pointer was captured
  35033. */
  35034. isPointerCaptured(pointerId?: number): boolean;
  35035. /**
  35036. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35037. * @param attachUp defines if you want to attach events to pointerup
  35038. * @param attachDown defines if you want to attach events to pointerdown
  35039. * @param attachMove defines if you want to attach events to pointermove
  35040. */
  35041. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35042. /** Detaches all event handlers*/
  35043. detachControl(): void;
  35044. /**
  35045. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35046. * Delay loaded resources are not taking in account
  35047. * @return true if all required resources are ready
  35048. */
  35049. isReady(): boolean;
  35050. /** Resets all cached information relative to material (including effect and visibility) */
  35051. resetCachedMaterial(): void;
  35052. /**
  35053. * Registers a function to be called before every frame render
  35054. * @param func defines the function to register
  35055. */
  35056. registerBeforeRender(func: () => void): void;
  35057. /**
  35058. * Unregisters a function called before every frame render
  35059. * @param func defines the function to unregister
  35060. */
  35061. unregisterBeforeRender(func: () => void): void;
  35062. /**
  35063. * Registers a function to be called after every frame render
  35064. * @param func defines the function to register
  35065. */
  35066. registerAfterRender(func: () => void): void;
  35067. /**
  35068. * Unregisters a function called after every frame render
  35069. * @param func defines the function to unregister
  35070. */
  35071. unregisterAfterRender(func: () => void): void;
  35072. private _executeOnceBeforeRender;
  35073. /**
  35074. * The provided function will run before render once and will be disposed afterwards.
  35075. * A timeout delay can be provided so that the function will be executed in N ms.
  35076. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35077. * @param func The function to be executed.
  35078. * @param timeout optional delay in ms
  35079. */
  35080. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35081. /** @hidden */
  35082. _addPendingData(data: any): void;
  35083. /** @hidden */
  35084. _removePendingData(data: any): void;
  35085. /**
  35086. * Returns the number of items waiting to be loaded
  35087. * @returns the number of items waiting to be loaded
  35088. */
  35089. getWaitingItemsCount(): number;
  35090. /**
  35091. * Returns a boolean indicating if the scene is still loading data
  35092. */
  35093. readonly isLoading: boolean;
  35094. /**
  35095. * Registers a function to be executed when the scene is ready
  35096. * @param {Function} func - the function to be executed
  35097. */
  35098. executeWhenReady(func: () => void): void;
  35099. /**
  35100. * Returns a promise that resolves when the scene is ready
  35101. * @returns A promise that resolves when the scene is ready
  35102. */
  35103. whenReadyAsync(): Promise<void>;
  35104. /** @hidden */
  35105. _checkIsReady(): void;
  35106. /**
  35107. * Gets all animatable attached to the scene
  35108. */
  35109. readonly animatables: Animatable[];
  35110. /**
  35111. * Resets the last animation time frame.
  35112. * Useful to override when animations start running when loading a scene for the first time.
  35113. */
  35114. resetLastAnimationTimeFrame(): void;
  35115. /**
  35116. * Gets the current view matrix
  35117. * @returns a Matrix
  35118. */
  35119. getViewMatrix(): Matrix;
  35120. /**
  35121. * Gets the current projection matrix
  35122. * @returns a Matrix
  35123. */
  35124. getProjectionMatrix(): Matrix;
  35125. /**
  35126. * Gets the current transform matrix
  35127. * @returns a Matrix made of View * Projection
  35128. */
  35129. getTransformMatrix(): Matrix;
  35130. /**
  35131. * Sets the current transform matrix
  35132. * @param viewL defines the View matrix to use
  35133. * @param projectionL defines the Projection matrix to use
  35134. * @param viewR defines the right View matrix to use (if provided)
  35135. * @param projectionR defines the right Projection matrix to use (if provided)
  35136. */
  35137. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35138. /**
  35139. * Gets the uniform buffer used to store scene data
  35140. * @returns a UniformBuffer
  35141. */
  35142. getSceneUniformBuffer(): UniformBuffer;
  35143. /**
  35144. * Gets an unique (relatively to the current scene) Id
  35145. * @returns an unique number for the scene
  35146. */
  35147. getUniqueId(): number;
  35148. /**
  35149. * Add a mesh to the list of scene's meshes
  35150. * @param newMesh defines the mesh to add
  35151. * @param recursive if all child meshes should also be added to the scene
  35152. */
  35153. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35154. /**
  35155. * Remove a mesh for the list of scene's meshes
  35156. * @param toRemove defines the mesh to remove
  35157. * @param recursive if all child meshes should also be removed from the scene
  35158. * @returns the index where the mesh was in the mesh list
  35159. */
  35160. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35161. /**
  35162. * Add a transform node to the list of scene's transform nodes
  35163. * @param newTransformNode defines the transform node to add
  35164. */
  35165. addTransformNode(newTransformNode: TransformNode): void;
  35166. /**
  35167. * Remove a transform node for the list of scene's transform nodes
  35168. * @param toRemove defines the transform node to remove
  35169. * @returns the index where the transform node was in the transform node list
  35170. */
  35171. removeTransformNode(toRemove: TransformNode): number;
  35172. /**
  35173. * Remove a skeleton for the list of scene's skeletons
  35174. * @param toRemove defines the skeleton to remove
  35175. * @returns the index where the skeleton was in the skeleton list
  35176. */
  35177. removeSkeleton(toRemove: Skeleton): number;
  35178. /**
  35179. * Remove a morph target for the list of scene's morph targets
  35180. * @param toRemove defines the morph target to remove
  35181. * @returns the index where the morph target was in the morph target list
  35182. */
  35183. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35184. /**
  35185. * Remove a light for the list of scene's lights
  35186. * @param toRemove defines the light to remove
  35187. * @returns the index where the light was in the light list
  35188. */
  35189. removeLight(toRemove: Light): number;
  35190. /**
  35191. * Remove a camera for the list of scene's cameras
  35192. * @param toRemove defines the camera to remove
  35193. * @returns the index where the camera was in the camera list
  35194. */
  35195. removeCamera(toRemove: Camera): number;
  35196. /**
  35197. * Remove a particle system for the list of scene's particle systems
  35198. * @param toRemove defines the particle system to remove
  35199. * @returns the index where the particle system was in the particle system list
  35200. */
  35201. removeParticleSystem(toRemove: IParticleSystem): number;
  35202. /**
  35203. * Remove a animation for the list of scene's animations
  35204. * @param toRemove defines the animation to remove
  35205. * @returns the index where the animation was in the animation list
  35206. */
  35207. removeAnimation(toRemove: Animation): number;
  35208. /**
  35209. * Will stop the animation of the given target
  35210. * @param target - the target
  35211. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35212. * @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)
  35213. */
  35214. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35215. /**
  35216. * Removes the given animation group from this scene.
  35217. * @param toRemove The animation group to remove
  35218. * @returns The index of the removed animation group
  35219. */
  35220. removeAnimationGroup(toRemove: AnimationGroup): number;
  35221. /**
  35222. * Removes the given multi-material from this scene.
  35223. * @param toRemove The multi-material to remove
  35224. * @returns The index of the removed multi-material
  35225. */
  35226. removeMultiMaterial(toRemove: MultiMaterial): number;
  35227. /**
  35228. * Removes the given material from this scene.
  35229. * @param toRemove The material to remove
  35230. * @returns The index of the removed material
  35231. */
  35232. removeMaterial(toRemove: Material): number;
  35233. /**
  35234. * Removes the given action manager from this scene.
  35235. * @param toRemove The action manager to remove
  35236. * @returns The index of the removed action manager
  35237. */
  35238. removeActionManager(toRemove: AbstractActionManager): number;
  35239. /**
  35240. * Removes the given texture from this scene.
  35241. * @param toRemove The texture to remove
  35242. * @returns The index of the removed texture
  35243. */
  35244. removeTexture(toRemove: BaseTexture): number;
  35245. /**
  35246. * Adds the given light to this scene
  35247. * @param newLight The light to add
  35248. */
  35249. addLight(newLight: Light): void;
  35250. /**
  35251. * Sorts the list list based on light priorities
  35252. */
  35253. sortLightsByPriority(): void;
  35254. /**
  35255. * Adds the given camera to this scene
  35256. * @param newCamera The camera to add
  35257. */
  35258. addCamera(newCamera: Camera): void;
  35259. /**
  35260. * Adds the given skeleton to this scene
  35261. * @param newSkeleton The skeleton to add
  35262. */
  35263. addSkeleton(newSkeleton: Skeleton): void;
  35264. /**
  35265. * Adds the given particle system to this scene
  35266. * @param newParticleSystem The particle system to add
  35267. */
  35268. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35269. /**
  35270. * Adds the given animation to this scene
  35271. * @param newAnimation The animation to add
  35272. */
  35273. addAnimation(newAnimation: Animation): void;
  35274. /**
  35275. * Adds the given animation group to this scene.
  35276. * @param newAnimationGroup The animation group to add
  35277. */
  35278. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35279. /**
  35280. * Adds the given multi-material to this scene
  35281. * @param newMultiMaterial The multi-material to add
  35282. */
  35283. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35284. /**
  35285. * Adds the given material to this scene
  35286. * @param newMaterial The material to add
  35287. */
  35288. addMaterial(newMaterial: Material): void;
  35289. /**
  35290. * Adds the given morph target to this scene
  35291. * @param newMorphTargetManager The morph target to add
  35292. */
  35293. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35294. /**
  35295. * Adds the given geometry to this scene
  35296. * @param newGeometry The geometry to add
  35297. */
  35298. addGeometry(newGeometry: Geometry): void;
  35299. /**
  35300. * Adds the given action manager to this scene
  35301. * @param newActionManager The action manager to add
  35302. */
  35303. addActionManager(newActionManager: AbstractActionManager): void;
  35304. /**
  35305. * Adds the given texture to this scene.
  35306. * @param newTexture The texture to add
  35307. */
  35308. addTexture(newTexture: BaseTexture): void;
  35309. /**
  35310. * Switch active camera
  35311. * @param newCamera defines the new active camera
  35312. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35313. */
  35314. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35315. /**
  35316. * sets the active camera of the scene using its ID
  35317. * @param id defines the camera's ID
  35318. * @return the new active camera or null if none found.
  35319. */
  35320. setActiveCameraByID(id: string): Nullable<Camera>;
  35321. /**
  35322. * sets the active camera of the scene using its name
  35323. * @param name defines the camera's name
  35324. * @returns the new active camera or null if none found.
  35325. */
  35326. setActiveCameraByName(name: string): Nullable<Camera>;
  35327. /**
  35328. * get an animation group using its name
  35329. * @param name defines the material's name
  35330. * @return the animation group or null if none found.
  35331. */
  35332. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35333. /**
  35334. * Get a material using its unique id
  35335. * @param uniqueId defines the material's unique id
  35336. * @return the material or null if none found.
  35337. */
  35338. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35339. /**
  35340. * get a material using its id
  35341. * @param id defines the material's ID
  35342. * @return the material or null if none found.
  35343. */
  35344. getMaterialByID(id: string): Nullable<Material>;
  35345. /**
  35346. * Gets a the last added material using a given id
  35347. * @param id defines the material's ID
  35348. * @return the last material with the given id or null if none found.
  35349. */
  35350. getLastMaterialByID(id: string): Nullable<Material>;
  35351. /**
  35352. * Gets a material using its name
  35353. * @param name defines the material's name
  35354. * @return the material or null if none found.
  35355. */
  35356. getMaterialByName(name: string): Nullable<Material>;
  35357. /**
  35358. * Get a texture using its unique id
  35359. * @param uniqueId defines the texture's unique id
  35360. * @return the texture or null if none found.
  35361. */
  35362. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35363. /**
  35364. * Gets a camera using its id
  35365. * @param id defines the id to look for
  35366. * @returns the camera or null if not found
  35367. */
  35368. getCameraByID(id: string): Nullable<Camera>;
  35369. /**
  35370. * Gets a camera using its unique id
  35371. * @param uniqueId defines the unique id to look for
  35372. * @returns the camera or null if not found
  35373. */
  35374. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35375. /**
  35376. * Gets a camera using its name
  35377. * @param name defines the camera's name
  35378. * @return the camera or null if none found.
  35379. */
  35380. getCameraByName(name: string): Nullable<Camera>;
  35381. /**
  35382. * Gets a bone using its id
  35383. * @param id defines the bone's id
  35384. * @return the bone or null if not found
  35385. */
  35386. getBoneByID(id: string): Nullable<Bone>;
  35387. /**
  35388. * Gets a bone using its id
  35389. * @param name defines the bone's name
  35390. * @return the bone or null if not found
  35391. */
  35392. getBoneByName(name: string): Nullable<Bone>;
  35393. /**
  35394. * Gets a light node using its name
  35395. * @param name defines the the light's name
  35396. * @return the light or null if none found.
  35397. */
  35398. getLightByName(name: string): Nullable<Light>;
  35399. /**
  35400. * Gets a light node using its id
  35401. * @param id defines the light's id
  35402. * @return the light or null if none found.
  35403. */
  35404. getLightByID(id: string): Nullable<Light>;
  35405. /**
  35406. * Gets a light node using its scene-generated unique ID
  35407. * @param uniqueId defines the light's unique id
  35408. * @return the light or null if none found.
  35409. */
  35410. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35411. /**
  35412. * Gets a particle system by id
  35413. * @param id defines the particle system id
  35414. * @return the corresponding system or null if none found
  35415. */
  35416. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35417. /**
  35418. * Gets a geometry using its ID
  35419. * @param id defines the geometry's id
  35420. * @return the geometry or null if none found.
  35421. */
  35422. getGeometryByID(id: string): Nullable<Geometry>;
  35423. private _getGeometryByUniqueID;
  35424. /**
  35425. * Add a new geometry to this scene
  35426. * @param geometry defines the geometry to be added to the scene.
  35427. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35428. * @return a boolean defining if the geometry was added or not
  35429. */
  35430. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35431. /**
  35432. * Removes an existing geometry
  35433. * @param geometry defines the geometry to be removed from the scene
  35434. * @return a boolean defining if the geometry was removed or not
  35435. */
  35436. removeGeometry(geometry: Geometry): boolean;
  35437. /**
  35438. * Gets the list of geometries attached to the scene
  35439. * @returns an array of Geometry
  35440. */
  35441. getGeometries(): Geometry[];
  35442. /**
  35443. * Gets the first added mesh found of a given ID
  35444. * @param id defines the id to search for
  35445. * @return the mesh found or null if not found at all
  35446. */
  35447. getMeshByID(id: string): Nullable<AbstractMesh>;
  35448. /**
  35449. * Gets a list of meshes using their id
  35450. * @param id defines the id to search for
  35451. * @returns a list of meshes
  35452. */
  35453. getMeshesByID(id: string): Array<AbstractMesh>;
  35454. /**
  35455. * Gets the first added transform node found of a given ID
  35456. * @param id defines the id to search for
  35457. * @return the found transform node or null if not found at all.
  35458. */
  35459. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35460. /**
  35461. * Gets a transform node with its auto-generated unique id
  35462. * @param uniqueId efines the unique id to search for
  35463. * @return the found transform node or null if not found at all.
  35464. */
  35465. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35466. /**
  35467. * Gets a list of transform nodes using their id
  35468. * @param id defines the id to search for
  35469. * @returns a list of transform nodes
  35470. */
  35471. getTransformNodesByID(id: string): Array<TransformNode>;
  35472. /**
  35473. * Gets a mesh with its auto-generated unique id
  35474. * @param uniqueId defines the unique id to search for
  35475. * @return the found mesh or null if not found at all.
  35476. */
  35477. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35478. /**
  35479. * Gets a the last added mesh using a given id
  35480. * @param id defines the id to search for
  35481. * @return the found mesh or null if not found at all.
  35482. */
  35483. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35484. /**
  35485. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35486. * @param id defines the id to search for
  35487. * @return the found node or null if not found at all
  35488. */
  35489. getLastEntryByID(id: string): Nullable<Node>;
  35490. /**
  35491. * Gets a node (Mesh, Camera, Light) using a given id
  35492. * @param id defines the id to search for
  35493. * @return the found node or null if not found at all
  35494. */
  35495. getNodeByID(id: string): Nullable<Node>;
  35496. /**
  35497. * Gets a node (Mesh, Camera, Light) using a given name
  35498. * @param name defines the name to search for
  35499. * @return the found node or null if not found at all.
  35500. */
  35501. getNodeByName(name: string): Nullable<Node>;
  35502. /**
  35503. * Gets a mesh using a given name
  35504. * @param name defines the name to search for
  35505. * @return the found mesh or null if not found at all.
  35506. */
  35507. getMeshByName(name: string): Nullable<AbstractMesh>;
  35508. /**
  35509. * Gets a transform node using a given name
  35510. * @param name defines the name to search for
  35511. * @return the found transform node or null if not found at all.
  35512. */
  35513. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35514. /**
  35515. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35516. * @param id defines the id to search for
  35517. * @return the found skeleton or null if not found at all.
  35518. */
  35519. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35520. /**
  35521. * Gets a skeleton using a given auto generated unique id
  35522. * @param uniqueId defines the unique id to search for
  35523. * @return the found skeleton or null if not found at all.
  35524. */
  35525. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35526. /**
  35527. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35528. * @param id defines the id to search for
  35529. * @return the found skeleton or null if not found at all.
  35530. */
  35531. getSkeletonById(id: string): Nullable<Skeleton>;
  35532. /**
  35533. * Gets a skeleton using a given name
  35534. * @param name defines the name to search for
  35535. * @return the found skeleton or null if not found at all.
  35536. */
  35537. getSkeletonByName(name: string): Nullable<Skeleton>;
  35538. /**
  35539. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35540. * @param id defines the id to search for
  35541. * @return the found morph target manager or null if not found at all.
  35542. */
  35543. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35544. /**
  35545. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35546. * @param id defines the id to search for
  35547. * @return the found morph target or null if not found at all.
  35548. */
  35549. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35550. /**
  35551. * Gets a boolean indicating if the given mesh is active
  35552. * @param mesh defines the mesh to look for
  35553. * @returns true if the mesh is in the active list
  35554. */
  35555. isActiveMesh(mesh: AbstractMesh): boolean;
  35556. /**
  35557. * Return a unique id as a string which can serve as an identifier for the scene
  35558. */
  35559. readonly uid: string;
  35560. /**
  35561. * Add an externaly attached data from its key.
  35562. * This method call will fail and return false, if such key already exists.
  35563. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35564. * @param key the unique key that identifies the data
  35565. * @param data the data object to associate to the key for this Engine instance
  35566. * @return true if no such key were already present and the data was added successfully, false otherwise
  35567. */
  35568. addExternalData<T>(key: string, data: T): boolean;
  35569. /**
  35570. * Get an externaly attached data from its key
  35571. * @param key the unique key that identifies the data
  35572. * @return the associated data, if present (can be null), or undefined if not present
  35573. */
  35574. getExternalData<T>(key: string): Nullable<T>;
  35575. /**
  35576. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35577. * @param key the unique key that identifies the data
  35578. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35579. * @return the associated data, can be null if the factory returned null.
  35580. */
  35581. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35582. /**
  35583. * Remove an externaly attached data from the Engine instance
  35584. * @param key the unique key that identifies the data
  35585. * @return true if the data was successfully removed, false if it doesn't exist
  35586. */
  35587. removeExternalData(key: string): boolean;
  35588. private _evaluateSubMesh;
  35589. /**
  35590. * Clear the processed materials smart array preventing retention point in material dispose.
  35591. */
  35592. freeProcessedMaterials(): void;
  35593. private _preventFreeActiveMeshesAndRenderingGroups;
  35594. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35595. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35596. * when disposing several meshes in a row or a hierarchy of meshes.
  35597. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35598. */
  35599. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35600. /**
  35601. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35602. */
  35603. freeActiveMeshes(): void;
  35604. /**
  35605. * Clear the info related to rendering groups preventing retention points during dispose.
  35606. */
  35607. freeRenderingGroups(): void;
  35608. /** @hidden */
  35609. _isInIntermediateRendering(): boolean;
  35610. /**
  35611. * Lambda returning the list of potentially active meshes.
  35612. */
  35613. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35614. /**
  35615. * Lambda returning the list of potentially active sub meshes.
  35616. */
  35617. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35618. /**
  35619. * Lambda returning the list of potentially intersecting sub meshes.
  35620. */
  35621. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35622. /**
  35623. * Lambda returning the list of potentially colliding sub meshes.
  35624. */
  35625. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35626. private _activeMeshesFrozen;
  35627. /**
  35628. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35629. * @returns the current scene
  35630. */
  35631. freezeActiveMeshes(): Scene;
  35632. /**
  35633. * Use this function to restart evaluating active meshes on every frame
  35634. * @returns the current scene
  35635. */
  35636. unfreezeActiveMeshes(): Scene;
  35637. private _evaluateActiveMeshes;
  35638. private _activeMesh;
  35639. /**
  35640. * Update the transform matrix to update from the current active camera
  35641. * @param force defines a boolean used to force the update even if cache is up to date
  35642. */
  35643. updateTransformMatrix(force?: boolean): void;
  35644. private _bindFrameBuffer;
  35645. /** @hidden */
  35646. _allowPostProcessClearColor: boolean;
  35647. /** @hidden */
  35648. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35649. private _processSubCameras;
  35650. private _checkIntersections;
  35651. /** @hidden */
  35652. _advancePhysicsEngineStep(step: number): void;
  35653. /**
  35654. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35655. */
  35656. getDeterministicFrameTime: () => number;
  35657. /** @hidden */
  35658. _animate(): void;
  35659. /** Execute all animations (for a frame) */
  35660. animate(): void;
  35661. /**
  35662. * Render the scene
  35663. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35664. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35665. */
  35666. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35667. /**
  35668. * Freeze all materials
  35669. * A frozen material will not be updatable but should be faster to render
  35670. */
  35671. freezeMaterials(): void;
  35672. /**
  35673. * Unfreeze all materials
  35674. * A frozen material will not be updatable but should be faster to render
  35675. */
  35676. unfreezeMaterials(): void;
  35677. /**
  35678. * Releases all held ressources
  35679. */
  35680. dispose(): void;
  35681. /**
  35682. * Gets if the scene is already disposed
  35683. */
  35684. readonly isDisposed: boolean;
  35685. /**
  35686. * Call this function to reduce memory footprint of the scene.
  35687. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35688. */
  35689. clearCachedVertexData(): void;
  35690. /**
  35691. * This function will remove the local cached buffer data from texture.
  35692. * It will save memory but will prevent the texture from being rebuilt
  35693. */
  35694. cleanCachedTextureBuffer(): void;
  35695. /**
  35696. * Get the world extend vectors with an optional filter
  35697. *
  35698. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35699. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35700. */
  35701. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35702. min: Vector3;
  35703. max: Vector3;
  35704. };
  35705. /**
  35706. * Creates a ray that can be used to pick in the scene
  35707. * @param x defines the x coordinate of the origin (on-screen)
  35708. * @param y defines the y coordinate of the origin (on-screen)
  35709. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35710. * @param camera defines the camera to use for the picking
  35711. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35712. * @returns a Ray
  35713. */
  35714. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35715. /**
  35716. * Creates a ray that can be used to pick in the scene
  35717. * @param x defines the x coordinate of the origin (on-screen)
  35718. * @param y defines the y coordinate of the origin (on-screen)
  35719. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35720. * @param result defines the ray where to store the picking ray
  35721. * @param camera defines the camera to use for the picking
  35722. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35723. * @returns the current scene
  35724. */
  35725. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35726. /**
  35727. * Creates a ray that can be used to pick in the scene
  35728. * @param x defines the x coordinate of the origin (on-screen)
  35729. * @param y defines the y coordinate of the origin (on-screen)
  35730. * @param camera defines the camera to use for the picking
  35731. * @returns a Ray
  35732. */
  35733. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35734. /**
  35735. * Creates a ray that can be used to pick in the scene
  35736. * @param x defines the x coordinate of the origin (on-screen)
  35737. * @param y defines the y coordinate of the origin (on-screen)
  35738. * @param result defines the ray where to store the picking ray
  35739. * @param camera defines the camera to use for the picking
  35740. * @returns the current scene
  35741. */
  35742. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35743. /** Launch a ray to try to pick a mesh in the scene
  35744. * @param x position on screen
  35745. * @param y position on screen
  35746. * @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
  35747. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35748. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35749. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35750. * @returns a PickingInfo
  35751. */
  35752. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35753. /** Use the given ray to pick a mesh in the scene
  35754. * @param ray The ray to use to pick meshes
  35755. * @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
  35756. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35757. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35758. * @returns a PickingInfo
  35759. */
  35760. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35761. /**
  35762. * Launch a ray to try to pick a mesh in the scene
  35763. * @param x X position on screen
  35764. * @param y Y position on screen
  35765. * @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
  35766. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35767. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35768. * @returns an array of PickingInfo
  35769. */
  35770. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35771. /**
  35772. * Launch a ray to try to pick a mesh in the scene
  35773. * @param ray Ray to use
  35774. * @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
  35775. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35776. * @returns an array of PickingInfo
  35777. */
  35778. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35779. /**
  35780. * Force the value of meshUnderPointer
  35781. * @param mesh defines the mesh to use
  35782. */
  35783. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35784. /**
  35785. * Gets the mesh under the pointer
  35786. * @returns a Mesh or null if no mesh is under the pointer
  35787. */
  35788. getPointerOverMesh(): Nullable<AbstractMesh>;
  35789. /** @hidden */
  35790. _rebuildGeometries(): void;
  35791. /** @hidden */
  35792. _rebuildTextures(): void;
  35793. private _getByTags;
  35794. /**
  35795. * Get a list of meshes by tags
  35796. * @param tagsQuery defines the tags query to use
  35797. * @param forEach defines a predicate used to filter results
  35798. * @returns an array of Mesh
  35799. */
  35800. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35801. /**
  35802. * Get a list of cameras by tags
  35803. * @param tagsQuery defines the tags query to use
  35804. * @param forEach defines a predicate used to filter results
  35805. * @returns an array of Camera
  35806. */
  35807. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35808. /**
  35809. * Get a list of lights by tags
  35810. * @param tagsQuery defines the tags query to use
  35811. * @param forEach defines a predicate used to filter results
  35812. * @returns an array of Light
  35813. */
  35814. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35815. /**
  35816. * Get a list of materials by tags
  35817. * @param tagsQuery defines the tags query to use
  35818. * @param forEach defines a predicate used to filter results
  35819. * @returns an array of Material
  35820. */
  35821. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35822. /**
  35823. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35824. * This allowed control for front to back rendering or reversly depending of the special needs.
  35825. *
  35826. * @param renderingGroupId The rendering group id corresponding to its index
  35827. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35828. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35829. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35830. */
  35831. 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;
  35832. /**
  35833. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35834. *
  35835. * @param renderingGroupId The rendering group id corresponding to its index
  35836. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35837. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35838. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35839. */
  35840. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35841. /**
  35842. * Gets the current auto clear configuration for one rendering group of the rendering
  35843. * manager.
  35844. * @param index the rendering group index to get the information for
  35845. * @returns The auto clear setup for the requested rendering group
  35846. */
  35847. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35848. private _blockMaterialDirtyMechanism;
  35849. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35850. blockMaterialDirtyMechanism: boolean;
  35851. /**
  35852. * Will flag all materials as dirty to trigger new shader compilation
  35853. * @param flag defines the flag used to specify which material part must be marked as dirty
  35854. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35855. */
  35856. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35857. /** @hidden */
  35858. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  35859. /** @hidden */
  35860. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35861. /** @hidden */
  35862. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  35863. /** @hidden */
  35864. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  35865. /** @hidden */
  35866. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35867. /** @hidden */
  35868. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35869. }
  35870. }
  35871. declare module "babylonjs/assetContainer" {
  35872. import { AbstractScene } from "babylonjs/abstractScene";
  35873. import { Scene } from "babylonjs/scene";
  35874. import { Mesh } from "babylonjs/Meshes/mesh";
  35875. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35876. import { Skeleton } from "babylonjs/Bones/skeleton";
  35877. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35878. /**
  35879. * Set of assets to keep when moving a scene into an asset container.
  35880. */
  35881. export class KeepAssets extends AbstractScene {
  35882. }
  35883. /**
  35884. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  35885. */
  35886. export class InstantiatedEntries {
  35887. /**
  35888. * List of new root nodes (eg. nodes with no parent)
  35889. */
  35890. rootNodes: TransformNode[];
  35891. /**
  35892. * List of new skeletons
  35893. */
  35894. skeletons: Skeleton[];
  35895. /**
  35896. * List of new animation groups
  35897. */
  35898. animationGroups: AnimationGroup[];
  35899. }
  35900. /**
  35901. * Container with a set of assets that can be added or removed from a scene.
  35902. */
  35903. export class AssetContainer extends AbstractScene {
  35904. /**
  35905. * The scene the AssetContainer belongs to.
  35906. */
  35907. scene: Scene;
  35908. /**
  35909. * Instantiates an AssetContainer.
  35910. * @param scene The scene the AssetContainer belongs to.
  35911. */
  35912. constructor(scene: Scene);
  35913. /**
  35914. * Instantiate or clone all meshes and add the new ones to the scene.
  35915. * Skeletons and animation groups will all be cloned
  35916. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  35917. */
  35918. instantiateModelsToScene(): InstantiatedEntries;
  35919. /**
  35920. * Adds all the assets from the container to the scene.
  35921. */
  35922. addAllToScene(): void;
  35923. /**
  35924. * Removes all the assets in the container from the scene
  35925. */
  35926. removeAllFromScene(): void;
  35927. /**
  35928. * Disposes all the assets in the container
  35929. */
  35930. dispose(): void;
  35931. private _moveAssets;
  35932. /**
  35933. * Removes all the assets contained in the scene and adds them to the container.
  35934. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35935. */
  35936. moveAllFromScene(keepAssets?: KeepAssets): void;
  35937. /**
  35938. * 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.
  35939. * @returns the root mesh
  35940. */
  35941. createRootMesh(): Mesh;
  35942. }
  35943. }
  35944. declare module "babylonjs/abstractScene" {
  35945. import { Scene } from "babylonjs/scene";
  35946. import { Nullable } from "babylonjs/types";
  35947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35949. import { Geometry } from "babylonjs/Meshes/geometry";
  35950. import { Skeleton } from "babylonjs/Bones/skeleton";
  35951. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35952. import { AssetContainer } from "babylonjs/assetContainer";
  35953. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35954. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35956. import { Material } from "babylonjs/Materials/material";
  35957. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35958. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35959. import { Camera } from "babylonjs/Cameras/camera";
  35960. import { Light } from "babylonjs/Lights/light";
  35961. import { Node } from "babylonjs/node";
  35962. import { Animation } from "babylonjs/Animations/animation";
  35963. /**
  35964. * Defines how the parser contract is defined.
  35965. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35966. */
  35967. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35968. /**
  35969. * Defines how the individual parser contract is defined.
  35970. * These parser can parse an individual asset
  35971. */
  35972. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35973. /**
  35974. * Base class of the scene acting as a container for the different elements composing a scene.
  35975. * This class is dynamically extended by the different components of the scene increasing
  35976. * flexibility and reducing coupling
  35977. */
  35978. export abstract class AbstractScene {
  35979. /**
  35980. * Stores the list of available parsers in the application.
  35981. */
  35982. private static _BabylonFileParsers;
  35983. /**
  35984. * Stores the list of available individual parsers in the application.
  35985. */
  35986. private static _IndividualBabylonFileParsers;
  35987. /**
  35988. * Adds a parser in the list of available ones
  35989. * @param name Defines the name of the parser
  35990. * @param parser Defines the parser to add
  35991. */
  35992. static AddParser(name: string, parser: BabylonFileParser): void;
  35993. /**
  35994. * Gets a general parser from the list of avaialble ones
  35995. * @param name Defines the name of the parser
  35996. * @returns the requested parser or null
  35997. */
  35998. static GetParser(name: string): Nullable<BabylonFileParser>;
  35999. /**
  36000. * Adds n individual parser in the list of available ones
  36001. * @param name Defines the name of the parser
  36002. * @param parser Defines the parser to add
  36003. */
  36004. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36005. /**
  36006. * Gets an individual parser from the list of avaialble ones
  36007. * @param name Defines the name of the parser
  36008. * @returns the requested parser or null
  36009. */
  36010. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36011. /**
  36012. * Parser json data and populate both a scene and its associated container object
  36013. * @param jsonData Defines the data to parse
  36014. * @param scene Defines the scene to parse the data for
  36015. * @param container Defines the container attached to the parsing sequence
  36016. * @param rootUrl Defines the root url of the data
  36017. */
  36018. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36019. /**
  36020. * Gets the list of root nodes (ie. nodes with no parent)
  36021. */
  36022. rootNodes: Node[];
  36023. /** All of the cameras added to this scene
  36024. * @see http://doc.babylonjs.com/babylon101/cameras
  36025. */
  36026. cameras: Camera[];
  36027. /**
  36028. * All of the lights added to this scene
  36029. * @see http://doc.babylonjs.com/babylon101/lights
  36030. */
  36031. lights: Light[];
  36032. /**
  36033. * All of the (abstract) meshes added to this scene
  36034. */
  36035. meshes: AbstractMesh[];
  36036. /**
  36037. * The list of skeletons added to the scene
  36038. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36039. */
  36040. skeletons: Skeleton[];
  36041. /**
  36042. * All of the particle systems added to this scene
  36043. * @see http://doc.babylonjs.com/babylon101/particles
  36044. */
  36045. particleSystems: IParticleSystem[];
  36046. /**
  36047. * Gets a list of Animations associated with the scene
  36048. */
  36049. animations: Animation[];
  36050. /**
  36051. * All of the animation groups added to this scene
  36052. * @see http://doc.babylonjs.com/how_to/group
  36053. */
  36054. animationGroups: AnimationGroup[];
  36055. /**
  36056. * All of the multi-materials added to this scene
  36057. * @see http://doc.babylonjs.com/how_to/multi_materials
  36058. */
  36059. multiMaterials: MultiMaterial[];
  36060. /**
  36061. * All of the materials added to this scene
  36062. * In the context of a Scene, it is not supposed to be modified manually.
  36063. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36064. * Note also that the order of the Material within the array is not significant and might change.
  36065. * @see http://doc.babylonjs.com/babylon101/materials
  36066. */
  36067. materials: Material[];
  36068. /**
  36069. * The list of morph target managers added to the scene
  36070. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36071. */
  36072. morphTargetManagers: MorphTargetManager[];
  36073. /**
  36074. * The list of geometries used in the scene.
  36075. */
  36076. geometries: Geometry[];
  36077. /**
  36078. * All of the tranform nodes added to this scene
  36079. * In the context of a Scene, it is not supposed to be modified manually.
  36080. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36081. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36082. * @see http://doc.babylonjs.com/how_to/transformnode
  36083. */
  36084. transformNodes: TransformNode[];
  36085. /**
  36086. * ActionManagers available on the scene.
  36087. */
  36088. actionManagers: AbstractActionManager[];
  36089. /**
  36090. * Textures to keep.
  36091. */
  36092. textures: BaseTexture[];
  36093. /**
  36094. * Environment texture for the scene
  36095. */
  36096. environmentTexture: Nullable<BaseTexture>;
  36097. }
  36098. }
  36099. declare module "babylonjs/Audio/sound" {
  36100. import { Observable } from "babylonjs/Misc/observable";
  36101. import { Vector3 } from "babylonjs/Maths/math.vector";
  36102. import { Nullable } from "babylonjs/types";
  36103. import { Scene } from "babylonjs/scene";
  36104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36105. /**
  36106. * Interface used to define options for Sound class
  36107. */
  36108. export interface ISoundOptions {
  36109. /**
  36110. * Does the sound autoplay once loaded.
  36111. */
  36112. autoplay?: boolean;
  36113. /**
  36114. * Does the sound loop after it finishes playing once.
  36115. */
  36116. loop?: boolean;
  36117. /**
  36118. * Sound's volume
  36119. */
  36120. volume?: number;
  36121. /**
  36122. * Is it a spatial sound?
  36123. */
  36124. spatialSound?: boolean;
  36125. /**
  36126. * Maximum distance to hear that sound
  36127. */
  36128. maxDistance?: number;
  36129. /**
  36130. * Uses user defined attenuation function
  36131. */
  36132. useCustomAttenuation?: boolean;
  36133. /**
  36134. * Define the roll off factor of spatial sounds.
  36135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36136. */
  36137. rolloffFactor?: number;
  36138. /**
  36139. * Define the reference distance the sound should be heard perfectly.
  36140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36141. */
  36142. refDistance?: number;
  36143. /**
  36144. * Define the distance attenuation model the sound will follow.
  36145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36146. */
  36147. distanceModel?: string;
  36148. /**
  36149. * Defines the playback speed (1 by default)
  36150. */
  36151. playbackRate?: number;
  36152. /**
  36153. * Defines if the sound is from a streaming source
  36154. */
  36155. streaming?: boolean;
  36156. /**
  36157. * Defines an optional length (in seconds) inside the sound file
  36158. */
  36159. length?: number;
  36160. /**
  36161. * Defines an optional offset (in seconds) inside the sound file
  36162. */
  36163. offset?: number;
  36164. /**
  36165. * If true, URLs will not be required to state the audio file codec to use.
  36166. */
  36167. skipCodecCheck?: boolean;
  36168. }
  36169. /**
  36170. * Defines a sound that can be played in the application.
  36171. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36172. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36173. */
  36174. export class Sound {
  36175. /**
  36176. * The name of the sound in the scene.
  36177. */
  36178. name: string;
  36179. /**
  36180. * Does the sound autoplay once loaded.
  36181. */
  36182. autoplay: boolean;
  36183. /**
  36184. * Does the sound loop after it finishes playing once.
  36185. */
  36186. loop: boolean;
  36187. /**
  36188. * Does the sound use a custom attenuation curve to simulate the falloff
  36189. * happening when the source gets further away from the camera.
  36190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36191. */
  36192. useCustomAttenuation: boolean;
  36193. /**
  36194. * The sound track id this sound belongs to.
  36195. */
  36196. soundTrackId: number;
  36197. /**
  36198. * Is this sound currently played.
  36199. */
  36200. isPlaying: boolean;
  36201. /**
  36202. * Is this sound currently paused.
  36203. */
  36204. isPaused: boolean;
  36205. /**
  36206. * Does this sound enables spatial sound.
  36207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36208. */
  36209. spatialSound: boolean;
  36210. /**
  36211. * Define the reference distance the sound should be heard perfectly.
  36212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36213. */
  36214. refDistance: number;
  36215. /**
  36216. * Define the roll off factor of spatial sounds.
  36217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36218. */
  36219. rolloffFactor: number;
  36220. /**
  36221. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36223. */
  36224. maxDistance: number;
  36225. /**
  36226. * Define the distance attenuation model the sound will follow.
  36227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36228. */
  36229. distanceModel: string;
  36230. /**
  36231. * @hidden
  36232. * Back Compat
  36233. **/
  36234. onended: () => any;
  36235. /**
  36236. * Observable event when the current playing sound finishes.
  36237. */
  36238. onEndedObservable: Observable<Sound>;
  36239. private _panningModel;
  36240. private _playbackRate;
  36241. private _streaming;
  36242. private _startTime;
  36243. private _startOffset;
  36244. private _position;
  36245. /** @hidden */
  36246. _positionInEmitterSpace: boolean;
  36247. private _localDirection;
  36248. private _volume;
  36249. private _isReadyToPlay;
  36250. private _isDirectional;
  36251. private _readyToPlayCallback;
  36252. private _audioBuffer;
  36253. private _soundSource;
  36254. private _streamingSource;
  36255. private _soundPanner;
  36256. private _soundGain;
  36257. private _inputAudioNode;
  36258. private _outputAudioNode;
  36259. private _coneInnerAngle;
  36260. private _coneOuterAngle;
  36261. private _coneOuterGain;
  36262. private _scene;
  36263. private _connectedTransformNode;
  36264. private _customAttenuationFunction;
  36265. private _registerFunc;
  36266. private _isOutputConnected;
  36267. private _htmlAudioElement;
  36268. private _urlType;
  36269. private _length?;
  36270. private _offset?;
  36271. /** @hidden */
  36272. static _SceneComponentInitialization: (scene: Scene) => void;
  36273. /**
  36274. * Create a sound and attach it to a scene
  36275. * @param name Name of your sound
  36276. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36277. * @param scene defines the scene the sound belongs to
  36278. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36279. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36280. */
  36281. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36282. /**
  36283. * Release the sound and its associated resources
  36284. */
  36285. dispose(): void;
  36286. /**
  36287. * Gets if the sounds is ready to be played or not.
  36288. * @returns true if ready, otherwise false
  36289. */
  36290. isReady(): boolean;
  36291. private _soundLoaded;
  36292. /**
  36293. * Sets the data of the sound from an audiobuffer
  36294. * @param audioBuffer The audioBuffer containing the data
  36295. */
  36296. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36297. /**
  36298. * Updates the current sounds options such as maxdistance, loop...
  36299. * @param options A JSON object containing values named as the object properties
  36300. */
  36301. updateOptions(options: ISoundOptions): void;
  36302. private _createSpatialParameters;
  36303. private _updateSpatialParameters;
  36304. /**
  36305. * Switch the panning model to HRTF:
  36306. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36308. */
  36309. switchPanningModelToHRTF(): void;
  36310. /**
  36311. * Switch the panning model to Equal Power:
  36312. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36314. */
  36315. switchPanningModelToEqualPower(): void;
  36316. private _switchPanningModel;
  36317. /**
  36318. * Connect this sound to a sound track audio node like gain...
  36319. * @param soundTrackAudioNode the sound track audio node to connect to
  36320. */
  36321. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36322. /**
  36323. * Transform this sound into a directional source
  36324. * @param coneInnerAngle Size of the inner cone in degree
  36325. * @param coneOuterAngle Size of the outer cone in degree
  36326. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36327. */
  36328. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36329. /**
  36330. * Gets or sets the inner angle for the directional cone.
  36331. */
  36332. /**
  36333. * Gets or sets the inner angle for the directional cone.
  36334. */
  36335. directionalConeInnerAngle: number;
  36336. /**
  36337. * Gets or sets the outer angle for the directional cone.
  36338. */
  36339. /**
  36340. * Gets or sets the outer angle for the directional cone.
  36341. */
  36342. directionalConeOuterAngle: number;
  36343. /**
  36344. * Sets the position of the emitter if spatial sound is enabled
  36345. * @param newPosition Defines the new posisiton
  36346. */
  36347. setPosition(newPosition: Vector3): void;
  36348. /**
  36349. * Sets the local direction of the emitter if spatial sound is enabled
  36350. * @param newLocalDirection Defines the new local direction
  36351. */
  36352. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36353. private _updateDirection;
  36354. /** @hidden */
  36355. updateDistanceFromListener(): void;
  36356. /**
  36357. * Sets a new custom attenuation function for the sound.
  36358. * @param callback Defines the function used for the attenuation
  36359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36360. */
  36361. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36362. /**
  36363. * Play the sound
  36364. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36365. * @param offset (optional) Start the sound at a specific time in seconds
  36366. * @param length (optional) Sound duration (in seconds)
  36367. */
  36368. play(time?: number, offset?: number, length?: number): void;
  36369. private _onended;
  36370. /**
  36371. * Stop the sound
  36372. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36373. */
  36374. stop(time?: number): void;
  36375. /**
  36376. * Put the sound in pause
  36377. */
  36378. pause(): void;
  36379. /**
  36380. * Sets a dedicated volume for this sounds
  36381. * @param newVolume Define the new volume of the sound
  36382. * @param time Define time for gradual change to new volume
  36383. */
  36384. setVolume(newVolume: number, time?: number): void;
  36385. /**
  36386. * Set the sound play back rate
  36387. * @param newPlaybackRate Define the playback rate the sound should be played at
  36388. */
  36389. setPlaybackRate(newPlaybackRate: number): void;
  36390. /**
  36391. * Gets the volume of the sound.
  36392. * @returns the volume of the sound
  36393. */
  36394. getVolume(): number;
  36395. /**
  36396. * Attach the sound to a dedicated mesh
  36397. * @param transformNode The transform node to connect the sound with
  36398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36399. */
  36400. attachToMesh(transformNode: TransformNode): void;
  36401. /**
  36402. * Detach the sound from the previously attached mesh
  36403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36404. */
  36405. detachFromMesh(): void;
  36406. private _onRegisterAfterWorldMatrixUpdate;
  36407. /**
  36408. * Clone the current sound in the scene.
  36409. * @returns the new sound clone
  36410. */
  36411. clone(): Nullable<Sound>;
  36412. /**
  36413. * Gets the current underlying audio buffer containing the data
  36414. * @returns the audio buffer
  36415. */
  36416. getAudioBuffer(): Nullable<AudioBuffer>;
  36417. /**
  36418. * Serializes the Sound in a JSON representation
  36419. * @returns the JSON representation of the sound
  36420. */
  36421. serialize(): any;
  36422. /**
  36423. * Parse a JSON representation of a sound to innstantiate in a given scene
  36424. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36425. * @param scene Define the scene the new parsed sound should be created in
  36426. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36427. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36428. * @returns the newly parsed sound
  36429. */
  36430. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36431. }
  36432. }
  36433. declare module "babylonjs/Actions/directAudioActions" {
  36434. import { Action } from "babylonjs/Actions/action";
  36435. import { Condition } from "babylonjs/Actions/condition";
  36436. import { Sound } from "babylonjs/Audio/sound";
  36437. /**
  36438. * This defines an action helpful to play a defined sound on a triggered action.
  36439. */
  36440. export class PlaySoundAction extends Action {
  36441. private _sound;
  36442. /**
  36443. * Instantiate the action
  36444. * @param triggerOptions defines the trigger options
  36445. * @param sound defines the sound to play
  36446. * @param condition defines the trigger related conditions
  36447. */
  36448. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36449. /** @hidden */
  36450. _prepare(): void;
  36451. /**
  36452. * Execute the action and play the sound.
  36453. */
  36454. execute(): void;
  36455. /**
  36456. * Serializes the actions and its related information.
  36457. * @param parent defines the object to serialize in
  36458. * @returns the serialized object
  36459. */
  36460. serialize(parent: any): any;
  36461. }
  36462. /**
  36463. * This defines an action helpful to stop a defined sound on a triggered action.
  36464. */
  36465. export class StopSoundAction extends Action {
  36466. private _sound;
  36467. /**
  36468. * Instantiate the action
  36469. * @param triggerOptions defines the trigger options
  36470. * @param sound defines the sound to stop
  36471. * @param condition defines the trigger related conditions
  36472. */
  36473. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36474. /** @hidden */
  36475. _prepare(): void;
  36476. /**
  36477. * Execute the action and stop the sound.
  36478. */
  36479. execute(): void;
  36480. /**
  36481. * Serializes the actions and its related information.
  36482. * @param parent defines the object to serialize in
  36483. * @returns the serialized object
  36484. */
  36485. serialize(parent: any): any;
  36486. }
  36487. }
  36488. declare module "babylonjs/Actions/interpolateValueAction" {
  36489. import { Action } from "babylonjs/Actions/action";
  36490. import { Condition } from "babylonjs/Actions/condition";
  36491. import { Observable } from "babylonjs/Misc/observable";
  36492. /**
  36493. * This defines an action responsible to change the value of a property
  36494. * by interpolating between its current value and the newly set one once triggered.
  36495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36496. */
  36497. export class InterpolateValueAction extends Action {
  36498. /**
  36499. * Defines the path of the property where the value should be interpolated
  36500. */
  36501. propertyPath: string;
  36502. /**
  36503. * Defines the target value at the end of the interpolation.
  36504. */
  36505. value: any;
  36506. /**
  36507. * Defines the time it will take for the property to interpolate to the value.
  36508. */
  36509. duration: number;
  36510. /**
  36511. * Defines if the other scene animations should be stopped when the action has been triggered
  36512. */
  36513. stopOtherAnimations?: boolean;
  36514. /**
  36515. * Defines a callback raised once the interpolation animation has been done.
  36516. */
  36517. onInterpolationDone?: () => void;
  36518. /**
  36519. * Observable triggered once the interpolation animation has been done.
  36520. */
  36521. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36522. private _target;
  36523. private _effectiveTarget;
  36524. private _property;
  36525. /**
  36526. * Instantiate the action
  36527. * @param triggerOptions defines the trigger options
  36528. * @param target defines the object containing the value to interpolate
  36529. * @param propertyPath defines the path to the property in the target object
  36530. * @param value defines the target value at the end of the interpolation
  36531. * @param duration deines the time it will take for the property to interpolate to the value.
  36532. * @param condition defines the trigger related conditions
  36533. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36534. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36535. */
  36536. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36537. /** @hidden */
  36538. _prepare(): void;
  36539. /**
  36540. * Execute the action starts the value interpolation.
  36541. */
  36542. execute(): void;
  36543. /**
  36544. * Serializes the actions and its related information.
  36545. * @param parent defines the object to serialize in
  36546. * @returns the serialized object
  36547. */
  36548. serialize(parent: any): any;
  36549. }
  36550. }
  36551. declare module "babylonjs/Actions/index" {
  36552. export * from "babylonjs/Actions/abstractActionManager";
  36553. export * from "babylonjs/Actions/action";
  36554. export * from "babylonjs/Actions/actionEvent";
  36555. export * from "babylonjs/Actions/actionManager";
  36556. export * from "babylonjs/Actions/condition";
  36557. export * from "babylonjs/Actions/directActions";
  36558. export * from "babylonjs/Actions/directAudioActions";
  36559. export * from "babylonjs/Actions/interpolateValueAction";
  36560. }
  36561. declare module "babylonjs/Animations/index" {
  36562. export * from "babylonjs/Animations/animatable";
  36563. export * from "babylonjs/Animations/animation";
  36564. export * from "babylonjs/Animations/animationGroup";
  36565. export * from "babylonjs/Animations/animationPropertiesOverride";
  36566. export * from "babylonjs/Animations/easing";
  36567. export * from "babylonjs/Animations/runtimeAnimation";
  36568. export * from "babylonjs/Animations/animationEvent";
  36569. export * from "babylonjs/Animations/animationGroup";
  36570. export * from "babylonjs/Animations/animationKey";
  36571. export * from "babylonjs/Animations/animationRange";
  36572. export * from "babylonjs/Animations/animatable.interface";
  36573. }
  36574. declare module "babylonjs/Audio/soundTrack" {
  36575. import { Sound } from "babylonjs/Audio/sound";
  36576. import { Analyser } from "babylonjs/Audio/analyser";
  36577. import { Scene } from "babylonjs/scene";
  36578. /**
  36579. * Options allowed during the creation of a sound track.
  36580. */
  36581. export interface ISoundTrackOptions {
  36582. /**
  36583. * The volume the sound track should take during creation
  36584. */
  36585. volume?: number;
  36586. /**
  36587. * Define if the sound track is the main sound track of the scene
  36588. */
  36589. mainTrack?: boolean;
  36590. }
  36591. /**
  36592. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36593. * It will be also used in a future release to apply effects on a specific track.
  36594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36595. */
  36596. export class SoundTrack {
  36597. /**
  36598. * The unique identifier of the sound track in the scene.
  36599. */
  36600. id: number;
  36601. /**
  36602. * The list of sounds included in the sound track.
  36603. */
  36604. soundCollection: Array<Sound>;
  36605. private _outputAudioNode;
  36606. private _scene;
  36607. private _isMainTrack;
  36608. private _connectedAnalyser;
  36609. private _options;
  36610. private _isInitialized;
  36611. /**
  36612. * Creates a new sound track.
  36613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36614. * @param scene Define the scene the sound track belongs to
  36615. * @param options
  36616. */
  36617. constructor(scene: Scene, options?: ISoundTrackOptions);
  36618. private _initializeSoundTrackAudioGraph;
  36619. /**
  36620. * Release the sound track and its associated resources
  36621. */
  36622. dispose(): void;
  36623. /**
  36624. * Adds a sound to this sound track
  36625. * @param sound define the cound to add
  36626. * @ignoreNaming
  36627. */
  36628. AddSound(sound: Sound): void;
  36629. /**
  36630. * Removes a sound to this sound track
  36631. * @param sound define the cound to remove
  36632. * @ignoreNaming
  36633. */
  36634. RemoveSound(sound: Sound): void;
  36635. /**
  36636. * Set a global volume for the full sound track.
  36637. * @param newVolume Define the new volume of the sound track
  36638. */
  36639. setVolume(newVolume: number): void;
  36640. /**
  36641. * Switch the panning model to HRTF:
  36642. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36644. */
  36645. switchPanningModelToHRTF(): void;
  36646. /**
  36647. * Switch the panning model to Equal Power:
  36648. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36650. */
  36651. switchPanningModelToEqualPower(): void;
  36652. /**
  36653. * Connect the sound track to an audio analyser allowing some amazing
  36654. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36656. * @param analyser The analyser to connect to the engine
  36657. */
  36658. connectToAnalyser(analyser: Analyser): void;
  36659. }
  36660. }
  36661. declare module "babylonjs/Audio/audioSceneComponent" {
  36662. import { Sound } from "babylonjs/Audio/sound";
  36663. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36664. import { Nullable } from "babylonjs/types";
  36665. import { Vector3 } from "babylonjs/Maths/math.vector";
  36666. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36667. import { Scene } from "babylonjs/scene";
  36668. import { AbstractScene } from "babylonjs/abstractScene";
  36669. import "babylonjs/Audio/audioEngine";
  36670. module "babylonjs/abstractScene" {
  36671. interface AbstractScene {
  36672. /**
  36673. * The list of sounds used in the scene.
  36674. */
  36675. sounds: Nullable<Array<Sound>>;
  36676. }
  36677. }
  36678. module "babylonjs/scene" {
  36679. interface Scene {
  36680. /**
  36681. * @hidden
  36682. * Backing field
  36683. */
  36684. _mainSoundTrack: SoundTrack;
  36685. /**
  36686. * The main sound track played by the scene.
  36687. * It cotains your primary collection of sounds.
  36688. */
  36689. mainSoundTrack: SoundTrack;
  36690. /**
  36691. * The list of sound tracks added to the scene
  36692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36693. */
  36694. soundTracks: Nullable<Array<SoundTrack>>;
  36695. /**
  36696. * Gets a sound using a given name
  36697. * @param name defines the name to search for
  36698. * @return the found sound or null if not found at all.
  36699. */
  36700. getSoundByName(name: string): Nullable<Sound>;
  36701. /**
  36702. * Gets or sets if audio support is enabled
  36703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36704. */
  36705. audioEnabled: boolean;
  36706. /**
  36707. * Gets or sets if audio will be output to headphones
  36708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36709. */
  36710. headphone: boolean;
  36711. /**
  36712. * Gets or sets custom audio listener position provider
  36713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36714. */
  36715. audioListenerPositionProvider: Nullable<() => Vector3>;
  36716. /**
  36717. * Gets or sets a refresh rate when using 3D audio positioning
  36718. */
  36719. audioPositioningRefreshRate: number;
  36720. }
  36721. }
  36722. /**
  36723. * Defines the sound scene component responsible to manage any sounds
  36724. * in a given scene.
  36725. */
  36726. export class AudioSceneComponent implements ISceneSerializableComponent {
  36727. /**
  36728. * The component name helpfull to identify the component in the list of scene components.
  36729. */
  36730. readonly name: string;
  36731. /**
  36732. * The scene the component belongs to.
  36733. */
  36734. scene: Scene;
  36735. private _audioEnabled;
  36736. /**
  36737. * Gets whether audio is enabled or not.
  36738. * Please use related enable/disable method to switch state.
  36739. */
  36740. readonly audioEnabled: boolean;
  36741. private _headphone;
  36742. /**
  36743. * Gets whether audio is outputing to headphone or not.
  36744. * Please use the according Switch methods to change output.
  36745. */
  36746. readonly headphone: boolean;
  36747. /**
  36748. * Gets or sets a refresh rate when using 3D audio positioning
  36749. */
  36750. audioPositioningRefreshRate: number;
  36751. private _audioListenerPositionProvider;
  36752. /**
  36753. * Gets the current audio listener position provider
  36754. */
  36755. /**
  36756. * Sets a custom listener position for all sounds in the scene
  36757. * By default, this is the position of the first active camera
  36758. */
  36759. audioListenerPositionProvider: Nullable<() => Vector3>;
  36760. /**
  36761. * Creates a new instance of the component for the given scene
  36762. * @param scene Defines the scene to register the component in
  36763. */
  36764. constructor(scene: Scene);
  36765. /**
  36766. * Registers the component in a given scene
  36767. */
  36768. register(): void;
  36769. /**
  36770. * Rebuilds the elements related to this component in case of
  36771. * context lost for instance.
  36772. */
  36773. rebuild(): void;
  36774. /**
  36775. * Serializes the component data to the specified json object
  36776. * @param serializationObject The object to serialize to
  36777. */
  36778. serialize(serializationObject: any): void;
  36779. /**
  36780. * Adds all the elements from the container to the scene
  36781. * @param container the container holding the elements
  36782. */
  36783. addFromContainer(container: AbstractScene): void;
  36784. /**
  36785. * Removes all the elements in the container from the scene
  36786. * @param container contains the elements to remove
  36787. * @param dispose if the removed element should be disposed (default: false)
  36788. */
  36789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36790. /**
  36791. * Disposes the component and the associated ressources.
  36792. */
  36793. dispose(): void;
  36794. /**
  36795. * Disables audio in the associated scene.
  36796. */
  36797. disableAudio(): void;
  36798. /**
  36799. * Enables audio in the associated scene.
  36800. */
  36801. enableAudio(): void;
  36802. /**
  36803. * Switch audio to headphone output.
  36804. */
  36805. switchAudioModeForHeadphones(): void;
  36806. /**
  36807. * Switch audio to normal speakers.
  36808. */
  36809. switchAudioModeForNormalSpeakers(): void;
  36810. private _cachedCameraDirection;
  36811. private _cachedCameraPosition;
  36812. private _lastCheck;
  36813. private _afterRender;
  36814. }
  36815. }
  36816. declare module "babylonjs/Audio/weightedsound" {
  36817. import { Sound } from "babylonjs/Audio/sound";
  36818. /**
  36819. * Wraps one or more Sound objects and selects one with random weight for playback.
  36820. */
  36821. export class WeightedSound {
  36822. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36823. loop: boolean;
  36824. private _coneInnerAngle;
  36825. private _coneOuterAngle;
  36826. private _volume;
  36827. /** A Sound is currently playing. */
  36828. isPlaying: boolean;
  36829. /** A Sound is currently paused. */
  36830. isPaused: boolean;
  36831. private _sounds;
  36832. private _weights;
  36833. private _currentIndex?;
  36834. /**
  36835. * Creates a new WeightedSound from the list of sounds given.
  36836. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36837. * @param sounds Array of Sounds that will be selected from.
  36838. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36839. */
  36840. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36841. /**
  36842. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36843. */
  36844. /**
  36845. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36846. */
  36847. directionalConeInnerAngle: number;
  36848. /**
  36849. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36850. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36851. */
  36852. /**
  36853. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36854. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36855. */
  36856. directionalConeOuterAngle: number;
  36857. /**
  36858. * Playback volume.
  36859. */
  36860. /**
  36861. * Playback volume.
  36862. */
  36863. volume: number;
  36864. private _onended;
  36865. /**
  36866. * Suspend playback
  36867. */
  36868. pause(): void;
  36869. /**
  36870. * Stop playback
  36871. */
  36872. stop(): void;
  36873. /**
  36874. * Start playback.
  36875. * @param startOffset Position the clip head at a specific time in seconds.
  36876. */
  36877. play(startOffset?: number): void;
  36878. }
  36879. }
  36880. declare module "babylonjs/Audio/index" {
  36881. export * from "babylonjs/Audio/analyser";
  36882. export * from "babylonjs/Audio/audioEngine";
  36883. export * from "babylonjs/Audio/audioSceneComponent";
  36884. export * from "babylonjs/Audio/sound";
  36885. export * from "babylonjs/Audio/soundTrack";
  36886. export * from "babylonjs/Audio/weightedsound";
  36887. }
  36888. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36889. import { Behavior } from "babylonjs/Behaviors/behavior";
  36890. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36891. import { BackEase } from "babylonjs/Animations/easing";
  36892. /**
  36893. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36894. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36895. */
  36896. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36897. /**
  36898. * Gets the name of the behavior.
  36899. */
  36900. readonly name: string;
  36901. /**
  36902. * The easing function used by animations
  36903. */
  36904. static EasingFunction: BackEase;
  36905. /**
  36906. * The easing mode used by animations
  36907. */
  36908. static EasingMode: number;
  36909. /**
  36910. * The duration of the animation, in milliseconds
  36911. */
  36912. transitionDuration: number;
  36913. /**
  36914. * Length of the distance animated by the transition when lower radius is reached
  36915. */
  36916. lowerRadiusTransitionRange: number;
  36917. /**
  36918. * Length of the distance animated by the transition when upper radius is reached
  36919. */
  36920. upperRadiusTransitionRange: number;
  36921. private _autoTransitionRange;
  36922. /**
  36923. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36924. */
  36925. /**
  36926. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36927. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36928. */
  36929. autoTransitionRange: boolean;
  36930. private _attachedCamera;
  36931. private _onAfterCheckInputsObserver;
  36932. private _onMeshTargetChangedObserver;
  36933. /**
  36934. * Initializes the behavior.
  36935. */
  36936. init(): void;
  36937. /**
  36938. * Attaches the behavior to its arc rotate camera.
  36939. * @param camera Defines the camera to attach the behavior to
  36940. */
  36941. attach(camera: ArcRotateCamera): void;
  36942. /**
  36943. * Detaches the behavior from its current arc rotate camera.
  36944. */
  36945. detach(): void;
  36946. private _radiusIsAnimating;
  36947. private _radiusBounceTransition;
  36948. private _animatables;
  36949. private _cachedWheelPrecision;
  36950. /**
  36951. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36952. * @param radiusLimit The limit to check against.
  36953. * @return Bool to indicate if at limit.
  36954. */
  36955. private _isRadiusAtLimit;
  36956. /**
  36957. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36958. * @param radiusDelta The delta by which to animate to. Can be negative.
  36959. */
  36960. private _applyBoundRadiusAnimation;
  36961. /**
  36962. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36963. */
  36964. protected _clearAnimationLocks(): void;
  36965. /**
  36966. * Stops and removes all animations that have been applied to the camera
  36967. */
  36968. stopAllAnimations(): void;
  36969. }
  36970. }
  36971. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36972. import { Behavior } from "babylonjs/Behaviors/behavior";
  36973. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36974. import { ExponentialEase } from "babylonjs/Animations/easing";
  36975. import { Nullable } from "babylonjs/types";
  36976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36977. import { Vector3 } from "babylonjs/Maths/math.vector";
  36978. /**
  36979. * 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.
  36980. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36981. */
  36982. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36983. /**
  36984. * Gets the name of the behavior.
  36985. */
  36986. readonly name: string;
  36987. private _mode;
  36988. private _radiusScale;
  36989. private _positionScale;
  36990. private _defaultElevation;
  36991. private _elevationReturnTime;
  36992. private _elevationReturnWaitTime;
  36993. private _zoomStopsAnimation;
  36994. private _framingTime;
  36995. /**
  36996. * The easing function used by animations
  36997. */
  36998. static EasingFunction: ExponentialEase;
  36999. /**
  37000. * The easing mode used by animations
  37001. */
  37002. static EasingMode: number;
  37003. /**
  37004. * Sets the current mode used by the behavior
  37005. */
  37006. /**
  37007. * Gets current mode used by the behavior.
  37008. */
  37009. mode: number;
  37010. /**
  37011. * Sets the scale applied to the radius (1 by default)
  37012. */
  37013. /**
  37014. * Gets the scale applied to the radius
  37015. */
  37016. radiusScale: number;
  37017. /**
  37018. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37019. */
  37020. /**
  37021. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37022. */
  37023. positionScale: number;
  37024. /**
  37025. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37026. * behaviour is triggered, in radians.
  37027. */
  37028. /**
  37029. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37030. * behaviour is triggered, in radians.
  37031. */
  37032. defaultElevation: number;
  37033. /**
  37034. * Sets the time (in milliseconds) taken to return to the default beta position.
  37035. * Negative value indicates camera should not return to default.
  37036. */
  37037. /**
  37038. * Gets the time (in milliseconds) taken to return to the default beta position.
  37039. * Negative value indicates camera should not return to default.
  37040. */
  37041. elevationReturnTime: number;
  37042. /**
  37043. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37044. */
  37045. /**
  37046. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37047. */
  37048. elevationReturnWaitTime: number;
  37049. /**
  37050. * Sets the flag that indicates if user zooming should stop animation.
  37051. */
  37052. /**
  37053. * Gets the flag that indicates if user zooming should stop animation.
  37054. */
  37055. zoomStopsAnimation: boolean;
  37056. /**
  37057. * Sets the transition time when framing the mesh, in milliseconds
  37058. */
  37059. /**
  37060. * Gets the transition time when framing the mesh, in milliseconds
  37061. */
  37062. framingTime: number;
  37063. /**
  37064. * Define if the behavior should automatically change the configured
  37065. * camera limits and sensibilities.
  37066. */
  37067. autoCorrectCameraLimitsAndSensibility: boolean;
  37068. private _onPrePointerObservableObserver;
  37069. private _onAfterCheckInputsObserver;
  37070. private _onMeshTargetChangedObserver;
  37071. private _attachedCamera;
  37072. private _isPointerDown;
  37073. private _lastInteractionTime;
  37074. /**
  37075. * Initializes the behavior.
  37076. */
  37077. init(): void;
  37078. /**
  37079. * Attaches the behavior to its arc rotate camera.
  37080. * @param camera Defines the camera to attach the behavior to
  37081. */
  37082. attach(camera: ArcRotateCamera): void;
  37083. /**
  37084. * Detaches the behavior from its current arc rotate camera.
  37085. */
  37086. detach(): void;
  37087. private _animatables;
  37088. private _betaIsAnimating;
  37089. private _betaTransition;
  37090. private _radiusTransition;
  37091. private _vectorTransition;
  37092. /**
  37093. * Targets the given mesh and updates zoom level accordingly.
  37094. * @param mesh The mesh to target.
  37095. * @param radius Optional. If a cached radius position already exists, overrides default.
  37096. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37097. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37098. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37099. */
  37100. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37101. /**
  37102. * Targets the given mesh with its children and updates zoom level accordingly.
  37103. * @param mesh The mesh to target.
  37104. * @param radius Optional. If a cached radius position already exists, overrides default.
  37105. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37106. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37107. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37108. */
  37109. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37110. /**
  37111. * Targets the given meshes with their children and updates zoom level accordingly.
  37112. * @param meshes The mesh to target.
  37113. * @param radius Optional. If a cached radius position already exists, overrides default.
  37114. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37115. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37116. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37117. */
  37118. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37119. /**
  37120. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37121. * @param minimumWorld Determines the smaller position of the bounding box extend
  37122. * @param maximumWorld Determines the bigger position of the bounding box extend
  37123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37125. */
  37126. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37127. /**
  37128. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37129. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37130. * frustum width.
  37131. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37132. * to fully enclose the mesh in the viewing frustum.
  37133. */
  37134. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37135. /**
  37136. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37137. * is automatically returned to its default position (expected to be above ground plane).
  37138. */
  37139. private _maintainCameraAboveGround;
  37140. /**
  37141. * Returns the frustum slope based on the canvas ratio and camera FOV
  37142. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37143. */
  37144. private _getFrustumSlope;
  37145. /**
  37146. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37147. */
  37148. private _clearAnimationLocks;
  37149. /**
  37150. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37151. */
  37152. private _applyUserInteraction;
  37153. /**
  37154. * Stops and removes all animations that have been applied to the camera
  37155. */
  37156. stopAllAnimations(): void;
  37157. /**
  37158. * Gets a value indicating if the user is moving the camera
  37159. */
  37160. readonly isUserIsMoving: boolean;
  37161. /**
  37162. * The camera can move all the way towards the mesh.
  37163. */
  37164. static IgnoreBoundsSizeMode: number;
  37165. /**
  37166. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37167. */
  37168. static FitFrustumSidesMode: number;
  37169. }
  37170. }
  37171. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37172. import { Nullable } from "babylonjs/types";
  37173. import { Camera } from "babylonjs/Cameras/camera";
  37174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37175. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37176. /**
  37177. * Base class for Camera Pointer Inputs.
  37178. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37179. * for example usage.
  37180. */
  37181. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37182. /**
  37183. * Defines the camera the input is attached to.
  37184. */
  37185. abstract camera: Camera;
  37186. /**
  37187. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37188. */
  37189. protected _altKey: boolean;
  37190. protected _ctrlKey: boolean;
  37191. protected _metaKey: boolean;
  37192. protected _shiftKey: boolean;
  37193. /**
  37194. * Which mouse buttons were pressed at time of last mouse event.
  37195. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37196. */
  37197. protected _buttonsPressed: number;
  37198. /**
  37199. * Defines the buttons associated with the input to handle camera move.
  37200. */
  37201. buttons: number[];
  37202. /**
  37203. * Attach the input controls to a specific dom element to get the input from.
  37204. * @param element Defines the element the controls should be listened from
  37205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37206. */
  37207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37208. /**
  37209. * Detach the current controls from the specified dom element.
  37210. * @param element Defines the element to stop listening the inputs from
  37211. */
  37212. detachControl(element: Nullable<HTMLElement>): void;
  37213. /**
  37214. * Gets the class name of the current input.
  37215. * @returns the class name
  37216. */
  37217. getClassName(): string;
  37218. /**
  37219. * Get the friendly name associated with the input class.
  37220. * @returns the input friendly name
  37221. */
  37222. getSimpleName(): string;
  37223. /**
  37224. * Called on pointer POINTERDOUBLETAP event.
  37225. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37226. */
  37227. protected onDoubleTap(type: string): void;
  37228. /**
  37229. * Called on pointer POINTERMOVE event if only a single touch is active.
  37230. * Override this method to provide functionality.
  37231. */
  37232. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37233. /**
  37234. * Called on pointer POINTERMOVE event if multiple touches are active.
  37235. * Override this method to provide functionality.
  37236. */
  37237. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37238. /**
  37239. * Called on JS contextmenu event.
  37240. * Override this method to provide functionality.
  37241. */
  37242. protected onContextMenu(evt: PointerEvent): void;
  37243. /**
  37244. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37245. * press.
  37246. * Override this method to provide functionality.
  37247. */
  37248. protected onButtonDown(evt: PointerEvent): void;
  37249. /**
  37250. * Called each time a new POINTERUP event occurs. Ie, for each button
  37251. * release.
  37252. * Override this method to provide functionality.
  37253. */
  37254. protected onButtonUp(evt: PointerEvent): void;
  37255. /**
  37256. * Called when window becomes inactive.
  37257. * Override this method to provide functionality.
  37258. */
  37259. protected onLostFocus(): void;
  37260. private _pointerInput;
  37261. private _observer;
  37262. private _onLostFocus;
  37263. private pointA;
  37264. private pointB;
  37265. }
  37266. }
  37267. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37268. import { Nullable } from "babylonjs/types";
  37269. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37270. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37271. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37272. /**
  37273. * Manage the pointers inputs to control an arc rotate camera.
  37274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37275. */
  37276. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37277. /**
  37278. * Defines the camera the input is attached to.
  37279. */
  37280. camera: ArcRotateCamera;
  37281. /**
  37282. * Gets the class name of the current input.
  37283. * @returns the class name
  37284. */
  37285. getClassName(): string;
  37286. /**
  37287. * Defines the buttons associated with the input to handle camera move.
  37288. */
  37289. buttons: number[];
  37290. /**
  37291. * Defines the pointer angular sensibility along the X axis or how fast is
  37292. * the camera rotating.
  37293. */
  37294. angularSensibilityX: number;
  37295. /**
  37296. * Defines the pointer angular sensibility along the Y axis or how fast is
  37297. * the camera rotating.
  37298. */
  37299. angularSensibilityY: number;
  37300. /**
  37301. * Defines the pointer pinch precision or how fast is the camera zooming.
  37302. */
  37303. pinchPrecision: number;
  37304. /**
  37305. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37306. * from 0.
  37307. * It defines the percentage of current camera.radius to use as delta when
  37308. * pinch zoom is used.
  37309. */
  37310. pinchDeltaPercentage: number;
  37311. /**
  37312. * Defines the pointer panning sensibility or how fast is the camera moving.
  37313. */
  37314. panningSensibility: number;
  37315. /**
  37316. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37317. */
  37318. multiTouchPanning: boolean;
  37319. /**
  37320. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37321. * zoom (pinch) through multitouch.
  37322. */
  37323. multiTouchPanAndZoom: boolean;
  37324. /**
  37325. * Revers pinch action direction.
  37326. */
  37327. pinchInwards: boolean;
  37328. private _isPanClick;
  37329. private _twoFingerActivityCount;
  37330. private _isPinching;
  37331. /**
  37332. * Called on pointer POINTERMOVE event if only a single touch is active.
  37333. */
  37334. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37335. /**
  37336. * Called on pointer POINTERDOUBLETAP event.
  37337. */
  37338. protected onDoubleTap(type: string): void;
  37339. /**
  37340. * Called on pointer POINTERMOVE event if multiple touches are active.
  37341. */
  37342. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37343. /**
  37344. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37345. * press.
  37346. */
  37347. protected onButtonDown(evt: PointerEvent): void;
  37348. /**
  37349. * Called each time a new POINTERUP event occurs. Ie, for each button
  37350. * release.
  37351. */
  37352. protected onButtonUp(evt: PointerEvent): void;
  37353. /**
  37354. * Called when window becomes inactive.
  37355. */
  37356. protected onLostFocus(): void;
  37357. }
  37358. }
  37359. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37360. import { Nullable } from "babylonjs/types";
  37361. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37362. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37363. /**
  37364. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37365. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37366. */
  37367. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37368. /**
  37369. * Defines the camera the input is attached to.
  37370. */
  37371. camera: ArcRotateCamera;
  37372. /**
  37373. * Defines the list of key codes associated with the up action (increase alpha)
  37374. */
  37375. keysUp: number[];
  37376. /**
  37377. * Defines the list of key codes associated with the down action (decrease alpha)
  37378. */
  37379. keysDown: number[];
  37380. /**
  37381. * Defines the list of key codes associated with the left action (increase beta)
  37382. */
  37383. keysLeft: number[];
  37384. /**
  37385. * Defines the list of key codes associated with the right action (decrease beta)
  37386. */
  37387. keysRight: number[];
  37388. /**
  37389. * Defines the list of key codes associated with the reset action.
  37390. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37391. */
  37392. keysReset: number[];
  37393. /**
  37394. * Defines the panning sensibility of the inputs.
  37395. * (How fast is the camera paning)
  37396. */
  37397. panningSensibility: number;
  37398. /**
  37399. * Defines the zooming sensibility of the inputs.
  37400. * (How fast is the camera zooming)
  37401. */
  37402. zoomingSensibility: number;
  37403. /**
  37404. * Defines wether maintaining the alt key down switch the movement mode from
  37405. * orientation to zoom.
  37406. */
  37407. useAltToZoom: boolean;
  37408. /**
  37409. * Rotation speed of the camera
  37410. */
  37411. angularSpeed: number;
  37412. private _keys;
  37413. private _ctrlPressed;
  37414. private _altPressed;
  37415. private _onCanvasBlurObserver;
  37416. private _onKeyboardObserver;
  37417. private _engine;
  37418. private _scene;
  37419. /**
  37420. * Attach the input controls to a specific dom element to get the input from.
  37421. * @param element Defines the element the controls should be listened from
  37422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37423. */
  37424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37425. /**
  37426. * Detach the current controls from the specified dom element.
  37427. * @param element Defines the element to stop listening the inputs from
  37428. */
  37429. detachControl(element: Nullable<HTMLElement>): void;
  37430. /**
  37431. * Update the current camera state depending on the inputs that have been used this frame.
  37432. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37433. */
  37434. checkInputs(): void;
  37435. /**
  37436. * Gets the class name of the current intput.
  37437. * @returns the class name
  37438. */
  37439. getClassName(): string;
  37440. /**
  37441. * Get the friendly name associated with the input class.
  37442. * @returns the input friendly name
  37443. */
  37444. getSimpleName(): string;
  37445. }
  37446. }
  37447. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37448. import { Nullable } from "babylonjs/types";
  37449. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37450. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37451. /**
  37452. * Manage the mouse wheel inputs to control an arc rotate camera.
  37453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37454. */
  37455. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37456. /**
  37457. * Defines the camera the input is attached to.
  37458. */
  37459. camera: ArcRotateCamera;
  37460. /**
  37461. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37462. */
  37463. wheelPrecision: number;
  37464. /**
  37465. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37466. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37467. */
  37468. wheelDeltaPercentage: number;
  37469. private _wheel;
  37470. private _observer;
  37471. private computeDeltaFromMouseWheelLegacyEvent;
  37472. /**
  37473. * Attach the input controls to a specific dom element to get the input from.
  37474. * @param element Defines the element the controls should be listened from
  37475. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37476. */
  37477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37478. /**
  37479. * Detach the current controls from the specified dom element.
  37480. * @param element Defines the element to stop listening the inputs from
  37481. */
  37482. detachControl(element: Nullable<HTMLElement>): void;
  37483. /**
  37484. * Gets the class name of the current intput.
  37485. * @returns the class name
  37486. */
  37487. getClassName(): string;
  37488. /**
  37489. * Get the friendly name associated with the input class.
  37490. * @returns the input friendly name
  37491. */
  37492. getSimpleName(): string;
  37493. }
  37494. }
  37495. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37496. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37497. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37498. /**
  37499. * Default Inputs manager for the ArcRotateCamera.
  37500. * It groups all the default supported inputs for ease of use.
  37501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37502. */
  37503. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37504. /**
  37505. * Instantiates a new ArcRotateCameraInputsManager.
  37506. * @param camera Defines the camera the inputs belong to
  37507. */
  37508. constructor(camera: ArcRotateCamera);
  37509. /**
  37510. * Add mouse wheel input support to the input manager.
  37511. * @returns the current input manager
  37512. */
  37513. addMouseWheel(): ArcRotateCameraInputsManager;
  37514. /**
  37515. * Add pointers input support to the input manager.
  37516. * @returns the current input manager
  37517. */
  37518. addPointers(): ArcRotateCameraInputsManager;
  37519. /**
  37520. * Add keyboard input support to the input manager.
  37521. * @returns the current input manager
  37522. */
  37523. addKeyboard(): ArcRotateCameraInputsManager;
  37524. }
  37525. }
  37526. declare module "babylonjs/Cameras/arcRotateCamera" {
  37527. import { Observable } from "babylonjs/Misc/observable";
  37528. import { Nullable } from "babylonjs/types";
  37529. import { Scene } from "babylonjs/scene";
  37530. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37532. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37533. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37534. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37535. import { Camera } from "babylonjs/Cameras/camera";
  37536. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37537. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37538. import { Collider } from "babylonjs/Collisions/collider";
  37539. /**
  37540. * This represents an orbital type of camera.
  37541. *
  37542. * 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.
  37543. * 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.
  37544. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37545. */
  37546. export class ArcRotateCamera extends TargetCamera {
  37547. /**
  37548. * Defines the rotation angle of the camera along the longitudinal axis.
  37549. */
  37550. alpha: number;
  37551. /**
  37552. * Defines the rotation angle of the camera along the latitudinal axis.
  37553. */
  37554. beta: number;
  37555. /**
  37556. * Defines the radius of the camera from it s target point.
  37557. */
  37558. radius: number;
  37559. protected _target: Vector3;
  37560. protected _targetHost: Nullable<AbstractMesh>;
  37561. /**
  37562. * Defines the target point of the camera.
  37563. * The camera looks towards it form the radius distance.
  37564. */
  37565. target: Vector3;
  37566. /**
  37567. * Define the current local position of the camera in the scene
  37568. */
  37569. position: Vector3;
  37570. protected _upVector: Vector3;
  37571. protected _upToYMatrix: Matrix;
  37572. protected _YToUpMatrix: Matrix;
  37573. /**
  37574. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37575. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37576. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37577. */
  37578. upVector: Vector3;
  37579. /**
  37580. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37581. */
  37582. setMatUp(): void;
  37583. /**
  37584. * Current inertia value on the longitudinal axis.
  37585. * The bigger this number the longer it will take for the camera to stop.
  37586. */
  37587. inertialAlphaOffset: number;
  37588. /**
  37589. * Current inertia value on the latitudinal axis.
  37590. * The bigger this number the longer it will take for the camera to stop.
  37591. */
  37592. inertialBetaOffset: number;
  37593. /**
  37594. * Current inertia value on the radius axis.
  37595. * The bigger this number the longer it will take for the camera to stop.
  37596. */
  37597. inertialRadiusOffset: number;
  37598. /**
  37599. * Minimum allowed angle on the longitudinal axis.
  37600. * This can help limiting how the Camera is able to move in the scene.
  37601. */
  37602. lowerAlphaLimit: Nullable<number>;
  37603. /**
  37604. * Maximum allowed angle on the longitudinal axis.
  37605. * This can help limiting how the Camera is able to move in the scene.
  37606. */
  37607. upperAlphaLimit: Nullable<number>;
  37608. /**
  37609. * Minimum allowed angle on the latitudinal axis.
  37610. * This can help limiting how the Camera is able to move in the scene.
  37611. */
  37612. lowerBetaLimit: number;
  37613. /**
  37614. * Maximum allowed angle on the latitudinal axis.
  37615. * This can help limiting how the Camera is able to move in the scene.
  37616. */
  37617. upperBetaLimit: number;
  37618. /**
  37619. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37620. * This can help limiting how the Camera is able to move in the scene.
  37621. */
  37622. lowerRadiusLimit: Nullable<number>;
  37623. /**
  37624. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37625. * This can help limiting how the Camera is able to move in the scene.
  37626. */
  37627. upperRadiusLimit: Nullable<number>;
  37628. /**
  37629. * Defines the current inertia value used during panning of the camera along the X axis.
  37630. */
  37631. inertialPanningX: number;
  37632. /**
  37633. * Defines the current inertia value used during panning of the camera along the Y axis.
  37634. */
  37635. inertialPanningY: number;
  37636. /**
  37637. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37638. * Basically if your fingers moves away from more than this distance you will be considered
  37639. * in pinch mode.
  37640. */
  37641. pinchToPanMaxDistance: number;
  37642. /**
  37643. * Defines the maximum distance the camera can pan.
  37644. * This could help keeping the cammera always in your scene.
  37645. */
  37646. panningDistanceLimit: Nullable<number>;
  37647. /**
  37648. * Defines the target of the camera before paning.
  37649. */
  37650. panningOriginTarget: Vector3;
  37651. /**
  37652. * Defines the value of the inertia used during panning.
  37653. * 0 would mean stop inertia and one would mean no decelleration at all.
  37654. */
  37655. panningInertia: number;
  37656. /**
  37657. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37658. */
  37659. angularSensibilityX: number;
  37660. /**
  37661. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37662. */
  37663. angularSensibilityY: number;
  37664. /**
  37665. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37666. */
  37667. pinchPrecision: number;
  37668. /**
  37669. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37670. * It will be used instead of pinchDeltaPrecision if different from 0.
  37671. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37672. */
  37673. pinchDeltaPercentage: number;
  37674. /**
  37675. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37676. */
  37677. panningSensibility: number;
  37678. /**
  37679. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37680. */
  37681. keysUp: number[];
  37682. /**
  37683. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37684. */
  37685. keysDown: number[];
  37686. /**
  37687. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37688. */
  37689. keysLeft: number[];
  37690. /**
  37691. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37692. */
  37693. keysRight: number[];
  37694. /**
  37695. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37696. */
  37697. wheelPrecision: number;
  37698. /**
  37699. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37700. * It will be used instead of pinchDeltaPrecision if different from 0.
  37701. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37702. */
  37703. wheelDeltaPercentage: number;
  37704. /**
  37705. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37706. */
  37707. zoomOnFactor: number;
  37708. /**
  37709. * Defines a screen offset for the camera position.
  37710. */
  37711. targetScreenOffset: Vector2;
  37712. /**
  37713. * Allows the camera to be completely reversed.
  37714. * If false the camera can not arrive upside down.
  37715. */
  37716. allowUpsideDown: boolean;
  37717. /**
  37718. * Define if double tap/click is used to restore the previously saved state of the camera.
  37719. */
  37720. useInputToRestoreState: boolean;
  37721. /** @hidden */
  37722. _viewMatrix: Matrix;
  37723. /** @hidden */
  37724. _useCtrlForPanning: boolean;
  37725. /** @hidden */
  37726. _panningMouseButton: number;
  37727. /**
  37728. * Defines the input associated to the camera.
  37729. */
  37730. inputs: ArcRotateCameraInputsManager;
  37731. /** @hidden */
  37732. _reset: () => void;
  37733. /**
  37734. * Defines the allowed panning axis.
  37735. */
  37736. panningAxis: Vector3;
  37737. protected _localDirection: Vector3;
  37738. protected _transformedDirection: Vector3;
  37739. private _bouncingBehavior;
  37740. /**
  37741. * Gets the bouncing behavior of the camera if it has been enabled.
  37742. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37743. */
  37744. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37745. /**
  37746. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37747. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37748. */
  37749. useBouncingBehavior: boolean;
  37750. private _framingBehavior;
  37751. /**
  37752. * Gets the framing behavior of the camera if it has been enabled.
  37753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37754. */
  37755. readonly framingBehavior: Nullable<FramingBehavior>;
  37756. /**
  37757. * Defines if the framing behavior of the camera is enabled on the camera.
  37758. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37759. */
  37760. useFramingBehavior: boolean;
  37761. private _autoRotationBehavior;
  37762. /**
  37763. * Gets the auto rotation behavior of the camera if it has been enabled.
  37764. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37765. */
  37766. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37767. /**
  37768. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37770. */
  37771. useAutoRotationBehavior: boolean;
  37772. /**
  37773. * Observable triggered when the mesh target has been changed on the camera.
  37774. */
  37775. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37776. /**
  37777. * Event raised when the camera is colliding with a mesh.
  37778. */
  37779. onCollide: (collidedMesh: AbstractMesh) => void;
  37780. /**
  37781. * Defines whether the camera should check collision with the objects oh the scene.
  37782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37783. */
  37784. checkCollisions: boolean;
  37785. /**
  37786. * Defines the collision radius of the camera.
  37787. * This simulates a sphere around the camera.
  37788. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37789. */
  37790. collisionRadius: Vector3;
  37791. protected _collider: Collider;
  37792. protected _previousPosition: Vector3;
  37793. protected _collisionVelocity: Vector3;
  37794. protected _newPosition: Vector3;
  37795. protected _previousAlpha: number;
  37796. protected _previousBeta: number;
  37797. protected _previousRadius: number;
  37798. protected _collisionTriggered: boolean;
  37799. protected _targetBoundingCenter: Nullable<Vector3>;
  37800. private _computationVector;
  37801. /**
  37802. * Instantiates a new ArcRotateCamera in a given scene
  37803. * @param name Defines the name of the camera
  37804. * @param alpha Defines the camera rotation along the logitudinal axis
  37805. * @param beta Defines the camera rotation along the latitudinal axis
  37806. * @param radius Defines the camera distance from its target
  37807. * @param target Defines the camera target
  37808. * @param scene Defines the scene the camera belongs to
  37809. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37810. */
  37811. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37812. /** @hidden */
  37813. _initCache(): void;
  37814. /** @hidden */
  37815. _updateCache(ignoreParentClass?: boolean): void;
  37816. protected _getTargetPosition(): Vector3;
  37817. private _storedAlpha;
  37818. private _storedBeta;
  37819. private _storedRadius;
  37820. private _storedTarget;
  37821. private _storedTargetScreenOffset;
  37822. /**
  37823. * Stores the current state of the camera (alpha, beta, radius and target)
  37824. * @returns the camera itself
  37825. */
  37826. storeState(): Camera;
  37827. /**
  37828. * @hidden
  37829. * Restored camera state. You must call storeState() first
  37830. */
  37831. _restoreStateValues(): boolean;
  37832. /** @hidden */
  37833. _isSynchronizedViewMatrix(): boolean;
  37834. /**
  37835. * Attached controls to the current camera.
  37836. * @param element Defines the element the controls should be listened from
  37837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37838. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37839. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37840. */
  37841. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37842. /**
  37843. * Detach the current controls from the camera.
  37844. * The camera will stop reacting to inputs.
  37845. * @param element Defines the element to stop listening the inputs from
  37846. */
  37847. detachControl(element: HTMLElement): void;
  37848. /** @hidden */
  37849. _checkInputs(): void;
  37850. protected _checkLimits(): void;
  37851. /**
  37852. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37853. */
  37854. rebuildAnglesAndRadius(): void;
  37855. /**
  37856. * Use a position to define the current camera related information like alpha, beta and radius
  37857. * @param position Defines the position to set the camera at
  37858. */
  37859. setPosition(position: Vector3): void;
  37860. /**
  37861. * Defines the target the camera should look at.
  37862. * This will automatically adapt alpha beta and radius to fit within the new target.
  37863. * @param target Defines the new target as a Vector or a mesh
  37864. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37865. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37866. */
  37867. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37868. /** @hidden */
  37869. _getViewMatrix(): Matrix;
  37870. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37871. /**
  37872. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37873. * @param meshes Defines the mesh to zoom on
  37874. * @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)
  37875. */
  37876. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37877. /**
  37878. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37879. * The target will be changed but the radius
  37880. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37881. * @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)
  37882. */
  37883. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37884. min: Vector3;
  37885. max: Vector3;
  37886. distance: number;
  37887. }, doNotUpdateMaxZ?: boolean): void;
  37888. /**
  37889. * @override
  37890. * Override Camera.createRigCamera
  37891. */
  37892. createRigCamera(name: string, cameraIndex: number): Camera;
  37893. /**
  37894. * @hidden
  37895. * @override
  37896. * Override Camera._updateRigCameras
  37897. */
  37898. _updateRigCameras(): void;
  37899. /**
  37900. * Destroy the camera and release the current resources hold by it.
  37901. */
  37902. dispose(): void;
  37903. /**
  37904. * Gets the current object class name.
  37905. * @return the class name
  37906. */
  37907. getClassName(): string;
  37908. }
  37909. }
  37910. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37911. import { Behavior } from "babylonjs/Behaviors/behavior";
  37912. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37913. /**
  37914. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37915. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37916. */
  37917. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37918. /**
  37919. * Gets the name of the behavior.
  37920. */
  37921. readonly name: string;
  37922. private _zoomStopsAnimation;
  37923. private _idleRotationSpeed;
  37924. private _idleRotationWaitTime;
  37925. private _idleRotationSpinupTime;
  37926. /**
  37927. * Sets the flag that indicates if user zooming should stop animation.
  37928. */
  37929. /**
  37930. * Gets the flag that indicates if user zooming should stop animation.
  37931. */
  37932. zoomStopsAnimation: boolean;
  37933. /**
  37934. * Sets the default speed at which the camera rotates around the model.
  37935. */
  37936. /**
  37937. * Gets the default speed at which the camera rotates around the model.
  37938. */
  37939. idleRotationSpeed: number;
  37940. /**
  37941. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37942. */
  37943. /**
  37944. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37945. */
  37946. idleRotationWaitTime: number;
  37947. /**
  37948. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37949. */
  37950. /**
  37951. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37952. */
  37953. idleRotationSpinupTime: number;
  37954. /**
  37955. * Gets a value indicating if the camera is currently rotating because of this behavior
  37956. */
  37957. readonly rotationInProgress: boolean;
  37958. private _onPrePointerObservableObserver;
  37959. private _onAfterCheckInputsObserver;
  37960. private _attachedCamera;
  37961. private _isPointerDown;
  37962. private _lastFrameTime;
  37963. private _lastInteractionTime;
  37964. private _cameraRotationSpeed;
  37965. /**
  37966. * Initializes the behavior.
  37967. */
  37968. init(): void;
  37969. /**
  37970. * Attaches the behavior to its arc rotate camera.
  37971. * @param camera Defines the camera to attach the behavior to
  37972. */
  37973. attach(camera: ArcRotateCamera): void;
  37974. /**
  37975. * Detaches the behavior from its current arc rotate camera.
  37976. */
  37977. detach(): void;
  37978. /**
  37979. * Returns true if user is scrolling.
  37980. * @return true if user is scrolling.
  37981. */
  37982. private _userIsZooming;
  37983. private _lastFrameRadius;
  37984. private _shouldAnimationStopForInteraction;
  37985. /**
  37986. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37987. */
  37988. private _applyUserInteraction;
  37989. private _userIsMoving;
  37990. }
  37991. }
  37992. declare module "babylonjs/Behaviors/Cameras/index" {
  37993. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37994. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37995. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37996. }
  37997. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37998. import { Mesh } from "babylonjs/Meshes/mesh";
  37999. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38000. import { Behavior } from "babylonjs/Behaviors/behavior";
  38001. /**
  38002. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38003. */
  38004. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38005. private ui;
  38006. /**
  38007. * The name of the behavior
  38008. */
  38009. name: string;
  38010. /**
  38011. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38012. */
  38013. distanceAwayFromFace: number;
  38014. /**
  38015. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38016. */
  38017. distanceAwayFromBottomOfFace: number;
  38018. private _faceVectors;
  38019. private _target;
  38020. private _scene;
  38021. private _onRenderObserver;
  38022. private _tmpMatrix;
  38023. private _tmpVector;
  38024. /**
  38025. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38026. * @param ui The transform node that should be attched to the mesh
  38027. */
  38028. constructor(ui: TransformNode);
  38029. /**
  38030. * Initializes the behavior
  38031. */
  38032. init(): void;
  38033. private _closestFace;
  38034. private _zeroVector;
  38035. private _lookAtTmpMatrix;
  38036. private _lookAtToRef;
  38037. /**
  38038. * Attaches the AttachToBoxBehavior to the passed in mesh
  38039. * @param target The mesh that the specified node will be attached to
  38040. */
  38041. attach(target: Mesh): void;
  38042. /**
  38043. * Detaches the behavior from the mesh
  38044. */
  38045. detach(): void;
  38046. }
  38047. }
  38048. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38049. import { Behavior } from "babylonjs/Behaviors/behavior";
  38050. import { Mesh } from "babylonjs/Meshes/mesh";
  38051. /**
  38052. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38053. */
  38054. export class FadeInOutBehavior implements Behavior<Mesh> {
  38055. /**
  38056. * Time in milliseconds to delay before fading in (Default: 0)
  38057. */
  38058. delay: number;
  38059. /**
  38060. * Time in milliseconds for the mesh to fade in (Default: 300)
  38061. */
  38062. fadeInTime: number;
  38063. private _millisecondsPerFrame;
  38064. private _hovered;
  38065. private _hoverValue;
  38066. private _ownerNode;
  38067. /**
  38068. * Instatiates the FadeInOutBehavior
  38069. */
  38070. constructor();
  38071. /**
  38072. * The name of the behavior
  38073. */
  38074. readonly name: string;
  38075. /**
  38076. * Initializes the behavior
  38077. */
  38078. init(): void;
  38079. /**
  38080. * Attaches the fade behavior on the passed in mesh
  38081. * @param ownerNode The mesh that will be faded in/out once attached
  38082. */
  38083. attach(ownerNode: Mesh): void;
  38084. /**
  38085. * Detaches the behavior from the mesh
  38086. */
  38087. detach(): void;
  38088. /**
  38089. * Triggers the mesh to begin fading in or out
  38090. * @param value if the object should fade in or out (true to fade in)
  38091. */
  38092. fadeIn(value: boolean): void;
  38093. private _update;
  38094. private _setAllVisibility;
  38095. }
  38096. }
  38097. declare module "babylonjs/Misc/pivotTools" {
  38098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38099. /**
  38100. * Class containing a set of static utilities functions for managing Pivots
  38101. * @hidden
  38102. */
  38103. export class PivotTools {
  38104. private static _PivotCached;
  38105. private static _OldPivotPoint;
  38106. private static _PivotTranslation;
  38107. private static _PivotTmpVector;
  38108. /** @hidden */
  38109. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38110. /** @hidden */
  38111. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38112. }
  38113. }
  38114. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38115. import { Scene } from "babylonjs/scene";
  38116. import { Vector4 } from "babylonjs/Maths/math.vector";
  38117. import { Mesh } from "babylonjs/Meshes/mesh";
  38118. import { Nullable } from "babylonjs/types";
  38119. import { Plane } from "babylonjs/Maths/math.plane";
  38120. /**
  38121. * Class containing static functions to help procedurally build meshes
  38122. */
  38123. export class PlaneBuilder {
  38124. /**
  38125. * Creates a plane mesh
  38126. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38127. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38128. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38132. * @param name defines the name of the mesh
  38133. * @param options defines the options used to create the mesh
  38134. * @param scene defines the hosting scene
  38135. * @returns the plane mesh
  38136. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38137. */
  38138. static CreatePlane(name: string, options: {
  38139. size?: number;
  38140. width?: number;
  38141. height?: number;
  38142. sideOrientation?: number;
  38143. frontUVs?: Vector4;
  38144. backUVs?: Vector4;
  38145. updatable?: boolean;
  38146. sourcePlane?: Plane;
  38147. }, scene?: Nullable<Scene>): Mesh;
  38148. }
  38149. }
  38150. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38151. import { Behavior } from "babylonjs/Behaviors/behavior";
  38152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38153. import { Observable } from "babylonjs/Misc/observable";
  38154. import { Vector3 } from "babylonjs/Maths/math.vector";
  38155. import { Ray } from "babylonjs/Culling/ray";
  38156. import "babylonjs/Meshes/Builders/planeBuilder";
  38157. /**
  38158. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38159. */
  38160. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38161. private static _AnyMouseID;
  38162. /**
  38163. * Abstract mesh the behavior is set on
  38164. */
  38165. attachedNode: AbstractMesh;
  38166. private _dragPlane;
  38167. private _scene;
  38168. private _pointerObserver;
  38169. private _beforeRenderObserver;
  38170. private static _planeScene;
  38171. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38172. /**
  38173. * 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)
  38174. */
  38175. maxDragAngle: number;
  38176. /**
  38177. * @hidden
  38178. */
  38179. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38180. /**
  38181. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38182. */
  38183. currentDraggingPointerID: number;
  38184. /**
  38185. * The last position where the pointer hit the drag plane in world space
  38186. */
  38187. lastDragPosition: Vector3;
  38188. /**
  38189. * If the behavior is currently in a dragging state
  38190. */
  38191. dragging: boolean;
  38192. /**
  38193. * 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)
  38194. */
  38195. dragDeltaRatio: number;
  38196. /**
  38197. * If the drag plane orientation should be updated during the dragging (Default: true)
  38198. */
  38199. updateDragPlane: boolean;
  38200. private _debugMode;
  38201. private _moving;
  38202. /**
  38203. * Fires each time the attached mesh is dragged with the pointer
  38204. * * delta between last drag position and current drag position in world space
  38205. * * dragDistance along the drag axis
  38206. * * dragPlaneNormal normal of the current drag plane used during the drag
  38207. * * dragPlanePoint in world space where the drag intersects the drag plane
  38208. */
  38209. onDragObservable: Observable<{
  38210. delta: Vector3;
  38211. dragPlanePoint: Vector3;
  38212. dragPlaneNormal: Vector3;
  38213. dragDistance: number;
  38214. pointerId: number;
  38215. }>;
  38216. /**
  38217. * Fires each time a drag begins (eg. mouse down on mesh)
  38218. */
  38219. onDragStartObservable: Observable<{
  38220. dragPlanePoint: Vector3;
  38221. pointerId: number;
  38222. }>;
  38223. /**
  38224. * Fires each time a drag ends (eg. mouse release after drag)
  38225. */
  38226. onDragEndObservable: Observable<{
  38227. dragPlanePoint: Vector3;
  38228. pointerId: number;
  38229. }>;
  38230. /**
  38231. * If the attached mesh should be moved when dragged
  38232. */
  38233. moveAttached: boolean;
  38234. /**
  38235. * If the drag behavior will react to drag events (Default: true)
  38236. */
  38237. enabled: boolean;
  38238. /**
  38239. * If pointer events should start and release the drag (Default: true)
  38240. */
  38241. startAndReleaseDragOnPointerEvents: boolean;
  38242. /**
  38243. * If camera controls should be detached during the drag
  38244. */
  38245. detachCameraControls: boolean;
  38246. /**
  38247. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38248. */
  38249. useObjectOrienationForDragging: boolean;
  38250. private _options;
  38251. /**
  38252. * Creates a pointer drag behavior that can be attached to a mesh
  38253. * @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)
  38254. */
  38255. constructor(options?: {
  38256. dragAxis?: Vector3;
  38257. dragPlaneNormal?: Vector3;
  38258. });
  38259. /**
  38260. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38261. */
  38262. validateDrag: (targetPosition: Vector3) => boolean;
  38263. /**
  38264. * The name of the behavior
  38265. */
  38266. readonly name: string;
  38267. /**
  38268. * Initializes the behavior
  38269. */
  38270. init(): void;
  38271. private _tmpVector;
  38272. private _alternatePickedPoint;
  38273. private _worldDragAxis;
  38274. private _targetPosition;
  38275. private _attachedElement;
  38276. /**
  38277. * Attaches the drag behavior the passed in mesh
  38278. * @param ownerNode The mesh that will be dragged around once attached
  38279. * @param predicate Predicate to use for pick filtering
  38280. */
  38281. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38282. /**
  38283. * Force relase the drag action by code.
  38284. */
  38285. releaseDrag(): void;
  38286. private _startDragRay;
  38287. private _lastPointerRay;
  38288. /**
  38289. * Simulates the start of a pointer drag event on the behavior
  38290. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38291. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38292. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38293. */
  38294. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38295. private _startDrag;
  38296. private _dragDelta;
  38297. private _moveDrag;
  38298. private _pickWithRayOnDragPlane;
  38299. private _pointA;
  38300. private _pointB;
  38301. private _pointC;
  38302. private _lineA;
  38303. private _lineB;
  38304. private _localAxis;
  38305. private _lookAt;
  38306. private _updateDragPlanePosition;
  38307. /**
  38308. * Detaches the behavior from the mesh
  38309. */
  38310. detach(): void;
  38311. }
  38312. }
  38313. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38314. import { Mesh } from "babylonjs/Meshes/mesh";
  38315. import { Behavior } from "babylonjs/Behaviors/behavior";
  38316. /**
  38317. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38318. */
  38319. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38320. private _dragBehaviorA;
  38321. private _dragBehaviorB;
  38322. private _startDistance;
  38323. private _initialScale;
  38324. private _targetScale;
  38325. private _ownerNode;
  38326. private _sceneRenderObserver;
  38327. /**
  38328. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38329. */
  38330. constructor();
  38331. /**
  38332. * The name of the behavior
  38333. */
  38334. readonly name: string;
  38335. /**
  38336. * Initializes the behavior
  38337. */
  38338. init(): void;
  38339. private _getCurrentDistance;
  38340. /**
  38341. * Attaches the scale behavior the passed in mesh
  38342. * @param ownerNode The mesh that will be scaled around once attached
  38343. */
  38344. attach(ownerNode: Mesh): void;
  38345. /**
  38346. * Detaches the behavior from the mesh
  38347. */
  38348. detach(): void;
  38349. }
  38350. }
  38351. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38352. import { Behavior } from "babylonjs/Behaviors/behavior";
  38353. import { Mesh } from "babylonjs/Meshes/mesh";
  38354. import { Observable } from "babylonjs/Misc/observable";
  38355. /**
  38356. * 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
  38357. */
  38358. export class SixDofDragBehavior implements Behavior<Mesh> {
  38359. private static _virtualScene;
  38360. private _ownerNode;
  38361. private _sceneRenderObserver;
  38362. private _scene;
  38363. private _targetPosition;
  38364. private _virtualOriginMesh;
  38365. private _virtualDragMesh;
  38366. private _pointerObserver;
  38367. private _moving;
  38368. private _startingOrientation;
  38369. /**
  38370. * 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)
  38371. */
  38372. private zDragFactor;
  38373. /**
  38374. * If the object should rotate to face the drag origin
  38375. */
  38376. rotateDraggedObject: boolean;
  38377. /**
  38378. * If the behavior is currently in a dragging state
  38379. */
  38380. dragging: boolean;
  38381. /**
  38382. * 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)
  38383. */
  38384. dragDeltaRatio: number;
  38385. /**
  38386. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38387. */
  38388. currentDraggingPointerID: number;
  38389. /**
  38390. * If camera controls should be detached during the drag
  38391. */
  38392. detachCameraControls: boolean;
  38393. /**
  38394. * Fires each time a drag starts
  38395. */
  38396. onDragStartObservable: Observable<{}>;
  38397. /**
  38398. * Fires each time a drag ends (eg. mouse release after drag)
  38399. */
  38400. onDragEndObservable: Observable<{}>;
  38401. /**
  38402. * 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
  38403. */
  38404. constructor();
  38405. /**
  38406. * The name of the behavior
  38407. */
  38408. readonly name: string;
  38409. /**
  38410. * Initializes the behavior
  38411. */
  38412. init(): void;
  38413. /**
  38414. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38415. */
  38416. private readonly _pointerCamera;
  38417. /**
  38418. * Attaches the scale behavior the passed in mesh
  38419. * @param ownerNode The mesh that will be scaled around once attached
  38420. */
  38421. attach(ownerNode: Mesh): void;
  38422. /**
  38423. * Detaches the behavior from the mesh
  38424. */
  38425. detach(): void;
  38426. }
  38427. }
  38428. declare module "babylonjs/Behaviors/Meshes/index" {
  38429. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38430. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38431. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38432. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38433. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38434. }
  38435. declare module "babylonjs/Behaviors/index" {
  38436. export * from "babylonjs/Behaviors/behavior";
  38437. export * from "babylonjs/Behaviors/Cameras/index";
  38438. export * from "babylonjs/Behaviors/Meshes/index";
  38439. }
  38440. declare module "babylonjs/Bones/boneIKController" {
  38441. import { Bone } from "babylonjs/Bones/bone";
  38442. import { Vector3 } from "babylonjs/Maths/math.vector";
  38443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38444. import { Nullable } from "babylonjs/types";
  38445. /**
  38446. * Class used to apply inverse kinematics to bones
  38447. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38448. */
  38449. export class BoneIKController {
  38450. private static _tmpVecs;
  38451. private static _tmpQuat;
  38452. private static _tmpMats;
  38453. /**
  38454. * Gets or sets the target mesh
  38455. */
  38456. targetMesh: AbstractMesh;
  38457. /** Gets or sets the mesh used as pole */
  38458. poleTargetMesh: AbstractMesh;
  38459. /**
  38460. * Gets or sets the bone used as pole
  38461. */
  38462. poleTargetBone: Nullable<Bone>;
  38463. /**
  38464. * Gets or sets the target position
  38465. */
  38466. targetPosition: Vector3;
  38467. /**
  38468. * Gets or sets the pole target position
  38469. */
  38470. poleTargetPosition: Vector3;
  38471. /**
  38472. * Gets or sets the pole target local offset
  38473. */
  38474. poleTargetLocalOffset: Vector3;
  38475. /**
  38476. * Gets or sets the pole angle
  38477. */
  38478. poleAngle: number;
  38479. /**
  38480. * Gets or sets the mesh associated with the controller
  38481. */
  38482. mesh: AbstractMesh;
  38483. /**
  38484. * 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)
  38485. */
  38486. slerpAmount: number;
  38487. private _bone1Quat;
  38488. private _bone1Mat;
  38489. private _bone2Ang;
  38490. private _bone1;
  38491. private _bone2;
  38492. private _bone1Length;
  38493. private _bone2Length;
  38494. private _maxAngle;
  38495. private _maxReach;
  38496. private _rightHandedSystem;
  38497. private _bendAxis;
  38498. private _slerping;
  38499. private _adjustRoll;
  38500. /**
  38501. * Gets or sets maximum allowed angle
  38502. */
  38503. maxAngle: number;
  38504. /**
  38505. * Creates a new BoneIKController
  38506. * @param mesh defines the mesh to control
  38507. * @param bone defines the bone to control
  38508. * @param options defines options to set up the controller
  38509. */
  38510. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38511. targetMesh?: AbstractMesh;
  38512. poleTargetMesh?: AbstractMesh;
  38513. poleTargetBone?: Bone;
  38514. poleTargetLocalOffset?: Vector3;
  38515. poleAngle?: number;
  38516. bendAxis?: Vector3;
  38517. maxAngle?: number;
  38518. slerpAmount?: number;
  38519. });
  38520. private _setMaxAngle;
  38521. /**
  38522. * Force the controller to update the bones
  38523. */
  38524. update(): void;
  38525. }
  38526. }
  38527. declare module "babylonjs/Bones/boneLookController" {
  38528. import { Vector3 } from "babylonjs/Maths/math.vector";
  38529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38530. import { Bone } from "babylonjs/Bones/bone";
  38531. import { Space } from "babylonjs/Maths/math.axis";
  38532. /**
  38533. * Class used to make a bone look toward a point in space
  38534. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38535. */
  38536. export class BoneLookController {
  38537. private static _tmpVecs;
  38538. private static _tmpQuat;
  38539. private static _tmpMats;
  38540. /**
  38541. * The target Vector3 that the bone will look at
  38542. */
  38543. target: Vector3;
  38544. /**
  38545. * The mesh that the bone is attached to
  38546. */
  38547. mesh: AbstractMesh;
  38548. /**
  38549. * The bone that will be looking to the target
  38550. */
  38551. bone: Bone;
  38552. /**
  38553. * The up axis of the coordinate system that is used when the bone is rotated
  38554. */
  38555. upAxis: Vector3;
  38556. /**
  38557. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38558. */
  38559. upAxisSpace: Space;
  38560. /**
  38561. * Used to make an adjustment to the yaw of the bone
  38562. */
  38563. adjustYaw: number;
  38564. /**
  38565. * Used to make an adjustment to the pitch of the bone
  38566. */
  38567. adjustPitch: number;
  38568. /**
  38569. * Used to make an adjustment to the roll of the bone
  38570. */
  38571. adjustRoll: number;
  38572. /**
  38573. * 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)
  38574. */
  38575. slerpAmount: number;
  38576. private _minYaw;
  38577. private _maxYaw;
  38578. private _minPitch;
  38579. private _maxPitch;
  38580. private _minYawSin;
  38581. private _minYawCos;
  38582. private _maxYawSin;
  38583. private _maxYawCos;
  38584. private _midYawConstraint;
  38585. private _minPitchTan;
  38586. private _maxPitchTan;
  38587. private _boneQuat;
  38588. private _slerping;
  38589. private _transformYawPitch;
  38590. private _transformYawPitchInv;
  38591. private _firstFrameSkipped;
  38592. private _yawRange;
  38593. private _fowardAxis;
  38594. /**
  38595. * Gets or sets the minimum yaw angle that the bone can look to
  38596. */
  38597. minYaw: number;
  38598. /**
  38599. * Gets or sets the maximum yaw angle that the bone can look to
  38600. */
  38601. maxYaw: number;
  38602. /**
  38603. * Gets or sets the minimum pitch angle that the bone can look to
  38604. */
  38605. minPitch: number;
  38606. /**
  38607. * Gets or sets the maximum pitch angle that the bone can look to
  38608. */
  38609. maxPitch: number;
  38610. /**
  38611. * Create a BoneLookController
  38612. * @param mesh the mesh that the bone belongs to
  38613. * @param bone the bone that will be looking to the target
  38614. * @param target the target Vector3 to look at
  38615. * @param options optional settings:
  38616. * * maxYaw: the maximum angle the bone will yaw to
  38617. * * minYaw: the minimum angle the bone will yaw to
  38618. * * maxPitch: the maximum angle the bone will pitch to
  38619. * * minPitch: the minimum angle the bone will yaw to
  38620. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38621. * * upAxis: the up axis of the coordinate system
  38622. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38623. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38624. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38625. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38626. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38627. * * adjustRoll: used to make an adjustment to the roll of the bone
  38628. **/
  38629. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38630. maxYaw?: number;
  38631. minYaw?: number;
  38632. maxPitch?: number;
  38633. minPitch?: number;
  38634. slerpAmount?: number;
  38635. upAxis?: Vector3;
  38636. upAxisSpace?: Space;
  38637. yawAxis?: Vector3;
  38638. pitchAxis?: Vector3;
  38639. adjustYaw?: number;
  38640. adjustPitch?: number;
  38641. adjustRoll?: number;
  38642. });
  38643. /**
  38644. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38645. */
  38646. update(): void;
  38647. private _getAngleDiff;
  38648. private _getAngleBetween;
  38649. private _isAngleBetween;
  38650. }
  38651. }
  38652. declare module "babylonjs/Bones/index" {
  38653. export * from "babylonjs/Bones/bone";
  38654. export * from "babylonjs/Bones/boneIKController";
  38655. export * from "babylonjs/Bones/boneLookController";
  38656. export * from "babylonjs/Bones/skeleton";
  38657. }
  38658. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38659. import { Nullable } from "babylonjs/types";
  38660. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38661. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38662. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38663. /**
  38664. * Manage the gamepad inputs to control an arc rotate camera.
  38665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38666. */
  38667. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38668. /**
  38669. * Defines the camera the input is attached to.
  38670. */
  38671. camera: ArcRotateCamera;
  38672. /**
  38673. * Defines the gamepad the input is gathering event from.
  38674. */
  38675. gamepad: Nullable<Gamepad>;
  38676. /**
  38677. * Defines the gamepad rotation sensiblity.
  38678. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38679. */
  38680. gamepadRotationSensibility: number;
  38681. /**
  38682. * Defines the gamepad move sensiblity.
  38683. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38684. */
  38685. gamepadMoveSensibility: number;
  38686. private _yAxisScale;
  38687. /**
  38688. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38689. */
  38690. invertYAxis: boolean;
  38691. private _onGamepadConnectedObserver;
  38692. private _onGamepadDisconnectedObserver;
  38693. /**
  38694. * Attach the input controls to a specific dom element to get the input from.
  38695. * @param element Defines the element the controls should be listened from
  38696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38697. */
  38698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38699. /**
  38700. * Detach the current controls from the specified dom element.
  38701. * @param element Defines the element to stop listening the inputs from
  38702. */
  38703. detachControl(element: Nullable<HTMLElement>): void;
  38704. /**
  38705. * Update the current camera state depending on the inputs that have been used this frame.
  38706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38707. */
  38708. checkInputs(): void;
  38709. /**
  38710. * Gets the class name of the current intput.
  38711. * @returns the class name
  38712. */
  38713. getClassName(): string;
  38714. /**
  38715. * Get the friendly name associated with the input class.
  38716. * @returns the input friendly name
  38717. */
  38718. getSimpleName(): string;
  38719. }
  38720. }
  38721. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38722. import { Nullable } from "babylonjs/types";
  38723. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38724. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38725. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38726. interface ArcRotateCameraInputsManager {
  38727. /**
  38728. * Add orientation input support to the input manager.
  38729. * @returns the current input manager
  38730. */
  38731. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38732. }
  38733. }
  38734. /**
  38735. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38737. */
  38738. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38739. /**
  38740. * Defines the camera the input is attached to.
  38741. */
  38742. camera: ArcRotateCamera;
  38743. /**
  38744. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38745. */
  38746. alphaCorrection: number;
  38747. /**
  38748. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38749. */
  38750. gammaCorrection: number;
  38751. private _alpha;
  38752. private _gamma;
  38753. private _dirty;
  38754. private _deviceOrientationHandler;
  38755. /**
  38756. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38757. */
  38758. constructor();
  38759. /**
  38760. * Attach the input controls to a specific dom element to get the input from.
  38761. * @param element Defines the element the controls should be listened from
  38762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38763. */
  38764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38765. /** @hidden */
  38766. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38767. /**
  38768. * Update the current camera state depending on the inputs that have been used this frame.
  38769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38770. */
  38771. checkInputs(): void;
  38772. /**
  38773. * Detach the current controls from the specified dom element.
  38774. * @param element Defines the element to stop listening the inputs from
  38775. */
  38776. detachControl(element: Nullable<HTMLElement>): void;
  38777. /**
  38778. * Gets the class name of the current intput.
  38779. * @returns the class name
  38780. */
  38781. getClassName(): string;
  38782. /**
  38783. * Get the friendly name associated with the input class.
  38784. * @returns the input friendly name
  38785. */
  38786. getSimpleName(): string;
  38787. }
  38788. }
  38789. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38790. import { Nullable } from "babylonjs/types";
  38791. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38792. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38793. /**
  38794. * Listen to mouse events to control the camera.
  38795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38796. */
  38797. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38798. /**
  38799. * Defines the camera the input is attached to.
  38800. */
  38801. camera: FlyCamera;
  38802. /**
  38803. * Defines if touch is enabled. (Default is true.)
  38804. */
  38805. touchEnabled: boolean;
  38806. /**
  38807. * Defines the buttons associated with the input to handle camera rotation.
  38808. */
  38809. buttons: number[];
  38810. /**
  38811. * Assign buttons for Yaw control.
  38812. */
  38813. buttonsYaw: number[];
  38814. /**
  38815. * Assign buttons for Pitch control.
  38816. */
  38817. buttonsPitch: number[];
  38818. /**
  38819. * Assign buttons for Roll control.
  38820. */
  38821. buttonsRoll: number[];
  38822. /**
  38823. * Detect if any button is being pressed while mouse is moved.
  38824. * -1 = Mouse locked.
  38825. * 0 = Left button.
  38826. * 1 = Middle Button.
  38827. * 2 = Right Button.
  38828. */
  38829. activeButton: number;
  38830. /**
  38831. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38832. * Higher values reduce its sensitivity.
  38833. */
  38834. angularSensibility: number;
  38835. private _mousemoveCallback;
  38836. private _observer;
  38837. private _rollObserver;
  38838. private previousPosition;
  38839. private noPreventDefault;
  38840. private element;
  38841. /**
  38842. * Listen to mouse events to control the camera.
  38843. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38845. */
  38846. constructor(touchEnabled?: boolean);
  38847. /**
  38848. * Attach the mouse control to the HTML DOM element.
  38849. * @param element Defines the element that listens to the input events.
  38850. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38851. */
  38852. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38853. /**
  38854. * Detach the current controls from the specified dom element.
  38855. * @param element Defines the element to stop listening the inputs from
  38856. */
  38857. detachControl(element: Nullable<HTMLElement>): void;
  38858. /**
  38859. * Gets the class name of the current input.
  38860. * @returns the class name.
  38861. */
  38862. getClassName(): string;
  38863. /**
  38864. * Get the friendly name associated with the input class.
  38865. * @returns the input's friendly name.
  38866. */
  38867. getSimpleName(): string;
  38868. private _pointerInput;
  38869. private _onMouseMove;
  38870. /**
  38871. * Rotate camera by mouse offset.
  38872. */
  38873. private rotateCamera;
  38874. }
  38875. }
  38876. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38877. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38878. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38879. /**
  38880. * Default Inputs manager for the FlyCamera.
  38881. * It groups all the default supported inputs for ease of use.
  38882. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38883. */
  38884. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38885. /**
  38886. * Instantiates a new FlyCameraInputsManager.
  38887. * @param camera Defines the camera the inputs belong to.
  38888. */
  38889. constructor(camera: FlyCamera);
  38890. /**
  38891. * Add keyboard input support to the input manager.
  38892. * @returns the new FlyCameraKeyboardMoveInput().
  38893. */
  38894. addKeyboard(): FlyCameraInputsManager;
  38895. /**
  38896. * Add mouse input support to the input manager.
  38897. * @param touchEnabled Enable touch screen support.
  38898. * @returns the new FlyCameraMouseInput().
  38899. */
  38900. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38901. }
  38902. }
  38903. declare module "babylonjs/Cameras/flyCamera" {
  38904. import { Scene } from "babylonjs/scene";
  38905. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38907. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38908. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38909. /**
  38910. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38911. * such as in a 3D Space Shooter or a Flight Simulator.
  38912. */
  38913. export class FlyCamera extends TargetCamera {
  38914. /**
  38915. * Define the collision ellipsoid of the camera.
  38916. * This is helpful for simulating a camera body, like a player's body.
  38917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38918. */
  38919. ellipsoid: Vector3;
  38920. /**
  38921. * Define an offset for the position of the ellipsoid around the camera.
  38922. * This can be helpful if the camera is attached away from the player's body center,
  38923. * such as at its head.
  38924. */
  38925. ellipsoidOffset: Vector3;
  38926. /**
  38927. * Enable or disable collisions of the camera with the rest of the scene objects.
  38928. */
  38929. checkCollisions: boolean;
  38930. /**
  38931. * Enable or disable gravity on the camera.
  38932. */
  38933. applyGravity: boolean;
  38934. /**
  38935. * Define the current direction the camera is moving to.
  38936. */
  38937. cameraDirection: Vector3;
  38938. /**
  38939. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38940. * This overrides and empties cameraRotation.
  38941. */
  38942. rotationQuaternion: Quaternion;
  38943. /**
  38944. * Track Roll to maintain the wanted Rolling when looking around.
  38945. */
  38946. _trackRoll: number;
  38947. /**
  38948. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38949. */
  38950. rollCorrect: number;
  38951. /**
  38952. * Mimic a banked turn, Rolling the camera when Yawing.
  38953. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38954. */
  38955. bankedTurn: boolean;
  38956. /**
  38957. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38958. */
  38959. bankedTurnLimit: number;
  38960. /**
  38961. * Value of 0 disables the banked Roll.
  38962. * Value of 1 is equal to the Yaw angle in radians.
  38963. */
  38964. bankedTurnMultiplier: number;
  38965. /**
  38966. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38967. */
  38968. inputs: FlyCameraInputsManager;
  38969. /**
  38970. * Gets the input sensibility for mouse input.
  38971. * Higher values reduce sensitivity.
  38972. */
  38973. /**
  38974. * Sets the input sensibility for a mouse input.
  38975. * Higher values reduce sensitivity.
  38976. */
  38977. angularSensibility: number;
  38978. /**
  38979. * Get the keys for camera movement forward.
  38980. */
  38981. /**
  38982. * Set the keys for camera movement forward.
  38983. */
  38984. keysForward: number[];
  38985. /**
  38986. * Get the keys for camera movement backward.
  38987. */
  38988. keysBackward: number[];
  38989. /**
  38990. * Get the keys for camera movement up.
  38991. */
  38992. /**
  38993. * Set the keys for camera movement up.
  38994. */
  38995. keysUp: number[];
  38996. /**
  38997. * Get the keys for camera movement down.
  38998. */
  38999. /**
  39000. * Set the keys for camera movement down.
  39001. */
  39002. keysDown: number[];
  39003. /**
  39004. * Get the keys for camera movement left.
  39005. */
  39006. /**
  39007. * Set the keys for camera movement left.
  39008. */
  39009. keysLeft: number[];
  39010. /**
  39011. * Set the keys for camera movement right.
  39012. */
  39013. /**
  39014. * Set the keys for camera movement right.
  39015. */
  39016. keysRight: number[];
  39017. /**
  39018. * Event raised when the camera collides with a mesh in the scene.
  39019. */
  39020. onCollide: (collidedMesh: AbstractMesh) => void;
  39021. private _collider;
  39022. private _needMoveForGravity;
  39023. private _oldPosition;
  39024. private _diffPosition;
  39025. private _newPosition;
  39026. /** @hidden */
  39027. _localDirection: Vector3;
  39028. /** @hidden */
  39029. _transformedDirection: Vector3;
  39030. /**
  39031. * Instantiates a FlyCamera.
  39032. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39033. * such as in a 3D Space Shooter or a Flight Simulator.
  39034. * @param name Define the name of the camera in the scene.
  39035. * @param position Define the starting position of the camera in the scene.
  39036. * @param scene Define the scene the camera belongs to.
  39037. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39038. */
  39039. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39040. /**
  39041. * Attach a control to the HTML DOM element.
  39042. * @param element Defines the element that listens to the input events.
  39043. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39044. */
  39045. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39046. /**
  39047. * Detach a control from the HTML DOM element.
  39048. * The camera will stop reacting to that input.
  39049. * @param element Defines the element that listens to the input events.
  39050. */
  39051. detachControl(element: HTMLElement): void;
  39052. private _collisionMask;
  39053. /**
  39054. * Get the mask that the camera ignores in collision events.
  39055. */
  39056. /**
  39057. * Set the mask that the camera ignores in collision events.
  39058. */
  39059. collisionMask: number;
  39060. /** @hidden */
  39061. _collideWithWorld(displacement: Vector3): void;
  39062. /** @hidden */
  39063. private _onCollisionPositionChange;
  39064. /** @hidden */
  39065. _checkInputs(): void;
  39066. /** @hidden */
  39067. _decideIfNeedsToMove(): boolean;
  39068. /** @hidden */
  39069. _updatePosition(): void;
  39070. /**
  39071. * Restore the Roll to its target value at the rate specified.
  39072. * @param rate - Higher means slower restoring.
  39073. * @hidden
  39074. */
  39075. restoreRoll(rate: number): void;
  39076. /**
  39077. * Destroy the camera and release the current resources held by it.
  39078. */
  39079. dispose(): void;
  39080. /**
  39081. * Get the current object class name.
  39082. * @returns the class name.
  39083. */
  39084. getClassName(): string;
  39085. }
  39086. }
  39087. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39088. import { Nullable } from "babylonjs/types";
  39089. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39090. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39091. /**
  39092. * Listen to keyboard events to control the camera.
  39093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39094. */
  39095. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39096. /**
  39097. * Defines the camera the input is attached to.
  39098. */
  39099. camera: FlyCamera;
  39100. /**
  39101. * The list of keyboard keys used to control the forward move of the camera.
  39102. */
  39103. keysForward: number[];
  39104. /**
  39105. * The list of keyboard keys used to control the backward move of the camera.
  39106. */
  39107. keysBackward: number[];
  39108. /**
  39109. * The list of keyboard keys used to control the forward move of the camera.
  39110. */
  39111. keysUp: number[];
  39112. /**
  39113. * The list of keyboard keys used to control the backward move of the camera.
  39114. */
  39115. keysDown: number[];
  39116. /**
  39117. * The list of keyboard keys used to control the right strafe move of the camera.
  39118. */
  39119. keysRight: number[];
  39120. /**
  39121. * The list of keyboard keys used to control the left strafe move of the camera.
  39122. */
  39123. keysLeft: number[];
  39124. private _keys;
  39125. private _onCanvasBlurObserver;
  39126. private _onKeyboardObserver;
  39127. private _engine;
  39128. private _scene;
  39129. /**
  39130. * Attach the input controls to a specific dom element to get the input from.
  39131. * @param element Defines the element the controls should be listened from
  39132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39133. */
  39134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39135. /**
  39136. * Detach the current controls from the specified dom element.
  39137. * @param element Defines the element to stop listening the inputs from
  39138. */
  39139. detachControl(element: Nullable<HTMLElement>): void;
  39140. /**
  39141. * Gets the class name of the current intput.
  39142. * @returns the class name
  39143. */
  39144. getClassName(): string;
  39145. /** @hidden */
  39146. _onLostFocus(e: FocusEvent): void;
  39147. /**
  39148. * Get the friendly name associated with the input class.
  39149. * @returns the input friendly name
  39150. */
  39151. getSimpleName(): string;
  39152. /**
  39153. * Update the current camera state depending on the inputs that have been used this frame.
  39154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39155. */
  39156. checkInputs(): void;
  39157. }
  39158. }
  39159. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39160. import { Nullable } from "babylonjs/types";
  39161. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39162. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39163. /**
  39164. * Manage the mouse wheel inputs to control a follow camera.
  39165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39166. */
  39167. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39168. /**
  39169. * Defines the camera the input is attached to.
  39170. */
  39171. camera: FollowCamera;
  39172. /**
  39173. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39174. */
  39175. axisControlRadius: boolean;
  39176. /**
  39177. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39178. */
  39179. axisControlHeight: boolean;
  39180. /**
  39181. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39182. */
  39183. axisControlRotation: boolean;
  39184. /**
  39185. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39186. * relation to mouseWheel events.
  39187. */
  39188. wheelPrecision: number;
  39189. /**
  39190. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39191. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39192. */
  39193. wheelDeltaPercentage: number;
  39194. private _wheel;
  39195. private _observer;
  39196. /**
  39197. * Attach the input controls to a specific dom element to get the input from.
  39198. * @param element Defines the element the controls should be listened from
  39199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39200. */
  39201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39202. /**
  39203. * Detach the current controls from the specified dom element.
  39204. * @param element Defines the element to stop listening the inputs from
  39205. */
  39206. detachControl(element: Nullable<HTMLElement>): void;
  39207. /**
  39208. * Gets the class name of the current intput.
  39209. * @returns the class name
  39210. */
  39211. getClassName(): string;
  39212. /**
  39213. * Get the friendly name associated with the input class.
  39214. * @returns the input friendly name
  39215. */
  39216. getSimpleName(): string;
  39217. }
  39218. }
  39219. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39220. import { Nullable } from "babylonjs/types";
  39221. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39222. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39223. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39224. /**
  39225. * Manage the pointers inputs to control an follow camera.
  39226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39227. */
  39228. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39229. /**
  39230. * Defines the camera the input is attached to.
  39231. */
  39232. camera: FollowCamera;
  39233. /**
  39234. * Gets the class name of the current input.
  39235. * @returns the class name
  39236. */
  39237. getClassName(): string;
  39238. /**
  39239. * Defines the pointer angular sensibility along the X axis or how fast is
  39240. * the camera rotating.
  39241. * A negative number will reverse the axis direction.
  39242. */
  39243. angularSensibilityX: number;
  39244. /**
  39245. * Defines the pointer angular sensibility along the Y axis or how fast is
  39246. * the camera rotating.
  39247. * A negative number will reverse the axis direction.
  39248. */
  39249. angularSensibilityY: number;
  39250. /**
  39251. * Defines the pointer pinch precision or how fast is the camera zooming.
  39252. * A negative number will reverse the axis direction.
  39253. */
  39254. pinchPrecision: number;
  39255. /**
  39256. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39257. * from 0.
  39258. * It defines the percentage of current camera.radius to use as delta when
  39259. * pinch zoom is used.
  39260. */
  39261. pinchDeltaPercentage: number;
  39262. /**
  39263. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39264. */
  39265. axisXControlRadius: boolean;
  39266. /**
  39267. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39268. */
  39269. axisXControlHeight: boolean;
  39270. /**
  39271. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39272. */
  39273. axisXControlRotation: boolean;
  39274. /**
  39275. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39276. */
  39277. axisYControlRadius: boolean;
  39278. /**
  39279. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39280. */
  39281. axisYControlHeight: boolean;
  39282. /**
  39283. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39284. */
  39285. axisYControlRotation: boolean;
  39286. /**
  39287. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39288. */
  39289. axisPinchControlRadius: boolean;
  39290. /**
  39291. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39292. */
  39293. axisPinchControlHeight: boolean;
  39294. /**
  39295. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39296. */
  39297. axisPinchControlRotation: boolean;
  39298. /**
  39299. * Log error messages if basic misconfiguration has occurred.
  39300. */
  39301. warningEnable: boolean;
  39302. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39303. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39304. private _warningCounter;
  39305. private _warning;
  39306. }
  39307. }
  39308. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39309. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39310. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39311. /**
  39312. * Default Inputs manager for the FollowCamera.
  39313. * It groups all the default supported inputs for ease of use.
  39314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39315. */
  39316. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39317. /**
  39318. * Instantiates a new FollowCameraInputsManager.
  39319. * @param camera Defines the camera the inputs belong to
  39320. */
  39321. constructor(camera: FollowCamera);
  39322. /**
  39323. * Add keyboard input support to the input manager.
  39324. * @returns the current input manager
  39325. */
  39326. addKeyboard(): FollowCameraInputsManager;
  39327. /**
  39328. * Add mouse wheel input support to the input manager.
  39329. * @returns the current input manager
  39330. */
  39331. addMouseWheel(): FollowCameraInputsManager;
  39332. /**
  39333. * Add pointers input support to the input manager.
  39334. * @returns the current input manager
  39335. */
  39336. addPointers(): FollowCameraInputsManager;
  39337. /**
  39338. * Add orientation input support to the input manager.
  39339. * @returns the current input manager
  39340. */
  39341. addVRDeviceOrientation(): FollowCameraInputsManager;
  39342. }
  39343. }
  39344. declare module "babylonjs/Cameras/followCamera" {
  39345. import { Nullable } from "babylonjs/types";
  39346. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39347. import { Scene } from "babylonjs/scene";
  39348. import { Vector3 } from "babylonjs/Maths/math.vector";
  39349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39350. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39351. /**
  39352. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39353. * an arc rotate version arcFollowCamera are available.
  39354. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39355. */
  39356. export class FollowCamera extends TargetCamera {
  39357. /**
  39358. * Distance the follow camera should follow an object at
  39359. */
  39360. radius: number;
  39361. /**
  39362. * Minimum allowed distance of the camera to the axis of rotation
  39363. * (The camera can not get closer).
  39364. * This can help limiting how the Camera is able to move in the scene.
  39365. */
  39366. lowerRadiusLimit: Nullable<number>;
  39367. /**
  39368. * Maximum allowed distance of the camera to the axis of rotation
  39369. * (The camera can not get further).
  39370. * This can help limiting how the Camera is able to move in the scene.
  39371. */
  39372. upperRadiusLimit: Nullable<number>;
  39373. /**
  39374. * Define a rotation offset between the camera and the object it follows
  39375. */
  39376. rotationOffset: number;
  39377. /**
  39378. * Minimum allowed angle to camera position relative to target object.
  39379. * This can help limiting how the Camera is able to move in the scene.
  39380. */
  39381. lowerRotationOffsetLimit: Nullable<number>;
  39382. /**
  39383. * Maximum allowed angle to camera position relative to target object.
  39384. * This can help limiting how the Camera is able to move in the scene.
  39385. */
  39386. upperRotationOffsetLimit: Nullable<number>;
  39387. /**
  39388. * Define a height offset between the camera and the object it follows.
  39389. * It can help following an object from the top (like a car chaing a plane)
  39390. */
  39391. heightOffset: number;
  39392. /**
  39393. * Minimum allowed height of camera position relative to target object.
  39394. * This can help limiting how the Camera is able to move in the scene.
  39395. */
  39396. lowerHeightOffsetLimit: Nullable<number>;
  39397. /**
  39398. * Maximum allowed height of camera position relative to target object.
  39399. * This can help limiting how the Camera is able to move in the scene.
  39400. */
  39401. upperHeightOffsetLimit: Nullable<number>;
  39402. /**
  39403. * Define how fast the camera can accelerate to follow it s target.
  39404. */
  39405. cameraAcceleration: number;
  39406. /**
  39407. * Define the speed limit of the camera following an object.
  39408. */
  39409. maxCameraSpeed: number;
  39410. /**
  39411. * Define the target of the camera.
  39412. */
  39413. lockedTarget: Nullable<AbstractMesh>;
  39414. /**
  39415. * Defines the input associated with the camera.
  39416. */
  39417. inputs: FollowCameraInputsManager;
  39418. /**
  39419. * Instantiates the follow camera.
  39420. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39421. * @param name Define the name of the camera in the scene
  39422. * @param position Define the position of the camera
  39423. * @param scene Define the scene the camera belong to
  39424. * @param lockedTarget Define the target of the camera
  39425. */
  39426. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39427. private _follow;
  39428. /**
  39429. * Attached controls to the current camera.
  39430. * @param element Defines the element the controls should be listened from
  39431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39432. */
  39433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39434. /**
  39435. * Detach the current controls from the camera.
  39436. * The camera will stop reacting to inputs.
  39437. * @param element Defines the element to stop listening the inputs from
  39438. */
  39439. detachControl(element: HTMLElement): void;
  39440. /** @hidden */
  39441. _checkInputs(): void;
  39442. private _checkLimits;
  39443. /**
  39444. * Gets the camera class name.
  39445. * @returns the class name
  39446. */
  39447. getClassName(): string;
  39448. }
  39449. /**
  39450. * Arc Rotate version of the follow camera.
  39451. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39452. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39453. */
  39454. export class ArcFollowCamera extends TargetCamera {
  39455. /** The longitudinal angle of the camera */
  39456. alpha: number;
  39457. /** The latitudinal angle of the camera */
  39458. beta: number;
  39459. /** The radius of the camera from its target */
  39460. radius: number;
  39461. /** Define the camera target (the messh it should follow) */
  39462. target: Nullable<AbstractMesh>;
  39463. private _cartesianCoordinates;
  39464. /**
  39465. * Instantiates a new ArcFollowCamera
  39466. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39467. * @param name Define the name of the camera
  39468. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39469. * @param beta Define the rotation angle of the camera around the elevation axis
  39470. * @param radius Define the radius of the camera from its target point
  39471. * @param target Define the target of the camera
  39472. * @param scene Define the scene the camera belongs to
  39473. */
  39474. constructor(name: string,
  39475. /** The longitudinal angle of the camera */
  39476. alpha: number,
  39477. /** The latitudinal angle of the camera */
  39478. beta: number,
  39479. /** The radius of the camera from its target */
  39480. radius: number,
  39481. /** Define the camera target (the messh it should follow) */
  39482. target: Nullable<AbstractMesh>, scene: Scene);
  39483. private _follow;
  39484. /** @hidden */
  39485. _checkInputs(): void;
  39486. /**
  39487. * Returns the class name of the object.
  39488. * It is mostly used internally for serialization purposes.
  39489. */
  39490. getClassName(): string;
  39491. }
  39492. }
  39493. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39495. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39496. import { Nullable } from "babylonjs/types";
  39497. /**
  39498. * Manage the keyboard inputs to control the movement of a follow camera.
  39499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39500. */
  39501. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39502. /**
  39503. * Defines the camera the input is attached to.
  39504. */
  39505. camera: FollowCamera;
  39506. /**
  39507. * Defines the list of key codes associated with the up action (increase heightOffset)
  39508. */
  39509. keysHeightOffsetIncr: number[];
  39510. /**
  39511. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39512. */
  39513. keysHeightOffsetDecr: number[];
  39514. /**
  39515. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39516. */
  39517. keysHeightOffsetModifierAlt: boolean;
  39518. /**
  39519. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39520. */
  39521. keysHeightOffsetModifierCtrl: boolean;
  39522. /**
  39523. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39524. */
  39525. keysHeightOffsetModifierShift: boolean;
  39526. /**
  39527. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39528. */
  39529. keysRotationOffsetIncr: number[];
  39530. /**
  39531. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39532. */
  39533. keysRotationOffsetDecr: number[];
  39534. /**
  39535. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39536. */
  39537. keysRotationOffsetModifierAlt: boolean;
  39538. /**
  39539. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39540. */
  39541. keysRotationOffsetModifierCtrl: boolean;
  39542. /**
  39543. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39544. */
  39545. keysRotationOffsetModifierShift: boolean;
  39546. /**
  39547. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39548. */
  39549. keysRadiusIncr: number[];
  39550. /**
  39551. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39552. */
  39553. keysRadiusDecr: number[];
  39554. /**
  39555. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39556. */
  39557. keysRadiusModifierAlt: boolean;
  39558. /**
  39559. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39560. */
  39561. keysRadiusModifierCtrl: boolean;
  39562. /**
  39563. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39564. */
  39565. keysRadiusModifierShift: boolean;
  39566. /**
  39567. * Defines the rate of change of heightOffset.
  39568. */
  39569. heightSensibility: number;
  39570. /**
  39571. * Defines the rate of change of rotationOffset.
  39572. */
  39573. rotationSensibility: number;
  39574. /**
  39575. * Defines the rate of change of radius.
  39576. */
  39577. radiusSensibility: number;
  39578. private _keys;
  39579. private _ctrlPressed;
  39580. private _altPressed;
  39581. private _shiftPressed;
  39582. private _onCanvasBlurObserver;
  39583. private _onKeyboardObserver;
  39584. private _engine;
  39585. private _scene;
  39586. /**
  39587. * Attach the input controls to a specific dom element to get the input from.
  39588. * @param element Defines the element the controls should be listened from
  39589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39590. */
  39591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39592. /**
  39593. * Detach the current controls from the specified dom element.
  39594. * @param element Defines the element to stop listening the inputs from
  39595. */
  39596. detachControl(element: Nullable<HTMLElement>): void;
  39597. /**
  39598. * Update the current camera state depending on the inputs that have been used this frame.
  39599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39600. */
  39601. checkInputs(): void;
  39602. /**
  39603. * Gets the class name of the current input.
  39604. * @returns the class name
  39605. */
  39606. getClassName(): string;
  39607. /**
  39608. * Get the friendly name associated with the input class.
  39609. * @returns the input friendly name
  39610. */
  39611. getSimpleName(): string;
  39612. /**
  39613. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39614. * allow modification of the heightOffset value.
  39615. */
  39616. private _modifierHeightOffset;
  39617. /**
  39618. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39619. * allow modification of the rotationOffset value.
  39620. */
  39621. private _modifierRotationOffset;
  39622. /**
  39623. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39624. * allow modification of the radius value.
  39625. */
  39626. private _modifierRadius;
  39627. }
  39628. }
  39629. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39630. import { Nullable } from "babylonjs/types";
  39631. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39632. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39633. import { Observable } from "babylonjs/Misc/observable";
  39634. module "babylonjs/Cameras/freeCameraInputsManager" {
  39635. interface FreeCameraInputsManager {
  39636. /**
  39637. * @hidden
  39638. */
  39639. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39640. /**
  39641. * Add orientation input support to the input manager.
  39642. * @returns the current input manager
  39643. */
  39644. addDeviceOrientation(): FreeCameraInputsManager;
  39645. }
  39646. }
  39647. /**
  39648. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39649. * Screen rotation is taken into account.
  39650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39651. */
  39652. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39653. private _camera;
  39654. private _screenOrientationAngle;
  39655. private _constantTranform;
  39656. private _screenQuaternion;
  39657. private _alpha;
  39658. private _beta;
  39659. private _gamma;
  39660. /**
  39661. * Can be used to detect if a device orientation sensor is availible on a device
  39662. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39663. * @returns a promise that will resolve on orientation change
  39664. */
  39665. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39666. /**
  39667. * @hidden
  39668. */
  39669. _onDeviceOrientationChangedObservable: Observable<void>;
  39670. /**
  39671. * Instantiates a new input
  39672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39673. */
  39674. constructor();
  39675. /**
  39676. * Define the camera controlled by the input.
  39677. */
  39678. camera: FreeCamera;
  39679. /**
  39680. * Attach the input controls to a specific dom element to get the input from.
  39681. * @param element Defines the element the controls should be listened from
  39682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39683. */
  39684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39685. private _orientationChanged;
  39686. private _deviceOrientation;
  39687. /**
  39688. * Detach the current controls from the specified dom element.
  39689. * @param element Defines the element to stop listening the inputs from
  39690. */
  39691. detachControl(element: Nullable<HTMLElement>): void;
  39692. /**
  39693. * Update the current camera state depending on the inputs that have been used this frame.
  39694. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39695. */
  39696. checkInputs(): void;
  39697. /**
  39698. * Gets the class name of the current intput.
  39699. * @returns the class name
  39700. */
  39701. getClassName(): string;
  39702. /**
  39703. * Get the friendly name associated with the input class.
  39704. * @returns the input friendly name
  39705. */
  39706. getSimpleName(): string;
  39707. }
  39708. }
  39709. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39710. import { Nullable } from "babylonjs/types";
  39711. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39712. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39713. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39714. /**
  39715. * Manage the gamepad inputs to control a free camera.
  39716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39717. */
  39718. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39719. /**
  39720. * Define the camera the input is attached to.
  39721. */
  39722. camera: FreeCamera;
  39723. /**
  39724. * Define the Gamepad controlling the input
  39725. */
  39726. gamepad: Nullable<Gamepad>;
  39727. /**
  39728. * Defines the gamepad rotation sensiblity.
  39729. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39730. */
  39731. gamepadAngularSensibility: number;
  39732. /**
  39733. * Defines the gamepad move sensiblity.
  39734. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39735. */
  39736. gamepadMoveSensibility: number;
  39737. private _yAxisScale;
  39738. /**
  39739. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39740. */
  39741. invertYAxis: boolean;
  39742. private _onGamepadConnectedObserver;
  39743. private _onGamepadDisconnectedObserver;
  39744. private _cameraTransform;
  39745. private _deltaTransform;
  39746. private _vector3;
  39747. private _vector2;
  39748. /**
  39749. * Attach the input controls to a specific dom element to get the input from.
  39750. * @param element Defines the element the controls should be listened from
  39751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39752. */
  39753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39754. /**
  39755. * Detach the current controls from the specified dom element.
  39756. * @param element Defines the element to stop listening the inputs from
  39757. */
  39758. detachControl(element: Nullable<HTMLElement>): void;
  39759. /**
  39760. * Update the current camera state depending on the inputs that have been used this frame.
  39761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39762. */
  39763. checkInputs(): void;
  39764. /**
  39765. * Gets the class name of the current intput.
  39766. * @returns the class name
  39767. */
  39768. getClassName(): string;
  39769. /**
  39770. * Get the friendly name associated with the input class.
  39771. * @returns the input friendly name
  39772. */
  39773. getSimpleName(): string;
  39774. }
  39775. }
  39776. declare module "babylonjs/Misc/virtualJoystick" {
  39777. import { Nullable } from "babylonjs/types";
  39778. import { Vector3 } from "babylonjs/Maths/math.vector";
  39779. /**
  39780. * Defines the potential axis of a Joystick
  39781. */
  39782. export enum JoystickAxis {
  39783. /** X axis */
  39784. X = 0,
  39785. /** Y axis */
  39786. Y = 1,
  39787. /** Z axis */
  39788. Z = 2
  39789. }
  39790. /**
  39791. * Class used to define virtual joystick (used in touch mode)
  39792. */
  39793. export class VirtualJoystick {
  39794. /**
  39795. * Gets or sets a boolean indicating that left and right values must be inverted
  39796. */
  39797. reverseLeftRight: boolean;
  39798. /**
  39799. * Gets or sets a boolean indicating that up and down values must be inverted
  39800. */
  39801. reverseUpDown: boolean;
  39802. /**
  39803. * Gets the offset value for the position (ie. the change of the position value)
  39804. */
  39805. deltaPosition: Vector3;
  39806. /**
  39807. * Gets a boolean indicating if the virtual joystick was pressed
  39808. */
  39809. pressed: boolean;
  39810. /**
  39811. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39812. */
  39813. static Canvas: Nullable<HTMLCanvasElement>;
  39814. private static _globalJoystickIndex;
  39815. private static vjCanvasContext;
  39816. private static vjCanvasWidth;
  39817. private static vjCanvasHeight;
  39818. private static halfWidth;
  39819. private _action;
  39820. private _axisTargetedByLeftAndRight;
  39821. private _axisTargetedByUpAndDown;
  39822. private _joystickSensibility;
  39823. private _inversedSensibility;
  39824. private _joystickPointerID;
  39825. private _joystickColor;
  39826. private _joystickPointerPos;
  39827. private _joystickPreviousPointerPos;
  39828. private _joystickPointerStartPos;
  39829. private _deltaJoystickVector;
  39830. private _leftJoystick;
  39831. private _touches;
  39832. private _onPointerDownHandlerRef;
  39833. private _onPointerMoveHandlerRef;
  39834. private _onPointerUpHandlerRef;
  39835. private _onResize;
  39836. /**
  39837. * Creates a new virtual joystick
  39838. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39839. */
  39840. constructor(leftJoystick?: boolean);
  39841. /**
  39842. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39843. * @param newJoystickSensibility defines the new sensibility
  39844. */
  39845. setJoystickSensibility(newJoystickSensibility: number): void;
  39846. private _onPointerDown;
  39847. private _onPointerMove;
  39848. private _onPointerUp;
  39849. /**
  39850. * Change the color of the virtual joystick
  39851. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39852. */
  39853. setJoystickColor(newColor: string): void;
  39854. /**
  39855. * Defines a callback to call when the joystick is touched
  39856. * @param action defines the callback
  39857. */
  39858. setActionOnTouch(action: () => any): void;
  39859. /**
  39860. * Defines which axis you'd like to control for left & right
  39861. * @param axis defines the axis to use
  39862. */
  39863. setAxisForLeftRight(axis: JoystickAxis): void;
  39864. /**
  39865. * Defines which axis you'd like to control for up & down
  39866. * @param axis defines the axis to use
  39867. */
  39868. setAxisForUpDown(axis: JoystickAxis): void;
  39869. private _drawVirtualJoystick;
  39870. /**
  39871. * Release internal HTML canvas
  39872. */
  39873. releaseCanvas(): void;
  39874. }
  39875. }
  39876. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39877. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39878. import { Nullable } from "babylonjs/types";
  39879. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39880. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39881. module "babylonjs/Cameras/freeCameraInputsManager" {
  39882. interface FreeCameraInputsManager {
  39883. /**
  39884. * Add virtual joystick input support to the input manager.
  39885. * @returns the current input manager
  39886. */
  39887. addVirtualJoystick(): FreeCameraInputsManager;
  39888. }
  39889. }
  39890. /**
  39891. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39893. */
  39894. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39895. /**
  39896. * Defines the camera the input is attached to.
  39897. */
  39898. camera: FreeCamera;
  39899. private _leftjoystick;
  39900. private _rightjoystick;
  39901. /**
  39902. * Gets the left stick of the virtual joystick.
  39903. * @returns The virtual Joystick
  39904. */
  39905. getLeftJoystick(): VirtualJoystick;
  39906. /**
  39907. * Gets the right stick of the virtual joystick.
  39908. * @returns The virtual Joystick
  39909. */
  39910. getRightJoystick(): VirtualJoystick;
  39911. /**
  39912. * Update the current camera state depending on the inputs that have been used this frame.
  39913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39914. */
  39915. checkInputs(): void;
  39916. /**
  39917. * Attach the input controls to a specific dom element to get the input from.
  39918. * @param element Defines the element the controls should be listened from
  39919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39920. */
  39921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39922. /**
  39923. * Detach the current controls from the specified dom element.
  39924. * @param element Defines the element to stop listening the inputs from
  39925. */
  39926. detachControl(element: Nullable<HTMLElement>): void;
  39927. /**
  39928. * Gets the class name of the current intput.
  39929. * @returns the class name
  39930. */
  39931. getClassName(): string;
  39932. /**
  39933. * Get the friendly name associated with the input class.
  39934. * @returns the input friendly name
  39935. */
  39936. getSimpleName(): string;
  39937. }
  39938. }
  39939. declare module "babylonjs/Cameras/Inputs/index" {
  39940. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39941. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39942. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39943. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39944. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39945. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39946. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39947. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39948. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39949. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39950. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39951. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39952. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39953. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39954. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39955. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39956. }
  39957. declare module "babylonjs/Cameras/touchCamera" {
  39958. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39959. import { Scene } from "babylonjs/scene";
  39960. import { Vector3 } from "babylonjs/Maths/math.vector";
  39961. /**
  39962. * This represents a FPS type of camera controlled by touch.
  39963. * This is like a universal camera minus the Gamepad controls.
  39964. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39965. */
  39966. export class TouchCamera extends FreeCamera {
  39967. /**
  39968. * Defines the touch sensibility for rotation.
  39969. * The higher the faster.
  39970. */
  39971. touchAngularSensibility: number;
  39972. /**
  39973. * Defines the touch sensibility for move.
  39974. * The higher the faster.
  39975. */
  39976. touchMoveSensibility: number;
  39977. /**
  39978. * Instantiates a new touch camera.
  39979. * This represents a FPS type of camera controlled by touch.
  39980. * This is like a universal camera minus the Gamepad controls.
  39981. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39982. * @param name Define the name of the camera in the scene
  39983. * @param position Define the start position of the camera in the scene
  39984. * @param scene Define the scene the camera belongs to
  39985. */
  39986. constructor(name: string, position: Vector3, scene: Scene);
  39987. /**
  39988. * Gets the current object class name.
  39989. * @return the class name
  39990. */
  39991. getClassName(): string;
  39992. /** @hidden */
  39993. _setupInputs(): void;
  39994. }
  39995. }
  39996. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39997. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39998. import { Scene } from "babylonjs/scene";
  39999. import { Vector3 } from "babylonjs/Maths/math.vector";
  40000. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40001. import { Axis } from "babylonjs/Maths/math.axis";
  40002. /**
  40003. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40004. * being tilted forward or back and left or right.
  40005. */
  40006. export class DeviceOrientationCamera extends FreeCamera {
  40007. private _initialQuaternion;
  40008. private _quaternionCache;
  40009. private _tmpDragQuaternion;
  40010. private _disablePointerInputWhenUsingDeviceOrientation;
  40011. /**
  40012. * Creates a new device orientation camera
  40013. * @param name The name of the camera
  40014. * @param position The start position camera
  40015. * @param scene The scene the camera belongs to
  40016. */
  40017. constructor(name: string, position: Vector3, scene: Scene);
  40018. /**
  40019. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40020. */
  40021. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40022. private _dragFactor;
  40023. /**
  40024. * Enabled turning on the y axis when the orientation sensor is active
  40025. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40026. */
  40027. enableHorizontalDragging(dragFactor?: number): void;
  40028. /**
  40029. * Gets the current instance class name ("DeviceOrientationCamera").
  40030. * This helps avoiding instanceof at run time.
  40031. * @returns the class name
  40032. */
  40033. getClassName(): string;
  40034. /**
  40035. * @hidden
  40036. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40037. */
  40038. _checkInputs(): void;
  40039. /**
  40040. * Reset the camera to its default orientation on the specified axis only.
  40041. * @param axis The axis to reset
  40042. */
  40043. resetToCurrentRotation(axis?: Axis): void;
  40044. }
  40045. }
  40046. declare module "babylonjs/Gamepads/xboxGamepad" {
  40047. import { Observable } from "babylonjs/Misc/observable";
  40048. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40049. /**
  40050. * Defines supported buttons for XBox360 compatible gamepads
  40051. */
  40052. export enum Xbox360Button {
  40053. /** A */
  40054. A = 0,
  40055. /** B */
  40056. B = 1,
  40057. /** X */
  40058. X = 2,
  40059. /** Y */
  40060. Y = 3,
  40061. /** Start */
  40062. Start = 4,
  40063. /** Back */
  40064. Back = 5,
  40065. /** Left button */
  40066. LB = 6,
  40067. /** Right button */
  40068. RB = 7,
  40069. /** Left stick */
  40070. LeftStick = 8,
  40071. /** Right stick */
  40072. RightStick = 9
  40073. }
  40074. /** Defines values for XBox360 DPad */
  40075. export enum Xbox360Dpad {
  40076. /** Up */
  40077. Up = 0,
  40078. /** Down */
  40079. Down = 1,
  40080. /** Left */
  40081. Left = 2,
  40082. /** Right */
  40083. Right = 3
  40084. }
  40085. /**
  40086. * Defines a XBox360 gamepad
  40087. */
  40088. export class Xbox360Pad extends Gamepad {
  40089. private _leftTrigger;
  40090. private _rightTrigger;
  40091. private _onlefttriggerchanged;
  40092. private _onrighttriggerchanged;
  40093. private _onbuttondown;
  40094. private _onbuttonup;
  40095. private _ondpaddown;
  40096. private _ondpadup;
  40097. /** Observable raised when a button is pressed */
  40098. onButtonDownObservable: Observable<Xbox360Button>;
  40099. /** Observable raised when a button is released */
  40100. onButtonUpObservable: Observable<Xbox360Button>;
  40101. /** Observable raised when a pad is pressed */
  40102. onPadDownObservable: Observable<Xbox360Dpad>;
  40103. /** Observable raised when a pad is released */
  40104. onPadUpObservable: Observable<Xbox360Dpad>;
  40105. private _buttonA;
  40106. private _buttonB;
  40107. private _buttonX;
  40108. private _buttonY;
  40109. private _buttonBack;
  40110. private _buttonStart;
  40111. private _buttonLB;
  40112. private _buttonRB;
  40113. private _buttonLeftStick;
  40114. private _buttonRightStick;
  40115. private _dPadUp;
  40116. private _dPadDown;
  40117. private _dPadLeft;
  40118. private _dPadRight;
  40119. private _isXboxOnePad;
  40120. /**
  40121. * Creates a new XBox360 gamepad object
  40122. * @param id defines the id of this gamepad
  40123. * @param index defines its index
  40124. * @param gamepad defines the internal HTML gamepad object
  40125. * @param xboxOne defines if it is a XBox One gamepad
  40126. */
  40127. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40128. /**
  40129. * Defines the callback to call when left trigger is pressed
  40130. * @param callback defines the callback to use
  40131. */
  40132. onlefttriggerchanged(callback: (value: number) => void): void;
  40133. /**
  40134. * Defines the callback to call when right trigger is pressed
  40135. * @param callback defines the callback to use
  40136. */
  40137. onrighttriggerchanged(callback: (value: number) => void): void;
  40138. /**
  40139. * Gets the left trigger value
  40140. */
  40141. /**
  40142. * Sets the left trigger value
  40143. */
  40144. leftTrigger: number;
  40145. /**
  40146. * Gets the right trigger value
  40147. */
  40148. /**
  40149. * Sets the right trigger value
  40150. */
  40151. rightTrigger: number;
  40152. /**
  40153. * Defines the callback to call when a button is pressed
  40154. * @param callback defines the callback to use
  40155. */
  40156. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40157. /**
  40158. * Defines the callback to call when a button is released
  40159. * @param callback defines the callback to use
  40160. */
  40161. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40162. /**
  40163. * Defines the callback to call when a pad is pressed
  40164. * @param callback defines the callback to use
  40165. */
  40166. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40167. /**
  40168. * Defines the callback to call when a pad is released
  40169. * @param callback defines the callback to use
  40170. */
  40171. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40172. private _setButtonValue;
  40173. private _setDPadValue;
  40174. /**
  40175. * Gets the value of the `A` button
  40176. */
  40177. /**
  40178. * Sets the value of the `A` button
  40179. */
  40180. buttonA: number;
  40181. /**
  40182. * Gets the value of the `B` button
  40183. */
  40184. /**
  40185. * Sets the value of the `B` button
  40186. */
  40187. buttonB: number;
  40188. /**
  40189. * Gets the value of the `X` button
  40190. */
  40191. /**
  40192. * Sets the value of the `X` button
  40193. */
  40194. buttonX: number;
  40195. /**
  40196. * Gets the value of the `Y` button
  40197. */
  40198. /**
  40199. * Sets the value of the `Y` button
  40200. */
  40201. buttonY: number;
  40202. /**
  40203. * Gets the value of the `Start` button
  40204. */
  40205. /**
  40206. * Sets the value of the `Start` button
  40207. */
  40208. buttonStart: number;
  40209. /**
  40210. * Gets the value of the `Back` button
  40211. */
  40212. /**
  40213. * Sets the value of the `Back` button
  40214. */
  40215. buttonBack: number;
  40216. /**
  40217. * Gets the value of the `Left` button
  40218. */
  40219. /**
  40220. * Sets the value of the `Left` button
  40221. */
  40222. buttonLB: number;
  40223. /**
  40224. * Gets the value of the `Right` button
  40225. */
  40226. /**
  40227. * Sets the value of the `Right` button
  40228. */
  40229. buttonRB: number;
  40230. /**
  40231. * Gets the value of the Left joystick
  40232. */
  40233. /**
  40234. * Sets the value of the Left joystick
  40235. */
  40236. buttonLeftStick: number;
  40237. /**
  40238. * Gets the value of the Right joystick
  40239. */
  40240. /**
  40241. * Sets the value of the Right joystick
  40242. */
  40243. buttonRightStick: number;
  40244. /**
  40245. * Gets the value of D-pad up
  40246. */
  40247. /**
  40248. * Sets the value of D-pad up
  40249. */
  40250. dPadUp: number;
  40251. /**
  40252. * Gets the value of D-pad down
  40253. */
  40254. /**
  40255. * Sets the value of D-pad down
  40256. */
  40257. dPadDown: number;
  40258. /**
  40259. * Gets the value of D-pad left
  40260. */
  40261. /**
  40262. * Sets the value of D-pad left
  40263. */
  40264. dPadLeft: number;
  40265. /**
  40266. * Gets the value of D-pad right
  40267. */
  40268. /**
  40269. * Sets the value of D-pad right
  40270. */
  40271. dPadRight: number;
  40272. /**
  40273. * Force the gamepad to synchronize with device values
  40274. */
  40275. update(): void;
  40276. /**
  40277. * Disposes the gamepad
  40278. */
  40279. dispose(): void;
  40280. }
  40281. }
  40282. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40283. import { Observable } from "babylonjs/Misc/observable";
  40284. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40285. /**
  40286. * Defines supported buttons for DualShock compatible gamepads
  40287. */
  40288. export enum DualShockButton {
  40289. /** Cross */
  40290. Cross = 0,
  40291. /** Circle */
  40292. Circle = 1,
  40293. /** Square */
  40294. Square = 2,
  40295. /** Triangle */
  40296. Triangle = 3,
  40297. /** Options */
  40298. Options = 4,
  40299. /** Share */
  40300. Share = 5,
  40301. /** L1 */
  40302. L1 = 6,
  40303. /** R1 */
  40304. R1 = 7,
  40305. /** Left stick */
  40306. LeftStick = 8,
  40307. /** Right stick */
  40308. RightStick = 9
  40309. }
  40310. /** Defines values for DualShock DPad */
  40311. export enum DualShockDpad {
  40312. /** Up */
  40313. Up = 0,
  40314. /** Down */
  40315. Down = 1,
  40316. /** Left */
  40317. Left = 2,
  40318. /** Right */
  40319. Right = 3
  40320. }
  40321. /**
  40322. * Defines a DualShock gamepad
  40323. */
  40324. export class DualShockPad extends Gamepad {
  40325. private _leftTrigger;
  40326. private _rightTrigger;
  40327. private _onlefttriggerchanged;
  40328. private _onrighttriggerchanged;
  40329. private _onbuttondown;
  40330. private _onbuttonup;
  40331. private _ondpaddown;
  40332. private _ondpadup;
  40333. /** Observable raised when a button is pressed */
  40334. onButtonDownObservable: Observable<DualShockButton>;
  40335. /** Observable raised when a button is released */
  40336. onButtonUpObservable: Observable<DualShockButton>;
  40337. /** Observable raised when a pad is pressed */
  40338. onPadDownObservable: Observable<DualShockDpad>;
  40339. /** Observable raised when a pad is released */
  40340. onPadUpObservable: Observable<DualShockDpad>;
  40341. private _buttonCross;
  40342. private _buttonCircle;
  40343. private _buttonSquare;
  40344. private _buttonTriangle;
  40345. private _buttonShare;
  40346. private _buttonOptions;
  40347. private _buttonL1;
  40348. private _buttonR1;
  40349. private _buttonLeftStick;
  40350. private _buttonRightStick;
  40351. private _dPadUp;
  40352. private _dPadDown;
  40353. private _dPadLeft;
  40354. private _dPadRight;
  40355. /**
  40356. * Creates a new DualShock gamepad object
  40357. * @param id defines the id of this gamepad
  40358. * @param index defines its index
  40359. * @param gamepad defines the internal HTML gamepad object
  40360. */
  40361. constructor(id: string, index: number, gamepad: any);
  40362. /**
  40363. * Defines the callback to call when left trigger is pressed
  40364. * @param callback defines the callback to use
  40365. */
  40366. onlefttriggerchanged(callback: (value: number) => void): void;
  40367. /**
  40368. * Defines the callback to call when right trigger is pressed
  40369. * @param callback defines the callback to use
  40370. */
  40371. onrighttriggerchanged(callback: (value: number) => void): void;
  40372. /**
  40373. * Gets the left trigger value
  40374. */
  40375. /**
  40376. * Sets the left trigger value
  40377. */
  40378. leftTrigger: number;
  40379. /**
  40380. * Gets the right trigger value
  40381. */
  40382. /**
  40383. * Sets the right trigger value
  40384. */
  40385. rightTrigger: number;
  40386. /**
  40387. * Defines the callback to call when a button is pressed
  40388. * @param callback defines the callback to use
  40389. */
  40390. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40391. /**
  40392. * Defines the callback to call when a button is released
  40393. * @param callback defines the callback to use
  40394. */
  40395. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40396. /**
  40397. * Defines the callback to call when a pad is pressed
  40398. * @param callback defines the callback to use
  40399. */
  40400. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40401. /**
  40402. * Defines the callback to call when a pad is released
  40403. * @param callback defines the callback to use
  40404. */
  40405. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40406. private _setButtonValue;
  40407. private _setDPadValue;
  40408. /**
  40409. * Gets the value of the `Cross` button
  40410. */
  40411. /**
  40412. * Sets the value of the `Cross` button
  40413. */
  40414. buttonCross: number;
  40415. /**
  40416. * Gets the value of the `Circle` button
  40417. */
  40418. /**
  40419. * Sets the value of the `Circle` button
  40420. */
  40421. buttonCircle: number;
  40422. /**
  40423. * Gets the value of the `Square` button
  40424. */
  40425. /**
  40426. * Sets the value of the `Square` button
  40427. */
  40428. buttonSquare: number;
  40429. /**
  40430. * Gets the value of the `Triangle` button
  40431. */
  40432. /**
  40433. * Sets the value of the `Triangle` button
  40434. */
  40435. buttonTriangle: number;
  40436. /**
  40437. * Gets the value of the `Options` button
  40438. */
  40439. /**
  40440. * Sets the value of the `Options` button
  40441. */
  40442. buttonOptions: number;
  40443. /**
  40444. * Gets the value of the `Share` button
  40445. */
  40446. /**
  40447. * Sets the value of the `Share` button
  40448. */
  40449. buttonShare: number;
  40450. /**
  40451. * Gets the value of the `L1` button
  40452. */
  40453. /**
  40454. * Sets the value of the `L1` button
  40455. */
  40456. buttonL1: number;
  40457. /**
  40458. * Gets the value of the `R1` button
  40459. */
  40460. /**
  40461. * Sets the value of the `R1` button
  40462. */
  40463. buttonR1: number;
  40464. /**
  40465. * Gets the value of the Left joystick
  40466. */
  40467. /**
  40468. * Sets the value of the Left joystick
  40469. */
  40470. buttonLeftStick: number;
  40471. /**
  40472. * Gets the value of the Right joystick
  40473. */
  40474. /**
  40475. * Sets the value of the Right joystick
  40476. */
  40477. buttonRightStick: number;
  40478. /**
  40479. * Gets the value of D-pad up
  40480. */
  40481. /**
  40482. * Sets the value of D-pad up
  40483. */
  40484. dPadUp: number;
  40485. /**
  40486. * Gets the value of D-pad down
  40487. */
  40488. /**
  40489. * Sets the value of D-pad down
  40490. */
  40491. dPadDown: number;
  40492. /**
  40493. * Gets the value of D-pad left
  40494. */
  40495. /**
  40496. * Sets the value of D-pad left
  40497. */
  40498. dPadLeft: number;
  40499. /**
  40500. * Gets the value of D-pad right
  40501. */
  40502. /**
  40503. * Sets the value of D-pad right
  40504. */
  40505. dPadRight: number;
  40506. /**
  40507. * Force the gamepad to synchronize with device values
  40508. */
  40509. update(): void;
  40510. /**
  40511. * Disposes the gamepad
  40512. */
  40513. dispose(): void;
  40514. }
  40515. }
  40516. declare module "babylonjs/Gamepads/gamepadManager" {
  40517. import { Observable } from "babylonjs/Misc/observable";
  40518. import { Nullable } from "babylonjs/types";
  40519. import { Scene } from "babylonjs/scene";
  40520. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40521. /**
  40522. * Manager for handling gamepads
  40523. */
  40524. export class GamepadManager {
  40525. private _scene?;
  40526. private _babylonGamepads;
  40527. private _oneGamepadConnected;
  40528. /** @hidden */
  40529. _isMonitoring: boolean;
  40530. private _gamepadEventSupported;
  40531. private _gamepadSupport;
  40532. /**
  40533. * observable to be triggered when the gamepad controller has been connected
  40534. */
  40535. onGamepadConnectedObservable: Observable<Gamepad>;
  40536. /**
  40537. * observable to be triggered when the gamepad controller has been disconnected
  40538. */
  40539. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40540. private _onGamepadConnectedEvent;
  40541. private _onGamepadDisconnectedEvent;
  40542. /**
  40543. * Initializes the gamepad manager
  40544. * @param _scene BabylonJS scene
  40545. */
  40546. constructor(_scene?: Scene | undefined);
  40547. /**
  40548. * The gamepads in the game pad manager
  40549. */
  40550. readonly gamepads: Gamepad[];
  40551. /**
  40552. * Get the gamepad controllers based on type
  40553. * @param type The type of gamepad controller
  40554. * @returns Nullable gamepad
  40555. */
  40556. getGamepadByType(type?: number): Nullable<Gamepad>;
  40557. /**
  40558. * Disposes the gamepad manager
  40559. */
  40560. dispose(): void;
  40561. private _addNewGamepad;
  40562. private _startMonitoringGamepads;
  40563. private _stopMonitoringGamepads;
  40564. /** @hidden */
  40565. _checkGamepadsStatus(): void;
  40566. private _updateGamepadObjects;
  40567. }
  40568. }
  40569. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40570. import { Nullable } from "babylonjs/types";
  40571. import { Scene } from "babylonjs/scene";
  40572. import { ISceneComponent } from "babylonjs/sceneComponent";
  40573. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40574. module "babylonjs/scene" {
  40575. interface Scene {
  40576. /** @hidden */
  40577. _gamepadManager: Nullable<GamepadManager>;
  40578. /**
  40579. * Gets the gamepad manager associated with the scene
  40580. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40581. */
  40582. gamepadManager: GamepadManager;
  40583. }
  40584. }
  40585. module "babylonjs/Cameras/freeCameraInputsManager" {
  40586. /**
  40587. * Interface representing a free camera inputs manager
  40588. */
  40589. interface FreeCameraInputsManager {
  40590. /**
  40591. * Adds gamepad input support to the FreeCameraInputsManager.
  40592. * @returns the FreeCameraInputsManager
  40593. */
  40594. addGamepad(): FreeCameraInputsManager;
  40595. }
  40596. }
  40597. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40598. /**
  40599. * Interface representing an arc rotate camera inputs manager
  40600. */
  40601. interface ArcRotateCameraInputsManager {
  40602. /**
  40603. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40604. * @returns the camera inputs manager
  40605. */
  40606. addGamepad(): ArcRotateCameraInputsManager;
  40607. }
  40608. }
  40609. /**
  40610. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40611. */
  40612. export class GamepadSystemSceneComponent implements ISceneComponent {
  40613. /**
  40614. * The component name helpfull to identify the component in the list of scene components.
  40615. */
  40616. readonly name: string;
  40617. /**
  40618. * The scene the component belongs to.
  40619. */
  40620. scene: Scene;
  40621. /**
  40622. * Creates a new instance of the component for the given scene
  40623. * @param scene Defines the scene to register the component in
  40624. */
  40625. constructor(scene: Scene);
  40626. /**
  40627. * Registers the component in a given scene
  40628. */
  40629. register(): void;
  40630. /**
  40631. * Rebuilds the elements related to this component in case of
  40632. * context lost for instance.
  40633. */
  40634. rebuild(): void;
  40635. /**
  40636. * Disposes the component and the associated ressources
  40637. */
  40638. dispose(): void;
  40639. private _beforeCameraUpdate;
  40640. }
  40641. }
  40642. declare module "babylonjs/Cameras/universalCamera" {
  40643. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40644. import { Scene } from "babylonjs/scene";
  40645. import { Vector3 } from "babylonjs/Maths/math.vector";
  40646. import "babylonjs/Gamepads/gamepadSceneComponent";
  40647. /**
  40648. * 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,
  40649. * which still works and will still be found in many Playgrounds.
  40650. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40651. */
  40652. export class UniversalCamera extends TouchCamera {
  40653. /**
  40654. * Defines the gamepad rotation sensiblity.
  40655. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40656. */
  40657. gamepadAngularSensibility: number;
  40658. /**
  40659. * Defines the gamepad move sensiblity.
  40660. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40661. */
  40662. gamepadMoveSensibility: number;
  40663. /**
  40664. * 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,
  40665. * which still works and will still be found in many Playgrounds.
  40666. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40667. * @param name Define the name of the camera in the scene
  40668. * @param position Define the start position of the camera in the scene
  40669. * @param scene Define the scene the camera belongs to
  40670. */
  40671. constructor(name: string, position: Vector3, scene: Scene);
  40672. /**
  40673. * Gets the current object class name.
  40674. * @return the class name
  40675. */
  40676. getClassName(): string;
  40677. }
  40678. }
  40679. declare module "babylonjs/Cameras/gamepadCamera" {
  40680. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40681. import { Scene } from "babylonjs/scene";
  40682. import { Vector3 } from "babylonjs/Maths/math.vector";
  40683. /**
  40684. * This represents a FPS type of camera. This is only here for back compat purpose.
  40685. * Please use the UniversalCamera instead as both are identical.
  40686. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40687. */
  40688. export class GamepadCamera extends UniversalCamera {
  40689. /**
  40690. * Instantiates a new Gamepad Camera
  40691. * This represents a FPS type of camera. This is only here for back compat purpose.
  40692. * Please use the UniversalCamera instead as both are identical.
  40693. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40694. * @param name Define the name of the camera in the scene
  40695. * @param position Define the start position of the camera in the scene
  40696. * @param scene Define the scene the camera belongs to
  40697. */
  40698. constructor(name: string, position: Vector3, scene: Scene);
  40699. /**
  40700. * Gets the current object class name.
  40701. * @return the class name
  40702. */
  40703. getClassName(): string;
  40704. }
  40705. }
  40706. declare module "babylonjs/Shaders/pass.fragment" {
  40707. /** @hidden */
  40708. export var passPixelShader: {
  40709. name: string;
  40710. shader: string;
  40711. };
  40712. }
  40713. declare module "babylonjs/Shaders/passCube.fragment" {
  40714. /** @hidden */
  40715. export var passCubePixelShader: {
  40716. name: string;
  40717. shader: string;
  40718. };
  40719. }
  40720. declare module "babylonjs/PostProcesses/passPostProcess" {
  40721. import { Nullable } from "babylonjs/types";
  40722. import { Camera } from "babylonjs/Cameras/camera";
  40723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40724. import { Engine } from "babylonjs/Engines/engine";
  40725. import "babylonjs/Shaders/pass.fragment";
  40726. import "babylonjs/Shaders/passCube.fragment";
  40727. /**
  40728. * PassPostProcess which produces an output the same as it's input
  40729. */
  40730. export class PassPostProcess extends PostProcess {
  40731. /**
  40732. * Creates the PassPostProcess
  40733. * @param name The name of the effect.
  40734. * @param options The required width/height ratio to downsize to before computing the render pass.
  40735. * @param camera The camera to apply the render pass to.
  40736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40737. * @param engine The engine which the post process will be applied. (default: current engine)
  40738. * @param reusable If the post process can be reused on the same frame. (default: false)
  40739. * @param textureType The type of texture to be used when performing the post processing.
  40740. * @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)
  40741. */
  40742. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40743. }
  40744. /**
  40745. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40746. */
  40747. export class PassCubePostProcess extends PostProcess {
  40748. private _face;
  40749. /**
  40750. * Gets or sets the cube face to display.
  40751. * * 0 is +X
  40752. * * 1 is -X
  40753. * * 2 is +Y
  40754. * * 3 is -Y
  40755. * * 4 is +Z
  40756. * * 5 is -Z
  40757. */
  40758. face: number;
  40759. /**
  40760. * Creates the PassCubePostProcess
  40761. * @param name The name of the effect.
  40762. * @param options The required width/height ratio to downsize to before computing the render pass.
  40763. * @param camera The camera to apply the render pass to.
  40764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40765. * @param engine The engine which the post process will be applied. (default: current engine)
  40766. * @param reusable If the post process can be reused on the same frame. (default: false)
  40767. * @param textureType The type of texture to be used when performing the post processing.
  40768. * @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)
  40769. */
  40770. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40771. }
  40772. }
  40773. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40774. /** @hidden */
  40775. export var anaglyphPixelShader: {
  40776. name: string;
  40777. shader: string;
  40778. };
  40779. }
  40780. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40781. import { Engine } from "babylonjs/Engines/engine";
  40782. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40783. import { Camera } from "babylonjs/Cameras/camera";
  40784. import "babylonjs/Shaders/anaglyph.fragment";
  40785. /**
  40786. * Postprocess used to generate anaglyphic rendering
  40787. */
  40788. export class AnaglyphPostProcess extends PostProcess {
  40789. private _passedProcess;
  40790. /**
  40791. * Creates a new AnaglyphPostProcess
  40792. * @param name defines postprocess name
  40793. * @param options defines creation options or target ratio scale
  40794. * @param rigCameras defines cameras using this postprocess
  40795. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40796. * @param engine defines hosting engine
  40797. * @param reusable defines if the postprocess will be reused multiple times per frame
  40798. */
  40799. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40800. }
  40801. }
  40802. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40803. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40804. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40805. import { Scene } from "babylonjs/scene";
  40806. import { Vector3 } from "babylonjs/Maths/math.vector";
  40807. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40808. /**
  40809. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40810. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40811. */
  40812. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40813. /**
  40814. * Creates a new AnaglyphArcRotateCamera
  40815. * @param name defines camera name
  40816. * @param alpha defines alpha angle (in radians)
  40817. * @param beta defines beta angle (in radians)
  40818. * @param radius defines radius
  40819. * @param target defines camera target
  40820. * @param interaxialDistance defines distance between each color axis
  40821. * @param scene defines the hosting scene
  40822. */
  40823. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40824. /**
  40825. * Gets camera class name
  40826. * @returns AnaglyphArcRotateCamera
  40827. */
  40828. getClassName(): string;
  40829. }
  40830. }
  40831. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40832. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40833. import { Scene } from "babylonjs/scene";
  40834. import { Vector3 } from "babylonjs/Maths/math.vector";
  40835. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40836. /**
  40837. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40838. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40839. */
  40840. export class AnaglyphFreeCamera extends FreeCamera {
  40841. /**
  40842. * Creates a new AnaglyphFreeCamera
  40843. * @param name defines camera name
  40844. * @param position defines initial position
  40845. * @param interaxialDistance defines distance between each color axis
  40846. * @param scene defines the hosting scene
  40847. */
  40848. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40849. /**
  40850. * Gets camera class name
  40851. * @returns AnaglyphFreeCamera
  40852. */
  40853. getClassName(): string;
  40854. }
  40855. }
  40856. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40857. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40858. import { Scene } from "babylonjs/scene";
  40859. import { Vector3 } from "babylonjs/Maths/math.vector";
  40860. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40861. /**
  40862. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40863. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40864. */
  40865. export class AnaglyphGamepadCamera extends GamepadCamera {
  40866. /**
  40867. * Creates a new AnaglyphGamepadCamera
  40868. * @param name defines camera name
  40869. * @param position defines initial position
  40870. * @param interaxialDistance defines distance between each color axis
  40871. * @param scene defines the hosting scene
  40872. */
  40873. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40874. /**
  40875. * Gets camera class name
  40876. * @returns AnaglyphGamepadCamera
  40877. */
  40878. getClassName(): string;
  40879. }
  40880. }
  40881. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40882. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40883. import { Scene } from "babylonjs/scene";
  40884. import { Vector3 } from "babylonjs/Maths/math.vector";
  40885. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40886. /**
  40887. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40888. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40889. */
  40890. export class AnaglyphUniversalCamera extends UniversalCamera {
  40891. /**
  40892. * Creates a new AnaglyphUniversalCamera
  40893. * @param name defines camera name
  40894. * @param position defines initial position
  40895. * @param interaxialDistance defines distance between each color axis
  40896. * @param scene defines the hosting scene
  40897. */
  40898. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40899. /**
  40900. * Gets camera class name
  40901. * @returns AnaglyphUniversalCamera
  40902. */
  40903. getClassName(): string;
  40904. }
  40905. }
  40906. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40907. /** @hidden */
  40908. export var stereoscopicInterlacePixelShader: {
  40909. name: string;
  40910. shader: string;
  40911. };
  40912. }
  40913. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40914. import { Camera } from "babylonjs/Cameras/camera";
  40915. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40916. import { Engine } from "babylonjs/Engines/engine";
  40917. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40918. /**
  40919. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40920. */
  40921. export class StereoscopicInterlacePostProcess extends PostProcess {
  40922. private _stepSize;
  40923. private _passedProcess;
  40924. /**
  40925. * Initializes a StereoscopicInterlacePostProcess
  40926. * @param name The name of the effect.
  40927. * @param rigCameras The rig cameras to be appled to the post process
  40928. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40930. * @param engine The engine which the post process will be applied. (default: current engine)
  40931. * @param reusable If the post process can be reused on the same frame. (default: false)
  40932. */
  40933. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40934. }
  40935. }
  40936. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40937. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40938. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40939. import { Scene } from "babylonjs/scene";
  40940. import { Vector3 } from "babylonjs/Maths/math.vector";
  40941. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40942. /**
  40943. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40944. * @see http://doc.babylonjs.com/features/cameras
  40945. */
  40946. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40947. /**
  40948. * Creates a new StereoscopicArcRotateCamera
  40949. * @param name defines camera name
  40950. * @param alpha defines alpha angle (in radians)
  40951. * @param beta defines beta angle (in radians)
  40952. * @param radius defines radius
  40953. * @param target defines camera target
  40954. * @param interaxialDistance defines distance between each color axis
  40955. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40956. * @param scene defines the hosting scene
  40957. */
  40958. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40959. /**
  40960. * Gets camera class name
  40961. * @returns StereoscopicArcRotateCamera
  40962. */
  40963. getClassName(): string;
  40964. }
  40965. }
  40966. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40967. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40968. import { Scene } from "babylonjs/scene";
  40969. import { Vector3 } from "babylonjs/Maths/math.vector";
  40970. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40971. /**
  40972. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40973. * @see http://doc.babylonjs.com/features/cameras
  40974. */
  40975. export class StereoscopicFreeCamera extends FreeCamera {
  40976. /**
  40977. * Creates a new StereoscopicFreeCamera
  40978. * @param name defines camera name
  40979. * @param position defines initial position
  40980. * @param interaxialDistance defines distance between each color axis
  40981. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40982. * @param scene defines the hosting scene
  40983. */
  40984. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40985. /**
  40986. * Gets camera class name
  40987. * @returns StereoscopicFreeCamera
  40988. */
  40989. getClassName(): string;
  40990. }
  40991. }
  40992. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40993. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40994. import { Scene } from "babylonjs/scene";
  40995. import { Vector3 } from "babylonjs/Maths/math.vector";
  40996. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40997. /**
  40998. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40999. * @see http://doc.babylonjs.com/features/cameras
  41000. */
  41001. export class StereoscopicGamepadCamera extends GamepadCamera {
  41002. /**
  41003. * Creates a new StereoscopicGamepadCamera
  41004. * @param name defines camera name
  41005. * @param position defines initial position
  41006. * @param interaxialDistance defines distance between each color axis
  41007. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41008. * @param scene defines the hosting scene
  41009. */
  41010. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41011. /**
  41012. * Gets camera class name
  41013. * @returns StereoscopicGamepadCamera
  41014. */
  41015. getClassName(): string;
  41016. }
  41017. }
  41018. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41019. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41020. import { Scene } from "babylonjs/scene";
  41021. import { Vector3 } from "babylonjs/Maths/math.vector";
  41022. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41023. /**
  41024. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41025. * @see http://doc.babylonjs.com/features/cameras
  41026. */
  41027. export class StereoscopicUniversalCamera extends UniversalCamera {
  41028. /**
  41029. * Creates a new StereoscopicUniversalCamera
  41030. * @param name defines camera name
  41031. * @param position defines initial position
  41032. * @param interaxialDistance defines distance between each color axis
  41033. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41034. * @param scene defines the hosting scene
  41035. */
  41036. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41037. /**
  41038. * Gets camera class name
  41039. * @returns StereoscopicUniversalCamera
  41040. */
  41041. getClassName(): string;
  41042. }
  41043. }
  41044. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41045. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41046. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41047. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41048. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41049. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41050. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41051. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41052. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41053. }
  41054. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41055. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41056. import { Scene } from "babylonjs/scene";
  41057. import { Vector3 } from "babylonjs/Maths/math.vector";
  41058. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41059. /**
  41060. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41061. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41062. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41063. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41064. */
  41065. export class VirtualJoysticksCamera extends FreeCamera {
  41066. /**
  41067. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41068. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41069. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41070. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41071. * @param name Define the name of the camera in the scene
  41072. * @param position Define the start position of the camera in the scene
  41073. * @param scene Define the scene the camera belongs to
  41074. */
  41075. constructor(name: string, position: Vector3, scene: Scene);
  41076. /**
  41077. * Gets the current object class name.
  41078. * @return the class name
  41079. */
  41080. getClassName(): string;
  41081. }
  41082. }
  41083. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41084. import { Matrix } from "babylonjs/Maths/math.vector";
  41085. /**
  41086. * This represents all the required metrics to create a VR camera.
  41087. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41088. */
  41089. export class VRCameraMetrics {
  41090. /**
  41091. * Define the horizontal resolution off the screen.
  41092. */
  41093. hResolution: number;
  41094. /**
  41095. * Define the vertical resolution off the screen.
  41096. */
  41097. vResolution: number;
  41098. /**
  41099. * Define the horizontal screen size.
  41100. */
  41101. hScreenSize: number;
  41102. /**
  41103. * Define the vertical screen size.
  41104. */
  41105. vScreenSize: number;
  41106. /**
  41107. * Define the vertical screen center position.
  41108. */
  41109. vScreenCenter: number;
  41110. /**
  41111. * Define the distance of the eyes to the screen.
  41112. */
  41113. eyeToScreenDistance: number;
  41114. /**
  41115. * Define the distance between both lenses
  41116. */
  41117. lensSeparationDistance: number;
  41118. /**
  41119. * Define the distance between both viewer's eyes.
  41120. */
  41121. interpupillaryDistance: number;
  41122. /**
  41123. * Define the distortion factor of the VR postprocess.
  41124. * Please, touch with care.
  41125. */
  41126. distortionK: number[];
  41127. /**
  41128. * Define the chromatic aberration correction factors for the VR post process.
  41129. */
  41130. chromaAbCorrection: number[];
  41131. /**
  41132. * Define the scale factor of the post process.
  41133. * The smaller the better but the slower.
  41134. */
  41135. postProcessScaleFactor: number;
  41136. /**
  41137. * Define an offset for the lens center.
  41138. */
  41139. lensCenterOffset: number;
  41140. /**
  41141. * Define if the current vr camera should compensate the distortion of the lense or not.
  41142. */
  41143. compensateDistortion: boolean;
  41144. /**
  41145. * Defines if multiview should be enabled when rendering (Default: false)
  41146. */
  41147. multiviewEnabled: boolean;
  41148. /**
  41149. * Gets the rendering aspect ratio based on the provided resolutions.
  41150. */
  41151. readonly aspectRatio: number;
  41152. /**
  41153. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41154. */
  41155. readonly aspectRatioFov: number;
  41156. /**
  41157. * @hidden
  41158. */
  41159. readonly leftHMatrix: Matrix;
  41160. /**
  41161. * @hidden
  41162. */
  41163. readonly rightHMatrix: Matrix;
  41164. /**
  41165. * @hidden
  41166. */
  41167. readonly leftPreViewMatrix: Matrix;
  41168. /**
  41169. * @hidden
  41170. */
  41171. readonly rightPreViewMatrix: Matrix;
  41172. /**
  41173. * Get the default VRMetrics based on the most generic setup.
  41174. * @returns the default vr metrics
  41175. */
  41176. static GetDefault(): VRCameraMetrics;
  41177. }
  41178. }
  41179. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41180. /** @hidden */
  41181. export var vrDistortionCorrectionPixelShader: {
  41182. name: string;
  41183. shader: string;
  41184. };
  41185. }
  41186. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41187. import { Camera } from "babylonjs/Cameras/camera";
  41188. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41189. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41190. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41191. /**
  41192. * VRDistortionCorrectionPostProcess used for mobile VR
  41193. */
  41194. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41195. private _isRightEye;
  41196. private _distortionFactors;
  41197. private _postProcessScaleFactor;
  41198. private _lensCenterOffset;
  41199. private _scaleIn;
  41200. private _scaleFactor;
  41201. private _lensCenter;
  41202. /**
  41203. * Initializes the VRDistortionCorrectionPostProcess
  41204. * @param name The name of the effect.
  41205. * @param camera The camera to apply the render pass to.
  41206. * @param isRightEye If this is for the right eye distortion
  41207. * @param vrMetrics All the required metrics for the VR camera
  41208. */
  41209. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41210. }
  41211. }
  41212. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41213. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41214. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41215. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41216. import { Scene } from "babylonjs/scene";
  41217. import { Vector3 } from "babylonjs/Maths/math.vector";
  41218. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41219. import "babylonjs/Cameras/RigModes/vrRigMode";
  41220. /**
  41221. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41222. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41223. */
  41224. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41225. /**
  41226. * Creates a new VRDeviceOrientationArcRotateCamera
  41227. * @param name defines camera name
  41228. * @param alpha defines the camera rotation along the logitudinal axis
  41229. * @param beta defines the camera rotation along the latitudinal axis
  41230. * @param radius defines the camera distance from its target
  41231. * @param target defines the camera target
  41232. * @param scene defines the scene the camera belongs to
  41233. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41234. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41235. */
  41236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41237. /**
  41238. * Gets camera class name
  41239. * @returns VRDeviceOrientationArcRotateCamera
  41240. */
  41241. getClassName(): string;
  41242. }
  41243. }
  41244. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41245. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41246. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41247. import { Scene } from "babylonjs/scene";
  41248. import { Vector3 } from "babylonjs/Maths/math.vector";
  41249. import "babylonjs/Cameras/RigModes/vrRigMode";
  41250. /**
  41251. * Camera used to simulate VR rendering (based on FreeCamera)
  41252. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41253. */
  41254. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41255. /**
  41256. * Creates a new VRDeviceOrientationFreeCamera
  41257. * @param name defines camera name
  41258. * @param position defines the start position of the camera
  41259. * @param scene defines the scene the camera belongs to
  41260. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41261. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41262. */
  41263. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41264. /**
  41265. * Gets camera class name
  41266. * @returns VRDeviceOrientationFreeCamera
  41267. */
  41268. getClassName(): string;
  41269. }
  41270. }
  41271. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41272. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41273. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41274. import { Scene } from "babylonjs/scene";
  41275. import { Vector3 } from "babylonjs/Maths/math.vector";
  41276. import "babylonjs/Gamepads/gamepadSceneComponent";
  41277. /**
  41278. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41279. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41280. */
  41281. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41282. /**
  41283. * Creates a new VRDeviceOrientationGamepadCamera
  41284. * @param name defines camera name
  41285. * @param position defines the start position of the camera
  41286. * @param scene defines the scene the camera belongs to
  41287. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41288. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41289. */
  41290. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41291. /**
  41292. * Gets camera class name
  41293. * @returns VRDeviceOrientationGamepadCamera
  41294. */
  41295. getClassName(): string;
  41296. }
  41297. }
  41298. declare module "babylonjs/Materials/pushMaterial" {
  41299. import { Nullable } from "babylonjs/types";
  41300. import { Scene } from "babylonjs/scene";
  41301. import { Matrix } from "babylonjs/Maths/math.vector";
  41302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41303. import { Mesh } from "babylonjs/Meshes/mesh";
  41304. import { Material } from "babylonjs/Materials/material";
  41305. import { Effect } from "babylonjs/Materials/effect";
  41306. /**
  41307. * Base class of materials working in push mode in babylon JS
  41308. * @hidden
  41309. */
  41310. export class PushMaterial extends Material {
  41311. protected _activeEffect: Effect;
  41312. protected _normalMatrix: Matrix;
  41313. /**
  41314. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41315. * This means that the material can keep using a previous shader while a new one is being compiled.
  41316. * This is mostly used when shader parallel compilation is supported (true by default)
  41317. */
  41318. allowShaderHotSwapping: boolean;
  41319. constructor(name: string, scene: Scene);
  41320. getEffect(): Effect;
  41321. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41322. /**
  41323. * Binds the given world matrix to the active effect
  41324. *
  41325. * @param world the matrix to bind
  41326. */
  41327. bindOnlyWorldMatrix(world: Matrix): void;
  41328. /**
  41329. * Binds the given normal matrix to the active effect
  41330. *
  41331. * @param normalMatrix the matrix to bind
  41332. */
  41333. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41334. bind(world: Matrix, mesh?: Mesh): void;
  41335. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41336. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41337. }
  41338. }
  41339. declare module "babylonjs/Materials/materialFlags" {
  41340. /**
  41341. * This groups all the flags used to control the materials channel.
  41342. */
  41343. export class MaterialFlags {
  41344. private static _DiffuseTextureEnabled;
  41345. /**
  41346. * Are diffuse textures enabled in the application.
  41347. */
  41348. static DiffuseTextureEnabled: boolean;
  41349. private static _AmbientTextureEnabled;
  41350. /**
  41351. * Are ambient textures enabled in the application.
  41352. */
  41353. static AmbientTextureEnabled: boolean;
  41354. private static _OpacityTextureEnabled;
  41355. /**
  41356. * Are opacity textures enabled in the application.
  41357. */
  41358. static OpacityTextureEnabled: boolean;
  41359. private static _ReflectionTextureEnabled;
  41360. /**
  41361. * Are reflection textures enabled in the application.
  41362. */
  41363. static ReflectionTextureEnabled: boolean;
  41364. private static _EmissiveTextureEnabled;
  41365. /**
  41366. * Are emissive textures enabled in the application.
  41367. */
  41368. static EmissiveTextureEnabled: boolean;
  41369. private static _SpecularTextureEnabled;
  41370. /**
  41371. * Are specular textures enabled in the application.
  41372. */
  41373. static SpecularTextureEnabled: boolean;
  41374. private static _BumpTextureEnabled;
  41375. /**
  41376. * Are bump textures enabled in the application.
  41377. */
  41378. static BumpTextureEnabled: boolean;
  41379. private static _LightmapTextureEnabled;
  41380. /**
  41381. * Are lightmap textures enabled in the application.
  41382. */
  41383. static LightmapTextureEnabled: boolean;
  41384. private static _RefractionTextureEnabled;
  41385. /**
  41386. * Are refraction textures enabled in the application.
  41387. */
  41388. static RefractionTextureEnabled: boolean;
  41389. private static _ColorGradingTextureEnabled;
  41390. /**
  41391. * Are color grading textures enabled in the application.
  41392. */
  41393. static ColorGradingTextureEnabled: boolean;
  41394. private static _FresnelEnabled;
  41395. /**
  41396. * Are fresnels enabled in the application.
  41397. */
  41398. static FresnelEnabled: boolean;
  41399. private static _ClearCoatTextureEnabled;
  41400. /**
  41401. * Are clear coat textures enabled in the application.
  41402. */
  41403. static ClearCoatTextureEnabled: boolean;
  41404. private static _ClearCoatBumpTextureEnabled;
  41405. /**
  41406. * Are clear coat bump textures enabled in the application.
  41407. */
  41408. static ClearCoatBumpTextureEnabled: boolean;
  41409. private static _ClearCoatTintTextureEnabled;
  41410. /**
  41411. * Are clear coat tint textures enabled in the application.
  41412. */
  41413. static ClearCoatTintTextureEnabled: boolean;
  41414. private static _SheenTextureEnabled;
  41415. /**
  41416. * Are sheen textures enabled in the application.
  41417. */
  41418. static SheenTextureEnabled: boolean;
  41419. private static _AnisotropicTextureEnabled;
  41420. /**
  41421. * Are anisotropic textures enabled in the application.
  41422. */
  41423. static AnisotropicTextureEnabled: boolean;
  41424. private static _ThicknessTextureEnabled;
  41425. /**
  41426. * Are thickness textures enabled in the application.
  41427. */
  41428. static ThicknessTextureEnabled: boolean;
  41429. }
  41430. }
  41431. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41432. /** @hidden */
  41433. export var defaultFragmentDeclaration: {
  41434. name: string;
  41435. shader: string;
  41436. };
  41437. }
  41438. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41439. /** @hidden */
  41440. export var defaultUboDeclaration: {
  41441. name: string;
  41442. shader: string;
  41443. };
  41444. }
  41445. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41446. /** @hidden */
  41447. export var lightFragmentDeclaration: {
  41448. name: string;
  41449. shader: string;
  41450. };
  41451. }
  41452. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41453. /** @hidden */
  41454. export var lightUboDeclaration: {
  41455. name: string;
  41456. shader: string;
  41457. };
  41458. }
  41459. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41460. /** @hidden */
  41461. export var lightsFragmentFunctions: {
  41462. name: string;
  41463. shader: string;
  41464. };
  41465. }
  41466. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41467. /** @hidden */
  41468. export var shadowsFragmentFunctions: {
  41469. name: string;
  41470. shader: string;
  41471. };
  41472. }
  41473. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41474. /** @hidden */
  41475. export var fresnelFunction: {
  41476. name: string;
  41477. shader: string;
  41478. };
  41479. }
  41480. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41481. /** @hidden */
  41482. export var reflectionFunction: {
  41483. name: string;
  41484. shader: string;
  41485. };
  41486. }
  41487. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41488. /** @hidden */
  41489. export var bumpFragmentFunctions: {
  41490. name: string;
  41491. shader: string;
  41492. };
  41493. }
  41494. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41495. /** @hidden */
  41496. export var logDepthDeclaration: {
  41497. name: string;
  41498. shader: string;
  41499. };
  41500. }
  41501. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41502. /** @hidden */
  41503. export var bumpFragment: {
  41504. name: string;
  41505. shader: string;
  41506. };
  41507. }
  41508. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41509. /** @hidden */
  41510. export var depthPrePass: {
  41511. name: string;
  41512. shader: string;
  41513. };
  41514. }
  41515. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41516. /** @hidden */
  41517. export var lightFragment: {
  41518. name: string;
  41519. shader: string;
  41520. };
  41521. }
  41522. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41523. /** @hidden */
  41524. export var logDepthFragment: {
  41525. name: string;
  41526. shader: string;
  41527. };
  41528. }
  41529. declare module "babylonjs/Shaders/default.fragment" {
  41530. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41531. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41532. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41533. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41534. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41535. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41536. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41537. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41538. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41539. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41540. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41541. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41542. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41543. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41544. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41545. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41546. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41547. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41548. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41549. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41550. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41551. /** @hidden */
  41552. export var defaultPixelShader: {
  41553. name: string;
  41554. shader: string;
  41555. };
  41556. }
  41557. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41558. /** @hidden */
  41559. export var defaultVertexDeclaration: {
  41560. name: string;
  41561. shader: string;
  41562. };
  41563. }
  41564. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41565. /** @hidden */
  41566. export var bumpVertexDeclaration: {
  41567. name: string;
  41568. shader: string;
  41569. };
  41570. }
  41571. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41572. /** @hidden */
  41573. export var bumpVertex: {
  41574. name: string;
  41575. shader: string;
  41576. };
  41577. }
  41578. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41579. /** @hidden */
  41580. export var fogVertex: {
  41581. name: string;
  41582. shader: string;
  41583. };
  41584. }
  41585. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41586. /** @hidden */
  41587. export var shadowsVertex: {
  41588. name: string;
  41589. shader: string;
  41590. };
  41591. }
  41592. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41593. /** @hidden */
  41594. export var pointCloudVertex: {
  41595. name: string;
  41596. shader: string;
  41597. };
  41598. }
  41599. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41600. /** @hidden */
  41601. export var logDepthVertex: {
  41602. name: string;
  41603. shader: string;
  41604. };
  41605. }
  41606. declare module "babylonjs/Shaders/default.vertex" {
  41607. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41608. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41610. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41611. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41612. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41613. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41614. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41615. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41616. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41617. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41618. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41619. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41620. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41621. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41622. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41623. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41625. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41626. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41627. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41628. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41629. /** @hidden */
  41630. export var defaultVertexShader: {
  41631. name: string;
  41632. shader: string;
  41633. };
  41634. }
  41635. declare module "babylonjs/Materials/standardMaterial" {
  41636. import { SmartArray } from "babylonjs/Misc/smartArray";
  41637. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41638. import { Nullable } from "babylonjs/types";
  41639. import { Scene } from "babylonjs/scene";
  41640. import { Matrix } from "babylonjs/Maths/math.vector";
  41641. import { Color3 } from "babylonjs/Maths/math.color";
  41642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41644. import { Mesh } from "babylonjs/Meshes/mesh";
  41645. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41646. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41647. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41648. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41649. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41651. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41652. import "babylonjs/Shaders/default.fragment";
  41653. import "babylonjs/Shaders/default.vertex";
  41654. /** @hidden */
  41655. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41656. MAINUV1: boolean;
  41657. MAINUV2: boolean;
  41658. DIFFUSE: boolean;
  41659. DIFFUSEDIRECTUV: number;
  41660. AMBIENT: boolean;
  41661. AMBIENTDIRECTUV: number;
  41662. OPACITY: boolean;
  41663. OPACITYDIRECTUV: number;
  41664. OPACITYRGB: boolean;
  41665. REFLECTION: boolean;
  41666. EMISSIVE: boolean;
  41667. EMISSIVEDIRECTUV: number;
  41668. SPECULAR: boolean;
  41669. SPECULARDIRECTUV: number;
  41670. BUMP: boolean;
  41671. BUMPDIRECTUV: number;
  41672. PARALLAX: boolean;
  41673. PARALLAXOCCLUSION: boolean;
  41674. SPECULAROVERALPHA: boolean;
  41675. CLIPPLANE: boolean;
  41676. CLIPPLANE2: boolean;
  41677. CLIPPLANE3: boolean;
  41678. CLIPPLANE4: boolean;
  41679. ALPHATEST: boolean;
  41680. DEPTHPREPASS: boolean;
  41681. ALPHAFROMDIFFUSE: boolean;
  41682. POINTSIZE: boolean;
  41683. FOG: boolean;
  41684. SPECULARTERM: boolean;
  41685. DIFFUSEFRESNEL: boolean;
  41686. OPACITYFRESNEL: boolean;
  41687. REFLECTIONFRESNEL: boolean;
  41688. REFRACTIONFRESNEL: boolean;
  41689. EMISSIVEFRESNEL: boolean;
  41690. FRESNEL: boolean;
  41691. NORMAL: boolean;
  41692. UV1: boolean;
  41693. UV2: boolean;
  41694. VERTEXCOLOR: boolean;
  41695. VERTEXALPHA: boolean;
  41696. NUM_BONE_INFLUENCERS: number;
  41697. BonesPerMesh: number;
  41698. BONETEXTURE: boolean;
  41699. INSTANCES: boolean;
  41700. GLOSSINESS: boolean;
  41701. ROUGHNESS: boolean;
  41702. EMISSIVEASILLUMINATION: boolean;
  41703. LINKEMISSIVEWITHDIFFUSE: boolean;
  41704. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41705. LIGHTMAP: boolean;
  41706. LIGHTMAPDIRECTUV: number;
  41707. OBJECTSPACE_NORMALMAP: boolean;
  41708. USELIGHTMAPASSHADOWMAP: boolean;
  41709. REFLECTIONMAP_3D: boolean;
  41710. REFLECTIONMAP_SPHERICAL: boolean;
  41711. REFLECTIONMAP_PLANAR: boolean;
  41712. REFLECTIONMAP_CUBIC: boolean;
  41713. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41714. REFLECTIONMAP_PROJECTION: boolean;
  41715. REFLECTIONMAP_SKYBOX: boolean;
  41716. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41717. REFLECTIONMAP_EXPLICIT: boolean;
  41718. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41719. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41720. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41721. INVERTCUBICMAP: boolean;
  41722. LOGARITHMICDEPTH: boolean;
  41723. REFRACTION: boolean;
  41724. REFRACTIONMAP_3D: boolean;
  41725. REFLECTIONOVERALPHA: boolean;
  41726. TWOSIDEDLIGHTING: boolean;
  41727. SHADOWFLOAT: boolean;
  41728. MORPHTARGETS: boolean;
  41729. MORPHTARGETS_NORMAL: boolean;
  41730. MORPHTARGETS_TANGENT: boolean;
  41731. MORPHTARGETS_UV: boolean;
  41732. NUM_MORPH_INFLUENCERS: number;
  41733. NONUNIFORMSCALING: boolean;
  41734. PREMULTIPLYALPHA: boolean;
  41735. IMAGEPROCESSING: boolean;
  41736. VIGNETTE: boolean;
  41737. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41738. VIGNETTEBLENDMODEOPAQUE: boolean;
  41739. TONEMAPPING: boolean;
  41740. TONEMAPPING_ACES: boolean;
  41741. CONTRAST: boolean;
  41742. COLORCURVES: boolean;
  41743. COLORGRADING: boolean;
  41744. COLORGRADING3D: boolean;
  41745. SAMPLER3DGREENDEPTH: boolean;
  41746. SAMPLER3DBGRMAP: boolean;
  41747. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41748. MULTIVIEW: boolean;
  41749. /**
  41750. * If the reflection texture on this material is in linear color space
  41751. * @hidden
  41752. */
  41753. IS_REFLECTION_LINEAR: boolean;
  41754. /**
  41755. * If the refraction texture on this material is in linear color space
  41756. * @hidden
  41757. */
  41758. IS_REFRACTION_LINEAR: boolean;
  41759. EXPOSURE: boolean;
  41760. constructor();
  41761. setReflectionMode(modeToEnable: string): void;
  41762. }
  41763. /**
  41764. * This is the default material used in Babylon. It is the best trade off between quality
  41765. * and performances.
  41766. * @see http://doc.babylonjs.com/babylon101/materials
  41767. */
  41768. export class StandardMaterial extends PushMaterial {
  41769. private _diffuseTexture;
  41770. /**
  41771. * The basic texture of the material as viewed under a light.
  41772. */
  41773. diffuseTexture: Nullable<BaseTexture>;
  41774. private _ambientTexture;
  41775. /**
  41776. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41777. */
  41778. ambientTexture: Nullable<BaseTexture>;
  41779. private _opacityTexture;
  41780. /**
  41781. * Define the transparency of the material from a texture.
  41782. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41783. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41784. */
  41785. opacityTexture: Nullable<BaseTexture>;
  41786. private _reflectionTexture;
  41787. /**
  41788. * Define the texture used to display the reflection.
  41789. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41790. */
  41791. reflectionTexture: Nullable<BaseTexture>;
  41792. private _emissiveTexture;
  41793. /**
  41794. * Define texture of the material as if self lit.
  41795. * This will be mixed in the final result even in the absence of light.
  41796. */
  41797. emissiveTexture: Nullable<BaseTexture>;
  41798. private _specularTexture;
  41799. /**
  41800. * Define how the color and intensity of the highlight given by the light in the material.
  41801. */
  41802. specularTexture: Nullable<BaseTexture>;
  41803. private _bumpTexture;
  41804. /**
  41805. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41806. * 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.
  41807. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41808. */
  41809. bumpTexture: Nullable<BaseTexture>;
  41810. private _lightmapTexture;
  41811. /**
  41812. * Complex lighting can be computationally expensive to compute at runtime.
  41813. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41814. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41815. */
  41816. lightmapTexture: Nullable<BaseTexture>;
  41817. private _refractionTexture;
  41818. /**
  41819. * Define the texture used to display the refraction.
  41820. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41821. */
  41822. refractionTexture: Nullable<BaseTexture>;
  41823. /**
  41824. * The color of the material lit by the environmental background lighting.
  41825. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41826. */
  41827. ambientColor: Color3;
  41828. /**
  41829. * The basic color of the material as viewed under a light.
  41830. */
  41831. diffuseColor: Color3;
  41832. /**
  41833. * Define how the color and intensity of the highlight given by the light in the material.
  41834. */
  41835. specularColor: Color3;
  41836. /**
  41837. * Define the color of the material as if self lit.
  41838. * This will be mixed in the final result even in the absence of light.
  41839. */
  41840. emissiveColor: Color3;
  41841. /**
  41842. * Defines how sharp are the highlights in the material.
  41843. * The bigger the value the sharper giving a more glossy feeling to the result.
  41844. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41845. */
  41846. specularPower: number;
  41847. private _useAlphaFromDiffuseTexture;
  41848. /**
  41849. * Does the transparency come from the diffuse texture alpha channel.
  41850. */
  41851. useAlphaFromDiffuseTexture: boolean;
  41852. private _useEmissiveAsIllumination;
  41853. /**
  41854. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41855. */
  41856. useEmissiveAsIllumination: boolean;
  41857. private _linkEmissiveWithDiffuse;
  41858. /**
  41859. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41860. * the emissive level when the final color is close to one.
  41861. */
  41862. linkEmissiveWithDiffuse: boolean;
  41863. private _useSpecularOverAlpha;
  41864. /**
  41865. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41866. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41867. */
  41868. useSpecularOverAlpha: boolean;
  41869. private _useReflectionOverAlpha;
  41870. /**
  41871. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41872. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41873. */
  41874. useReflectionOverAlpha: boolean;
  41875. private _disableLighting;
  41876. /**
  41877. * Does lights from the scene impacts this material.
  41878. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41879. */
  41880. disableLighting: boolean;
  41881. private _useObjectSpaceNormalMap;
  41882. /**
  41883. * Allows using an object space normal map (instead of tangent space).
  41884. */
  41885. useObjectSpaceNormalMap: boolean;
  41886. private _useParallax;
  41887. /**
  41888. * Is parallax enabled or not.
  41889. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41890. */
  41891. useParallax: boolean;
  41892. private _useParallaxOcclusion;
  41893. /**
  41894. * Is parallax occlusion enabled or not.
  41895. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41896. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41897. */
  41898. useParallaxOcclusion: boolean;
  41899. /**
  41900. * 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.
  41901. */
  41902. parallaxScaleBias: number;
  41903. private _roughness;
  41904. /**
  41905. * Helps to define how blurry the reflections should appears in the material.
  41906. */
  41907. roughness: number;
  41908. /**
  41909. * In case of refraction, define the value of the index of refraction.
  41910. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41911. */
  41912. indexOfRefraction: number;
  41913. /**
  41914. * Invert the refraction texture alongside the y axis.
  41915. * It can be useful with procedural textures or probe for instance.
  41916. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41917. */
  41918. invertRefractionY: boolean;
  41919. /**
  41920. * Defines the alpha limits in alpha test mode.
  41921. */
  41922. alphaCutOff: number;
  41923. private _useLightmapAsShadowmap;
  41924. /**
  41925. * In case of light mapping, define whether the map contains light or shadow informations.
  41926. */
  41927. useLightmapAsShadowmap: boolean;
  41928. private _diffuseFresnelParameters;
  41929. /**
  41930. * Define the diffuse fresnel parameters of the material.
  41931. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41932. */
  41933. diffuseFresnelParameters: FresnelParameters;
  41934. private _opacityFresnelParameters;
  41935. /**
  41936. * Define the opacity fresnel parameters of the material.
  41937. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41938. */
  41939. opacityFresnelParameters: FresnelParameters;
  41940. private _reflectionFresnelParameters;
  41941. /**
  41942. * Define the reflection fresnel parameters of the material.
  41943. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41944. */
  41945. reflectionFresnelParameters: FresnelParameters;
  41946. private _refractionFresnelParameters;
  41947. /**
  41948. * Define the refraction fresnel parameters of the material.
  41949. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41950. */
  41951. refractionFresnelParameters: FresnelParameters;
  41952. private _emissiveFresnelParameters;
  41953. /**
  41954. * Define the emissive fresnel parameters of the material.
  41955. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41956. */
  41957. emissiveFresnelParameters: FresnelParameters;
  41958. private _useReflectionFresnelFromSpecular;
  41959. /**
  41960. * If true automatically deducts the fresnels values from the material specularity.
  41961. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41962. */
  41963. useReflectionFresnelFromSpecular: boolean;
  41964. private _useGlossinessFromSpecularMapAlpha;
  41965. /**
  41966. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41967. */
  41968. useGlossinessFromSpecularMapAlpha: boolean;
  41969. private _maxSimultaneousLights;
  41970. /**
  41971. * Defines the maximum number of lights that can be used in the material
  41972. */
  41973. maxSimultaneousLights: number;
  41974. private _invertNormalMapX;
  41975. /**
  41976. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41977. */
  41978. invertNormalMapX: boolean;
  41979. private _invertNormalMapY;
  41980. /**
  41981. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41982. */
  41983. invertNormalMapY: boolean;
  41984. private _twoSidedLighting;
  41985. /**
  41986. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41987. */
  41988. twoSidedLighting: boolean;
  41989. /**
  41990. * Default configuration related to image processing available in the standard Material.
  41991. */
  41992. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41993. /**
  41994. * Gets the image processing configuration used either in this material.
  41995. */
  41996. /**
  41997. * Sets the Default image processing configuration used either in the this material.
  41998. *
  41999. * If sets to null, the scene one is in use.
  42000. */
  42001. imageProcessingConfiguration: ImageProcessingConfiguration;
  42002. /**
  42003. * Keep track of the image processing observer to allow dispose and replace.
  42004. */
  42005. private _imageProcessingObserver;
  42006. /**
  42007. * Attaches a new image processing configuration to the Standard Material.
  42008. * @param configuration
  42009. */
  42010. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42011. /**
  42012. * Gets wether the color curves effect is enabled.
  42013. */
  42014. /**
  42015. * Sets wether the color curves effect is enabled.
  42016. */
  42017. cameraColorCurvesEnabled: boolean;
  42018. /**
  42019. * Gets wether the color grading effect is enabled.
  42020. */
  42021. /**
  42022. * Gets wether the color grading effect is enabled.
  42023. */
  42024. cameraColorGradingEnabled: boolean;
  42025. /**
  42026. * Gets wether tonemapping is enabled or not.
  42027. */
  42028. /**
  42029. * Sets wether tonemapping is enabled or not
  42030. */
  42031. cameraToneMappingEnabled: boolean;
  42032. /**
  42033. * The camera exposure used on this material.
  42034. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42035. * This corresponds to a photographic exposure.
  42036. */
  42037. /**
  42038. * The camera exposure used on this material.
  42039. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42040. * This corresponds to a photographic exposure.
  42041. */
  42042. cameraExposure: number;
  42043. /**
  42044. * Gets The camera contrast used on this material.
  42045. */
  42046. /**
  42047. * Sets The camera contrast used on this material.
  42048. */
  42049. cameraContrast: number;
  42050. /**
  42051. * Gets the Color Grading 2D Lookup Texture.
  42052. */
  42053. /**
  42054. * Sets the Color Grading 2D Lookup Texture.
  42055. */
  42056. cameraColorGradingTexture: Nullable<BaseTexture>;
  42057. /**
  42058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42060. * 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;
  42061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42062. */
  42063. /**
  42064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42066. * 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;
  42067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42068. */
  42069. cameraColorCurves: Nullable<ColorCurves>;
  42070. /**
  42071. * Custom callback helping to override the default shader used in the material.
  42072. */
  42073. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42074. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42075. protected _worldViewProjectionMatrix: Matrix;
  42076. protected _globalAmbientColor: Color3;
  42077. protected _useLogarithmicDepth: boolean;
  42078. protected _rebuildInParallel: boolean;
  42079. /**
  42080. * Instantiates a new standard material.
  42081. * This is the default material used in Babylon. It is the best trade off between quality
  42082. * and performances.
  42083. * @see http://doc.babylonjs.com/babylon101/materials
  42084. * @param name Define the name of the material in the scene
  42085. * @param scene Define the scene the material belong to
  42086. */
  42087. constructor(name: string, scene: Scene);
  42088. /**
  42089. * Gets a boolean indicating that current material needs to register RTT
  42090. */
  42091. readonly hasRenderTargetTextures: boolean;
  42092. /**
  42093. * Gets the current class name of the material e.g. "StandardMaterial"
  42094. * Mainly use in serialization.
  42095. * @returns the class name
  42096. */
  42097. getClassName(): string;
  42098. /**
  42099. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42100. * You can try switching to logarithmic depth.
  42101. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42102. */
  42103. useLogarithmicDepth: boolean;
  42104. /**
  42105. * Specifies if the material will require alpha blending
  42106. * @returns a boolean specifying if alpha blending is needed
  42107. */
  42108. needAlphaBlending(): boolean;
  42109. /**
  42110. * Specifies if this material should be rendered in alpha test mode
  42111. * @returns a boolean specifying if an alpha test is needed.
  42112. */
  42113. needAlphaTesting(): boolean;
  42114. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42115. /**
  42116. * Get the texture used for alpha test purpose.
  42117. * @returns the diffuse texture in case of the standard material.
  42118. */
  42119. getAlphaTestTexture(): Nullable<BaseTexture>;
  42120. /**
  42121. * Get if the submesh is ready to be used and all its information available.
  42122. * Child classes can use it to update shaders
  42123. * @param mesh defines the mesh to check
  42124. * @param subMesh defines which submesh to check
  42125. * @param useInstances specifies that instances should be used
  42126. * @returns a boolean indicating that the submesh is ready or not
  42127. */
  42128. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42129. /**
  42130. * Builds the material UBO layouts.
  42131. * Used internally during the effect preparation.
  42132. */
  42133. buildUniformLayout(): void;
  42134. /**
  42135. * Unbinds the material from the mesh
  42136. */
  42137. unbind(): void;
  42138. /**
  42139. * Binds the submesh to this material by preparing the effect and shader to draw
  42140. * @param world defines the world transformation matrix
  42141. * @param mesh defines the mesh containing the submesh
  42142. * @param subMesh defines the submesh to bind the material to
  42143. */
  42144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42145. /**
  42146. * Get the list of animatables in the material.
  42147. * @returns the list of animatables object used in the material
  42148. */
  42149. getAnimatables(): IAnimatable[];
  42150. /**
  42151. * Gets the active textures from the material
  42152. * @returns an array of textures
  42153. */
  42154. getActiveTextures(): BaseTexture[];
  42155. /**
  42156. * Specifies if the material uses a texture
  42157. * @param texture defines the texture to check against the material
  42158. * @returns a boolean specifying if the material uses the texture
  42159. */
  42160. hasTexture(texture: BaseTexture): boolean;
  42161. /**
  42162. * Disposes the material
  42163. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42164. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42165. */
  42166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42167. /**
  42168. * Makes a duplicate of the material, and gives it a new name
  42169. * @param name defines the new name for the duplicated material
  42170. * @returns the cloned material
  42171. */
  42172. clone(name: string): StandardMaterial;
  42173. /**
  42174. * Serializes this material in a JSON representation
  42175. * @returns the serialized material object
  42176. */
  42177. serialize(): any;
  42178. /**
  42179. * Creates a standard material from parsed material data
  42180. * @param source defines the JSON representation of the material
  42181. * @param scene defines the hosting scene
  42182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42183. * @returns a new standard material
  42184. */
  42185. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42186. /**
  42187. * Are diffuse textures enabled in the application.
  42188. */
  42189. static DiffuseTextureEnabled: boolean;
  42190. /**
  42191. * Are ambient textures enabled in the application.
  42192. */
  42193. static AmbientTextureEnabled: boolean;
  42194. /**
  42195. * Are opacity textures enabled in the application.
  42196. */
  42197. static OpacityTextureEnabled: boolean;
  42198. /**
  42199. * Are reflection textures enabled in the application.
  42200. */
  42201. static ReflectionTextureEnabled: boolean;
  42202. /**
  42203. * Are emissive textures enabled in the application.
  42204. */
  42205. static EmissiveTextureEnabled: boolean;
  42206. /**
  42207. * Are specular textures enabled in the application.
  42208. */
  42209. static SpecularTextureEnabled: boolean;
  42210. /**
  42211. * Are bump textures enabled in the application.
  42212. */
  42213. static BumpTextureEnabled: boolean;
  42214. /**
  42215. * Are lightmap textures enabled in the application.
  42216. */
  42217. static LightmapTextureEnabled: boolean;
  42218. /**
  42219. * Are refraction textures enabled in the application.
  42220. */
  42221. static RefractionTextureEnabled: boolean;
  42222. /**
  42223. * Are color grading textures enabled in the application.
  42224. */
  42225. static ColorGradingTextureEnabled: boolean;
  42226. /**
  42227. * Are fresnels enabled in the application.
  42228. */
  42229. static FresnelEnabled: boolean;
  42230. }
  42231. }
  42232. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42233. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42234. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42235. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42236. /** @hidden */
  42237. export var imageProcessingPixelShader: {
  42238. name: string;
  42239. shader: string;
  42240. };
  42241. }
  42242. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42243. import { Nullable } from "babylonjs/types";
  42244. import { Color4 } from "babylonjs/Maths/math.color";
  42245. import { Camera } from "babylonjs/Cameras/camera";
  42246. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42247. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42248. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42250. import { Engine } from "babylonjs/Engines/engine";
  42251. import "babylonjs/Shaders/imageProcessing.fragment";
  42252. import "babylonjs/Shaders/postprocess.vertex";
  42253. /**
  42254. * ImageProcessingPostProcess
  42255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42256. */
  42257. export class ImageProcessingPostProcess extends PostProcess {
  42258. /**
  42259. * Default configuration related to image processing available in the PBR Material.
  42260. */
  42261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42262. /**
  42263. * Gets the image processing configuration used either in this material.
  42264. */
  42265. /**
  42266. * Sets the Default image processing configuration used either in the this material.
  42267. *
  42268. * If sets to null, the scene one is in use.
  42269. */
  42270. imageProcessingConfiguration: ImageProcessingConfiguration;
  42271. /**
  42272. * Keep track of the image processing observer to allow dispose and replace.
  42273. */
  42274. private _imageProcessingObserver;
  42275. /**
  42276. * Attaches a new image processing configuration to the PBR Material.
  42277. * @param configuration
  42278. */
  42279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42280. /**
  42281. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42282. */
  42283. /**
  42284. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42285. */
  42286. colorCurves: Nullable<ColorCurves>;
  42287. /**
  42288. * Gets wether the color curves effect is enabled.
  42289. */
  42290. /**
  42291. * Sets wether the color curves effect is enabled.
  42292. */
  42293. colorCurvesEnabled: boolean;
  42294. /**
  42295. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42296. */
  42297. /**
  42298. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42299. */
  42300. colorGradingTexture: Nullable<BaseTexture>;
  42301. /**
  42302. * Gets wether the color grading effect is enabled.
  42303. */
  42304. /**
  42305. * Gets wether the color grading effect is enabled.
  42306. */
  42307. colorGradingEnabled: boolean;
  42308. /**
  42309. * Gets exposure used in the effect.
  42310. */
  42311. /**
  42312. * Sets exposure used in the effect.
  42313. */
  42314. exposure: number;
  42315. /**
  42316. * Gets wether tonemapping is enabled or not.
  42317. */
  42318. /**
  42319. * Sets wether tonemapping is enabled or not
  42320. */
  42321. toneMappingEnabled: boolean;
  42322. /**
  42323. * Gets the type of tone mapping effect.
  42324. */
  42325. /**
  42326. * Sets the type of tone mapping effect.
  42327. */
  42328. toneMappingType: number;
  42329. /**
  42330. * Gets contrast used in the effect.
  42331. */
  42332. /**
  42333. * Sets contrast used in the effect.
  42334. */
  42335. contrast: number;
  42336. /**
  42337. * Gets Vignette stretch size.
  42338. */
  42339. /**
  42340. * Sets Vignette stretch size.
  42341. */
  42342. vignetteStretch: number;
  42343. /**
  42344. * Gets Vignette centre X Offset.
  42345. */
  42346. /**
  42347. * Sets Vignette centre X Offset.
  42348. */
  42349. vignetteCentreX: number;
  42350. /**
  42351. * Gets Vignette centre Y Offset.
  42352. */
  42353. /**
  42354. * Sets Vignette centre Y Offset.
  42355. */
  42356. vignetteCentreY: number;
  42357. /**
  42358. * Gets Vignette weight or intensity of the vignette effect.
  42359. */
  42360. /**
  42361. * Sets Vignette weight or intensity of the vignette effect.
  42362. */
  42363. vignetteWeight: number;
  42364. /**
  42365. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42366. * if vignetteEnabled is set to true.
  42367. */
  42368. /**
  42369. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42370. * if vignetteEnabled is set to true.
  42371. */
  42372. vignetteColor: Color4;
  42373. /**
  42374. * Gets Camera field of view used by the Vignette effect.
  42375. */
  42376. /**
  42377. * Sets Camera field of view used by the Vignette effect.
  42378. */
  42379. vignetteCameraFov: number;
  42380. /**
  42381. * Gets the vignette blend mode allowing different kind of effect.
  42382. */
  42383. /**
  42384. * Sets the vignette blend mode allowing different kind of effect.
  42385. */
  42386. vignetteBlendMode: number;
  42387. /**
  42388. * Gets wether the vignette effect is enabled.
  42389. */
  42390. /**
  42391. * Sets wether the vignette effect is enabled.
  42392. */
  42393. vignetteEnabled: boolean;
  42394. private _fromLinearSpace;
  42395. /**
  42396. * Gets wether the input of the processing is in Gamma or Linear Space.
  42397. */
  42398. /**
  42399. * Sets wether the input of the processing is in Gamma or Linear Space.
  42400. */
  42401. fromLinearSpace: boolean;
  42402. /**
  42403. * Defines cache preventing GC.
  42404. */
  42405. private _defines;
  42406. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42407. /**
  42408. * "ImageProcessingPostProcess"
  42409. * @returns "ImageProcessingPostProcess"
  42410. */
  42411. getClassName(): string;
  42412. protected _updateParameters(): void;
  42413. dispose(camera?: Camera): void;
  42414. }
  42415. }
  42416. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42417. import { Scene } from "babylonjs/scene";
  42418. import { Color3 } from "babylonjs/Maths/math.color";
  42419. import { Mesh } from "babylonjs/Meshes/mesh";
  42420. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42421. import { Nullable } from "babylonjs/types";
  42422. /**
  42423. * Class containing static functions to help procedurally build meshes
  42424. */
  42425. export class GroundBuilder {
  42426. /**
  42427. * Creates a ground mesh
  42428. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42429. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42431. * @param name defines the name of the mesh
  42432. * @param options defines the options used to create the mesh
  42433. * @param scene defines the hosting scene
  42434. * @returns the ground mesh
  42435. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42436. */
  42437. static CreateGround(name: string, options: {
  42438. width?: number;
  42439. height?: number;
  42440. subdivisions?: number;
  42441. subdivisionsX?: number;
  42442. subdivisionsY?: number;
  42443. updatable?: boolean;
  42444. }, scene: any): Mesh;
  42445. /**
  42446. * Creates a tiled ground mesh
  42447. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42448. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42449. * * 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
  42450. * * 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
  42451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42452. * @param name defines the name of the mesh
  42453. * @param options defines the options used to create the mesh
  42454. * @param scene defines the hosting scene
  42455. * @returns the tiled ground mesh
  42456. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42457. */
  42458. static CreateTiledGround(name: string, options: {
  42459. xmin: number;
  42460. zmin: number;
  42461. xmax: number;
  42462. zmax: number;
  42463. subdivisions?: {
  42464. w: number;
  42465. h: number;
  42466. };
  42467. precision?: {
  42468. w: number;
  42469. h: number;
  42470. };
  42471. updatable?: boolean;
  42472. }, scene?: Nullable<Scene>): Mesh;
  42473. /**
  42474. * Creates a ground mesh from a height map
  42475. * * The parameter `url` sets the URL of the height map image resource.
  42476. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42477. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42478. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42479. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42480. * * 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.
  42481. * * 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).
  42482. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42484. * @param name defines the name of the mesh
  42485. * @param url defines the url to the height map
  42486. * @param options defines the options used to create the mesh
  42487. * @param scene defines the hosting scene
  42488. * @returns the ground mesh
  42489. * @see https://doc.babylonjs.com/babylon101/height_map
  42490. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42491. */
  42492. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42493. width?: number;
  42494. height?: number;
  42495. subdivisions?: number;
  42496. minHeight?: number;
  42497. maxHeight?: number;
  42498. colorFilter?: Color3;
  42499. alphaFilter?: number;
  42500. updatable?: boolean;
  42501. onReady?: (mesh: GroundMesh) => void;
  42502. }, scene?: Nullable<Scene>): GroundMesh;
  42503. }
  42504. }
  42505. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42506. import { Vector4 } from "babylonjs/Maths/math.vector";
  42507. import { Mesh } from "babylonjs/Meshes/mesh";
  42508. /**
  42509. * Class containing static functions to help procedurally build meshes
  42510. */
  42511. export class TorusBuilder {
  42512. /**
  42513. * Creates a torus mesh
  42514. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42515. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42516. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42520. * @param name defines the name of the mesh
  42521. * @param options defines the options used to create the mesh
  42522. * @param scene defines the hosting scene
  42523. * @returns the torus mesh
  42524. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42525. */
  42526. static CreateTorus(name: string, options: {
  42527. diameter?: number;
  42528. thickness?: number;
  42529. tessellation?: number;
  42530. updatable?: boolean;
  42531. sideOrientation?: number;
  42532. frontUVs?: Vector4;
  42533. backUVs?: Vector4;
  42534. }, scene: any): Mesh;
  42535. }
  42536. }
  42537. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42538. import { Vector4 } from "babylonjs/Maths/math.vector";
  42539. import { Color4 } from "babylonjs/Maths/math.color";
  42540. import { Mesh } from "babylonjs/Meshes/mesh";
  42541. /**
  42542. * Class containing static functions to help procedurally build meshes
  42543. */
  42544. export class CylinderBuilder {
  42545. /**
  42546. * Creates a cylinder or a cone mesh
  42547. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42548. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42549. * * 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.
  42550. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42551. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42552. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42553. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42554. * * 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).
  42555. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42556. * * 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).
  42557. * * 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
  42558. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42559. * * 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
  42560. * * 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.
  42561. * * If `enclose` is false, a ring surface is one element.
  42562. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42563. * * 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
  42564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42567. * @param name defines the name of the mesh
  42568. * @param options defines the options used to create the mesh
  42569. * @param scene defines the hosting scene
  42570. * @returns the cylinder mesh
  42571. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42572. */
  42573. static CreateCylinder(name: string, options: {
  42574. height?: number;
  42575. diameterTop?: number;
  42576. diameterBottom?: number;
  42577. diameter?: number;
  42578. tessellation?: number;
  42579. subdivisions?: number;
  42580. arc?: number;
  42581. faceColors?: Color4[];
  42582. faceUV?: Vector4[];
  42583. updatable?: boolean;
  42584. hasRings?: boolean;
  42585. enclose?: boolean;
  42586. cap?: number;
  42587. sideOrientation?: number;
  42588. frontUVs?: Vector4;
  42589. backUVs?: Vector4;
  42590. }, scene: any): Mesh;
  42591. }
  42592. }
  42593. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42594. import { Observable } from "babylonjs/Misc/observable";
  42595. import { Nullable } from "babylonjs/types";
  42596. import { Camera } from "babylonjs/Cameras/camera";
  42597. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42598. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42599. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42600. import { Scene } from "babylonjs/scene";
  42601. import { Vector3 } from "babylonjs/Maths/math.vector";
  42602. import { Color3 } from "babylonjs/Maths/math.color";
  42603. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42605. import { Mesh } from "babylonjs/Meshes/mesh";
  42606. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42607. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42608. import "babylonjs/Meshes/Builders/groundBuilder";
  42609. import "babylonjs/Meshes/Builders/torusBuilder";
  42610. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42611. import "babylonjs/Gamepads/gamepadSceneComponent";
  42612. import "babylonjs/Animations/animatable";
  42613. /**
  42614. * Options to modify the vr teleportation behavior.
  42615. */
  42616. export interface VRTeleportationOptions {
  42617. /**
  42618. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42619. */
  42620. floorMeshName?: string;
  42621. /**
  42622. * A list of meshes to be used as the teleportation floor. (default: empty)
  42623. */
  42624. floorMeshes?: Mesh[];
  42625. }
  42626. /**
  42627. * Options to modify the vr experience helper's behavior.
  42628. */
  42629. export interface VRExperienceHelperOptions extends WebVROptions {
  42630. /**
  42631. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42632. */
  42633. createDeviceOrientationCamera?: boolean;
  42634. /**
  42635. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42636. */
  42637. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42638. /**
  42639. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42640. */
  42641. laserToggle?: boolean;
  42642. /**
  42643. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42644. */
  42645. floorMeshes?: Mesh[];
  42646. /**
  42647. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42648. */
  42649. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42650. }
  42651. /**
  42652. * Event containing information after VR has been entered
  42653. */
  42654. export class OnAfterEnteringVRObservableEvent {
  42655. /**
  42656. * If entering vr was successful
  42657. */
  42658. success: boolean;
  42659. }
  42660. /**
  42661. * Helps to quickly add VR support to an existing scene.
  42662. * See http://doc.babylonjs.com/how_to/webvr_helper
  42663. */
  42664. export class VRExperienceHelper {
  42665. /** Options to modify the vr experience helper's behavior. */
  42666. webVROptions: VRExperienceHelperOptions;
  42667. private _scene;
  42668. private _position;
  42669. private _btnVR;
  42670. private _btnVRDisplayed;
  42671. private _webVRsupported;
  42672. private _webVRready;
  42673. private _webVRrequesting;
  42674. private _webVRpresenting;
  42675. private _hasEnteredVR;
  42676. private _fullscreenVRpresenting;
  42677. private _canvas;
  42678. private _webVRCamera;
  42679. private _vrDeviceOrientationCamera;
  42680. private _deviceOrientationCamera;
  42681. private _existingCamera;
  42682. private _onKeyDown;
  42683. private _onVrDisplayPresentChange;
  42684. private _onVRDisplayChanged;
  42685. private _onVRRequestPresentStart;
  42686. private _onVRRequestPresentComplete;
  42687. /**
  42688. * 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)
  42689. */
  42690. enableGazeEvenWhenNoPointerLock: boolean;
  42691. /**
  42692. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42693. */
  42694. exitVROnDoubleTap: boolean;
  42695. /**
  42696. * Observable raised right before entering VR.
  42697. */
  42698. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42699. /**
  42700. * Observable raised when entering VR has completed.
  42701. */
  42702. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42703. /**
  42704. * Observable raised when exiting VR.
  42705. */
  42706. onExitingVRObservable: Observable<VRExperienceHelper>;
  42707. /**
  42708. * Observable raised when controller mesh is loaded.
  42709. */
  42710. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42711. /** Return this.onEnteringVRObservable
  42712. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42713. */
  42714. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42715. /** Return this.onExitingVRObservable
  42716. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42717. */
  42718. readonly onExitingVR: Observable<VRExperienceHelper>;
  42719. /** Return this.onControllerMeshLoadedObservable
  42720. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42721. */
  42722. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42723. private _rayLength;
  42724. private _useCustomVRButton;
  42725. private _teleportationRequested;
  42726. private _teleportActive;
  42727. private _floorMeshName;
  42728. private _floorMeshesCollection;
  42729. private _rotationAllowed;
  42730. private _teleportBackwardsVector;
  42731. private _teleportationTarget;
  42732. private _isDefaultTeleportationTarget;
  42733. private _postProcessMove;
  42734. private _teleportationFillColor;
  42735. private _teleportationBorderColor;
  42736. private _rotationAngle;
  42737. private _haloCenter;
  42738. private _cameraGazer;
  42739. private _padSensibilityUp;
  42740. private _padSensibilityDown;
  42741. private _leftController;
  42742. private _rightController;
  42743. /**
  42744. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42745. */
  42746. onNewMeshSelected: Observable<AbstractMesh>;
  42747. /**
  42748. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42749. * This observable will provide the mesh and the controller used to select the mesh
  42750. */
  42751. onMeshSelectedWithController: Observable<{
  42752. mesh: AbstractMesh;
  42753. controller: WebVRController;
  42754. }>;
  42755. /**
  42756. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42757. */
  42758. onNewMeshPicked: Observable<PickingInfo>;
  42759. private _circleEase;
  42760. /**
  42761. * Observable raised before camera teleportation
  42762. */
  42763. onBeforeCameraTeleport: Observable<Vector3>;
  42764. /**
  42765. * Observable raised after camera teleportation
  42766. */
  42767. onAfterCameraTeleport: Observable<Vector3>;
  42768. /**
  42769. * Observable raised when current selected mesh gets unselected
  42770. */
  42771. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42772. private _raySelectionPredicate;
  42773. /**
  42774. * To be optionaly changed by user to define custom ray selection
  42775. */
  42776. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42777. /**
  42778. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42779. */
  42780. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42781. /**
  42782. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42783. */
  42784. teleportationEnabled: boolean;
  42785. private _defaultHeight;
  42786. private _teleportationInitialized;
  42787. private _interactionsEnabled;
  42788. private _interactionsRequested;
  42789. private _displayGaze;
  42790. private _displayLaserPointer;
  42791. /**
  42792. * The mesh used to display where the user is going to teleport.
  42793. */
  42794. /**
  42795. * Sets the mesh to be used to display where the user is going to teleport.
  42796. */
  42797. teleportationTarget: Mesh;
  42798. /**
  42799. * 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
  42800. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42801. * See http://doc.babylonjs.com/resources/baking_transformations
  42802. */
  42803. gazeTrackerMesh: Mesh;
  42804. /**
  42805. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42806. */
  42807. updateGazeTrackerScale: boolean;
  42808. /**
  42809. * If the gaze trackers color should be updated when selecting meshes
  42810. */
  42811. updateGazeTrackerColor: boolean;
  42812. /**
  42813. * If the controller laser color should be updated when selecting meshes
  42814. */
  42815. updateControllerLaserColor: boolean;
  42816. /**
  42817. * The gaze tracking mesh corresponding to the left controller
  42818. */
  42819. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42820. /**
  42821. * The gaze tracking mesh corresponding to the right controller
  42822. */
  42823. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42824. /**
  42825. * If the ray of the gaze should be displayed.
  42826. */
  42827. /**
  42828. * Sets if the ray of the gaze should be displayed.
  42829. */
  42830. displayGaze: boolean;
  42831. /**
  42832. * If the ray of the LaserPointer should be displayed.
  42833. */
  42834. /**
  42835. * Sets if the ray of the LaserPointer should be displayed.
  42836. */
  42837. displayLaserPointer: boolean;
  42838. /**
  42839. * The deviceOrientationCamera used as the camera when not in VR.
  42840. */
  42841. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42842. /**
  42843. * Based on the current WebVR support, returns the current VR camera used.
  42844. */
  42845. readonly currentVRCamera: Nullable<Camera>;
  42846. /**
  42847. * The webVRCamera which is used when in VR.
  42848. */
  42849. readonly webVRCamera: WebVRFreeCamera;
  42850. /**
  42851. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42852. */
  42853. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42854. /**
  42855. * The html button that is used to trigger entering into VR.
  42856. */
  42857. readonly vrButton: Nullable<HTMLButtonElement>;
  42858. private readonly _teleportationRequestInitiated;
  42859. /**
  42860. * Defines wether or not Pointer lock should be requested when switching to
  42861. * full screen.
  42862. */
  42863. requestPointerLockOnFullScreen: boolean;
  42864. /**
  42865. * Instantiates a VRExperienceHelper.
  42866. * Helps to quickly add VR support to an existing scene.
  42867. * @param scene The scene the VRExperienceHelper belongs to.
  42868. * @param webVROptions Options to modify the vr experience helper's behavior.
  42869. */
  42870. constructor(scene: Scene,
  42871. /** Options to modify the vr experience helper's behavior. */
  42872. webVROptions?: VRExperienceHelperOptions);
  42873. private _onDefaultMeshLoaded;
  42874. private _onResize;
  42875. private _onFullscreenChange;
  42876. /**
  42877. * Gets a value indicating if we are currently in VR mode.
  42878. */
  42879. readonly isInVRMode: boolean;
  42880. private onVrDisplayPresentChange;
  42881. private onVRDisplayChanged;
  42882. private moveButtonToBottomRight;
  42883. private displayVRButton;
  42884. private updateButtonVisibility;
  42885. private _cachedAngularSensibility;
  42886. /**
  42887. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42888. * Otherwise, will use the fullscreen API.
  42889. */
  42890. enterVR(): void;
  42891. /**
  42892. * Attempt to exit VR, or fullscreen.
  42893. */
  42894. exitVR(): void;
  42895. /**
  42896. * The position of the vr experience helper.
  42897. */
  42898. /**
  42899. * Sets the position of the vr experience helper.
  42900. */
  42901. position: Vector3;
  42902. /**
  42903. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42904. */
  42905. enableInteractions(): void;
  42906. private readonly _noControllerIsActive;
  42907. private beforeRender;
  42908. private _isTeleportationFloor;
  42909. /**
  42910. * Adds a floor mesh to be used for teleportation.
  42911. * @param floorMesh the mesh to be used for teleportation.
  42912. */
  42913. addFloorMesh(floorMesh: Mesh): void;
  42914. /**
  42915. * Removes a floor mesh from being used for teleportation.
  42916. * @param floorMesh the mesh to be removed.
  42917. */
  42918. removeFloorMesh(floorMesh: Mesh): void;
  42919. /**
  42920. * Enables interactions and teleportation using the VR controllers and gaze.
  42921. * @param vrTeleportationOptions options to modify teleportation behavior.
  42922. */
  42923. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42924. private _onNewGamepadConnected;
  42925. private _tryEnableInteractionOnController;
  42926. private _onNewGamepadDisconnected;
  42927. private _enableInteractionOnController;
  42928. private _checkTeleportWithRay;
  42929. private _checkRotate;
  42930. private _checkTeleportBackwards;
  42931. private _enableTeleportationOnController;
  42932. private _createTeleportationCircles;
  42933. private _displayTeleportationTarget;
  42934. private _hideTeleportationTarget;
  42935. private _rotateCamera;
  42936. private _moveTeleportationSelectorTo;
  42937. private _workingVector;
  42938. private _workingQuaternion;
  42939. private _workingMatrix;
  42940. /**
  42941. * Teleports the users feet to the desired location
  42942. * @param location The location where the user's feet should be placed
  42943. */
  42944. teleportCamera(location: Vector3): void;
  42945. private _convertNormalToDirectionOfRay;
  42946. private _castRayAndSelectObject;
  42947. private _notifySelectedMeshUnselected;
  42948. /**
  42949. * Sets the color of the laser ray from the vr controllers.
  42950. * @param color new color for the ray.
  42951. */
  42952. changeLaserColor(color: Color3): void;
  42953. /**
  42954. * Sets the color of the ray from the vr headsets gaze.
  42955. * @param color new color for the ray.
  42956. */
  42957. changeGazeColor(color: Color3): void;
  42958. /**
  42959. * Exits VR and disposes of the vr experience helper
  42960. */
  42961. dispose(): void;
  42962. /**
  42963. * Gets the name of the VRExperienceHelper class
  42964. * @returns "VRExperienceHelper"
  42965. */
  42966. getClassName(): string;
  42967. }
  42968. }
  42969. declare module "babylonjs/Cameras/VR/index" {
  42970. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42971. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42972. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42973. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42974. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42975. export * from "babylonjs/Cameras/VR/webVRCamera";
  42976. }
  42977. declare module "babylonjs/Cameras/XR/webXRTypes" {
  42978. import { Nullable } from "babylonjs/types";
  42979. import { IDisposable } from "babylonjs/scene";
  42980. /**
  42981. * States of the webXR experience
  42982. */
  42983. export enum WebXRState {
  42984. /**
  42985. * Transitioning to being in XR mode
  42986. */
  42987. ENTERING_XR = 0,
  42988. /**
  42989. * Transitioning to non XR mode
  42990. */
  42991. EXITING_XR = 1,
  42992. /**
  42993. * In XR mode and presenting
  42994. */
  42995. IN_XR = 2,
  42996. /**
  42997. * Not entered XR mode
  42998. */
  42999. NOT_IN_XR = 3
  43000. }
  43001. /**
  43002. * Abstraction of the XR render target
  43003. */
  43004. export interface WebXRRenderTarget extends IDisposable {
  43005. /**
  43006. * xrpresent context of the canvas which can be used to display/mirror xr content
  43007. */
  43008. canvasContext: WebGLRenderingContext;
  43009. /**
  43010. * xr layer for the canvas
  43011. */
  43012. xrLayer: Nullable<XRWebGLLayer>;
  43013. /**
  43014. * Initializes the xr layer for the session
  43015. * @param xrSession xr session
  43016. * @returns a promise that will resolve once the XR Layer has been created
  43017. */
  43018. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43019. }
  43020. }
  43021. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43022. import { Nullable } from "babylonjs/types";
  43023. import { Observable } from "babylonjs/Misc/observable";
  43024. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43025. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43026. /**
  43027. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43028. */
  43029. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43030. private _engine;
  43031. private _canvas;
  43032. /**
  43033. * xrpresent context of the canvas which can be used to display/mirror xr content
  43034. */
  43035. canvasContext: WebGLRenderingContext;
  43036. /**
  43037. * xr layer for the canvas
  43038. */
  43039. xrLayer: Nullable<XRWebGLLayer>;
  43040. /**
  43041. * Initializes the xr layer for the session
  43042. * @param xrSession xr session
  43043. * @returns a promise that will resolve once the XR Layer has been created
  43044. */
  43045. initializeXRLayerAsync(xrSession: any): any;
  43046. /**
  43047. * Initializes the canvas to be added/removed upon entering/exiting xr
  43048. * @param engine the Babylon engine
  43049. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43050. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43051. */
  43052. constructor(engine: ThinEngine, onStateChangedObservable: Observable<WebXRState>, canvas?: HTMLCanvasElement);
  43053. /**
  43054. * Disposes of the object
  43055. */
  43056. dispose(): void;
  43057. private _setManagedOutputCanvas;
  43058. private _addCanvas;
  43059. private _removeCanvas;
  43060. }
  43061. }
  43062. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43063. import { Observable } from "babylonjs/Misc/observable";
  43064. import { Nullable } from "babylonjs/types";
  43065. import { IDisposable, Scene } from "babylonjs/scene";
  43066. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43067. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43068. /**
  43069. * Manages an XRSession to work with Babylon's engine
  43070. * @see https://doc.babylonjs.com/how_to/webxr
  43071. */
  43072. export class WebXRSessionManager implements IDisposable {
  43073. private scene;
  43074. /**
  43075. * Fires every time a new xrFrame arrives which can be used to update the camera
  43076. */
  43077. onXRFrameObservable: Observable<any>;
  43078. /**
  43079. * Fires when the xr session is ended either by the device or manually done
  43080. */
  43081. onXRSessionEnded: Observable<any>;
  43082. /**
  43083. * Underlying xr session
  43084. */
  43085. session: XRSession;
  43086. /**
  43087. * Type of reference space used when creating the session
  43088. */
  43089. referenceSpace: XRReferenceSpace;
  43090. /**
  43091. * Current XR frame
  43092. */
  43093. currentFrame: Nullable<XRFrame>;
  43094. private _xrNavigator;
  43095. private baseLayer;
  43096. private _rttProvider;
  43097. private _sessionEnded;
  43098. /**
  43099. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43100. * @param scene The scene which the session should be created for
  43101. */
  43102. constructor(scene: Scene);
  43103. /**
  43104. * Initializes the manager
  43105. * After initialization enterXR can be called to start an XR session
  43106. * @returns Promise which resolves after it is initialized
  43107. */
  43108. initializeAsync(): Promise<void>;
  43109. /**
  43110. * Initializes an xr session
  43111. * @param xrSessionMode mode to initialize
  43112. * @returns a promise which will resolve once the session has been initialized
  43113. */
  43114. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  43115. /**
  43116. * Sets the reference space on the xr session
  43117. * @param referenceSpace space to set
  43118. * @returns a promise that will resolve once the reference space has been set
  43119. */
  43120. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43121. /**
  43122. * Updates the render state of the session
  43123. * @param state state to set
  43124. * @returns a promise that resolves once the render state has been updated
  43125. */
  43126. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43127. /**
  43128. * Starts rendering to the xr layer
  43129. * @returns a promise that will resolve once rendering has started
  43130. */
  43131. startRenderingToXRAsync(): Promise<void>;
  43132. /**
  43133. * Gets the correct render target texture to be rendered this frame for this eye
  43134. * @param eye the eye for which to get the render target
  43135. * @returns the render target for the specified eye
  43136. */
  43137. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43138. /**
  43139. * Stops the xrSession and restores the renderloop
  43140. * @returns Promise which resolves after it exits XR
  43141. */
  43142. exitXRAsync(): Promise<void>;
  43143. /**
  43144. * Checks if a session would be supported for the creation options specified
  43145. * @param sessionMode session mode to check if supported eg. immersive-vr
  43146. * @returns true if supported
  43147. */
  43148. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43149. /**
  43150. * Creates a WebXRRenderTarget object for the XR session
  43151. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43152. * @returns a WebXR render target to which the session can render
  43153. */
  43154. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  43155. /**
  43156. * @hidden
  43157. * Converts the render layer of xrSession to a render target
  43158. * @param session session to create render target for
  43159. * @param scene scene the new render target should be created for
  43160. */
  43161. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43162. /**
  43163. * Disposes of the session manager
  43164. */
  43165. dispose(): void;
  43166. }
  43167. }
  43168. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43169. import { Scene } from "babylonjs/scene";
  43170. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43171. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43172. /**
  43173. * WebXR Camera which holds the views for the xrSession
  43174. * @see https://doc.babylonjs.com/how_to/webxr
  43175. */
  43176. export class WebXRCamera extends FreeCamera {
  43177. private static _TmpMatrix;
  43178. /**
  43179. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43180. * @param name the name of the camera
  43181. * @param scene the scene to add the camera to
  43182. */
  43183. constructor(name: string, scene: Scene);
  43184. private _updateNumberOfRigCameras;
  43185. /** @hidden */
  43186. _updateForDualEyeDebugging(): void;
  43187. /**
  43188. * Updates the cameras position from the current pose information of the XR session
  43189. * @param xrSessionManager the session containing pose information
  43190. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43191. */
  43192. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43193. }
  43194. }
  43195. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43196. import { Observable } from "babylonjs/Misc/observable";
  43197. import { IDisposable, Scene } from "babylonjs/scene";
  43198. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43200. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43201. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43202. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43203. /**
  43204. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43205. * @see https://doc.babylonjs.com/how_to/webxr
  43206. */
  43207. export class WebXRExperienceHelper implements IDisposable {
  43208. private scene;
  43209. /**
  43210. * 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
  43211. */
  43212. container: AbstractMesh;
  43213. /**
  43214. * Camera used to render xr content
  43215. */
  43216. camera: WebXRCamera;
  43217. /**
  43218. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43219. */
  43220. state: WebXRState;
  43221. private _setState;
  43222. private static _TmpVector;
  43223. /**
  43224. * Fires when the state of the experience helper has changed
  43225. */
  43226. onStateChangedObservable: Observable<WebXRState>;
  43227. /** Session manager used to keep track of xr session */
  43228. sessionManager: WebXRSessionManager;
  43229. private _nonVRCamera;
  43230. private _originalSceneAutoClear;
  43231. private _supported;
  43232. /**
  43233. * Creates the experience helper
  43234. * @param scene the scene to attach the experience helper to
  43235. * @returns a promise for the experience helper
  43236. */
  43237. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43238. /**
  43239. * Creates a WebXRExperienceHelper
  43240. * @param scene The scene the helper should be created in
  43241. */
  43242. private constructor();
  43243. /**
  43244. * Exits XR mode and returns the scene to its original state
  43245. * @returns promise that resolves after xr mode has exited
  43246. */
  43247. exitXRAsync(): Promise<void>;
  43248. /**
  43249. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43250. * @param sessionCreationOptions options for the XR session
  43251. * @param referenceSpaceType frame of reference of the XR session
  43252. * @param renderTarget the output canvas that will be used to enter XR mode
  43253. * @returns promise that resolves after xr mode has entered
  43254. */
  43255. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  43256. /**
  43257. * Updates the global position of the camera by moving the camera's container
  43258. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43259. * @param position The desired global position of the camera
  43260. */
  43261. setPositionOfCameraUsingContainer(position: Vector3): void;
  43262. /**
  43263. * Rotates the xr camera by rotating the camera's container around the camera's position
  43264. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43265. * @param rotation the desired quaternion rotation to apply to the camera
  43266. */
  43267. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43268. /**
  43269. * Disposes of the experience helper
  43270. */
  43271. dispose(): void;
  43272. }
  43273. }
  43274. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43275. import { Nullable } from "babylonjs/types";
  43276. import { Observable } from "babylonjs/Misc/observable";
  43277. import { IDisposable, Scene } from "babylonjs/scene";
  43278. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43279. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43280. /**
  43281. * Button which can be used to enter a different mode of XR
  43282. */
  43283. export class WebXREnterExitUIButton {
  43284. /** button element */
  43285. element: HTMLElement;
  43286. /** XR initialization options for the button */
  43287. sessionMode: XRSessionMode;
  43288. /** Reference space type */
  43289. referenceSpaceType: XRReferenceSpaceType;
  43290. /**
  43291. * Creates a WebXREnterExitUIButton
  43292. * @param element button element
  43293. * @param sessionMode XR initialization session mode
  43294. * @param referenceSpaceType the type of reference space to be used
  43295. */
  43296. constructor(
  43297. /** button element */
  43298. element: HTMLElement,
  43299. /** XR initialization options for the button */
  43300. sessionMode: XRSessionMode,
  43301. /** Reference space type */
  43302. referenceSpaceType: XRReferenceSpaceType);
  43303. /**
  43304. * Overwritable function which can be used to update the button's visuals when the state changes
  43305. * @param activeButton the current active button in the UI
  43306. */
  43307. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43308. }
  43309. /**
  43310. * Options to create the webXR UI
  43311. */
  43312. export class WebXREnterExitUIOptions {
  43313. /**
  43314. * Context to enter xr with
  43315. */
  43316. renderTarget?: Nullable<WebXRRenderTarget>;
  43317. /**
  43318. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43319. */
  43320. customButtons?: Array<WebXREnterExitUIButton>;
  43321. }
  43322. /**
  43323. * UI to allow the user to enter/exit XR mode
  43324. */
  43325. export class WebXREnterExitUI implements IDisposable {
  43326. private scene;
  43327. private _overlay;
  43328. private _buttons;
  43329. private _activeButton;
  43330. /**
  43331. * Fired every time the active button is changed.
  43332. *
  43333. * When xr is entered via a button that launches xr that button will be the callback parameter
  43334. *
  43335. * When exiting xr the callback parameter will be null)
  43336. */
  43337. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43338. /**
  43339. * Creates UI to allow the user to enter/exit XR mode
  43340. * @param scene the scene to add the ui to
  43341. * @param helper the xr experience helper to enter/exit xr with
  43342. * @param options options to configure the UI
  43343. * @returns the created ui
  43344. */
  43345. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43346. private constructor();
  43347. private _updateButtons;
  43348. /**
  43349. * Disposes of the object
  43350. */
  43351. dispose(): void;
  43352. }
  43353. }
  43354. declare module "babylonjs/Cameras/XR/webXRController" {
  43355. import { Nullable } from "babylonjs/types";
  43356. import { Observable } from "babylonjs/Misc/observable";
  43357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43358. import { Ray } from "babylonjs/Culling/ray";
  43359. import { Scene } from "babylonjs/scene";
  43360. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43361. /**
  43362. * Represents an XR input
  43363. */
  43364. export class WebXRController {
  43365. private scene;
  43366. /** The underlying input source for the controller */
  43367. inputSource: XRInputSource;
  43368. private parentContainer;
  43369. /**
  43370. * 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
  43371. */
  43372. grip?: AbstractMesh;
  43373. /**
  43374. * Pointer which can be used to select objects or attach a visible laser to
  43375. */
  43376. pointer: AbstractMesh;
  43377. private _gamepadMode;
  43378. /**
  43379. * If available, this is the gamepad object related to this controller.
  43380. * Using this object it is possible to get click events and trackpad changes of the
  43381. * webxr controller that is currently being used.
  43382. */
  43383. gamepadController?: WebVRController;
  43384. /**
  43385. * Event that fires when the controller is removed/disposed
  43386. */
  43387. onDisposeObservable: Observable<{}>;
  43388. private _tmpMatrix;
  43389. private _tmpQuaternion;
  43390. private _tmpVector;
  43391. /**
  43392. * Creates the controller
  43393. * @see https://doc.babylonjs.com/how_to/webxr
  43394. * @param scene the scene which the controller should be associated to
  43395. * @param inputSource the underlying input source for the controller
  43396. * @param parentContainer parent that the controller meshes should be children of
  43397. */
  43398. constructor(scene: Scene,
  43399. /** The underlying input source for the controller */
  43400. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43401. /**
  43402. * Updates the controller pose based on the given XRFrame
  43403. * @param xrFrame xr frame to update the pose with
  43404. * @param referenceSpace reference space to use
  43405. */
  43406. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43407. /**
  43408. * Gets a world space ray coming from the controller
  43409. * @param result the resulting ray
  43410. */
  43411. getWorldPointerRayToRef(result: Ray): void;
  43412. /**
  43413. * Get the scene associated with this controller
  43414. * @returns the scene object
  43415. */
  43416. getScene(): Scene;
  43417. /**
  43418. * Disposes of the object
  43419. */
  43420. dispose(): void;
  43421. }
  43422. }
  43423. declare module "babylonjs/Cameras/XR/webXRInput" {
  43424. import { Observable } from "babylonjs/Misc/observable";
  43425. import { IDisposable } from "babylonjs/scene";
  43426. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43427. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43428. /**
  43429. * XR input used to track XR inputs such as controllers/rays
  43430. */
  43431. export class WebXRInput implements IDisposable {
  43432. /**
  43433. * Base experience the input listens to
  43434. */
  43435. baseExperience: WebXRExperienceHelper;
  43436. /**
  43437. * XR controllers being tracked
  43438. */
  43439. controllers: Array<WebXRController>;
  43440. private _frameObserver;
  43441. private _stateObserver;
  43442. /**
  43443. * Event when a controller has been connected/added
  43444. */
  43445. onControllerAddedObservable: Observable<WebXRController>;
  43446. /**
  43447. * Event when a controller has been removed/disconnected
  43448. */
  43449. onControllerRemovedObservable: Observable<WebXRController>;
  43450. /**
  43451. * Initializes the WebXRInput
  43452. * @param baseExperience experience helper which the input should be created for
  43453. */
  43454. constructor(
  43455. /**
  43456. * Base experience the input listens to
  43457. */
  43458. baseExperience: WebXRExperienceHelper);
  43459. private _onInputSourcesChange;
  43460. private _addAndRemoveControllers;
  43461. /**
  43462. * Disposes of the object
  43463. */
  43464. dispose(): void;
  43465. }
  43466. }
  43467. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43469. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43470. /**
  43471. * Enables teleportation
  43472. */
  43473. export class WebXRControllerTeleportation {
  43474. private _teleportationFillColor;
  43475. private _teleportationBorderColor;
  43476. private _tmpRay;
  43477. private _tmpVector;
  43478. /**
  43479. * Creates a WebXRControllerTeleportation
  43480. * @param input input manager to add teleportation to
  43481. * @param floorMeshes floormeshes which can be teleported to
  43482. */
  43483. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43484. }
  43485. }
  43486. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43487. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43488. /**
  43489. * Handles pointer input automatically for the pointer of XR controllers
  43490. */
  43491. export class WebXRControllerPointerSelection {
  43492. private static _idCounter;
  43493. private _tmpRay;
  43494. /**
  43495. * Creates a WebXRControllerPointerSelection
  43496. * @param input input manager to setup pointer selection
  43497. */
  43498. constructor(input: WebXRInput);
  43499. private _convertNormalToDirectionOfRay;
  43500. private _updatePointerDistance;
  43501. }
  43502. }
  43503. declare module "babylonjs/Loading/sceneLoader" {
  43504. import { Observable } from "babylonjs/Misc/observable";
  43505. import { Nullable } from "babylonjs/types";
  43506. import { Scene } from "babylonjs/scene";
  43507. import { Engine } from "babylonjs/Engines/engine";
  43508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43509. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43510. import { AssetContainer } from "babylonjs/assetContainer";
  43511. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43512. import { Skeleton } from "babylonjs/Bones/skeleton";
  43513. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43514. import { WebRequest } from "babylonjs/Misc/webRequest";
  43515. /**
  43516. * Class used to represent data loading progression
  43517. */
  43518. export class SceneLoaderProgressEvent {
  43519. /** defines if data length to load can be evaluated */
  43520. readonly lengthComputable: boolean;
  43521. /** defines the loaded data length */
  43522. readonly loaded: number;
  43523. /** defines the data length to load */
  43524. readonly total: number;
  43525. /**
  43526. * Create a new progress event
  43527. * @param lengthComputable defines if data length to load can be evaluated
  43528. * @param loaded defines the loaded data length
  43529. * @param total defines the data length to load
  43530. */
  43531. constructor(
  43532. /** defines if data length to load can be evaluated */
  43533. lengthComputable: boolean,
  43534. /** defines the loaded data length */
  43535. loaded: number,
  43536. /** defines the data length to load */
  43537. total: number);
  43538. /**
  43539. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43540. * @param event defines the source event
  43541. * @returns a new SceneLoaderProgressEvent
  43542. */
  43543. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43544. }
  43545. /**
  43546. * Interface used by SceneLoader plugins to define supported file extensions
  43547. */
  43548. export interface ISceneLoaderPluginExtensions {
  43549. /**
  43550. * Defines the list of supported extensions
  43551. */
  43552. [extension: string]: {
  43553. isBinary: boolean;
  43554. };
  43555. }
  43556. /**
  43557. * Interface used by SceneLoader plugin factory
  43558. */
  43559. export interface ISceneLoaderPluginFactory {
  43560. /**
  43561. * Defines the name of the factory
  43562. */
  43563. name: string;
  43564. /**
  43565. * Function called to create a new plugin
  43566. * @return the new plugin
  43567. */
  43568. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43569. /**
  43570. * The callback that returns true if the data can be directly loaded.
  43571. * @param data string containing the file data
  43572. * @returns if the data can be loaded directly
  43573. */
  43574. canDirectLoad?(data: string): boolean;
  43575. }
  43576. /**
  43577. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43578. */
  43579. export interface ISceneLoaderPluginBase {
  43580. /**
  43581. * The friendly name of this plugin.
  43582. */
  43583. name: string;
  43584. /**
  43585. * The file extensions supported by this plugin.
  43586. */
  43587. extensions: string | ISceneLoaderPluginExtensions;
  43588. /**
  43589. * The callback called when loading from a url.
  43590. * @param scene scene loading this url
  43591. * @param url url to load
  43592. * @param onSuccess callback called when the file successfully loads
  43593. * @param onProgress callback called while file is loading (if the server supports this mode)
  43594. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43595. * @param onError callback called when the file fails to load
  43596. * @returns a file request object
  43597. */
  43598. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43599. /**
  43600. * The callback called when loading from a file object.
  43601. * @param scene scene loading this file
  43602. * @param file defines the file to load
  43603. * @param onSuccess defines the callback to call when data is loaded
  43604. * @param onProgress defines the callback to call during loading process
  43605. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43606. * @param onError defines the callback to call when an error occurs
  43607. * @returns a file request object
  43608. */
  43609. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43610. /**
  43611. * The callback that returns true if the data can be directly loaded.
  43612. * @param data string containing the file data
  43613. * @returns if the data can be loaded directly
  43614. */
  43615. canDirectLoad?(data: string): boolean;
  43616. /**
  43617. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43618. * @param scene scene loading this data
  43619. * @param data string containing the data
  43620. * @returns data to pass to the plugin
  43621. */
  43622. directLoad?(scene: Scene, data: string): any;
  43623. /**
  43624. * The callback that allows custom handling of the root url based on the response url.
  43625. * @param rootUrl the original root url
  43626. * @param responseURL the response url if available
  43627. * @returns the new root url
  43628. */
  43629. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43630. }
  43631. /**
  43632. * Interface used to define a SceneLoader plugin
  43633. */
  43634. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43635. /**
  43636. * Import meshes into a scene.
  43637. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43638. * @param scene The scene to import into
  43639. * @param data The data to import
  43640. * @param rootUrl The root url for scene and resources
  43641. * @param meshes The meshes array to import into
  43642. * @param particleSystems The particle systems array to import into
  43643. * @param skeletons The skeletons array to import into
  43644. * @param onError The callback when import fails
  43645. * @returns True if successful or false otherwise
  43646. */
  43647. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43648. /**
  43649. * Load into a scene.
  43650. * @param scene The scene to load into
  43651. * @param data The data to import
  43652. * @param rootUrl The root url for scene and resources
  43653. * @param onError The callback when import fails
  43654. * @returns True if successful or false otherwise
  43655. */
  43656. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43657. /**
  43658. * Load into an asset container.
  43659. * @param scene The scene to load into
  43660. * @param data The data to import
  43661. * @param rootUrl The root url for scene and resources
  43662. * @param onError The callback when import fails
  43663. * @returns The loaded asset container
  43664. */
  43665. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43666. }
  43667. /**
  43668. * Interface used to define an async SceneLoader plugin
  43669. */
  43670. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43671. /**
  43672. * Import meshes into a scene.
  43673. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43674. * @param scene The scene to import into
  43675. * @param data The data to import
  43676. * @param rootUrl The root url for scene and resources
  43677. * @param onProgress The callback when the load progresses
  43678. * @param fileName Defines the name of the file to load
  43679. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43680. */
  43681. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43682. meshes: AbstractMesh[];
  43683. particleSystems: IParticleSystem[];
  43684. skeletons: Skeleton[];
  43685. animationGroups: AnimationGroup[];
  43686. }>;
  43687. /**
  43688. * Load into a scene.
  43689. * @param scene The scene to load into
  43690. * @param data The data to import
  43691. * @param rootUrl The root url for scene and resources
  43692. * @param onProgress The callback when the load progresses
  43693. * @param fileName Defines the name of the file to load
  43694. * @returns Nothing
  43695. */
  43696. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43697. /**
  43698. * Load into an asset container.
  43699. * @param scene The scene to load into
  43700. * @param data The data to import
  43701. * @param rootUrl The root url for scene and resources
  43702. * @param onProgress The callback when the load progresses
  43703. * @param fileName Defines the name of the file to load
  43704. * @returns The loaded asset container
  43705. */
  43706. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43707. }
  43708. /**
  43709. * Class used to load scene from various file formats using registered plugins
  43710. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43711. */
  43712. export class SceneLoader {
  43713. /**
  43714. * No logging while loading
  43715. */
  43716. static readonly NO_LOGGING: number;
  43717. /**
  43718. * Minimal logging while loading
  43719. */
  43720. static readonly MINIMAL_LOGGING: number;
  43721. /**
  43722. * Summary logging while loading
  43723. */
  43724. static readonly SUMMARY_LOGGING: number;
  43725. /**
  43726. * Detailled logging while loading
  43727. */
  43728. static readonly DETAILED_LOGGING: number;
  43729. /**
  43730. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43731. */
  43732. static ForceFullSceneLoadingForIncremental: boolean;
  43733. /**
  43734. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43735. */
  43736. static ShowLoadingScreen: boolean;
  43737. /**
  43738. * Defines the current logging level (while loading the scene)
  43739. * @ignorenaming
  43740. */
  43741. static loggingLevel: number;
  43742. /**
  43743. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43744. */
  43745. static CleanBoneMatrixWeights: boolean;
  43746. /**
  43747. * Event raised when a plugin is used to load a scene
  43748. */
  43749. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43750. private static _registeredPlugins;
  43751. private static _getDefaultPlugin;
  43752. private static _getPluginForExtension;
  43753. private static _getPluginForDirectLoad;
  43754. private static _getPluginForFilename;
  43755. private static _getDirectLoad;
  43756. private static _loadData;
  43757. private static _getFileInfo;
  43758. /**
  43759. * Gets a plugin that can load the given extension
  43760. * @param extension defines the extension to load
  43761. * @returns a plugin or null if none works
  43762. */
  43763. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43764. /**
  43765. * Gets a boolean indicating that the given extension can be loaded
  43766. * @param extension defines the extension to load
  43767. * @returns true if the extension is supported
  43768. */
  43769. static IsPluginForExtensionAvailable(extension: string): boolean;
  43770. /**
  43771. * Adds a new plugin to the list of registered plugins
  43772. * @param plugin defines the plugin to add
  43773. */
  43774. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43775. /**
  43776. * Import meshes into a scene
  43777. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43778. * @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)
  43779. * @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)
  43780. * @param scene the instance of BABYLON.Scene to append to
  43781. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43782. * @param onProgress a callback with a progress event for each file being loaded
  43783. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43784. * @param pluginExtension the extension used to determine the plugin
  43785. * @returns The loaded plugin
  43786. */
  43787. 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>;
  43788. /**
  43789. * Import meshes into a scene
  43790. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43791. * @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)
  43792. * @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)
  43793. * @param scene the instance of BABYLON.Scene to append to
  43794. * @param onProgress a callback with a progress event for each file being loaded
  43795. * @param pluginExtension the extension used to determine the plugin
  43796. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43797. */
  43798. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43799. meshes: AbstractMesh[];
  43800. particleSystems: IParticleSystem[];
  43801. skeletons: Skeleton[];
  43802. animationGroups: AnimationGroup[];
  43803. }>;
  43804. /**
  43805. * Load a scene
  43806. * @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)
  43807. * @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)
  43808. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43809. * @param onSuccess a callback with the scene when import succeeds
  43810. * @param onProgress a callback with a progress event for each file being loaded
  43811. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43812. * @param pluginExtension the extension used to determine the plugin
  43813. * @returns The loaded plugin
  43814. */
  43815. 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>;
  43816. /**
  43817. * Load a scene
  43818. * @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)
  43819. * @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)
  43820. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43821. * @param onProgress a callback with a progress event for each file being loaded
  43822. * @param pluginExtension the extension used to determine the plugin
  43823. * @returns The loaded scene
  43824. */
  43825. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43826. /**
  43827. * Append a scene
  43828. * @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)
  43829. * @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)
  43830. * @param scene is the instance of BABYLON.Scene to append to
  43831. * @param onSuccess a callback with the scene when import succeeds
  43832. * @param onProgress a callback with a progress event for each file being loaded
  43833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43834. * @param pluginExtension the extension used to determine the plugin
  43835. * @returns The loaded plugin
  43836. */
  43837. 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>;
  43838. /**
  43839. * Append a scene
  43840. * @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)
  43841. * @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)
  43842. * @param scene is the instance of BABYLON.Scene to append to
  43843. * @param onProgress a callback with a progress event for each file being loaded
  43844. * @param pluginExtension the extension used to determine the plugin
  43845. * @returns The given scene
  43846. */
  43847. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43848. /**
  43849. * Load a scene into an asset container
  43850. * @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)
  43851. * @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)
  43852. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43853. * @param onSuccess a callback with the scene when import succeeds
  43854. * @param onProgress a callback with a progress event for each file being loaded
  43855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43856. * @param pluginExtension the extension used to determine the plugin
  43857. * @returns The loaded plugin
  43858. */
  43859. 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>;
  43860. /**
  43861. * Load a scene into an asset container
  43862. * @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)
  43863. * @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)
  43864. * @param scene is the instance of Scene to append to
  43865. * @param onProgress a callback with a progress event for each file being loaded
  43866. * @param pluginExtension the extension used to determine the plugin
  43867. * @returns The loaded asset container
  43868. */
  43869. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43870. }
  43871. }
  43872. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43873. import { Scene } from "babylonjs/scene";
  43874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43875. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43876. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43877. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43878. /**
  43879. * Generic Controller
  43880. */
  43881. export class GenericController extends WebVRController {
  43882. /**
  43883. * Base Url for the controller model.
  43884. */
  43885. static readonly MODEL_BASE_URL: string;
  43886. /**
  43887. * File name for the controller model.
  43888. */
  43889. static readonly MODEL_FILENAME: string;
  43890. /**
  43891. * Creates a new GenericController from a gamepad
  43892. * @param vrGamepad the gamepad that the controller should be created from
  43893. */
  43894. constructor(vrGamepad: any);
  43895. /**
  43896. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43897. * @param scene scene in which to add meshes
  43898. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43899. */
  43900. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43901. /**
  43902. * Called once for each button that changed state since the last frame
  43903. * @param buttonIdx Which button index changed
  43904. * @param state New state of the button
  43905. * @param changes Which properties on the state changed since last frame
  43906. */
  43907. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43908. }
  43909. }
  43910. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43911. import { Observable } from "babylonjs/Misc/observable";
  43912. import { Scene } from "babylonjs/scene";
  43913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43914. import { Ray } from "babylonjs/Culling/ray";
  43915. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43916. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43917. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43918. /**
  43919. * Defines the WindowsMotionController object that the state of the windows motion controller
  43920. */
  43921. export class WindowsMotionController extends WebVRController {
  43922. /**
  43923. * The base url used to load the left and right controller models
  43924. */
  43925. static MODEL_BASE_URL: string;
  43926. /**
  43927. * The name of the left controller model file
  43928. */
  43929. static MODEL_LEFT_FILENAME: string;
  43930. /**
  43931. * The name of the right controller model file
  43932. */
  43933. static MODEL_RIGHT_FILENAME: string;
  43934. /**
  43935. * The controller name prefix for this controller type
  43936. */
  43937. static readonly GAMEPAD_ID_PREFIX: string;
  43938. /**
  43939. * The controller id pattern for this controller type
  43940. */
  43941. private static readonly GAMEPAD_ID_PATTERN;
  43942. private _loadedMeshInfo;
  43943. private readonly _mapping;
  43944. /**
  43945. * Fired when the trackpad on this controller is clicked
  43946. */
  43947. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43948. /**
  43949. * Fired when the trackpad on this controller is modified
  43950. */
  43951. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43952. /**
  43953. * The current x and y values of this controller's trackpad
  43954. */
  43955. trackpad: StickValues;
  43956. /**
  43957. * Creates a new WindowsMotionController from a gamepad
  43958. * @param vrGamepad the gamepad that the controller should be created from
  43959. */
  43960. constructor(vrGamepad: any);
  43961. /**
  43962. * Fired when the trigger on this controller is modified
  43963. */
  43964. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43965. /**
  43966. * Fired when the menu button on this controller is modified
  43967. */
  43968. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43969. /**
  43970. * Fired when the grip button on this controller is modified
  43971. */
  43972. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43973. /**
  43974. * Fired when the thumbstick button on this controller is modified
  43975. */
  43976. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43977. /**
  43978. * Fired when the touchpad button on this controller is modified
  43979. */
  43980. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43981. /**
  43982. * Fired when the touchpad values on this controller are modified
  43983. */
  43984. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43985. private _updateTrackpad;
  43986. /**
  43987. * Called once per frame by the engine.
  43988. */
  43989. update(): void;
  43990. /**
  43991. * Called once for each button that changed state since the last frame
  43992. * @param buttonIdx Which button index changed
  43993. * @param state New state of the button
  43994. * @param changes Which properties on the state changed since last frame
  43995. */
  43996. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43997. /**
  43998. * Moves the buttons on the controller mesh based on their current state
  43999. * @param buttonName the name of the button to move
  44000. * @param buttonValue the value of the button which determines the buttons new position
  44001. */
  44002. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44003. /**
  44004. * Moves the axis on the controller mesh based on its current state
  44005. * @param axis the index of the axis
  44006. * @param axisValue the value of the axis which determines the meshes new position
  44007. * @hidden
  44008. */
  44009. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44010. /**
  44011. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44012. * @param scene scene in which to add meshes
  44013. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44014. */
  44015. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44016. /**
  44017. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44018. * can be transformed by button presses and axes values, based on this._mapping.
  44019. *
  44020. * @param scene scene in which the meshes exist
  44021. * @param meshes list of meshes that make up the controller model to process
  44022. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44023. */
  44024. private processModel;
  44025. private createMeshInfo;
  44026. /**
  44027. * Gets the ray of the controller in the direction the controller is pointing
  44028. * @param length the length the resulting ray should be
  44029. * @returns a ray in the direction the controller is pointing
  44030. */
  44031. getForwardRay(length?: number): Ray;
  44032. /**
  44033. * Disposes of the controller
  44034. */
  44035. dispose(): void;
  44036. }
  44037. }
  44038. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44039. import { Observable } from "babylonjs/Misc/observable";
  44040. import { Scene } from "babylonjs/scene";
  44041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44042. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44043. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44044. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44045. /**
  44046. * Oculus Touch Controller
  44047. */
  44048. export class OculusTouchController extends WebVRController {
  44049. /**
  44050. * Base Url for the controller model.
  44051. */
  44052. static MODEL_BASE_URL: string;
  44053. /**
  44054. * File name for the left controller model.
  44055. */
  44056. static MODEL_LEFT_FILENAME: string;
  44057. /**
  44058. * File name for the right controller model.
  44059. */
  44060. static MODEL_RIGHT_FILENAME: string;
  44061. /**
  44062. * Base Url for the Quest controller model.
  44063. */
  44064. static QUEST_MODEL_BASE_URL: string;
  44065. /**
  44066. * @hidden
  44067. * If the controllers are running on a device that needs the updated Quest controller models
  44068. */
  44069. static _IsQuest: boolean;
  44070. /**
  44071. * Fired when the secondary trigger on this controller is modified
  44072. */
  44073. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44074. /**
  44075. * Fired when the thumb rest on this controller is modified
  44076. */
  44077. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44078. /**
  44079. * Creates a new OculusTouchController from a gamepad
  44080. * @param vrGamepad the gamepad that the controller should be created from
  44081. */
  44082. constructor(vrGamepad: any);
  44083. /**
  44084. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44085. * @param scene scene in which to add meshes
  44086. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44087. */
  44088. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44089. /**
  44090. * Fired when the A button on this controller is modified
  44091. */
  44092. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44093. /**
  44094. * Fired when the B button on this controller is modified
  44095. */
  44096. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44097. /**
  44098. * Fired when the X button on this controller is modified
  44099. */
  44100. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44101. /**
  44102. * Fired when the Y button on this controller is modified
  44103. */
  44104. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44105. /**
  44106. * Called once for each button that changed state since the last frame
  44107. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44108. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44109. * 2) secondary trigger (same)
  44110. * 3) A (right) X (left), touch, pressed = value
  44111. * 4) B / Y
  44112. * 5) thumb rest
  44113. * @param buttonIdx Which button index changed
  44114. * @param state New state of the button
  44115. * @param changes Which properties on the state changed since last frame
  44116. */
  44117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44118. }
  44119. }
  44120. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44121. import { Scene } from "babylonjs/scene";
  44122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44123. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44124. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44125. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44126. import { Observable } from "babylonjs/Misc/observable";
  44127. /**
  44128. * Vive Controller
  44129. */
  44130. export class ViveController extends WebVRController {
  44131. /**
  44132. * Base Url for the controller model.
  44133. */
  44134. static MODEL_BASE_URL: string;
  44135. /**
  44136. * File name for the controller model.
  44137. */
  44138. static MODEL_FILENAME: string;
  44139. /**
  44140. * Creates a new ViveController from a gamepad
  44141. * @param vrGamepad the gamepad that the controller should be created from
  44142. */
  44143. constructor(vrGamepad: any);
  44144. /**
  44145. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44146. * @param scene scene in which to add meshes
  44147. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44148. */
  44149. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44150. /**
  44151. * Fired when the left button on this controller is modified
  44152. */
  44153. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44154. /**
  44155. * Fired when the right button on this controller is modified
  44156. */
  44157. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44158. /**
  44159. * Fired when the menu button on this controller is modified
  44160. */
  44161. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44162. /**
  44163. * Called once for each button that changed state since the last frame
  44164. * Vive mapping:
  44165. * 0: touchpad
  44166. * 1: trigger
  44167. * 2: left AND right buttons
  44168. * 3: menu button
  44169. * @param buttonIdx Which button index changed
  44170. * @param state New state of the button
  44171. * @param changes Which properties on the state changed since last frame
  44172. */
  44173. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44174. }
  44175. }
  44176. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44177. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44178. /**
  44179. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44180. */
  44181. export class WebXRControllerModelLoader {
  44182. /**
  44183. * Creates the WebXRControllerModelLoader
  44184. * @param input xr input that creates the controllers
  44185. */
  44186. constructor(input: WebXRInput);
  44187. }
  44188. }
  44189. declare module "babylonjs/Cameras/XR/index" {
  44190. export * from "babylonjs/Cameras/XR/webXRCamera";
  44191. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44192. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44193. export * from "babylonjs/Cameras/XR/webXRInput";
  44194. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44195. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44196. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44197. export * from "babylonjs/Cameras/XR/webXRController";
  44198. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44199. export * from "babylonjs/Cameras/XR/webXRTypes";
  44200. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44201. }
  44202. declare module "babylonjs/Cameras/RigModes/index" {
  44203. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44204. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44205. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44206. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44207. }
  44208. declare module "babylonjs/Cameras/index" {
  44209. export * from "babylonjs/Cameras/Inputs/index";
  44210. export * from "babylonjs/Cameras/cameraInputsManager";
  44211. export * from "babylonjs/Cameras/camera";
  44212. export * from "babylonjs/Cameras/targetCamera";
  44213. export * from "babylonjs/Cameras/freeCamera";
  44214. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44215. export * from "babylonjs/Cameras/touchCamera";
  44216. export * from "babylonjs/Cameras/arcRotateCamera";
  44217. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44218. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44219. export * from "babylonjs/Cameras/flyCamera";
  44220. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44221. export * from "babylonjs/Cameras/followCamera";
  44222. export * from "babylonjs/Cameras/followCameraInputsManager";
  44223. export * from "babylonjs/Cameras/gamepadCamera";
  44224. export * from "babylonjs/Cameras/Stereoscopic/index";
  44225. export * from "babylonjs/Cameras/universalCamera";
  44226. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44227. export * from "babylonjs/Cameras/VR/index";
  44228. export * from "babylonjs/Cameras/XR/index";
  44229. export * from "babylonjs/Cameras/RigModes/index";
  44230. }
  44231. declare module "babylonjs/Collisions/index" {
  44232. export * from "babylonjs/Collisions/collider";
  44233. export * from "babylonjs/Collisions/collisionCoordinator";
  44234. export * from "babylonjs/Collisions/pickingInfo";
  44235. export * from "babylonjs/Collisions/intersectionInfo";
  44236. export * from "babylonjs/Collisions/meshCollisionData";
  44237. }
  44238. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44239. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44240. import { Vector3 } from "babylonjs/Maths/math.vector";
  44241. import { Ray } from "babylonjs/Culling/ray";
  44242. import { Plane } from "babylonjs/Maths/math.plane";
  44243. /**
  44244. * Contains an array of blocks representing the octree
  44245. */
  44246. export interface IOctreeContainer<T> {
  44247. /**
  44248. * Blocks within the octree
  44249. */
  44250. blocks: Array<OctreeBlock<T>>;
  44251. }
  44252. /**
  44253. * Class used to store a cell in an octree
  44254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44255. */
  44256. export class OctreeBlock<T> {
  44257. /**
  44258. * Gets the content of the current block
  44259. */
  44260. entries: T[];
  44261. /**
  44262. * Gets the list of block children
  44263. */
  44264. blocks: Array<OctreeBlock<T>>;
  44265. private _depth;
  44266. private _maxDepth;
  44267. private _capacity;
  44268. private _minPoint;
  44269. private _maxPoint;
  44270. private _boundingVectors;
  44271. private _creationFunc;
  44272. /**
  44273. * Creates a new block
  44274. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44275. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44276. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44277. * @param depth defines the current depth of this block in the octree
  44278. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44279. * @param creationFunc defines a callback to call when an element is added to the block
  44280. */
  44281. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44282. /**
  44283. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44284. */
  44285. readonly capacity: number;
  44286. /**
  44287. * Gets the minimum vector (in world space) of the block's bounding box
  44288. */
  44289. readonly minPoint: Vector3;
  44290. /**
  44291. * Gets the maximum vector (in world space) of the block's bounding box
  44292. */
  44293. readonly maxPoint: Vector3;
  44294. /**
  44295. * Add a new element to this block
  44296. * @param entry defines the element to add
  44297. */
  44298. addEntry(entry: T): void;
  44299. /**
  44300. * Remove an element from this block
  44301. * @param entry defines the element to remove
  44302. */
  44303. removeEntry(entry: T): void;
  44304. /**
  44305. * Add an array of elements to this block
  44306. * @param entries defines the array of elements to add
  44307. */
  44308. addEntries(entries: T[]): void;
  44309. /**
  44310. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44311. * @param frustumPlanes defines the frustum planes to test
  44312. * @param selection defines the array to store current content if selection is positive
  44313. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44314. */
  44315. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44316. /**
  44317. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44318. * @param sphereCenter defines the bounding sphere center
  44319. * @param sphereRadius defines the bounding sphere radius
  44320. * @param selection defines the array to store current content if selection is positive
  44321. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44322. */
  44323. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44324. /**
  44325. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44326. * @param ray defines the ray to test with
  44327. * @param selection defines the array to store current content if selection is positive
  44328. */
  44329. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44330. /**
  44331. * Subdivide the content into child blocks (this block will then be empty)
  44332. */
  44333. createInnerBlocks(): void;
  44334. /**
  44335. * @hidden
  44336. */
  44337. 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;
  44338. }
  44339. }
  44340. declare module "babylonjs/Culling/Octrees/octree" {
  44341. import { SmartArray } from "babylonjs/Misc/smartArray";
  44342. import { Vector3 } from "babylonjs/Maths/math.vector";
  44343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44345. import { Ray } from "babylonjs/Culling/ray";
  44346. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44347. import { Plane } from "babylonjs/Maths/math.plane";
  44348. /**
  44349. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44350. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44351. */
  44352. export class Octree<T> {
  44353. /** 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.) */
  44354. maxDepth: number;
  44355. /**
  44356. * Blocks within the octree containing objects
  44357. */
  44358. blocks: Array<OctreeBlock<T>>;
  44359. /**
  44360. * Content stored in the octree
  44361. */
  44362. dynamicContent: T[];
  44363. private _maxBlockCapacity;
  44364. private _selectionContent;
  44365. private _creationFunc;
  44366. /**
  44367. * Creates a octree
  44368. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44369. * @param creationFunc function to be used to instatiate the octree
  44370. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44371. * @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.)
  44372. */
  44373. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44374. /** 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.) */
  44375. maxDepth?: number);
  44376. /**
  44377. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44378. * @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);
  44379. * @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);
  44380. * @param entries meshes to be added to the octree blocks
  44381. */
  44382. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44383. /**
  44384. * Adds a mesh to the octree
  44385. * @param entry Mesh to add to the octree
  44386. */
  44387. addMesh(entry: T): void;
  44388. /**
  44389. * Remove an element from the octree
  44390. * @param entry defines the element to remove
  44391. */
  44392. removeMesh(entry: T): void;
  44393. /**
  44394. * Selects an array of meshes within the frustum
  44395. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44396. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44397. * @returns array of meshes within the frustum
  44398. */
  44399. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44400. /**
  44401. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44402. * @param sphereCenter defines the bounding sphere center
  44403. * @param sphereRadius defines the bounding sphere radius
  44404. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44405. * @returns an array of objects that intersect the sphere
  44406. */
  44407. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44408. /**
  44409. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44410. * @param ray defines the ray to test with
  44411. * @returns array of intersected objects
  44412. */
  44413. intersectsRay(ray: Ray): SmartArray<T>;
  44414. /**
  44415. * Adds a mesh into the octree block if it intersects the block
  44416. */
  44417. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44418. /**
  44419. * Adds a submesh into the octree block if it intersects the block
  44420. */
  44421. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44422. }
  44423. }
  44424. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44425. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44426. import { Scene } from "babylonjs/scene";
  44427. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44429. import { Ray } from "babylonjs/Culling/ray";
  44430. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44431. import { Collider } from "babylonjs/Collisions/collider";
  44432. module "babylonjs/scene" {
  44433. interface Scene {
  44434. /**
  44435. * @hidden
  44436. * Backing Filed
  44437. */
  44438. _selectionOctree: Octree<AbstractMesh>;
  44439. /**
  44440. * Gets the octree used to boost mesh selection (picking)
  44441. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44442. */
  44443. selectionOctree: Octree<AbstractMesh>;
  44444. /**
  44445. * Creates or updates the octree used to boost selection (picking)
  44446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44447. * @param maxCapacity defines the maximum capacity per leaf
  44448. * @param maxDepth defines the maximum depth of the octree
  44449. * @returns an octree of AbstractMesh
  44450. */
  44451. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44452. }
  44453. }
  44454. module "babylonjs/Meshes/abstractMesh" {
  44455. interface AbstractMesh {
  44456. /**
  44457. * @hidden
  44458. * Backing Field
  44459. */
  44460. _submeshesOctree: Octree<SubMesh>;
  44461. /**
  44462. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44463. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44464. * @param maxCapacity defines the maximum size of each block (64 by default)
  44465. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44466. * @returns the new octree
  44467. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44468. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44469. */
  44470. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44471. }
  44472. }
  44473. /**
  44474. * Defines the octree scene component responsible to manage any octrees
  44475. * in a given scene.
  44476. */
  44477. export class OctreeSceneComponent {
  44478. /**
  44479. * The component name help to identify the component in the list of scene components.
  44480. */
  44481. readonly name: string;
  44482. /**
  44483. * The scene the component belongs to.
  44484. */
  44485. scene: Scene;
  44486. /**
  44487. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44488. */
  44489. readonly checksIsEnabled: boolean;
  44490. /**
  44491. * Creates a new instance of the component for the given scene
  44492. * @param scene Defines the scene to register the component in
  44493. */
  44494. constructor(scene: Scene);
  44495. /**
  44496. * Registers the component in a given scene
  44497. */
  44498. register(): void;
  44499. /**
  44500. * Return the list of active meshes
  44501. * @returns the list of active meshes
  44502. */
  44503. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44504. /**
  44505. * Return the list of active sub meshes
  44506. * @param mesh The mesh to get the candidates sub meshes from
  44507. * @returns the list of active sub meshes
  44508. */
  44509. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44510. private _tempRay;
  44511. /**
  44512. * Return the list of sub meshes intersecting with a given local ray
  44513. * @param mesh defines the mesh to find the submesh for
  44514. * @param localRay defines the ray in local space
  44515. * @returns the list of intersecting sub meshes
  44516. */
  44517. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44518. /**
  44519. * Return the list of sub meshes colliding with a collider
  44520. * @param mesh defines the mesh to find the submesh for
  44521. * @param collider defines the collider to evaluate the collision against
  44522. * @returns the list of colliding sub meshes
  44523. */
  44524. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44525. /**
  44526. * Rebuilds the elements related to this component in case of
  44527. * context lost for instance.
  44528. */
  44529. rebuild(): void;
  44530. /**
  44531. * Disposes the component and the associated ressources.
  44532. */
  44533. dispose(): void;
  44534. }
  44535. }
  44536. declare module "babylonjs/Culling/Octrees/index" {
  44537. export * from "babylonjs/Culling/Octrees/octree";
  44538. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44539. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44540. }
  44541. declare module "babylonjs/Culling/index" {
  44542. export * from "babylonjs/Culling/boundingBox";
  44543. export * from "babylonjs/Culling/boundingInfo";
  44544. export * from "babylonjs/Culling/boundingSphere";
  44545. export * from "babylonjs/Culling/Octrees/index";
  44546. export * from "babylonjs/Culling/ray";
  44547. }
  44548. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44549. import { IDisposable, Scene } from "babylonjs/scene";
  44550. import { Nullable } from "babylonjs/types";
  44551. import { Observable } from "babylonjs/Misc/observable";
  44552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44553. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44554. import { Camera } from "babylonjs/Cameras/camera";
  44555. /**
  44556. * Renders a layer on top of an existing scene
  44557. */
  44558. export class UtilityLayerRenderer implements IDisposable {
  44559. /** the original scene that will be rendered on top of */
  44560. originalScene: Scene;
  44561. private _pointerCaptures;
  44562. private _lastPointerEvents;
  44563. private static _DefaultUtilityLayer;
  44564. private static _DefaultKeepDepthUtilityLayer;
  44565. private _sharedGizmoLight;
  44566. private _renderCamera;
  44567. /**
  44568. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44569. * @returns the camera that is used when rendering the utility layer
  44570. */
  44571. getRenderCamera(): Nullable<Camera>;
  44572. /**
  44573. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44574. * @param cam the camera that should be used when rendering the utility layer
  44575. */
  44576. setRenderCamera(cam: Nullable<Camera>): void;
  44577. /**
  44578. * @hidden
  44579. * Light which used by gizmos to get light shading
  44580. */
  44581. _getSharedGizmoLight(): HemisphericLight;
  44582. /**
  44583. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44584. */
  44585. pickUtilitySceneFirst: boolean;
  44586. /**
  44587. * 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)
  44588. */
  44589. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44590. /**
  44591. * 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)
  44592. */
  44593. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44594. /**
  44595. * The scene that is rendered on top of the original scene
  44596. */
  44597. utilityLayerScene: Scene;
  44598. /**
  44599. * If the utility layer should automatically be rendered on top of existing scene
  44600. */
  44601. shouldRender: boolean;
  44602. /**
  44603. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44604. */
  44605. onlyCheckPointerDownEvents: boolean;
  44606. /**
  44607. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44608. */
  44609. processAllEvents: boolean;
  44610. /**
  44611. * Observable raised when the pointer move from the utility layer scene to the main scene
  44612. */
  44613. onPointerOutObservable: Observable<number>;
  44614. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44615. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44616. private _afterRenderObserver;
  44617. private _sceneDisposeObserver;
  44618. private _originalPointerObserver;
  44619. /**
  44620. * Instantiates a UtilityLayerRenderer
  44621. * @param originalScene the original scene that will be rendered on top of
  44622. * @param handleEvents boolean indicating if the utility layer should handle events
  44623. */
  44624. constructor(
  44625. /** the original scene that will be rendered on top of */
  44626. originalScene: Scene, handleEvents?: boolean);
  44627. private _notifyObservers;
  44628. /**
  44629. * Renders the utility layers scene on top of the original scene
  44630. */
  44631. render(): void;
  44632. /**
  44633. * Disposes of the renderer
  44634. */
  44635. dispose(): void;
  44636. private _updateCamera;
  44637. }
  44638. }
  44639. declare module "babylonjs/Gizmos/gizmo" {
  44640. import { Nullable } from "babylonjs/types";
  44641. import { IDisposable } from "babylonjs/scene";
  44642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44643. import { Mesh } from "babylonjs/Meshes/mesh";
  44644. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44645. /**
  44646. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44647. */
  44648. export class Gizmo implements IDisposable {
  44649. /** The utility layer the gizmo will be added to */
  44650. gizmoLayer: UtilityLayerRenderer;
  44651. /**
  44652. * The root mesh of the gizmo
  44653. */
  44654. _rootMesh: Mesh;
  44655. private _attachedMesh;
  44656. /**
  44657. * Ratio for the scale of the gizmo (Default: 1)
  44658. */
  44659. scaleRatio: number;
  44660. /**
  44661. * If a custom mesh has been set (Default: false)
  44662. */
  44663. protected _customMeshSet: boolean;
  44664. /**
  44665. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44666. * * When set, interactions will be enabled
  44667. */
  44668. attachedMesh: Nullable<AbstractMesh>;
  44669. /**
  44670. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44671. * @param mesh The mesh to replace the default mesh of the gizmo
  44672. */
  44673. setCustomMesh(mesh: Mesh): void;
  44674. /**
  44675. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44676. */
  44677. updateGizmoRotationToMatchAttachedMesh: boolean;
  44678. /**
  44679. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44680. */
  44681. updateGizmoPositionToMatchAttachedMesh: boolean;
  44682. /**
  44683. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44684. */
  44685. updateScale: boolean;
  44686. protected _interactionsEnabled: boolean;
  44687. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44688. private _beforeRenderObserver;
  44689. private _tempVector;
  44690. /**
  44691. * Creates a gizmo
  44692. * @param gizmoLayer The utility layer the gizmo will be added to
  44693. */
  44694. constructor(
  44695. /** The utility layer the gizmo will be added to */
  44696. gizmoLayer?: UtilityLayerRenderer);
  44697. /**
  44698. * Updates the gizmo to match the attached mesh's position/rotation
  44699. */
  44700. protected _update(): void;
  44701. /**
  44702. * Disposes of the gizmo
  44703. */
  44704. dispose(): void;
  44705. }
  44706. }
  44707. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44708. import { Observable } from "babylonjs/Misc/observable";
  44709. import { Nullable } from "babylonjs/types";
  44710. import { Vector3 } from "babylonjs/Maths/math.vector";
  44711. import { Color3 } from "babylonjs/Maths/math.color";
  44712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44714. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44715. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44716. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44717. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44718. import { Scene } from "babylonjs/scene";
  44719. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44720. /**
  44721. * Single plane drag gizmo
  44722. */
  44723. export class PlaneDragGizmo extends Gizmo {
  44724. /**
  44725. * Drag behavior responsible for the gizmos dragging interactions
  44726. */
  44727. dragBehavior: PointerDragBehavior;
  44728. private _pointerObserver;
  44729. /**
  44730. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44731. */
  44732. snapDistance: number;
  44733. /**
  44734. * Event that fires each time the gizmo snaps to a new location.
  44735. * * snapDistance is the the change in distance
  44736. */
  44737. onSnapObservable: Observable<{
  44738. snapDistance: number;
  44739. }>;
  44740. private _plane;
  44741. private _coloredMaterial;
  44742. private _hoverMaterial;
  44743. private _isEnabled;
  44744. private _parent;
  44745. /** @hidden */
  44746. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44747. /** @hidden */
  44748. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44749. /**
  44750. * Creates a PlaneDragGizmo
  44751. * @param gizmoLayer The utility layer the gizmo will be added to
  44752. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44753. * @param color The color of the gizmo
  44754. */
  44755. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44756. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44757. /**
  44758. * If the gizmo is enabled
  44759. */
  44760. isEnabled: boolean;
  44761. /**
  44762. * Disposes of the gizmo
  44763. */
  44764. dispose(): void;
  44765. }
  44766. }
  44767. declare module "babylonjs/Gizmos/positionGizmo" {
  44768. import { Observable } from "babylonjs/Misc/observable";
  44769. import { Nullable } from "babylonjs/types";
  44770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44771. import { Mesh } from "babylonjs/Meshes/mesh";
  44772. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44773. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44774. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44775. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44776. /**
  44777. * Gizmo that enables dragging a mesh along 3 axis
  44778. */
  44779. export class PositionGizmo extends Gizmo {
  44780. /**
  44781. * Internal gizmo used for interactions on the x axis
  44782. */
  44783. xGizmo: AxisDragGizmo;
  44784. /**
  44785. * Internal gizmo used for interactions on the y axis
  44786. */
  44787. yGizmo: AxisDragGizmo;
  44788. /**
  44789. * Internal gizmo used for interactions on the z axis
  44790. */
  44791. zGizmo: AxisDragGizmo;
  44792. /**
  44793. * Internal gizmo used for interactions on the yz plane
  44794. */
  44795. xPlaneGizmo: PlaneDragGizmo;
  44796. /**
  44797. * Internal gizmo used for interactions on the xz plane
  44798. */
  44799. yPlaneGizmo: PlaneDragGizmo;
  44800. /**
  44801. * Internal gizmo used for interactions on the xy plane
  44802. */
  44803. zPlaneGizmo: PlaneDragGizmo;
  44804. /**
  44805. * private variables
  44806. */
  44807. private _meshAttached;
  44808. private _updateGizmoRotationToMatchAttachedMesh;
  44809. private _snapDistance;
  44810. private _scaleRatio;
  44811. /** Fires an event when any of it's sub gizmos are dragged */
  44812. onDragStartObservable: Observable<unknown>;
  44813. /** Fires an event when any of it's sub gizmos are released from dragging */
  44814. onDragEndObservable: Observable<unknown>;
  44815. /**
  44816. * If set to true, planar drag is enabled
  44817. */
  44818. private _planarGizmoEnabled;
  44819. attachedMesh: Nullable<AbstractMesh>;
  44820. /**
  44821. * Creates a PositionGizmo
  44822. * @param gizmoLayer The utility layer the gizmo will be added to
  44823. */
  44824. constructor(gizmoLayer?: UtilityLayerRenderer);
  44825. /**
  44826. * If the planar drag gizmo is enabled
  44827. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44828. */
  44829. planarGizmoEnabled: boolean;
  44830. updateGizmoRotationToMatchAttachedMesh: boolean;
  44831. /**
  44832. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44833. */
  44834. snapDistance: number;
  44835. /**
  44836. * Ratio for the scale of the gizmo (Default: 1)
  44837. */
  44838. scaleRatio: number;
  44839. /**
  44840. * Disposes of the gizmo
  44841. */
  44842. dispose(): void;
  44843. /**
  44844. * CustomMeshes are not supported by this gizmo
  44845. * @param mesh The mesh to replace the default mesh of the gizmo
  44846. */
  44847. setCustomMesh(mesh: Mesh): void;
  44848. }
  44849. }
  44850. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44851. import { Observable } from "babylonjs/Misc/observable";
  44852. import { Nullable } from "babylonjs/types";
  44853. import { Vector3 } from "babylonjs/Maths/math.vector";
  44854. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44856. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44857. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44858. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44859. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44860. import { Scene } from "babylonjs/scene";
  44861. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44862. import { Color3 } from "babylonjs/Maths/math.color";
  44863. /**
  44864. * Single axis drag gizmo
  44865. */
  44866. export class AxisDragGizmo extends Gizmo {
  44867. /**
  44868. * Drag behavior responsible for the gizmos dragging interactions
  44869. */
  44870. dragBehavior: PointerDragBehavior;
  44871. private _pointerObserver;
  44872. /**
  44873. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44874. */
  44875. snapDistance: number;
  44876. /**
  44877. * Event that fires each time the gizmo snaps to a new location.
  44878. * * snapDistance is the the change in distance
  44879. */
  44880. onSnapObservable: Observable<{
  44881. snapDistance: number;
  44882. }>;
  44883. private _isEnabled;
  44884. private _parent;
  44885. private _arrow;
  44886. private _coloredMaterial;
  44887. private _hoverMaterial;
  44888. /** @hidden */
  44889. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44890. /** @hidden */
  44891. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44892. /**
  44893. * Creates an AxisDragGizmo
  44894. * @param gizmoLayer The utility layer the gizmo will be added to
  44895. * @param dragAxis The axis which the gizmo will be able to drag on
  44896. * @param color The color of the gizmo
  44897. */
  44898. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44899. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44900. /**
  44901. * If the gizmo is enabled
  44902. */
  44903. isEnabled: boolean;
  44904. /**
  44905. * Disposes of the gizmo
  44906. */
  44907. dispose(): void;
  44908. }
  44909. }
  44910. declare module "babylonjs/Debug/axesViewer" {
  44911. import { Vector3 } from "babylonjs/Maths/math.vector";
  44912. import { Nullable } from "babylonjs/types";
  44913. import { Scene } from "babylonjs/scene";
  44914. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44915. /**
  44916. * The Axes viewer will show 3 axes in a specific point in space
  44917. */
  44918. export class AxesViewer {
  44919. private _xAxis;
  44920. private _yAxis;
  44921. private _zAxis;
  44922. private _scaleLinesFactor;
  44923. private _instanced;
  44924. /**
  44925. * Gets the hosting scene
  44926. */
  44927. scene: Scene;
  44928. /**
  44929. * Gets or sets a number used to scale line length
  44930. */
  44931. scaleLines: number;
  44932. /** Gets the node hierarchy used to render x-axis */
  44933. readonly xAxis: TransformNode;
  44934. /** Gets the node hierarchy used to render y-axis */
  44935. readonly yAxis: TransformNode;
  44936. /** Gets the node hierarchy used to render z-axis */
  44937. readonly zAxis: TransformNode;
  44938. /**
  44939. * Creates a new AxesViewer
  44940. * @param scene defines the hosting scene
  44941. * @param scaleLines defines a number used to scale line length (1 by default)
  44942. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44943. * @param xAxis defines the node hierarchy used to render the x-axis
  44944. * @param yAxis defines the node hierarchy used to render the y-axis
  44945. * @param zAxis defines the node hierarchy used to render the z-axis
  44946. */
  44947. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44948. /**
  44949. * Force the viewer to update
  44950. * @param position defines the position of the viewer
  44951. * @param xaxis defines the x axis of the viewer
  44952. * @param yaxis defines the y axis of the viewer
  44953. * @param zaxis defines the z axis of the viewer
  44954. */
  44955. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44956. /**
  44957. * Creates an instance of this axes viewer.
  44958. * @returns a new axes viewer with instanced meshes
  44959. */
  44960. createInstance(): AxesViewer;
  44961. /** Releases resources */
  44962. dispose(): void;
  44963. private static _SetRenderingGroupId;
  44964. }
  44965. }
  44966. declare module "babylonjs/Debug/boneAxesViewer" {
  44967. import { Nullable } from "babylonjs/types";
  44968. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44969. import { Vector3 } from "babylonjs/Maths/math.vector";
  44970. import { Mesh } from "babylonjs/Meshes/mesh";
  44971. import { Bone } from "babylonjs/Bones/bone";
  44972. import { Scene } from "babylonjs/scene";
  44973. /**
  44974. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44975. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44976. */
  44977. export class BoneAxesViewer extends AxesViewer {
  44978. /**
  44979. * Gets or sets the target mesh where to display the axes viewer
  44980. */
  44981. mesh: Nullable<Mesh>;
  44982. /**
  44983. * Gets or sets the target bone where to display the axes viewer
  44984. */
  44985. bone: Nullable<Bone>;
  44986. /** Gets current position */
  44987. pos: Vector3;
  44988. /** Gets direction of X axis */
  44989. xaxis: Vector3;
  44990. /** Gets direction of Y axis */
  44991. yaxis: Vector3;
  44992. /** Gets direction of Z axis */
  44993. zaxis: Vector3;
  44994. /**
  44995. * Creates a new BoneAxesViewer
  44996. * @param scene defines the hosting scene
  44997. * @param bone defines the target bone
  44998. * @param mesh defines the target mesh
  44999. * @param scaleLines defines a scaling factor for line length (1 by default)
  45000. */
  45001. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45002. /**
  45003. * Force the viewer to update
  45004. */
  45005. update(): void;
  45006. /** Releases resources */
  45007. dispose(): void;
  45008. }
  45009. }
  45010. declare module "babylonjs/Debug/debugLayer" {
  45011. import { Scene } from "babylonjs/scene";
  45012. /**
  45013. * Interface used to define scene explorer extensibility option
  45014. */
  45015. export interface IExplorerExtensibilityOption {
  45016. /**
  45017. * Define the option label
  45018. */
  45019. label: string;
  45020. /**
  45021. * Defines the action to execute on click
  45022. */
  45023. action: (entity: any) => void;
  45024. }
  45025. /**
  45026. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45027. */
  45028. export interface IExplorerExtensibilityGroup {
  45029. /**
  45030. * Defines a predicate to test if a given type mut be extended
  45031. */
  45032. predicate: (entity: any) => boolean;
  45033. /**
  45034. * Gets the list of options added to a type
  45035. */
  45036. entries: IExplorerExtensibilityOption[];
  45037. }
  45038. /**
  45039. * Interface used to define the options to use to create the Inspector
  45040. */
  45041. export interface IInspectorOptions {
  45042. /**
  45043. * Display in overlay mode (default: false)
  45044. */
  45045. overlay?: boolean;
  45046. /**
  45047. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45048. */
  45049. globalRoot?: HTMLElement;
  45050. /**
  45051. * Display the Scene explorer
  45052. */
  45053. showExplorer?: boolean;
  45054. /**
  45055. * Display the property inspector
  45056. */
  45057. showInspector?: boolean;
  45058. /**
  45059. * Display in embed mode (both panes on the right)
  45060. */
  45061. embedMode?: boolean;
  45062. /**
  45063. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45064. */
  45065. handleResize?: boolean;
  45066. /**
  45067. * Allow the panes to popup (default: true)
  45068. */
  45069. enablePopup?: boolean;
  45070. /**
  45071. * Allow the panes to be closed by users (default: true)
  45072. */
  45073. enableClose?: boolean;
  45074. /**
  45075. * Optional list of extensibility entries
  45076. */
  45077. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45078. /**
  45079. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45080. */
  45081. inspectorURL?: string;
  45082. }
  45083. module "babylonjs/scene" {
  45084. interface Scene {
  45085. /**
  45086. * @hidden
  45087. * Backing field
  45088. */
  45089. _debugLayer: DebugLayer;
  45090. /**
  45091. * Gets the debug layer (aka Inspector) associated with the scene
  45092. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45093. */
  45094. debugLayer: DebugLayer;
  45095. }
  45096. }
  45097. /**
  45098. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45099. * what is happening in your scene
  45100. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45101. */
  45102. export class DebugLayer {
  45103. /**
  45104. * Define the url to get the inspector script from.
  45105. * By default it uses the babylonjs CDN.
  45106. * @ignoreNaming
  45107. */
  45108. static InspectorURL: string;
  45109. private _scene;
  45110. private BJSINSPECTOR;
  45111. private _onPropertyChangedObservable?;
  45112. /**
  45113. * Observable triggered when a property is changed through the inspector.
  45114. */
  45115. readonly onPropertyChangedObservable: any;
  45116. /**
  45117. * Instantiates a new debug layer.
  45118. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45119. * what is happening in your scene
  45120. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45121. * @param scene Defines the scene to inspect
  45122. */
  45123. constructor(scene: Scene);
  45124. /** Creates the inspector window. */
  45125. private _createInspector;
  45126. /**
  45127. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45128. * @param entity defines the entity to select
  45129. * @param lineContainerTitle defines the specific block to highlight
  45130. */
  45131. select(entity: any, lineContainerTitle?: string): void;
  45132. /** Get the inspector from bundle or global */
  45133. private _getGlobalInspector;
  45134. /**
  45135. * Get if the inspector is visible or not.
  45136. * @returns true if visible otherwise, false
  45137. */
  45138. isVisible(): boolean;
  45139. /**
  45140. * Hide the inspector and close its window.
  45141. */
  45142. hide(): void;
  45143. /**
  45144. * Launch the debugLayer.
  45145. * @param config Define the configuration of the inspector
  45146. * @return a promise fulfilled when the debug layer is visible
  45147. */
  45148. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45149. }
  45150. }
  45151. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45152. import { Nullable } from "babylonjs/types";
  45153. import { Scene } from "babylonjs/scene";
  45154. import { Vector4 } from "babylonjs/Maths/math.vector";
  45155. import { Color4 } from "babylonjs/Maths/math.color";
  45156. import { Mesh } from "babylonjs/Meshes/mesh";
  45157. /**
  45158. * Class containing static functions to help procedurally build meshes
  45159. */
  45160. export class BoxBuilder {
  45161. /**
  45162. * Creates a box mesh
  45163. * * The parameter `size` sets the size (float) of each box side (default 1)
  45164. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45165. * * 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)
  45166. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45170. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45171. * @param name defines the name of the mesh
  45172. * @param options defines the options used to create the mesh
  45173. * @param scene defines the hosting scene
  45174. * @returns the box mesh
  45175. */
  45176. static CreateBox(name: string, options: {
  45177. size?: number;
  45178. width?: number;
  45179. height?: number;
  45180. depth?: number;
  45181. faceUV?: Vector4[];
  45182. faceColors?: Color4[];
  45183. sideOrientation?: number;
  45184. frontUVs?: Vector4;
  45185. backUVs?: Vector4;
  45186. wrap?: boolean;
  45187. topBaseAt?: number;
  45188. bottomBaseAt?: number;
  45189. updatable?: boolean;
  45190. }, scene?: Nullable<Scene>): Mesh;
  45191. }
  45192. }
  45193. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45194. import { Vector4 } from "babylonjs/Maths/math.vector";
  45195. import { Mesh } from "babylonjs/Meshes/mesh";
  45196. import { Scene } from "babylonjs/scene";
  45197. import { Nullable } from "babylonjs/types";
  45198. /**
  45199. * Class containing static functions to help procedurally build meshes
  45200. */
  45201. export class SphereBuilder {
  45202. /**
  45203. * Creates a sphere mesh
  45204. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45205. * * 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`)
  45206. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45207. * * 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
  45208. * * 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)
  45209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45212. * @param name defines the name of the mesh
  45213. * @param options defines the options used to create the mesh
  45214. * @param scene defines the hosting scene
  45215. * @returns the sphere mesh
  45216. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45217. */
  45218. static CreateSphere(name: string, options: {
  45219. segments?: number;
  45220. diameter?: number;
  45221. diameterX?: number;
  45222. diameterY?: number;
  45223. diameterZ?: number;
  45224. arc?: number;
  45225. slice?: number;
  45226. sideOrientation?: number;
  45227. frontUVs?: Vector4;
  45228. backUVs?: Vector4;
  45229. updatable?: boolean;
  45230. }, scene?: Nullable<Scene>): Mesh;
  45231. }
  45232. }
  45233. declare module "babylonjs/Debug/physicsViewer" {
  45234. import { Nullable } from "babylonjs/types";
  45235. import { Scene } from "babylonjs/scene";
  45236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45237. import { Mesh } from "babylonjs/Meshes/mesh";
  45238. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45239. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45240. /**
  45241. * Used to show the physics impostor around the specific mesh
  45242. */
  45243. export class PhysicsViewer {
  45244. /** @hidden */
  45245. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45246. /** @hidden */
  45247. protected _meshes: Array<Nullable<AbstractMesh>>;
  45248. /** @hidden */
  45249. protected _scene: Nullable<Scene>;
  45250. /** @hidden */
  45251. protected _numMeshes: number;
  45252. /** @hidden */
  45253. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45254. private _renderFunction;
  45255. private _utilityLayer;
  45256. private _debugBoxMesh;
  45257. private _debugSphereMesh;
  45258. private _debugCylinderMesh;
  45259. private _debugMaterial;
  45260. private _debugMeshMeshes;
  45261. /**
  45262. * Creates a new PhysicsViewer
  45263. * @param scene defines the hosting scene
  45264. */
  45265. constructor(scene: Scene);
  45266. /** @hidden */
  45267. protected _updateDebugMeshes(): void;
  45268. /**
  45269. * Renders a specified physic impostor
  45270. * @param impostor defines the impostor to render
  45271. * @param targetMesh defines the mesh represented by the impostor
  45272. * @returns the new debug mesh used to render the impostor
  45273. */
  45274. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45275. /**
  45276. * Hides a specified physic impostor
  45277. * @param impostor defines the impostor to hide
  45278. */
  45279. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45280. private _getDebugMaterial;
  45281. private _getDebugBoxMesh;
  45282. private _getDebugSphereMesh;
  45283. private _getDebugCylinderMesh;
  45284. private _getDebugMeshMesh;
  45285. private _getDebugMesh;
  45286. /** Releases all resources */
  45287. dispose(): void;
  45288. }
  45289. }
  45290. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45291. import { Vector3 } from "babylonjs/Maths/math.vector";
  45292. import { Color4 } from "babylonjs/Maths/math.color";
  45293. import { Nullable } from "babylonjs/types";
  45294. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45295. import { Scene } from "babylonjs/scene";
  45296. /**
  45297. * Class containing static functions to help procedurally build meshes
  45298. */
  45299. export class LinesBuilder {
  45300. /**
  45301. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45302. * * 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
  45303. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45304. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45305. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45306. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45307. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45308. * * 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
  45309. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45311. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45312. * @param name defines the name of the new line system
  45313. * @param options defines the options used to create the line system
  45314. * @param scene defines the hosting scene
  45315. * @returns a new line system mesh
  45316. */
  45317. static CreateLineSystem(name: string, options: {
  45318. lines: Vector3[][];
  45319. updatable?: boolean;
  45320. instance?: Nullable<LinesMesh>;
  45321. colors?: Nullable<Color4[][]>;
  45322. useVertexAlpha?: boolean;
  45323. }, scene: Nullable<Scene>): LinesMesh;
  45324. /**
  45325. * Creates a line mesh
  45326. * 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
  45327. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45328. * * The parameter `points` is an array successive Vector3
  45329. * * 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
  45330. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45331. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45332. * * When updating an instance, remember that only point positions can change, not the number of points
  45333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45335. * @param name defines the name of the new line system
  45336. * @param options defines the options used to create the line system
  45337. * @param scene defines the hosting scene
  45338. * @returns a new line mesh
  45339. */
  45340. static CreateLines(name: string, options: {
  45341. points: Vector3[];
  45342. updatable?: boolean;
  45343. instance?: Nullable<LinesMesh>;
  45344. colors?: Color4[];
  45345. useVertexAlpha?: boolean;
  45346. }, scene?: Nullable<Scene>): LinesMesh;
  45347. /**
  45348. * Creates a dashed line mesh
  45349. * * 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
  45350. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45351. * * The parameter `points` is an array successive Vector3
  45352. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45353. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45354. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45355. * * 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
  45356. * * When updating an instance, remember that only point positions can change, not the number of points
  45357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45358. * @param name defines the name of the mesh
  45359. * @param options defines the options used to create the mesh
  45360. * @param scene defines the hosting scene
  45361. * @returns the dashed line mesh
  45362. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45363. */
  45364. static CreateDashedLines(name: string, options: {
  45365. points: Vector3[];
  45366. dashSize?: number;
  45367. gapSize?: number;
  45368. dashNb?: number;
  45369. updatable?: boolean;
  45370. instance?: LinesMesh;
  45371. }, scene?: Nullable<Scene>): LinesMesh;
  45372. }
  45373. }
  45374. declare module "babylonjs/Debug/rayHelper" {
  45375. import { Nullable } from "babylonjs/types";
  45376. import { Ray } from "babylonjs/Culling/ray";
  45377. import { Vector3 } from "babylonjs/Maths/math.vector";
  45378. import { Color3 } from "babylonjs/Maths/math.color";
  45379. import { Scene } from "babylonjs/scene";
  45380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45381. import "babylonjs/Meshes/Builders/linesBuilder";
  45382. /**
  45383. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45384. * in order to better appreciate the issue one might have.
  45385. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45386. */
  45387. export class RayHelper {
  45388. /**
  45389. * Defines the ray we are currently tryin to visualize.
  45390. */
  45391. ray: Nullable<Ray>;
  45392. private _renderPoints;
  45393. private _renderLine;
  45394. private _renderFunction;
  45395. private _scene;
  45396. private _updateToMeshFunction;
  45397. private _attachedToMesh;
  45398. private _meshSpaceDirection;
  45399. private _meshSpaceOrigin;
  45400. /**
  45401. * Helper function to create a colored helper in a scene in one line.
  45402. * @param ray Defines the ray we are currently tryin to visualize
  45403. * @param scene Defines the scene the ray is used in
  45404. * @param color Defines the color we want to see the ray in
  45405. * @returns The newly created ray helper.
  45406. */
  45407. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45408. /**
  45409. * Instantiate a new ray helper.
  45410. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45411. * in order to better appreciate the issue one might have.
  45412. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45413. * @param ray Defines the ray we are currently tryin to visualize
  45414. */
  45415. constructor(ray: Ray);
  45416. /**
  45417. * Shows the ray we are willing to debug.
  45418. * @param scene Defines the scene the ray needs to be rendered in
  45419. * @param color Defines the color the ray needs to be rendered in
  45420. */
  45421. show(scene: Scene, color?: Color3): void;
  45422. /**
  45423. * Hides the ray we are debugging.
  45424. */
  45425. hide(): void;
  45426. private _render;
  45427. /**
  45428. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45429. * @param mesh Defines the mesh we want the helper attached to
  45430. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45431. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45432. * @param length Defines the length of the ray
  45433. */
  45434. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45435. /**
  45436. * Detach the ray helper from the mesh it has previously been attached to.
  45437. */
  45438. detachFromMesh(): void;
  45439. private _updateToMesh;
  45440. /**
  45441. * Dispose the helper and release its associated resources.
  45442. */
  45443. dispose(): void;
  45444. }
  45445. }
  45446. declare module "babylonjs/Debug/skeletonViewer" {
  45447. import { Color3 } from "babylonjs/Maths/math.color";
  45448. import { Scene } from "babylonjs/scene";
  45449. import { Nullable } from "babylonjs/types";
  45450. import { Skeleton } from "babylonjs/Bones/skeleton";
  45451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45452. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45453. /**
  45454. * Class used to render a debug view of a given skeleton
  45455. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45456. */
  45457. export class SkeletonViewer {
  45458. /** defines the skeleton to render */
  45459. skeleton: Skeleton;
  45460. /** defines the mesh attached to the skeleton */
  45461. mesh: AbstractMesh;
  45462. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45463. autoUpdateBonesMatrices: boolean;
  45464. /** defines the rendering group id to use with the viewer */
  45465. renderingGroupId: number;
  45466. /** Gets or sets the color used to render the skeleton */
  45467. color: Color3;
  45468. private _scene;
  45469. private _debugLines;
  45470. private _debugMesh;
  45471. private _isEnabled;
  45472. private _renderFunction;
  45473. private _utilityLayer;
  45474. /**
  45475. * Returns the mesh used to render the bones
  45476. */
  45477. readonly debugMesh: Nullable<LinesMesh>;
  45478. /**
  45479. * Creates a new SkeletonViewer
  45480. * @param skeleton defines the skeleton to render
  45481. * @param mesh defines the mesh attached to the skeleton
  45482. * @param scene defines the hosting scene
  45483. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45484. * @param renderingGroupId defines the rendering group id to use with the viewer
  45485. */
  45486. constructor(
  45487. /** defines the skeleton to render */
  45488. skeleton: Skeleton,
  45489. /** defines the mesh attached to the skeleton */
  45490. mesh: AbstractMesh, scene: Scene,
  45491. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45492. autoUpdateBonesMatrices?: boolean,
  45493. /** defines the rendering group id to use with the viewer */
  45494. renderingGroupId?: number);
  45495. /** Gets or sets a boolean indicating if the viewer is enabled */
  45496. isEnabled: boolean;
  45497. private _getBonePosition;
  45498. private _getLinesForBonesWithLength;
  45499. private _getLinesForBonesNoLength;
  45500. /** Update the viewer to sync with current skeleton state */
  45501. update(): void;
  45502. /** Release associated resources */
  45503. dispose(): void;
  45504. }
  45505. }
  45506. declare module "babylonjs/Debug/index" {
  45507. export * from "babylonjs/Debug/axesViewer";
  45508. export * from "babylonjs/Debug/boneAxesViewer";
  45509. export * from "babylonjs/Debug/debugLayer";
  45510. export * from "babylonjs/Debug/physicsViewer";
  45511. export * from "babylonjs/Debug/rayHelper";
  45512. export * from "babylonjs/Debug/skeletonViewer";
  45513. }
  45514. declare module "babylonjs/Engines/nullEngine" {
  45515. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45516. import { Scene } from "babylonjs/scene";
  45517. import { Engine } from "babylonjs/Engines/engine";
  45518. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45519. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45520. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45521. import { Effect } from "babylonjs/Materials/effect";
  45522. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45523. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45524. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45525. /**
  45526. * Options to create the null engine
  45527. */
  45528. export class NullEngineOptions {
  45529. /**
  45530. * Render width (Default: 512)
  45531. */
  45532. renderWidth: number;
  45533. /**
  45534. * Render height (Default: 256)
  45535. */
  45536. renderHeight: number;
  45537. /**
  45538. * Texture size (Default: 512)
  45539. */
  45540. textureSize: number;
  45541. /**
  45542. * If delta time between frames should be constant
  45543. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45544. */
  45545. deterministicLockstep: boolean;
  45546. /**
  45547. * Maximum about of steps between frames (Default: 4)
  45548. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45549. */
  45550. lockstepMaxSteps: number;
  45551. }
  45552. /**
  45553. * The null engine class provides support for headless version of babylon.js.
  45554. * This can be used in server side scenario or for testing purposes
  45555. */
  45556. export class NullEngine extends Engine {
  45557. private _options;
  45558. /**
  45559. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45561. * @returns true if engine is in deterministic lock step mode
  45562. */
  45563. isDeterministicLockStep(): boolean;
  45564. /**
  45565. * Gets the max steps when engine is running in deterministic lock step
  45566. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45567. * @returns the max steps
  45568. */
  45569. getLockstepMaxSteps(): number;
  45570. /**
  45571. * Gets the current hardware scaling level.
  45572. * By default the hardware scaling level is computed from the window device ratio.
  45573. * 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.
  45574. * @returns a number indicating the current hardware scaling level
  45575. */
  45576. getHardwareScalingLevel(): number;
  45577. constructor(options?: NullEngineOptions);
  45578. /**
  45579. * Creates a vertex buffer
  45580. * @param vertices the data for the vertex buffer
  45581. * @returns the new WebGL static buffer
  45582. */
  45583. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45584. /**
  45585. * Creates a new index buffer
  45586. * @param indices defines the content of the index buffer
  45587. * @param updatable defines if the index buffer must be updatable
  45588. * @returns a new webGL buffer
  45589. */
  45590. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45591. /**
  45592. * Clear the current render buffer or the current render target (if any is set up)
  45593. * @param color defines the color to use
  45594. * @param backBuffer defines if the back buffer must be cleared
  45595. * @param depth defines if the depth buffer must be cleared
  45596. * @param stencil defines if the stencil buffer must be cleared
  45597. */
  45598. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45599. /**
  45600. * Gets the current render width
  45601. * @param useScreen defines if screen size must be used (or the current render target if any)
  45602. * @returns a number defining the current render width
  45603. */
  45604. getRenderWidth(useScreen?: boolean): number;
  45605. /**
  45606. * Gets the current render height
  45607. * @param useScreen defines if screen size must be used (or the current render target if any)
  45608. * @returns a number defining the current render height
  45609. */
  45610. getRenderHeight(useScreen?: boolean): number;
  45611. /**
  45612. * Set the WebGL's viewport
  45613. * @param viewport defines the viewport element to be used
  45614. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45615. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45616. */
  45617. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45618. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45619. /**
  45620. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45621. * @param pipelineContext defines the pipeline context to use
  45622. * @param uniformsNames defines the list of uniform names
  45623. * @returns an array of webGL uniform locations
  45624. */
  45625. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45626. /**
  45627. * Gets the lsit of active attributes for a given webGL program
  45628. * @param pipelineContext defines the pipeline context to use
  45629. * @param attributesNames defines the list of attribute names to get
  45630. * @returns an array of indices indicating the offset of each attribute
  45631. */
  45632. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45633. /**
  45634. * Binds an effect to the webGL context
  45635. * @param effect defines the effect to bind
  45636. */
  45637. bindSamplers(effect: Effect): void;
  45638. /**
  45639. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45640. * @param effect defines the effect to activate
  45641. */
  45642. enableEffect(effect: Effect): void;
  45643. /**
  45644. * Set various states to the webGL context
  45645. * @param culling defines backface culling state
  45646. * @param zOffset defines the value to apply to zOffset (0 by default)
  45647. * @param force defines if states must be applied even if cache is up to date
  45648. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45649. */
  45650. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45651. /**
  45652. * Set the value of an uniform to an array of int32
  45653. * @param uniform defines the webGL uniform location where to store the value
  45654. * @param array defines the array of int32 to store
  45655. */
  45656. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45657. /**
  45658. * Set the value of an uniform to an array of int32 (stored as vec2)
  45659. * @param uniform defines the webGL uniform location where to store the value
  45660. * @param array defines the array of int32 to store
  45661. */
  45662. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45663. /**
  45664. * Set the value of an uniform to an array of int32 (stored as vec3)
  45665. * @param uniform defines the webGL uniform location where to store the value
  45666. * @param array defines the array of int32 to store
  45667. */
  45668. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45669. /**
  45670. * Set the value of an uniform to an array of int32 (stored as vec4)
  45671. * @param uniform defines the webGL uniform location where to store the value
  45672. * @param array defines the array of int32 to store
  45673. */
  45674. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45675. /**
  45676. * Set the value of an uniform to an array of float32
  45677. * @param uniform defines the webGL uniform location where to store the value
  45678. * @param array defines the array of float32 to store
  45679. */
  45680. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45681. /**
  45682. * Set the value of an uniform to an array of float32 (stored as vec2)
  45683. * @param uniform defines the webGL uniform location where to store the value
  45684. * @param array defines the array of float32 to store
  45685. */
  45686. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45687. /**
  45688. * Set the value of an uniform to an array of float32 (stored as vec3)
  45689. * @param uniform defines the webGL uniform location where to store the value
  45690. * @param array defines the array of float32 to store
  45691. */
  45692. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45693. /**
  45694. * Set the value of an uniform to an array of float32 (stored as vec4)
  45695. * @param uniform defines the webGL uniform location where to store the value
  45696. * @param array defines the array of float32 to store
  45697. */
  45698. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45699. /**
  45700. * Set the value of an uniform to an array of number
  45701. * @param uniform defines the webGL uniform location where to store the value
  45702. * @param array defines the array of number to store
  45703. */
  45704. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45705. /**
  45706. * Set the value of an uniform to an array of number (stored as vec2)
  45707. * @param uniform defines the webGL uniform location where to store the value
  45708. * @param array defines the array of number to store
  45709. */
  45710. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45711. /**
  45712. * Set the value of an uniform to an array of number (stored as vec3)
  45713. * @param uniform defines the webGL uniform location where to store the value
  45714. * @param array defines the array of number to store
  45715. */
  45716. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45717. /**
  45718. * Set the value of an uniform to an array of number (stored as vec4)
  45719. * @param uniform defines the webGL uniform location where to store the value
  45720. * @param array defines the array of number to store
  45721. */
  45722. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45723. /**
  45724. * Set the value of an uniform to an array of float32 (stored as matrices)
  45725. * @param uniform defines the webGL uniform location where to store the value
  45726. * @param matrices defines the array of float32 to store
  45727. */
  45728. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45729. /**
  45730. * Set the value of an uniform to a matrix (3x3)
  45731. * @param uniform defines the webGL uniform location where to store the value
  45732. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45733. */
  45734. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45735. /**
  45736. * Set the value of an uniform to a matrix (2x2)
  45737. * @param uniform defines the webGL uniform location where to store the value
  45738. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45739. */
  45740. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45741. /**
  45742. * Set the value of an uniform to a number (float)
  45743. * @param uniform defines the webGL uniform location where to store the value
  45744. * @param value defines the float number to store
  45745. */
  45746. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45747. /**
  45748. * Set the value of an uniform to a vec2
  45749. * @param uniform defines the webGL uniform location where to store the value
  45750. * @param x defines the 1st component of the value
  45751. * @param y defines the 2nd component of the value
  45752. */
  45753. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45754. /**
  45755. * Set the value of an uniform to a vec3
  45756. * @param uniform defines the webGL uniform location where to store the value
  45757. * @param x defines the 1st component of the value
  45758. * @param y defines the 2nd component of the value
  45759. * @param z defines the 3rd component of the value
  45760. */
  45761. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45762. /**
  45763. * Set the value of an uniform to a boolean
  45764. * @param uniform defines the webGL uniform location where to store the value
  45765. * @param bool defines the boolean to store
  45766. */
  45767. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45768. /**
  45769. * Set the value of an uniform to a vec4
  45770. * @param uniform defines the webGL uniform location where to store the value
  45771. * @param x defines the 1st component of the value
  45772. * @param y defines the 2nd component of the value
  45773. * @param z defines the 3rd component of the value
  45774. * @param w defines the 4th component of the value
  45775. */
  45776. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45777. /**
  45778. * Sets the current alpha mode
  45779. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45780. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45781. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45782. */
  45783. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45784. /**
  45785. * Bind webGl buffers directly to the webGL context
  45786. * @param vertexBuffers defines the vertex buffer to bind
  45787. * @param indexBuffer defines the index buffer to bind
  45788. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45789. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45790. * @param effect defines the effect associated with the vertex buffer
  45791. */
  45792. bindBuffers(vertexBuffers: {
  45793. [key: string]: VertexBuffer;
  45794. }, indexBuffer: DataBuffer, effect: Effect): void;
  45795. /**
  45796. * Force the entire cache to be cleared
  45797. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45798. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45799. */
  45800. wipeCaches(bruteForce?: boolean): void;
  45801. /**
  45802. * Send a draw order
  45803. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45804. * @param indexStart defines the starting index
  45805. * @param indexCount defines the number of index to draw
  45806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45807. */
  45808. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45809. /**
  45810. * Draw a list of indexed primitives
  45811. * @param fillMode defines the primitive to use
  45812. * @param indexStart defines the starting index
  45813. * @param indexCount defines the number of index to draw
  45814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45815. */
  45816. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45817. /**
  45818. * Draw a list of unindexed primitives
  45819. * @param fillMode defines the primitive to use
  45820. * @param verticesStart defines the index of first vertex to draw
  45821. * @param verticesCount defines the count of vertices to draw
  45822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45823. */
  45824. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45825. /** @hidden */
  45826. _createTexture(): WebGLTexture;
  45827. /** @hidden */
  45828. _releaseTexture(texture: InternalTexture): void;
  45829. /**
  45830. * Usually called from Texture.ts.
  45831. * Passed information to create a WebGLTexture
  45832. * @param urlArg defines a value which contains one of the following:
  45833. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45834. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45835. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45837. * @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)
  45838. * @param scene needed for loading to the correct scene
  45839. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45840. * @param onLoad optional callback to be called upon successful completion
  45841. * @param onError optional callback to be called upon failure
  45842. * @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
  45843. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45844. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45845. * @param forcedExtension defines the extension to use to pick the right loader
  45846. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45847. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45848. */
  45849. 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;
  45850. /**
  45851. * Creates a new render target texture
  45852. * @param size defines the size of the texture
  45853. * @param options defines the options used to create the texture
  45854. * @returns a new render target texture stored in an InternalTexture
  45855. */
  45856. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45857. /**
  45858. * Update the sampling mode of a given texture
  45859. * @param samplingMode defines the required sampling mode
  45860. * @param texture defines the texture to update
  45861. */
  45862. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45863. /**
  45864. * Binds the frame buffer to the specified texture.
  45865. * @param texture The texture to render to or null for the default canvas
  45866. * @param faceIndex The face of the texture to render to in case of cube texture
  45867. * @param requiredWidth The width of the target to render to
  45868. * @param requiredHeight The height of the target to render to
  45869. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45870. * @param depthStencilTexture The depth stencil texture to use to render
  45871. * @param lodLevel defines le lod level to bind to the frame buffer
  45872. */
  45873. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45874. /**
  45875. * Unbind the current render target texture from the webGL context
  45876. * @param texture defines the render target texture to unbind
  45877. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45878. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45879. */
  45880. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45881. /**
  45882. * Creates a dynamic vertex buffer
  45883. * @param vertices the data for the dynamic vertex buffer
  45884. * @returns the new WebGL dynamic buffer
  45885. */
  45886. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45887. /**
  45888. * Update the content of a dynamic texture
  45889. * @param texture defines the texture to update
  45890. * @param canvas defines the canvas containing the source
  45891. * @param invertY defines if data must be stored with Y axis inverted
  45892. * @param premulAlpha defines if alpha is stored as premultiplied
  45893. * @param format defines the format of the data
  45894. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45895. */
  45896. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45897. /**
  45898. * Gets a boolean indicating if all created effects are ready
  45899. * @returns true if all effects are ready
  45900. */
  45901. areAllEffectsReady(): boolean;
  45902. /**
  45903. * @hidden
  45904. * Get the current error code of the webGL context
  45905. * @returns the error code
  45906. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45907. */
  45908. getError(): number;
  45909. /** @hidden */
  45910. _getUnpackAlignement(): number;
  45911. /** @hidden */
  45912. _unpackFlipY(value: boolean): void;
  45913. /**
  45914. * Update a dynamic index buffer
  45915. * @param indexBuffer defines the target index buffer
  45916. * @param indices defines the data to update
  45917. * @param offset defines the offset in the target index buffer where update should start
  45918. */
  45919. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45920. /**
  45921. * Updates a dynamic vertex buffer.
  45922. * @param vertexBuffer the vertex buffer to update
  45923. * @param vertices the data used to update the vertex buffer
  45924. * @param byteOffset the byte offset of the data (optional)
  45925. * @param byteLength the byte length of the data (optional)
  45926. */
  45927. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45928. /** @hidden */
  45929. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45930. /** @hidden */
  45931. _bindTexture(channel: number, texture: InternalTexture): void;
  45932. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45933. /**
  45934. * 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
  45935. */
  45936. releaseEffects(): void;
  45937. displayLoadingUI(): void;
  45938. hideLoadingUI(): void;
  45939. /** @hidden */
  45940. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45941. /** @hidden */
  45942. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45943. /** @hidden */
  45944. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45945. /** @hidden */
  45946. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45947. }
  45948. }
  45949. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45950. import { Nullable, int } from "babylonjs/types";
  45951. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45952. /** @hidden */
  45953. export class _OcclusionDataStorage {
  45954. /** @hidden */
  45955. occlusionInternalRetryCounter: number;
  45956. /** @hidden */
  45957. isOcclusionQueryInProgress: boolean;
  45958. /** @hidden */
  45959. isOccluded: boolean;
  45960. /** @hidden */
  45961. occlusionRetryCount: number;
  45962. /** @hidden */
  45963. occlusionType: number;
  45964. /** @hidden */
  45965. occlusionQueryAlgorithmType: number;
  45966. }
  45967. module "babylonjs/Engines/engine" {
  45968. interface Engine {
  45969. /**
  45970. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45971. * @return the new query
  45972. */
  45973. createQuery(): WebGLQuery;
  45974. /**
  45975. * Delete and release a webGL query
  45976. * @param query defines the query to delete
  45977. * @return the current engine
  45978. */
  45979. deleteQuery(query: WebGLQuery): Engine;
  45980. /**
  45981. * Check if a given query has resolved and got its value
  45982. * @param query defines the query to check
  45983. * @returns true if the query got its value
  45984. */
  45985. isQueryResultAvailable(query: WebGLQuery): boolean;
  45986. /**
  45987. * Gets the value of a given query
  45988. * @param query defines the query to check
  45989. * @returns the value of the query
  45990. */
  45991. getQueryResult(query: WebGLQuery): number;
  45992. /**
  45993. * Initiates an occlusion query
  45994. * @param algorithmType defines the algorithm to use
  45995. * @param query defines the query to use
  45996. * @returns the current engine
  45997. * @see http://doc.babylonjs.com/features/occlusionquery
  45998. */
  45999. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46000. /**
  46001. * Ends an occlusion query
  46002. * @see http://doc.babylonjs.com/features/occlusionquery
  46003. * @param algorithmType defines the algorithm to use
  46004. * @returns the current engine
  46005. */
  46006. endOcclusionQuery(algorithmType: number): Engine;
  46007. /**
  46008. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46009. * Please note that only one query can be issued at a time
  46010. * @returns a time token used to track the time span
  46011. */
  46012. startTimeQuery(): Nullable<_TimeToken>;
  46013. /**
  46014. * Ends a time query
  46015. * @param token defines the token used to measure the time span
  46016. * @returns the time spent (in ns)
  46017. */
  46018. endTimeQuery(token: _TimeToken): int;
  46019. /** @hidden */
  46020. _currentNonTimestampToken: Nullable<_TimeToken>;
  46021. /** @hidden */
  46022. _createTimeQuery(): WebGLQuery;
  46023. /** @hidden */
  46024. _deleteTimeQuery(query: WebGLQuery): void;
  46025. /** @hidden */
  46026. _getGlAlgorithmType(algorithmType: number): number;
  46027. /** @hidden */
  46028. _getTimeQueryResult(query: WebGLQuery): any;
  46029. /** @hidden */
  46030. _getTimeQueryAvailability(query: WebGLQuery): any;
  46031. }
  46032. }
  46033. module "babylonjs/Meshes/abstractMesh" {
  46034. interface AbstractMesh {
  46035. /**
  46036. * Backing filed
  46037. * @hidden
  46038. */
  46039. __occlusionDataStorage: _OcclusionDataStorage;
  46040. /**
  46041. * Access property
  46042. * @hidden
  46043. */
  46044. _occlusionDataStorage: _OcclusionDataStorage;
  46045. /**
  46046. * 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.
  46047. * The default value is -1 which means don't break the query and wait till the result
  46048. * @see http://doc.babylonjs.com/features/occlusionquery
  46049. */
  46050. occlusionRetryCount: number;
  46051. /**
  46052. * 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:
  46053. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46054. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46055. * * 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.
  46056. * @see http://doc.babylonjs.com/features/occlusionquery
  46057. */
  46058. occlusionType: number;
  46059. /**
  46060. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46061. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46062. * * 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.
  46063. * @see http://doc.babylonjs.com/features/occlusionquery
  46064. */
  46065. occlusionQueryAlgorithmType: number;
  46066. /**
  46067. * 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
  46068. * @see http://doc.babylonjs.com/features/occlusionquery
  46069. */
  46070. isOccluded: boolean;
  46071. /**
  46072. * Flag to check the progress status of the query
  46073. * @see http://doc.babylonjs.com/features/occlusionquery
  46074. */
  46075. isOcclusionQueryInProgress: boolean;
  46076. }
  46077. }
  46078. }
  46079. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46080. import { Nullable } from "babylonjs/types";
  46081. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46082. /** @hidden */
  46083. export var _forceTransformFeedbackToBundle: boolean;
  46084. module "babylonjs/Engines/engine" {
  46085. interface Engine {
  46086. /**
  46087. * Creates a webGL transform feedback object
  46088. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46089. * @returns the webGL transform feedback object
  46090. */
  46091. createTransformFeedback(): WebGLTransformFeedback;
  46092. /**
  46093. * Delete a webGL transform feedback object
  46094. * @param value defines the webGL transform feedback object to delete
  46095. */
  46096. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46097. /**
  46098. * Bind a webGL transform feedback object to the webgl context
  46099. * @param value defines the webGL transform feedback object to bind
  46100. */
  46101. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46102. /**
  46103. * Begins a transform feedback operation
  46104. * @param usePoints defines if points or triangles must be used
  46105. */
  46106. beginTransformFeedback(usePoints: boolean): void;
  46107. /**
  46108. * Ends a transform feedback operation
  46109. */
  46110. endTransformFeedback(): void;
  46111. /**
  46112. * Specify the varyings to use with transform feedback
  46113. * @param program defines the associated webGL program
  46114. * @param value defines the list of strings representing the varying names
  46115. */
  46116. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46117. /**
  46118. * Bind a webGL buffer for a transform feedback operation
  46119. * @param value defines the webGL buffer to bind
  46120. */
  46121. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46122. }
  46123. }
  46124. }
  46125. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46126. import { Scene } from "babylonjs/scene";
  46127. import { Engine } from "babylonjs/Engines/engine";
  46128. import { Texture } from "babylonjs/Materials/Textures/texture";
  46129. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46130. import "babylonjs/Engines/Extensions/engine.multiRender";
  46131. /**
  46132. * Creation options of the multi render target texture.
  46133. */
  46134. export interface IMultiRenderTargetOptions {
  46135. /**
  46136. * Define if the texture needs to create mip maps after render.
  46137. */
  46138. generateMipMaps?: boolean;
  46139. /**
  46140. * Define the types of all the draw buffers we want to create
  46141. */
  46142. types?: number[];
  46143. /**
  46144. * Define the sampling modes of all the draw buffers we want to create
  46145. */
  46146. samplingModes?: number[];
  46147. /**
  46148. * Define if a depth buffer is required
  46149. */
  46150. generateDepthBuffer?: boolean;
  46151. /**
  46152. * Define if a stencil buffer is required
  46153. */
  46154. generateStencilBuffer?: boolean;
  46155. /**
  46156. * Define if a depth texture is required instead of a depth buffer
  46157. */
  46158. generateDepthTexture?: boolean;
  46159. /**
  46160. * Define the number of desired draw buffers
  46161. */
  46162. textureCount?: number;
  46163. /**
  46164. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46165. */
  46166. doNotChangeAspectRatio?: boolean;
  46167. /**
  46168. * Define the default type of the buffers we are creating
  46169. */
  46170. defaultType?: number;
  46171. }
  46172. /**
  46173. * A multi render target, like a render target provides the ability to render to a texture.
  46174. * Unlike the render target, it can render to several draw buffers in one draw.
  46175. * This is specially interesting in deferred rendering or for any effects requiring more than
  46176. * just one color from a single pass.
  46177. */
  46178. export class MultiRenderTarget extends RenderTargetTexture {
  46179. private _internalTextures;
  46180. private _textures;
  46181. private _multiRenderTargetOptions;
  46182. /**
  46183. * Get if draw buffers are currently supported by the used hardware and browser.
  46184. */
  46185. readonly isSupported: boolean;
  46186. /**
  46187. * Get the list of textures generated by the multi render target.
  46188. */
  46189. readonly textures: Texture[];
  46190. /**
  46191. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46192. */
  46193. readonly depthTexture: Texture;
  46194. /**
  46195. * Set the wrapping mode on U of all the textures we are rendering to.
  46196. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46197. */
  46198. wrapU: number;
  46199. /**
  46200. * Set the wrapping mode on V of all the textures we are rendering to.
  46201. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46202. */
  46203. wrapV: number;
  46204. /**
  46205. * Instantiate a new multi render target texture.
  46206. * A multi render target, like a render target provides the ability to render to a texture.
  46207. * Unlike the render target, it can render to several draw buffers in one draw.
  46208. * This is specially interesting in deferred rendering or for any effects requiring more than
  46209. * just one color from a single pass.
  46210. * @param name Define the name of the texture
  46211. * @param size Define the size of the buffers to render to
  46212. * @param count Define the number of target we are rendering into
  46213. * @param scene Define the scene the texture belongs to
  46214. * @param options Define the options used to create the multi render target
  46215. */
  46216. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46217. /** @hidden */
  46218. _rebuild(): void;
  46219. private _createInternalTextures;
  46220. private _createTextures;
  46221. /**
  46222. * Define the number of samples used if MSAA is enabled.
  46223. */
  46224. samples: number;
  46225. /**
  46226. * Resize all the textures in the multi render target.
  46227. * Be carrefull as it will recreate all the data in the new texture.
  46228. * @param size Define the new size
  46229. */
  46230. resize(size: any): void;
  46231. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46232. /**
  46233. * Dispose the render targets and their associated resources
  46234. */
  46235. dispose(): void;
  46236. /**
  46237. * Release all the underlying texture used as draw buffers.
  46238. */
  46239. releaseInternalTextures(): void;
  46240. }
  46241. }
  46242. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46243. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46244. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46245. import { Nullable } from "babylonjs/types";
  46246. module "babylonjs/Engines/thinEngine" {
  46247. interface ThinEngine {
  46248. /**
  46249. * Unbind a list of render target textures from the webGL context
  46250. * This is used only when drawBuffer extension or webGL2 are active
  46251. * @param textures defines the render target textures to unbind
  46252. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46253. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46254. */
  46255. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46256. /**
  46257. * Create a multi render target texture
  46258. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46259. * @param size defines the size of the texture
  46260. * @param options defines the creation options
  46261. * @returns the cube texture as an InternalTexture
  46262. */
  46263. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46264. /**
  46265. * Update the sample count for a given multiple render target texture
  46266. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46267. * @param textures defines the textures to update
  46268. * @param samples defines the sample count to set
  46269. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46270. */
  46271. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46272. }
  46273. }
  46274. }
  46275. declare module "babylonjs/Engines/Extensions/index" {
  46276. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46277. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46278. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46279. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46280. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46281. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46282. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46283. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46284. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46285. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46286. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46287. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46288. }
  46289. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46290. import { Nullable } from "babylonjs/types";
  46291. /**
  46292. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46293. */
  46294. export interface CubeMapInfo {
  46295. /**
  46296. * The pixel array for the front face.
  46297. * This is stored in format, left to right, up to down format.
  46298. */
  46299. front: Nullable<ArrayBufferView>;
  46300. /**
  46301. * The pixel array for the back face.
  46302. * This is stored in format, left to right, up to down format.
  46303. */
  46304. back: Nullable<ArrayBufferView>;
  46305. /**
  46306. * The pixel array for the left face.
  46307. * This is stored in format, left to right, up to down format.
  46308. */
  46309. left: Nullable<ArrayBufferView>;
  46310. /**
  46311. * The pixel array for the right face.
  46312. * This is stored in format, left to right, up to down format.
  46313. */
  46314. right: Nullable<ArrayBufferView>;
  46315. /**
  46316. * The pixel array for the up face.
  46317. * This is stored in format, left to right, up to down format.
  46318. */
  46319. up: Nullable<ArrayBufferView>;
  46320. /**
  46321. * The pixel array for the down face.
  46322. * This is stored in format, left to right, up to down format.
  46323. */
  46324. down: Nullable<ArrayBufferView>;
  46325. /**
  46326. * The size of the cubemap stored.
  46327. *
  46328. * Each faces will be size * size pixels.
  46329. */
  46330. size: number;
  46331. /**
  46332. * The format of the texture.
  46333. *
  46334. * RGBA, RGB.
  46335. */
  46336. format: number;
  46337. /**
  46338. * The type of the texture data.
  46339. *
  46340. * UNSIGNED_INT, FLOAT.
  46341. */
  46342. type: number;
  46343. /**
  46344. * Specifies whether the texture is in gamma space.
  46345. */
  46346. gammaSpace: boolean;
  46347. }
  46348. /**
  46349. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46350. */
  46351. export class PanoramaToCubeMapTools {
  46352. private static FACE_FRONT;
  46353. private static FACE_BACK;
  46354. private static FACE_RIGHT;
  46355. private static FACE_LEFT;
  46356. private static FACE_DOWN;
  46357. private static FACE_UP;
  46358. /**
  46359. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46360. *
  46361. * @param float32Array The source data.
  46362. * @param inputWidth The width of the input panorama.
  46363. * @param inputHeight The height of the input panorama.
  46364. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46365. * @return The cubemap data
  46366. */
  46367. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46368. private static CreateCubemapTexture;
  46369. private static CalcProjectionSpherical;
  46370. }
  46371. }
  46372. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46373. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46375. import { Nullable } from "babylonjs/types";
  46376. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46377. /**
  46378. * Helper class dealing with the extraction of spherical polynomial dataArray
  46379. * from a cube map.
  46380. */
  46381. export class CubeMapToSphericalPolynomialTools {
  46382. private static FileFaces;
  46383. /**
  46384. * Converts a texture to the according Spherical Polynomial data.
  46385. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46386. *
  46387. * @param texture The texture to extract the information from.
  46388. * @return The Spherical Polynomial data.
  46389. */
  46390. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46391. /**
  46392. * Converts a cubemap to the according Spherical Polynomial data.
  46393. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46394. *
  46395. * @param cubeInfo The Cube map to extract the information from.
  46396. * @return The Spherical Polynomial data.
  46397. */
  46398. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46399. }
  46400. }
  46401. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46402. import { Nullable } from "babylonjs/types";
  46403. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46404. module "babylonjs/Materials/Textures/baseTexture" {
  46405. interface BaseTexture {
  46406. /**
  46407. * Get the polynomial representation of the texture data.
  46408. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46409. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46410. */
  46411. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46412. }
  46413. }
  46414. }
  46415. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46416. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46417. /** @hidden */
  46418. export var rgbdEncodePixelShader: {
  46419. name: string;
  46420. shader: string;
  46421. };
  46422. }
  46423. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46424. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46425. /** @hidden */
  46426. export var rgbdDecodePixelShader: {
  46427. name: string;
  46428. shader: string;
  46429. };
  46430. }
  46431. declare module "babylonjs/Misc/environmentTextureTools" {
  46432. import { Nullable } from "babylonjs/types";
  46433. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46434. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46435. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46436. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46437. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46438. import "babylonjs/Shaders/rgbdEncode.fragment";
  46439. import "babylonjs/Shaders/rgbdDecode.fragment";
  46440. /**
  46441. * Raw texture data and descriptor sufficient for WebGL texture upload
  46442. */
  46443. export interface EnvironmentTextureInfo {
  46444. /**
  46445. * Version of the environment map
  46446. */
  46447. version: number;
  46448. /**
  46449. * Width of image
  46450. */
  46451. width: number;
  46452. /**
  46453. * Irradiance information stored in the file.
  46454. */
  46455. irradiance: any;
  46456. /**
  46457. * Specular information stored in the file.
  46458. */
  46459. specular: any;
  46460. }
  46461. /**
  46462. * Defines One Image in the file. It requires only the position in the file
  46463. * as well as the length.
  46464. */
  46465. interface BufferImageData {
  46466. /**
  46467. * Length of the image data.
  46468. */
  46469. length: number;
  46470. /**
  46471. * Position of the data from the null terminator delimiting the end of the JSON.
  46472. */
  46473. position: number;
  46474. }
  46475. /**
  46476. * Defines the specular data enclosed in the file.
  46477. * This corresponds to the version 1 of the data.
  46478. */
  46479. export interface EnvironmentTextureSpecularInfoV1 {
  46480. /**
  46481. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46482. */
  46483. specularDataPosition?: number;
  46484. /**
  46485. * This contains all the images data needed to reconstruct the cubemap.
  46486. */
  46487. mipmaps: Array<BufferImageData>;
  46488. /**
  46489. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46490. */
  46491. lodGenerationScale: number;
  46492. }
  46493. /**
  46494. * Sets of helpers addressing the serialization and deserialization of environment texture
  46495. * stored in a BabylonJS env file.
  46496. * Those files are usually stored as .env files.
  46497. */
  46498. export class EnvironmentTextureTools {
  46499. /**
  46500. * Magic number identifying the env file.
  46501. */
  46502. private static _MagicBytes;
  46503. /**
  46504. * Gets the environment info from an env file.
  46505. * @param data The array buffer containing the .env bytes.
  46506. * @returns the environment file info (the json header) if successfully parsed.
  46507. */
  46508. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46509. /**
  46510. * Creates an environment texture from a loaded cube texture.
  46511. * @param texture defines the cube texture to convert in env file
  46512. * @return a promise containing the environment data if succesfull.
  46513. */
  46514. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46515. /**
  46516. * Creates a JSON representation of the spherical data.
  46517. * @param texture defines the texture containing the polynomials
  46518. * @return the JSON representation of the spherical info
  46519. */
  46520. private static _CreateEnvTextureIrradiance;
  46521. /**
  46522. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46523. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46524. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46525. * @return the views described by info providing access to the underlying buffer
  46526. */
  46527. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46528. /**
  46529. * Uploads the texture info contained in the env file to the GPU.
  46530. * @param texture defines the internal texture to upload to
  46531. * @param arrayBuffer defines the buffer cotaining the data to load
  46532. * @param info defines the texture info retrieved through the GetEnvInfo method
  46533. * @returns a promise
  46534. */
  46535. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46536. private static _OnImageReadyAsync;
  46537. /**
  46538. * Uploads the levels of image data to the GPU.
  46539. * @param texture defines the internal texture to upload to
  46540. * @param imageData defines the array buffer views of image data [mipmap][face]
  46541. * @returns a promise
  46542. */
  46543. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46544. /**
  46545. * Uploads spherical polynomials information to the texture.
  46546. * @param texture defines the texture we are trying to upload the information to
  46547. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46548. */
  46549. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46550. /** @hidden */
  46551. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46552. }
  46553. }
  46554. declare module "babylonjs/Maths/math.vertexFormat" {
  46555. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46556. /**
  46557. * Contains position and normal vectors for a vertex
  46558. */
  46559. export class PositionNormalVertex {
  46560. /** the position of the vertex (defaut: 0,0,0) */
  46561. position: Vector3;
  46562. /** the normal of the vertex (defaut: 0,1,0) */
  46563. normal: Vector3;
  46564. /**
  46565. * Creates a PositionNormalVertex
  46566. * @param position the position of the vertex (defaut: 0,0,0)
  46567. * @param normal the normal of the vertex (defaut: 0,1,0)
  46568. */
  46569. constructor(
  46570. /** the position of the vertex (defaut: 0,0,0) */
  46571. position?: Vector3,
  46572. /** the normal of the vertex (defaut: 0,1,0) */
  46573. normal?: Vector3);
  46574. /**
  46575. * Clones the PositionNormalVertex
  46576. * @returns the cloned PositionNormalVertex
  46577. */
  46578. clone(): PositionNormalVertex;
  46579. }
  46580. /**
  46581. * Contains position, normal and uv vectors for a vertex
  46582. */
  46583. export class PositionNormalTextureVertex {
  46584. /** the position of the vertex (defaut: 0,0,0) */
  46585. position: Vector3;
  46586. /** the normal of the vertex (defaut: 0,1,0) */
  46587. normal: Vector3;
  46588. /** the uv of the vertex (default: 0,0) */
  46589. uv: Vector2;
  46590. /**
  46591. * Creates a PositionNormalTextureVertex
  46592. * @param position the position of the vertex (defaut: 0,0,0)
  46593. * @param normal the normal of the vertex (defaut: 0,1,0)
  46594. * @param uv the uv of the vertex (default: 0,0)
  46595. */
  46596. constructor(
  46597. /** the position of the vertex (defaut: 0,0,0) */
  46598. position?: Vector3,
  46599. /** the normal of the vertex (defaut: 0,1,0) */
  46600. normal?: Vector3,
  46601. /** the uv of the vertex (default: 0,0) */
  46602. uv?: Vector2);
  46603. /**
  46604. * Clones the PositionNormalTextureVertex
  46605. * @returns the cloned PositionNormalTextureVertex
  46606. */
  46607. clone(): PositionNormalTextureVertex;
  46608. }
  46609. }
  46610. declare module "babylonjs/Maths/math" {
  46611. export * from "babylonjs/Maths/math.axis";
  46612. export * from "babylonjs/Maths/math.color";
  46613. export * from "babylonjs/Maths/math.constants";
  46614. export * from "babylonjs/Maths/math.frustum";
  46615. export * from "babylonjs/Maths/math.path";
  46616. export * from "babylonjs/Maths/math.plane";
  46617. export * from "babylonjs/Maths/math.size";
  46618. export * from "babylonjs/Maths/math.vector";
  46619. export * from "babylonjs/Maths/math.vertexFormat";
  46620. export * from "babylonjs/Maths/math.viewport";
  46621. }
  46622. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46623. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46624. /** @hidden */
  46625. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46626. private _genericAttributeLocation;
  46627. private _varyingLocationCount;
  46628. private _varyingLocationMap;
  46629. private _replacements;
  46630. private _textureCount;
  46631. private _uniforms;
  46632. lineProcessor(line: string): string;
  46633. attributeProcessor(attribute: string): string;
  46634. varyingProcessor(varying: string, isFragment: boolean): string;
  46635. uniformProcessor(uniform: string): string;
  46636. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46637. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46638. }
  46639. }
  46640. declare module "babylonjs/Engines/nativeEngine" {
  46641. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46642. import { Engine } from "babylonjs/Engines/engine";
  46643. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46644. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46646. import { Effect } from "babylonjs/Materials/effect";
  46647. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46648. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46649. import { Scene } from "babylonjs/scene";
  46650. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46651. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46652. /**
  46653. * Container for accessors for natively-stored mesh data buffers.
  46654. */
  46655. class NativeDataBuffer extends DataBuffer {
  46656. /**
  46657. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46658. */
  46659. nativeIndexBuffer?: any;
  46660. /**
  46661. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46662. */
  46663. nativeVertexBuffer?: any;
  46664. }
  46665. /** @hidden */
  46666. class NativeTexture extends InternalTexture {
  46667. getInternalTexture(): InternalTexture;
  46668. getViewCount(): number;
  46669. }
  46670. /** @hidden */
  46671. export class NativeEngine extends Engine {
  46672. private readonly _native;
  46673. getHardwareScalingLevel(): number;
  46674. constructor();
  46675. /**
  46676. * Can be used to override the current requestAnimationFrame requester.
  46677. * @hidden
  46678. */
  46679. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  46680. /**
  46681. * Override default engine behavior.
  46682. * @param color
  46683. * @param backBuffer
  46684. * @param depth
  46685. * @param stencil
  46686. */
  46687. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  46688. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46689. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46690. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46691. recordVertexArrayObject(vertexBuffers: {
  46692. [key: string]: VertexBuffer;
  46693. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46694. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46695. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46696. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46697. /**
  46698. * Draw a list of indexed primitives
  46699. * @param fillMode defines the primitive to use
  46700. * @param indexStart defines the starting index
  46701. * @param indexCount defines the number of index to draw
  46702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46703. */
  46704. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46705. /**
  46706. * Draw a list of unindexed primitives
  46707. * @param fillMode defines the primitive to use
  46708. * @param verticesStart defines the index of first vertex to draw
  46709. * @param verticesCount defines the count of vertices to draw
  46710. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46711. */
  46712. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46713. createPipelineContext(): IPipelineContext;
  46714. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46715. /** @hidden */
  46716. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46717. /** @hidden */
  46718. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46719. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46720. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46721. protected _setProgram(program: WebGLProgram): void;
  46722. _releaseEffect(effect: Effect): void;
  46723. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46724. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46725. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46726. bindSamplers(effect: Effect): void;
  46727. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46728. getRenderWidth(useScreen?: boolean): number;
  46729. getRenderHeight(useScreen?: boolean): number;
  46730. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46731. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46732. /**
  46733. * Set the z offset to apply to current rendering
  46734. * @param value defines the offset to apply
  46735. */
  46736. setZOffset(value: number): void;
  46737. /**
  46738. * Gets the current value of the zOffset
  46739. * @returns the current zOffset state
  46740. */
  46741. getZOffset(): number;
  46742. /**
  46743. * Enable or disable depth buffering
  46744. * @param enable defines the state to set
  46745. */
  46746. setDepthBuffer(enable: boolean): void;
  46747. /**
  46748. * Gets a boolean indicating if depth writing is enabled
  46749. * @returns the current depth writing state
  46750. */
  46751. getDepthWrite(): boolean;
  46752. /**
  46753. * Enable or disable depth writing
  46754. * @param enable defines the state to set
  46755. */
  46756. setDepthWrite(enable: boolean): void;
  46757. /**
  46758. * Enable or disable color writing
  46759. * @param enable defines the state to set
  46760. */
  46761. setColorWrite(enable: boolean): void;
  46762. /**
  46763. * Gets a boolean indicating if color writing is enabled
  46764. * @returns the current color writing state
  46765. */
  46766. getColorWrite(): boolean;
  46767. /**
  46768. * Sets alpha constants used by some alpha blending modes
  46769. * @param r defines the red component
  46770. * @param g defines the green component
  46771. * @param b defines the blue component
  46772. * @param a defines the alpha component
  46773. */
  46774. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46775. /**
  46776. * Sets the current alpha mode
  46777. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46778. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46779. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46780. */
  46781. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46782. /**
  46783. * Gets the current alpha mode
  46784. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46785. * @returns the current alpha mode
  46786. */
  46787. getAlphaMode(): number;
  46788. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46789. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46790. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46791. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46792. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46793. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46794. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46795. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46796. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46797. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46798. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46799. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46800. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46801. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46802. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46803. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46804. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46805. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46806. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46807. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46808. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46809. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46810. wipeCaches(bruteForce?: boolean): void;
  46811. _createTexture(): WebGLTexture;
  46812. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46813. /**
  46814. * Usually called from BABYLON.Texture.ts.
  46815. * Passed information to create a WebGLTexture
  46816. * @param urlArg defines a value which contains one of the following:
  46817. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46818. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46819. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46820. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46821. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46822. * @param scene needed for loading to the correct scene
  46823. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46824. * @param onLoad optional callback to be called upon successful completion
  46825. * @param onError optional callback to be called upon failure
  46826. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46827. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46828. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46829. * @param forcedExtension defines the extension to use to pick the right loader
  46830. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46831. */
  46832. 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;
  46833. /**
  46834. * Creates a cube texture
  46835. * @param rootUrl defines the url where the files to load is located
  46836. * @param scene defines the current scene
  46837. * @param files defines the list of files to load (1 per face)
  46838. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46839. * @param onLoad defines an optional callback raised when the texture is loaded
  46840. * @param onError defines an optional callback raised if there is an issue to load the texture
  46841. * @param format defines the format of the data
  46842. * @param forcedExtension defines the extension to use to pick the right loader
  46843. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46844. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46845. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46846. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46847. * @returns the cube texture as an InternalTexture
  46848. */
  46849. 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;
  46850. private _getSamplingFilter;
  46851. private static _GetNativeTextureFormat;
  46852. createRenderTargetTexture(size: number | {
  46853. width: number;
  46854. height: number;
  46855. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  46856. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46857. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46858. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46859. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46860. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46861. /**
  46862. * Updates a dynamic vertex buffer.
  46863. * @param vertexBuffer the vertex buffer to update
  46864. * @param data the data used to update the vertex buffer
  46865. * @param byteOffset the byte offset of the data (optional)
  46866. * @param byteLength the byte length of the data (optional)
  46867. */
  46868. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46869. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46870. private _updateAnisotropicLevel;
  46871. private _getAddressMode;
  46872. /** @hidden */
  46873. _bindTexture(channel: number, texture: InternalTexture): void;
  46874. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46875. releaseEffects(): void;
  46876. /** @hidden */
  46877. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46878. /** @hidden */
  46879. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46880. /** @hidden */
  46881. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46882. /** @hidden */
  46883. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46884. }
  46885. }
  46886. declare module "babylonjs/Engines/index" {
  46887. export * from "babylonjs/Engines/constants";
  46888. export * from "babylonjs/Engines/engineCapabilities";
  46889. export * from "babylonjs/Engines/instancingAttributeInfo";
  46890. export * from "babylonjs/Engines/thinEngine";
  46891. export * from "babylonjs/Engines/engine";
  46892. export * from "babylonjs/Engines/engineStore";
  46893. export * from "babylonjs/Engines/nullEngine";
  46894. export * from "babylonjs/Engines/Extensions/index";
  46895. export * from "babylonjs/Engines/IPipelineContext";
  46896. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46897. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46898. export * from "babylonjs/Engines/nativeEngine";
  46899. }
  46900. declare module "babylonjs/Events/clipboardEvents" {
  46901. /**
  46902. * Gather the list of clipboard event types as constants.
  46903. */
  46904. export class ClipboardEventTypes {
  46905. /**
  46906. * The clipboard event is fired when a copy command is active (pressed).
  46907. */
  46908. static readonly COPY: number;
  46909. /**
  46910. * The clipboard event is fired when a cut command is active (pressed).
  46911. */
  46912. static readonly CUT: number;
  46913. /**
  46914. * The clipboard event is fired when a paste command is active (pressed).
  46915. */
  46916. static readonly PASTE: number;
  46917. }
  46918. /**
  46919. * This class is used to store clipboard related info for the onClipboardObservable event.
  46920. */
  46921. export class ClipboardInfo {
  46922. /**
  46923. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46924. */
  46925. type: number;
  46926. /**
  46927. * Defines the related dom event
  46928. */
  46929. event: ClipboardEvent;
  46930. /**
  46931. *Creates an instance of ClipboardInfo.
  46932. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46933. * @param event Defines the related dom event
  46934. */
  46935. constructor(
  46936. /**
  46937. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46938. */
  46939. type: number,
  46940. /**
  46941. * Defines the related dom event
  46942. */
  46943. event: ClipboardEvent);
  46944. /**
  46945. * Get the clipboard event's type from the keycode.
  46946. * @param keyCode Defines the keyCode for the current keyboard event.
  46947. * @return {number}
  46948. */
  46949. static GetTypeFromCharacter(keyCode: number): number;
  46950. }
  46951. }
  46952. declare module "babylonjs/Events/index" {
  46953. export * from "babylonjs/Events/keyboardEvents";
  46954. export * from "babylonjs/Events/pointerEvents";
  46955. export * from "babylonjs/Events/clipboardEvents";
  46956. }
  46957. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46958. import { Scene } from "babylonjs/scene";
  46959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46960. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46961. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46962. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46963. /**
  46964. * Google Daydream controller
  46965. */
  46966. export class DaydreamController extends WebVRController {
  46967. /**
  46968. * Base Url for the controller model.
  46969. */
  46970. static MODEL_BASE_URL: string;
  46971. /**
  46972. * File name for the controller model.
  46973. */
  46974. static MODEL_FILENAME: string;
  46975. /**
  46976. * Gamepad Id prefix used to identify Daydream Controller.
  46977. */
  46978. static readonly GAMEPAD_ID_PREFIX: string;
  46979. /**
  46980. * Creates a new DaydreamController from a gamepad
  46981. * @param vrGamepad the gamepad that the controller should be created from
  46982. */
  46983. constructor(vrGamepad: any);
  46984. /**
  46985. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46986. * @param scene scene in which to add meshes
  46987. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46988. */
  46989. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46990. /**
  46991. * Called once for each button that changed state since the last frame
  46992. * @param buttonIdx Which button index changed
  46993. * @param state New state of the button
  46994. * @param changes Which properties on the state changed since last frame
  46995. */
  46996. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46997. }
  46998. }
  46999. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47000. import { Scene } from "babylonjs/scene";
  47001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47002. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47003. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47004. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47005. /**
  47006. * Gear VR Controller
  47007. */
  47008. export class GearVRController extends WebVRController {
  47009. /**
  47010. * Base Url for the controller model.
  47011. */
  47012. static MODEL_BASE_URL: string;
  47013. /**
  47014. * File name for the controller model.
  47015. */
  47016. static MODEL_FILENAME: string;
  47017. /**
  47018. * Gamepad Id prefix used to identify this controller.
  47019. */
  47020. static readonly GAMEPAD_ID_PREFIX: string;
  47021. private readonly _buttonIndexToObservableNameMap;
  47022. /**
  47023. * Creates a new GearVRController from a gamepad
  47024. * @param vrGamepad the gamepad that the controller should be created from
  47025. */
  47026. constructor(vrGamepad: any);
  47027. /**
  47028. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47029. * @param scene scene in which to add meshes
  47030. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47031. */
  47032. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47033. /**
  47034. * Called once for each button that changed state since the last frame
  47035. * @param buttonIdx Which button index changed
  47036. * @param state New state of the button
  47037. * @param changes Which properties on the state changed since last frame
  47038. */
  47039. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47040. }
  47041. }
  47042. declare module "babylonjs/Gamepads/Controllers/index" {
  47043. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47044. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47045. export * from "babylonjs/Gamepads/Controllers/genericController";
  47046. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47047. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47048. export * from "babylonjs/Gamepads/Controllers/viveController";
  47049. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47050. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47051. }
  47052. declare module "babylonjs/Gamepads/index" {
  47053. export * from "babylonjs/Gamepads/Controllers/index";
  47054. export * from "babylonjs/Gamepads/gamepad";
  47055. export * from "babylonjs/Gamepads/gamepadManager";
  47056. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47057. export * from "babylonjs/Gamepads/xboxGamepad";
  47058. export * from "babylonjs/Gamepads/dualShockGamepad";
  47059. }
  47060. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47061. import { Scene } from "babylonjs/scene";
  47062. import { Vector4 } from "babylonjs/Maths/math.vector";
  47063. import { Color4 } from "babylonjs/Maths/math.color";
  47064. import { Mesh } from "babylonjs/Meshes/mesh";
  47065. import { Nullable } from "babylonjs/types";
  47066. /**
  47067. * Class containing static functions to help procedurally build meshes
  47068. */
  47069. export class PolyhedronBuilder {
  47070. /**
  47071. * Creates a polyhedron mesh
  47072. * * 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
  47073. * * The parameter `size` (positive float, default 1) sets the polygon size
  47074. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47075. * * 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`
  47076. * * 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
  47077. * * 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)`)
  47078. * * 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
  47079. * * 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
  47080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47083. * @param name defines the name of the mesh
  47084. * @param options defines the options used to create the mesh
  47085. * @param scene defines the hosting scene
  47086. * @returns the polyhedron mesh
  47087. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47088. */
  47089. static CreatePolyhedron(name: string, options: {
  47090. type?: number;
  47091. size?: number;
  47092. sizeX?: number;
  47093. sizeY?: number;
  47094. sizeZ?: number;
  47095. custom?: any;
  47096. faceUV?: Vector4[];
  47097. faceColors?: Color4[];
  47098. flat?: boolean;
  47099. updatable?: boolean;
  47100. sideOrientation?: number;
  47101. frontUVs?: Vector4;
  47102. backUVs?: Vector4;
  47103. }, scene?: Nullable<Scene>): Mesh;
  47104. }
  47105. }
  47106. declare module "babylonjs/Gizmos/scaleGizmo" {
  47107. import { Observable } from "babylonjs/Misc/observable";
  47108. import { Nullable } from "babylonjs/types";
  47109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47110. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47111. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47112. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47113. /**
  47114. * Gizmo that enables scaling a mesh along 3 axis
  47115. */
  47116. export class ScaleGizmo extends Gizmo {
  47117. /**
  47118. * Internal gizmo used for interactions on the x axis
  47119. */
  47120. xGizmo: AxisScaleGizmo;
  47121. /**
  47122. * Internal gizmo used for interactions on the y axis
  47123. */
  47124. yGizmo: AxisScaleGizmo;
  47125. /**
  47126. * Internal gizmo used for interactions on the z axis
  47127. */
  47128. zGizmo: AxisScaleGizmo;
  47129. /**
  47130. * Internal gizmo used to scale all axis equally
  47131. */
  47132. uniformScaleGizmo: AxisScaleGizmo;
  47133. private _meshAttached;
  47134. private _updateGizmoRotationToMatchAttachedMesh;
  47135. private _snapDistance;
  47136. private _scaleRatio;
  47137. private _uniformScalingMesh;
  47138. private _octahedron;
  47139. /** Fires an event when any of it's sub gizmos are dragged */
  47140. onDragStartObservable: Observable<unknown>;
  47141. /** Fires an event when any of it's sub gizmos are released from dragging */
  47142. onDragEndObservable: Observable<unknown>;
  47143. attachedMesh: Nullable<AbstractMesh>;
  47144. /**
  47145. * Creates a ScaleGizmo
  47146. * @param gizmoLayer The utility layer the gizmo will be added to
  47147. */
  47148. constructor(gizmoLayer?: UtilityLayerRenderer);
  47149. updateGizmoRotationToMatchAttachedMesh: boolean;
  47150. /**
  47151. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47152. */
  47153. snapDistance: number;
  47154. /**
  47155. * Ratio for the scale of the gizmo (Default: 1)
  47156. */
  47157. scaleRatio: number;
  47158. /**
  47159. * Disposes of the gizmo
  47160. */
  47161. dispose(): void;
  47162. }
  47163. }
  47164. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47165. import { Observable } from "babylonjs/Misc/observable";
  47166. import { Nullable } from "babylonjs/types";
  47167. import { Vector3 } from "babylonjs/Maths/math.vector";
  47168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47169. import { Mesh } from "babylonjs/Meshes/mesh";
  47170. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47171. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47172. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47173. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47174. import { Color3 } from "babylonjs/Maths/math.color";
  47175. /**
  47176. * Single axis scale gizmo
  47177. */
  47178. export class AxisScaleGizmo extends Gizmo {
  47179. /**
  47180. * Drag behavior responsible for the gizmos dragging interactions
  47181. */
  47182. dragBehavior: PointerDragBehavior;
  47183. private _pointerObserver;
  47184. /**
  47185. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47186. */
  47187. snapDistance: number;
  47188. /**
  47189. * Event that fires each time the gizmo snaps to a new location.
  47190. * * snapDistance is the the change in distance
  47191. */
  47192. onSnapObservable: Observable<{
  47193. snapDistance: number;
  47194. }>;
  47195. /**
  47196. * If the scaling operation should be done on all axis (default: false)
  47197. */
  47198. uniformScaling: boolean;
  47199. private _isEnabled;
  47200. private _parent;
  47201. private _arrow;
  47202. private _coloredMaterial;
  47203. private _hoverMaterial;
  47204. /**
  47205. * Creates an AxisScaleGizmo
  47206. * @param gizmoLayer The utility layer the gizmo will be added to
  47207. * @param dragAxis The axis which the gizmo will be able to scale on
  47208. * @param color The color of the gizmo
  47209. */
  47210. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47211. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47212. /**
  47213. * If the gizmo is enabled
  47214. */
  47215. isEnabled: boolean;
  47216. /**
  47217. * Disposes of the gizmo
  47218. */
  47219. dispose(): void;
  47220. /**
  47221. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47222. * @param mesh The mesh to replace the default mesh of the gizmo
  47223. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47224. */
  47225. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47226. }
  47227. }
  47228. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47229. import { Observable } from "babylonjs/Misc/observable";
  47230. import { Nullable } from "babylonjs/types";
  47231. import { Vector3 } from "babylonjs/Maths/math.vector";
  47232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47233. import { Mesh } from "babylonjs/Meshes/mesh";
  47234. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47235. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47236. import { Color3 } from "babylonjs/Maths/math.color";
  47237. import "babylonjs/Meshes/Builders/boxBuilder";
  47238. /**
  47239. * Bounding box gizmo
  47240. */
  47241. export class BoundingBoxGizmo extends Gizmo {
  47242. private _lineBoundingBox;
  47243. private _rotateSpheresParent;
  47244. private _scaleBoxesParent;
  47245. private _boundingDimensions;
  47246. private _renderObserver;
  47247. private _pointerObserver;
  47248. private _scaleDragSpeed;
  47249. private _tmpQuaternion;
  47250. private _tmpVector;
  47251. private _tmpRotationMatrix;
  47252. /**
  47253. * 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)
  47254. */
  47255. ignoreChildren: boolean;
  47256. /**
  47257. * 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)
  47258. */
  47259. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47260. /**
  47261. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47262. */
  47263. rotationSphereSize: number;
  47264. /**
  47265. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47266. */
  47267. scaleBoxSize: number;
  47268. /**
  47269. * 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)
  47270. */
  47271. fixedDragMeshScreenSize: boolean;
  47272. /**
  47273. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47274. */
  47275. fixedDragMeshScreenSizeDistanceFactor: number;
  47276. /**
  47277. * Fired when a rotation sphere or scale box is dragged
  47278. */
  47279. onDragStartObservable: Observable<{}>;
  47280. /**
  47281. * Fired when a scale box is dragged
  47282. */
  47283. onScaleBoxDragObservable: Observable<{}>;
  47284. /**
  47285. * Fired when a scale box drag is ended
  47286. */
  47287. onScaleBoxDragEndObservable: Observable<{}>;
  47288. /**
  47289. * Fired when a rotation sphere is dragged
  47290. */
  47291. onRotationSphereDragObservable: Observable<{}>;
  47292. /**
  47293. * Fired when a rotation sphere drag is ended
  47294. */
  47295. onRotationSphereDragEndObservable: Observable<{}>;
  47296. /**
  47297. * 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)
  47298. */
  47299. scalePivot: Nullable<Vector3>;
  47300. /**
  47301. * Mesh used as a pivot to rotate the attached mesh
  47302. */
  47303. private _anchorMesh;
  47304. private _existingMeshScale;
  47305. private _dragMesh;
  47306. private pointerDragBehavior;
  47307. private coloredMaterial;
  47308. private hoverColoredMaterial;
  47309. /**
  47310. * Sets the color of the bounding box gizmo
  47311. * @param color the color to set
  47312. */
  47313. setColor(color: Color3): void;
  47314. /**
  47315. * Creates an BoundingBoxGizmo
  47316. * @param gizmoLayer The utility layer the gizmo will be added to
  47317. * @param color The color of the gizmo
  47318. */
  47319. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47320. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47321. private _selectNode;
  47322. /**
  47323. * Updates the bounding box information for the Gizmo
  47324. */
  47325. updateBoundingBox(): void;
  47326. private _updateRotationSpheres;
  47327. private _updateScaleBoxes;
  47328. /**
  47329. * Enables rotation on the specified axis and disables rotation on the others
  47330. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47331. */
  47332. setEnabledRotationAxis(axis: string): void;
  47333. /**
  47334. * Enables/disables scaling
  47335. * @param enable if scaling should be enabled
  47336. */
  47337. setEnabledScaling(enable: boolean): void;
  47338. private _updateDummy;
  47339. /**
  47340. * Enables a pointer drag behavior on the bounding box of the gizmo
  47341. */
  47342. enableDragBehavior(): void;
  47343. /**
  47344. * Disposes of the gizmo
  47345. */
  47346. dispose(): void;
  47347. /**
  47348. * 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)
  47349. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47350. * @returns the bounding box mesh with the passed in mesh as a child
  47351. */
  47352. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47353. /**
  47354. * CustomMeshes are not supported by this gizmo
  47355. * @param mesh The mesh to replace the default mesh of the gizmo
  47356. */
  47357. setCustomMesh(mesh: Mesh): void;
  47358. }
  47359. }
  47360. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47361. import { Observable } from "babylonjs/Misc/observable";
  47362. import { Nullable } from "babylonjs/types";
  47363. import { Vector3 } from "babylonjs/Maths/math.vector";
  47364. import { Color3 } from "babylonjs/Maths/math.color";
  47365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47366. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47367. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47368. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47369. import "babylonjs/Meshes/Builders/linesBuilder";
  47370. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47371. /**
  47372. * Single plane rotation gizmo
  47373. */
  47374. export class PlaneRotationGizmo extends Gizmo {
  47375. /**
  47376. * Drag behavior responsible for the gizmos dragging interactions
  47377. */
  47378. dragBehavior: PointerDragBehavior;
  47379. private _pointerObserver;
  47380. /**
  47381. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47382. */
  47383. snapDistance: number;
  47384. /**
  47385. * Event that fires each time the gizmo snaps to a new location.
  47386. * * snapDistance is the the change in distance
  47387. */
  47388. onSnapObservable: Observable<{
  47389. snapDistance: number;
  47390. }>;
  47391. private _isEnabled;
  47392. private _parent;
  47393. /**
  47394. * Creates a PlaneRotationGizmo
  47395. * @param gizmoLayer The utility layer the gizmo will be added to
  47396. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47397. * @param color The color of the gizmo
  47398. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47399. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47400. */
  47401. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47402. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47403. /**
  47404. * If the gizmo is enabled
  47405. */
  47406. isEnabled: boolean;
  47407. /**
  47408. * Disposes of the gizmo
  47409. */
  47410. dispose(): void;
  47411. }
  47412. }
  47413. declare module "babylonjs/Gizmos/rotationGizmo" {
  47414. import { Observable } from "babylonjs/Misc/observable";
  47415. import { Nullable } from "babylonjs/types";
  47416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47417. import { Mesh } from "babylonjs/Meshes/mesh";
  47418. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47419. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47420. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47421. /**
  47422. * Gizmo that enables rotating a mesh along 3 axis
  47423. */
  47424. export class RotationGizmo extends Gizmo {
  47425. /**
  47426. * Internal gizmo used for interactions on the x axis
  47427. */
  47428. xGizmo: PlaneRotationGizmo;
  47429. /**
  47430. * Internal gizmo used for interactions on the y axis
  47431. */
  47432. yGizmo: PlaneRotationGizmo;
  47433. /**
  47434. * Internal gizmo used for interactions on the z axis
  47435. */
  47436. zGizmo: PlaneRotationGizmo;
  47437. /** Fires an event when any of it's sub gizmos are dragged */
  47438. onDragStartObservable: Observable<unknown>;
  47439. /** Fires an event when any of it's sub gizmos are released from dragging */
  47440. onDragEndObservable: Observable<unknown>;
  47441. private _meshAttached;
  47442. attachedMesh: Nullable<AbstractMesh>;
  47443. /**
  47444. * Creates a RotationGizmo
  47445. * @param gizmoLayer The utility layer the gizmo will be added to
  47446. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47447. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47448. */
  47449. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47450. updateGizmoRotationToMatchAttachedMesh: boolean;
  47451. /**
  47452. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47453. */
  47454. snapDistance: number;
  47455. /**
  47456. * Ratio for the scale of the gizmo (Default: 1)
  47457. */
  47458. scaleRatio: number;
  47459. /**
  47460. * Disposes of the gizmo
  47461. */
  47462. dispose(): void;
  47463. /**
  47464. * CustomMeshes are not supported by this gizmo
  47465. * @param mesh The mesh to replace the default mesh of the gizmo
  47466. */
  47467. setCustomMesh(mesh: Mesh): void;
  47468. }
  47469. }
  47470. declare module "babylonjs/Gizmos/gizmoManager" {
  47471. import { Observable } from "babylonjs/Misc/observable";
  47472. import { Nullable } from "babylonjs/types";
  47473. import { Scene, IDisposable } from "babylonjs/scene";
  47474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47475. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47476. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47477. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47478. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47479. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47480. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47481. /**
  47482. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47483. */
  47484. export class GizmoManager implements IDisposable {
  47485. private scene;
  47486. /**
  47487. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47488. */
  47489. gizmos: {
  47490. positionGizmo: Nullable<PositionGizmo>;
  47491. rotationGizmo: Nullable<RotationGizmo>;
  47492. scaleGizmo: Nullable<ScaleGizmo>;
  47493. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47494. };
  47495. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47496. clearGizmoOnEmptyPointerEvent: boolean;
  47497. /** Fires an event when the manager is attached to a mesh */
  47498. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47499. private _gizmosEnabled;
  47500. private _pointerObserver;
  47501. private _attachedMesh;
  47502. private _boundingBoxColor;
  47503. private _defaultUtilityLayer;
  47504. private _defaultKeepDepthUtilityLayer;
  47505. /**
  47506. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47507. */
  47508. boundingBoxDragBehavior: SixDofDragBehavior;
  47509. /**
  47510. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47511. */
  47512. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47513. /**
  47514. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47515. */
  47516. usePointerToAttachGizmos: boolean;
  47517. /**
  47518. * Utility layer that the bounding box gizmo belongs to
  47519. */
  47520. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47521. /**
  47522. * Utility layer that all gizmos besides bounding box belong to
  47523. */
  47524. readonly utilityLayer: UtilityLayerRenderer;
  47525. /**
  47526. * Instatiates a gizmo manager
  47527. * @param scene the scene to overlay the gizmos on top of
  47528. */
  47529. constructor(scene: Scene);
  47530. /**
  47531. * Attaches a set of gizmos to the specified mesh
  47532. * @param mesh The mesh the gizmo's should be attached to
  47533. */
  47534. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47535. /**
  47536. * If the position gizmo is enabled
  47537. */
  47538. positionGizmoEnabled: boolean;
  47539. /**
  47540. * If the rotation gizmo is enabled
  47541. */
  47542. rotationGizmoEnabled: boolean;
  47543. /**
  47544. * If the scale gizmo is enabled
  47545. */
  47546. scaleGizmoEnabled: boolean;
  47547. /**
  47548. * If the boundingBox gizmo is enabled
  47549. */
  47550. boundingBoxGizmoEnabled: boolean;
  47551. /**
  47552. * Disposes of the gizmo manager
  47553. */
  47554. dispose(): void;
  47555. }
  47556. }
  47557. declare module "babylonjs/Lights/directionalLight" {
  47558. import { Camera } from "babylonjs/Cameras/camera";
  47559. import { Scene } from "babylonjs/scene";
  47560. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47562. import { Light } from "babylonjs/Lights/light";
  47563. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47564. import { Effect } from "babylonjs/Materials/effect";
  47565. /**
  47566. * A directional light is defined by a direction (what a surprise!).
  47567. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47568. * 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.
  47569. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47570. */
  47571. export class DirectionalLight extends ShadowLight {
  47572. private _shadowFrustumSize;
  47573. /**
  47574. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47575. */
  47576. /**
  47577. * Specifies a fix frustum size for the shadow generation.
  47578. */
  47579. shadowFrustumSize: number;
  47580. private _shadowOrthoScale;
  47581. /**
  47582. * Gets the shadow projection scale against the optimal computed one.
  47583. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47584. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47585. */
  47586. /**
  47587. * Sets the shadow projection scale against the optimal computed one.
  47588. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47589. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47590. */
  47591. shadowOrthoScale: number;
  47592. /**
  47593. * Automatically compute the projection matrix to best fit (including all the casters)
  47594. * on each frame.
  47595. */
  47596. autoUpdateExtends: boolean;
  47597. private _orthoLeft;
  47598. private _orthoRight;
  47599. private _orthoTop;
  47600. private _orthoBottom;
  47601. /**
  47602. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47603. * The directional light is emitted from everywhere in the given direction.
  47604. * It can cast shadows.
  47605. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47606. * @param name The friendly name of the light
  47607. * @param direction The direction of the light
  47608. * @param scene The scene the light belongs to
  47609. */
  47610. constructor(name: string, direction: Vector3, scene: Scene);
  47611. /**
  47612. * Returns the string "DirectionalLight".
  47613. * @return The class name
  47614. */
  47615. getClassName(): string;
  47616. /**
  47617. * Returns the integer 1.
  47618. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47619. */
  47620. getTypeID(): number;
  47621. /**
  47622. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47623. * Returns the DirectionalLight Shadow projection matrix.
  47624. */
  47625. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47626. /**
  47627. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47628. * Returns the DirectionalLight Shadow projection matrix.
  47629. */
  47630. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47631. /**
  47632. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47633. * Returns the DirectionalLight Shadow projection matrix.
  47634. */
  47635. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47636. protected _buildUniformLayout(): void;
  47637. /**
  47638. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47639. * @param effect The effect to update
  47640. * @param lightIndex The index of the light in the effect to update
  47641. * @returns The directional light
  47642. */
  47643. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47644. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47645. /**
  47646. * Gets the minZ used for shadow according to both the scene and the light.
  47647. *
  47648. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47649. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47650. * @param activeCamera The camera we are returning the min for
  47651. * @returns the depth min z
  47652. */
  47653. getDepthMinZ(activeCamera: Camera): number;
  47654. /**
  47655. * Gets the maxZ used for shadow according to both the scene and the light.
  47656. *
  47657. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47658. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47659. * @param activeCamera The camera we are returning the max for
  47660. * @returns the depth max z
  47661. */
  47662. getDepthMaxZ(activeCamera: Camera): number;
  47663. /**
  47664. * Prepares the list of defines specific to the light type.
  47665. * @param defines the list of defines
  47666. * @param lightIndex defines the index of the light for the effect
  47667. */
  47668. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47669. }
  47670. }
  47671. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47672. import { Mesh } from "babylonjs/Meshes/mesh";
  47673. /**
  47674. * Class containing static functions to help procedurally build meshes
  47675. */
  47676. export class HemisphereBuilder {
  47677. /**
  47678. * Creates a hemisphere mesh
  47679. * @param name defines the name of the mesh
  47680. * @param options defines the options used to create the mesh
  47681. * @param scene defines the hosting scene
  47682. * @returns the hemisphere mesh
  47683. */
  47684. static CreateHemisphere(name: string, options: {
  47685. segments?: number;
  47686. diameter?: number;
  47687. sideOrientation?: number;
  47688. }, scene: any): Mesh;
  47689. }
  47690. }
  47691. declare module "babylonjs/Lights/spotLight" {
  47692. import { Nullable } from "babylonjs/types";
  47693. import { Scene } from "babylonjs/scene";
  47694. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47696. import { Effect } from "babylonjs/Materials/effect";
  47697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47698. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47699. /**
  47700. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47701. * These values define a cone of light starting from the position, emitting toward the direction.
  47702. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47703. * and the exponent defines the speed of the decay of the light with distance (reach).
  47704. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47705. */
  47706. export class SpotLight extends ShadowLight {
  47707. private _angle;
  47708. private _innerAngle;
  47709. private _cosHalfAngle;
  47710. private _lightAngleScale;
  47711. private _lightAngleOffset;
  47712. /**
  47713. * Gets the cone angle of the spot light in Radians.
  47714. */
  47715. /**
  47716. * Sets the cone angle of the spot light in Radians.
  47717. */
  47718. angle: number;
  47719. /**
  47720. * Only used in gltf falloff mode, this defines the angle where
  47721. * the directional falloff will start before cutting at angle which could be seen
  47722. * as outer angle.
  47723. */
  47724. /**
  47725. * Only used in gltf falloff mode, this defines the angle where
  47726. * the directional falloff will start before cutting at angle which could be seen
  47727. * as outer angle.
  47728. */
  47729. innerAngle: number;
  47730. private _shadowAngleScale;
  47731. /**
  47732. * Allows scaling the angle of the light for shadow generation only.
  47733. */
  47734. /**
  47735. * Allows scaling the angle of the light for shadow generation only.
  47736. */
  47737. shadowAngleScale: number;
  47738. /**
  47739. * The light decay speed with the distance from the emission spot.
  47740. */
  47741. exponent: number;
  47742. private _projectionTextureMatrix;
  47743. /**
  47744. * Allows reading the projecton texture
  47745. */
  47746. readonly projectionTextureMatrix: Matrix;
  47747. protected _projectionTextureLightNear: number;
  47748. /**
  47749. * Gets the near clip of the Spotlight for texture projection.
  47750. */
  47751. /**
  47752. * Sets the near clip of the Spotlight for texture projection.
  47753. */
  47754. projectionTextureLightNear: number;
  47755. protected _projectionTextureLightFar: number;
  47756. /**
  47757. * Gets the far clip of the Spotlight for texture projection.
  47758. */
  47759. /**
  47760. * Sets the far clip of the Spotlight for texture projection.
  47761. */
  47762. projectionTextureLightFar: number;
  47763. protected _projectionTextureUpDirection: Vector3;
  47764. /**
  47765. * Gets the Up vector of the Spotlight for texture projection.
  47766. */
  47767. /**
  47768. * Sets the Up vector of the Spotlight for texture projection.
  47769. */
  47770. projectionTextureUpDirection: Vector3;
  47771. private _projectionTexture;
  47772. /**
  47773. * Gets the projection texture of the light.
  47774. */
  47775. /**
  47776. * Sets the projection texture of the light.
  47777. */
  47778. projectionTexture: Nullable<BaseTexture>;
  47779. private _projectionTextureViewLightDirty;
  47780. private _projectionTextureProjectionLightDirty;
  47781. private _projectionTextureDirty;
  47782. private _projectionTextureViewTargetVector;
  47783. private _projectionTextureViewLightMatrix;
  47784. private _projectionTextureProjectionLightMatrix;
  47785. private _projectionTextureScalingMatrix;
  47786. /**
  47787. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47788. * It can cast shadows.
  47789. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47790. * @param name The light friendly name
  47791. * @param position The position of the spot light in the scene
  47792. * @param direction The direction of the light in the scene
  47793. * @param angle The cone angle of the light in Radians
  47794. * @param exponent The light decay speed with the distance from the emission spot
  47795. * @param scene The scene the lights belongs to
  47796. */
  47797. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47798. /**
  47799. * Returns the string "SpotLight".
  47800. * @returns the class name
  47801. */
  47802. getClassName(): string;
  47803. /**
  47804. * Returns the integer 2.
  47805. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47806. */
  47807. getTypeID(): number;
  47808. /**
  47809. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47810. */
  47811. protected _setDirection(value: Vector3): void;
  47812. /**
  47813. * Overrides the position setter to recompute the projection texture view light Matrix.
  47814. */
  47815. protected _setPosition(value: Vector3): void;
  47816. /**
  47817. * 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.
  47818. * Returns the SpotLight.
  47819. */
  47820. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47821. protected _computeProjectionTextureViewLightMatrix(): void;
  47822. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47823. /**
  47824. * Main function for light texture projection matrix computing.
  47825. */
  47826. protected _computeProjectionTextureMatrix(): void;
  47827. protected _buildUniformLayout(): void;
  47828. private _computeAngleValues;
  47829. /**
  47830. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47831. * @param effect The effect to update
  47832. * @param lightIndex The index of the light in the effect to update
  47833. * @returns The spot light
  47834. */
  47835. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47836. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47837. /**
  47838. * Disposes the light and the associated resources.
  47839. */
  47840. dispose(): void;
  47841. /**
  47842. * Prepares the list of defines specific to the light type.
  47843. * @param defines the list of defines
  47844. * @param lightIndex defines the index of the light for the effect
  47845. */
  47846. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47847. }
  47848. }
  47849. declare module "babylonjs/Gizmos/lightGizmo" {
  47850. import { Nullable } from "babylonjs/types";
  47851. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47852. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47853. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47854. import { Light } from "babylonjs/Lights/light";
  47855. /**
  47856. * Gizmo that enables viewing a light
  47857. */
  47858. export class LightGizmo extends Gizmo {
  47859. private _lightMesh;
  47860. private _material;
  47861. private cachedPosition;
  47862. private cachedForward;
  47863. /**
  47864. * Creates a LightGizmo
  47865. * @param gizmoLayer The utility layer the gizmo will be added to
  47866. */
  47867. constructor(gizmoLayer?: UtilityLayerRenderer);
  47868. private _light;
  47869. /**
  47870. * The light that the gizmo is attached to
  47871. */
  47872. light: Nullable<Light>;
  47873. /**
  47874. * Gets the material used to render the light gizmo
  47875. */
  47876. readonly material: StandardMaterial;
  47877. /**
  47878. * @hidden
  47879. * Updates the gizmo to match the attached mesh's position/rotation
  47880. */
  47881. protected _update(): void;
  47882. private static _Scale;
  47883. /**
  47884. * Creates the lines for a light mesh
  47885. */
  47886. private static _createLightLines;
  47887. /**
  47888. * Disposes of the light gizmo
  47889. */
  47890. dispose(): void;
  47891. private static _CreateHemisphericLightMesh;
  47892. private static _CreatePointLightMesh;
  47893. private static _CreateSpotLightMesh;
  47894. private static _CreateDirectionalLightMesh;
  47895. }
  47896. }
  47897. declare module "babylonjs/Gizmos/index" {
  47898. export * from "babylonjs/Gizmos/axisDragGizmo";
  47899. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47900. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47901. export * from "babylonjs/Gizmos/gizmo";
  47902. export * from "babylonjs/Gizmos/gizmoManager";
  47903. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47904. export * from "babylonjs/Gizmos/positionGizmo";
  47905. export * from "babylonjs/Gizmos/rotationGizmo";
  47906. export * from "babylonjs/Gizmos/scaleGizmo";
  47907. export * from "babylonjs/Gizmos/lightGizmo";
  47908. export * from "babylonjs/Gizmos/planeDragGizmo";
  47909. }
  47910. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47911. /** @hidden */
  47912. export var backgroundFragmentDeclaration: {
  47913. name: string;
  47914. shader: string;
  47915. };
  47916. }
  47917. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47918. /** @hidden */
  47919. export var backgroundUboDeclaration: {
  47920. name: string;
  47921. shader: string;
  47922. };
  47923. }
  47924. declare module "babylonjs/Shaders/background.fragment" {
  47925. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47926. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47927. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47928. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47929. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47930. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47931. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47932. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47933. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47934. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47935. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47936. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47937. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47938. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47939. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47940. /** @hidden */
  47941. export var backgroundPixelShader: {
  47942. name: string;
  47943. shader: string;
  47944. };
  47945. }
  47946. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47947. /** @hidden */
  47948. export var backgroundVertexDeclaration: {
  47949. name: string;
  47950. shader: string;
  47951. };
  47952. }
  47953. declare module "babylonjs/Shaders/background.vertex" {
  47954. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47955. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47956. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47957. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47958. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47959. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47960. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47961. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47962. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47963. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47964. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47965. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47966. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47967. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47968. /** @hidden */
  47969. export var backgroundVertexShader: {
  47970. name: string;
  47971. shader: string;
  47972. };
  47973. }
  47974. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47975. import { Nullable, int, float } from "babylonjs/types";
  47976. import { Scene } from "babylonjs/scene";
  47977. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47978. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47980. import { Mesh } from "babylonjs/Meshes/mesh";
  47981. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47982. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47983. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47985. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47986. import { Color3 } from "babylonjs/Maths/math.color";
  47987. import "babylonjs/Shaders/background.fragment";
  47988. import "babylonjs/Shaders/background.vertex";
  47989. /**
  47990. * Background material used to create an efficient environement around your scene.
  47991. */
  47992. export class BackgroundMaterial extends PushMaterial {
  47993. /**
  47994. * Standard reflectance value at parallel view angle.
  47995. */
  47996. static StandardReflectance0: number;
  47997. /**
  47998. * Standard reflectance value at grazing angle.
  47999. */
  48000. static StandardReflectance90: number;
  48001. protected _primaryColor: Color3;
  48002. /**
  48003. * Key light Color (multiply against the environement texture)
  48004. */
  48005. primaryColor: Color3;
  48006. protected __perceptualColor: Nullable<Color3>;
  48007. /**
  48008. * Experimental Internal Use Only.
  48009. *
  48010. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48011. * This acts as a helper to set the primary color to a more "human friendly" value.
  48012. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48013. * output color as close as possible from the chosen value.
  48014. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48015. * part of lighting setup.)
  48016. */
  48017. _perceptualColor: Nullable<Color3>;
  48018. protected _primaryColorShadowLevel: float;
  48019. /**
  48020. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48021. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48022. */
  48023. primaryColorShadowLevel: float;
  48024. protected _primaryColorHighlightLevel: float;
  48025. /**
  48026. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48027. * The primary color is used at the level chosen to define what the white area would look.
  48028. */
  48029. primaryColorHighlightLevel: float;
  48030. protected _reflectionTexture: Nullable<BaseTexture>;
  48031. /**
  48032. * Reflection Texture used in the material.
  48033. * Should be author in a specific way for the best result (refer to the documentation).
  48034. */
  48035. reflectionTexture: Nullable<BaseTexture>;
  48036. protected _reflectionBlur: float;
  48037. /**
  48038. * Reflection Texture level of blur.
  48039. *
  48040. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48041. * texture twice.
  48042. */
  48043. reflectionBlur: float;
  48044. protected _diffuseTexture: Nullable<BaseTexture>;
  48045. /**
  48046. * Diffuse Texture used in the material.
  48047. * Should be author in a specific way for the best result (refer to the documentation).
  48048. */
  48049. diffuseTexture: Nullable<BaseTexture>;
  48050. protected _shadowLights: Nullable<IShadowLight[]>;
  48051. /**
  48052. * Specify the list of lights casting shadow on the material.
  48053. * All scene shadow lights will be included if null.
  48054. */
  48055. shadowLights: Nullable<IShadowLight[]>;
  48056. protected _shadowLevel: float;
  48057. /**
  48058. * Helps adjusting the shadow to a softer level if required.
  48059. * 0 means black shadows and 1 means no shadows.
  48060. */
  48061. shadowLevel: float;
  48062. protected _sceneCenter: Vector3;
  48063. /**
  48064. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48065. * It is usually zero but might be interesting to modify according to your setup.
  48066. */
  48067. sceneCenter: Vector3;
  48068. protected _opacityFresnel: boolean;
  48069. /**
  48070. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48071. * This helps ensuring a nice transition when the camera goes under the ground.
  48072. */
  48073. opacityFresnel: boolean;
  48074. protected _reflectionFresnel: boolean;
  48075. /**
  48076. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48077. * This helps adding a mirror texture on the ground.
  48078. */
  48079. reflectionFresnel: boolean;
  48080. protected _reflectionFalloffDistance: number;
  48081. /**
  48082. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48083. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48084. */
  48085. reflectionFalloffDistance: number;
  48086. protected _reflectionAmount: number;
  48087. /**
  48088. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48089. */
  48090. reflectionAmount: number;
  48091. protected _reflectionReflectance0: number;
  48092. /**
  48093. * This specifies the weight of the reflection at grazing angle.
  48094. */
  48095. reflectionReflectance0: number;
  48096. protected _reflectionReflectance90: number;
  48097. /**
  48098. * This specifies the weight of the reflection at a perpendicular point of view.
  48099. */
  48100. reflectionReflectance90: number;
  48101. /**
  48102. * Sets the reflection reflectance fresnel values according to the default standard
  48103. * empirically know to work well :-)
  48104. */
  48105. reflectionStandardFresnelWeight: number;
  48106. protected _useRGBColor: boolean;
  48107. /**
  48108. * Helps to directly use the maps channels instead of their level.
  48109. */
  48110. useRGBColor: boolean;
  48111. protected _enableNoise: boolean;
  48112. /**
  48113. * This helps reducing the banding effect that could occur on the background.
  48114. */
  48115. enableNoise: boolean;
  48116. /**
  48117. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48118. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48119. * Recommended to be keep at 1.0 except for special cases.
  48120. */
  48121. fovMultiplier: number;
  48122. private _fovMultiplier;
  48123. /**
  48124. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48125. */
  48126. useEquirectangularFOV: boolean;
  48127. private _maxSimultaneousLights;
  48128. /**
  48129. * Number of Simultaneous lights allowed on the material.
  48130. */
  48131. maxSimultaneousLights: int;
  48132. /**
  48133. * Default configuration related to image processing available in the Background Material.
  48134. */
  48135. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48136. /**
  48137. * Keep track of the image processing observer to allow dispose and replace.
  48138. */
  48139. private _imageProcessingObserver;
  48140. /**
  48141. * Attaches a new image processing configuration to the PBR Material.
  48142. * @param configuration (if null the scene configuration will be use)
  48143. */
  48144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48145. /**
  48146. * Gets the image processing configuration used either in this material.
  48147. */
  48148. /**
  48149. * Sets the Default image processing configuration used either in the this material.
  48150. *
  48151. * If sets to null, the scene one is in use.
  48152. */
  48153. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48154. /**
  48155. * Gets wether the color curves effect is enabled.
  48156. */
  48157. /**
  48158. * Sets wether the color curves effect is enabled.
  48159. */
  48160. cameraColorCurvesEnabled: boolean;
  48161. /**
  48162. * Gets wether the color grading effect is enabled.
  48163. */
  48164. /**
  48165. * Gets wether the color grading effect is enabled.
  48166. */
  48167. cameraColorGradingEnabled: boolean;
  48168. /**
  48169. * Gets wether tonemapping is enabled or not.
  48170. */
  48171. /**
  48172. * Sets wether tonemapping is enabled or not
  48173. */
  48174. cameraToneMappingEnabled: boolean;
  48175. /**
  48176. * The camera exposure used on this material.
  48177. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48178. * This corresponds to a photographic exposure.
  48179. */
  48180. /**
  48181. * The camera exposure used on this material.
  48182. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48183. * This corresponds to a photographic exposure.
  48184. */
  48185. cameraExposure: float;
  48186. /**
  48187. * Gets The camera contrast used on this material.
  48188. */
  48189. /**
  48190. * Sets The camera contrast used on this material.
  48191. */
  48192. cameraContrast: float;
  48193. /**
  48194. * Gets the Color Grading 2D Lookup Texture.
  48195. */
  48196. /**
  48197. * Sets the Color Grading 2D Lookup Texture.
  48198. */
  48199. cameraColorGradingTexture: Nullable<BaseTexture>;
  48200. /**
  48201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48203. * 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;
  48204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48205. */
  48206. /**
  48207. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48208. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48209. * 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;
  48210. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48211. */
  48212. cameraColorCurves: Nullable<ColorCurves>;
  48213. /**
  48214. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48215. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48216. */
  48217. switchToBGR: boolean;
  48218. private _renderTargets;
  48219. private _reflectionControls;
  48220. private _white;
  48221. private _primaryShadowColor;
  48222. private _primaryHighlightColor;
  48223. /**
  48224. * Instantiates a Background Material in the given scene
  48225. * @param name The friendly name of the material
  48226. * @param scene The scene to add the material to
  48227. */
  48228. constructor(name: string, scene: Scene);
  48229. /**
  48230. * Gets a boolean indicating that current material needs to register RTT
  48231. */
  48232. readonly hasRenderTargetTextures: boolean;
  48233. /**
  48234. * The entire material has been created in order to prevent overdraw.
  48235. * @returns false
  48236. */
  48237. needAlphaTesting(): boolean;
  48238. /**
  48239. * The entire material has been created in order to prevent overdraw.
  48240. * @returns true if blending is enable
  48241. */
  48242. needAlphaBlending(): boolean;
  48243. /**
  48244. * Checks wether the material is ready to be rendered for a given mesh.
  48245. * @param mesh The mesh to render
  48246. * @param subMesh The submesh to check against
  48247. * @param useInstances Specify wether or not the material is used with instances
  48248. * @returns true if all the dependencies are ready (Textures, Effects...)
  48249. */
  48250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48251. /**
  48252. * Compute the primary color according to the chosen perceptual color.
  48253. */
  48254. private _computePrimaryColorFromPerceptualColor;
  48255. /**
  48256. * Compute the highlights and shadow colors according to their chosen levels.
  48257. */
  48258. private _computePrimaryColors;
  48259. /**
  48260. * Build the uniform buffer used in the material.
  48261. */
  48262. buildUniformLayout(): void;
  48263. /**
  48264. * Unbind the material.
  48265. */
  48266. unbind(): void;
  48267. /**
  48268. * Bind only the world matrix to the material.
  48269. * @param world The world matrix to bind.
  48270. */
  48271. bindOnlyWorldMatrix(world: Matrix): void;
  48272. /**
  48273. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48274. * @param world The world matrix to bind.
  48275. * @param subMesh The submesh to bind for.
  48276. */
  48277. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48278. /**
  48279. * Checks to see if a texture is used in the material.
  48280. * @param texture - Base texture to use.
  48281. * @returns - Boolean specifying if a texture is used in the material.
  48282. */
  48283. hasTexture(texture: BaseTexture): boolean;
  48284. /**
  48285. * Dispose the material.
  48286. * @param forceDisposeEffect Force disposal of the associated effect.
  48287. * @param forceDisposeTextures Force disposal of the associated textures.
  48288. */
  48289. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48290. /**
  48291. * Clones the material.
  48292. * @param name The cloned name.
  48293. * @returns The cloned material.
  48294. */
  48295. clone(name: string): BackgroundMaterial;
  48296. /**
  48297. * Serializes the current material to its JSON representation.
  48298. * @returns The JSON representation.
  48299. */
  48300. serialize(): any;
  48301. /**
  48302. * Gets the class name of the material
  48303. * @returns "BackgroundMaterial"
  48304. */
  48305. getClassName(): string;
  48306. /**
  48307. * Parse a JSON input to create back a background material.
  48308. * @param source The JSON data to parse
  48309. * @param scene The scene to create the parsed material in
  48310. * @param rootUrl The root url of the assets the material depends upon
  48311. * @returns the instantiated BackgroundMaterial.
  48312. */
  48313. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48314. }
  48315. }
  48316. declare module "babylonjs/Helpers/environmentHelper" {
  48317. import { Observable } from "babylonjs/Misc/observable";
  48318. import { Nullable } from "babylonjs/types";
  48319. import { Scene } from "babylonjs/scene";
  48320. import { Vector3 } from "babylonjs/Maths/math.vector";
  48321. import { Color3 } from "babylonjs/Maths/math.color";
  48322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48323. import { Mesh } from "babylonjs/Meshes/mesh";
  48324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48325. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48326. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48327. import "babylonjs/Meshes/Builders/planeBuilder";
  48328. import "babylonjs/Meshes/Builders/boxBuilder";
  48329. /**
  48330. * Represents the different options available during the creation of
  48331. * a Environment helper.
  48332. *
  48333. * This can control the default ground, skybox and image processing setup of your scene.
  48334. */
  48335. export interface IEnvironmentHelperOptions {
  48336. /**
  48337. * Specifies wether or not to create a ground.
  48338. * True by default.
  48339. */
  48340. createGround: boolean;
  48341. /**
  48342. * Specifies the ground size.
  48343. * 15 by default.
  48344. */
  48345. groundSize: number;
  48346. /**
  48347. * The texture used on the ground for the main color.
  48348. * Comes from the BabylonJS CDN by default.
  48349. *
  48350. * Remarks: Can be either a texture or a url.
  48351. */
  48352. groundTexture: string | BaseTexture;
  48353. /**
  48354. * The color mixed in the ground texture by default.
  48355. * BabylonJS clearColor by default.
  48356. */
  48357. groundColor: Color3;
  48358. /**
  48359. * Specifies the ground opacity.
  48360. * 1 by default.
  48361. */
  48362. groundOpacity: number;
  48363. /**
  48364. * Enables the ground to receive shadows.
  48365. * True by default.
  48366. */
  48367. enableGroundShadow: boolean;
  48368. /**
  48369. * Helps preventing the shadow to be fully black on the ground.
  48370. * 0.5 by default.
  48371. */
  48372. groundShadowLevel: number;
  48373. /**
  48374. * Creates a mirror texture attach to the ground.
  48375. * false by default.
  48376. */
  48377. enableGroundMirror: boolean;
  48378. /**
  48379. * Specifies the ground mirror size ratio.
  48380. * 0.3 by default as the default kernel is 64.
  48381. */
  48382. groundMirrorSizeRatio: number;
  48383. /**
  48384. * Specifies the ground mirror blur kernel size.
  48385. * 64 by default.
  48386. */
  48387. groundMirrorBlurKernel: number;
  48388. /**
  48389. * Specifies the ground mirror visibility amount.
  48390. * 1 by default
  48391. */
  48392. groundMirrorAmount: number;
  48393. /**
  48394. * Specifies the ground mirror reflectance weight.
  48395. * This uses the standard weight of the background material to setup the fresnel effect
  48396. * of the mirror.
  48397. * 1 by default.
  48398. */
  48399. groundMirrorFresnelWeight: number;
  48400. /**
  48401. * Specifies the ground mirror Falloff distance.
  48402. * This can helps reducing the size of the reflection.
  48403. * 0 by Default.
  48404. */
  48405. groundMirrorFallOffDistance: number;
  48406. /**
  48407. * Specifies the ground mirror texture type.
  48408. * Unsigned Int by Default.
  48409. */
  48410. groundMirrorTextureType: number;
  48411. /**
  48412. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48413. * the shown objects.
  48414. */
  48415. groundYBias: number;
  48416. /**
  48417. * Specifies wether or not to create a skybox.
  48418. * True by default.
  48419. */
  48420. createSkybox: boolean;
  48421. /**
  48422. * Specifies the skybox size.
  48423. * 20 by default.
  48424. */
  48425. skyboxSize: number;
  48426. /**
  48427. * The texture used on the skybox for the main color.
  48428. * Comes from the BabylonJS CDN by default.
  48429. *
  48430. * Remarks: Can be either a texture or a url.
  48431. */
  48432. skyboxTexture: string | BaseTexture;
  48433. /**
  48434. * The color mixed in the skybox texture by default.
  48435. * BabylonJS clearColor by default.
  48436. */
  48437. skyboxColor: Color3;
  48438. /**
  48439. * The background rotation around the Y axis of the scene.
  48440. * This helps aligning the key lights of your scene with the background.
  48441. * 0 by default.
  48442. */
  48443. backgroundYRotation: number;
  48444. /**
  48445. * Compute automatically the size of the elements to best fit with the scene.
  48446. */
  48447. sizeAuto: boolean;
  48448. /**
  48449. * Default position of the rootMesh if autoSize is not true.
  48450. */
  48451. rootPosition: Vector3;
  48452. /**
  48453. * Sets up the image processing in the scene.
  48454. * true by default.
  48455. */
  48456. setupImageProcessing: boolean;
  48457. /**
  48458. * The texture used as your environment texture in the scene.
  48459. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48460. *
  48461. * Remarks: Can be either a texture or a url.
  48462. */
  48463. environmentTexture: string | BaseTexture;
  48464. /**
  48465. * The value of the exposure to apply to the scene.
  48466. * 0.6 by default if setupImageProcessing is true.
  48467. */
  48468. cameraExposure: number;
  48469. /**
  48470. * The value of the contrast to apply to the scene.
  48471. * 1.6 by default if setupImageProcessing is true.
  48472. */
  48473. cameraContrast: number;
  48474. /**
  48475. * Specifies wether or not tonemapping should be enabled in the scene.
  48476. * true by default if setupImageProcessing is true.
  48477. */
  48478. toneMappingEnabled: boolean;
  48479. }
  48480. /**
  48481. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48482. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48483. * It also helps with the default setup of your imageProcessing configuration.
  48484. */
  48485. export class EnvironmentHelper {
  48486. /**
  48487. * Default ground texture URL.
  48488. */
  48489. private static _groundTextureCDNUrl;
  48490. /**
  48491. * Default skybox texture URL.
  48492. */
  48493. private static _skyboxTextureCDNUrl;
  48494. /**
  48495. * Default environment texture URL.
  48496. */
  48497. private static _environmentTextureCDNUrl;
  48498. /**
  48499. * Creates the default options for the helper.
  48500. */
  48501. private static _getDefaultOptions;
  48502. private _rootMesh;
  48503. /**
  48504. * Gets the root mesh created by the helper.
  48505. */
  48506. readonly rootMesh: Mesh;
  48507. private _skybox;
  48508. /**
  48509. * Gets the skybox created by the helper.
  48510. */
  48511. readonly skybox: Nullable<Mesh>;
  48512. private _skyboxTexture;
  48513. /**
  48514. * Gets the skybox texture created by the helper.
  48515. */
  48516. readonly skyboxTexture: Nullable<BaseTexture>;
  48517. private _skyboxMaterial;
  48518. /**
  48519. * Gets the skybox material created by the helper.
  48520. */
  48521. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48522. private _ground;
  48523. /**
  48524. * Gets the ground mesh created by the helper.
  48525. */
  48526. readonly ground: Nullable<Mesh>;
  48527. private _groundTexture;
  48528. /**
  48529. * Gets the ground texture created by the helper.
  48530. */
  48531. readonly groundTexture: Nullable<BaseTexture>;
  48532. private _groundMirror;
  48533. /**
  48534. * Gets the ground mirror created by the helper.
  48535. */
  48536. readonly groundMirror: Nullable<MirrorTexture>;
  48537. /**
  48538. * Gets the ground mirror render list to helps pushing the meshes
  48539. * you wish in the ground reflection.
  48540. */
  48541. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48542. private _groundMaterial;
  48543. /**
  48544. * Gets the ground material created by the helper.
  48545. */
  48546. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48547. /**
  48548. * Stores the creation options.
  48549. */
  48550. private readonly _scene;
  48551. private _options;
  48552. /**
  48553. * This observable will be notified with any error during the creation of the environment,
  48554. * mainly texture creation errors.
  48555. */
  48556. onErrorObservable: Observable<{
  48557. message?: string;
  48558. exception?: any;
  48559. }>;
  48560. /**
  48561. * constructor
  48562. * @param options Defines the options we want to customize the helper
  48563. * @param scene The scene to add the material to
  48564. */
  48565. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48566. /**
  48567. * Updates the background according to the new options
  48568. * @param options
  48569. */
  48570. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48571. /**
  48572. * Sets the primary color of all the available elements.
  48573. * @param color the main color to affect to the ground and the background
  48574. */
  48575. setMainColor(color: Color3): void;
  48576. /**
  48577. * Setup the image processing according to the specified options.
  48578. */
  48579. private _setupImageProcessing;
  48580. /**
  48581. * Setup the environment texture according to the specified options.
  48582. */
  48583. private _setupEnvironmentTexture;
  48584. /**
  48585. * Setup the background according to the specified options.
  48586. */
  48587. private _setupBackground;
  48588. /**
  48589. * Get the scene sizes according to the setup.
  48590. */
  48591. private _getSceneSize;
  48592. /**
  48593. * Setup the ground according to the specified options.
  48594. */
  48595. private _setupGround;
  48596. /**
  48597. * Setup the ground material according to the specified options.
  48598. */
  48599. private _setupGroundMaterial;
  48600. /**
  48601. * Setup the ground diffuse texture according to the specified options.
  48602. */
  48603. private _setupGroundDiffuseTexture;
  48604. /**
  48605. * Setup the ground mirror texture according to the specified options.
  48606. */
  48607. private _setupGroundMirrorTexture;
  48608. /**
  48609. * Setup the ground to receive the mirror texture.
  48610. */
  48611. private _setupMirrorInGroundMaterial;
  48612. /**
  48613. * Setup the skybox according to the specified options.
  48614. */
  48615. private _setupSkybox;
  48616. /**
  48617. * Setup the skybox material according to the specified options.
  48618. */
  48619. private _setupSkyboxMaterial;
  48620. /**
  48621. * Setup the skybox reflection texture according to the specified options.
  48622. */
  48623. private _setupSkyboxReflectionTexture;
  48624. private _errorHandler;
  48625. /**
  48626. * Dispose all the elements created by the Helper.
  48627. */
  48628. dispose(): void;
  48629. }
  48630. }
  48631. declare module "babylonjs/Helpers/photoDome" {
  48632. import { Observable } from "babylonjs/Misc/observable";
  48633. import { Nullable } from "babylonjs/types";
  48634. import { Scene } from "babylonjs/scene";
  48635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48636. import { Mesh } from "babylonjs/Meshes/mesh";
  48637. import { Texture } from "babylonjs/Materials/Textures/texture";
  48638. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48639. import "babylonjs/Meshes/Builders/sphereBuilder";
  48640. /**
  48641. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48642. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48643. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48644. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48645. */
  48646. export class PhotoDome extends TransformNode {
  48647. /**
  48648. * Define the image as a Monoscopic panoramic 360 image.
  48649. */
  48650. static readonly MODE_MONOSCOPIC: number;
  48651. /**
  48652. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48653. */
  48654. static readonly MODE_TOPBOTTOM: number;
  48655. /**
  48656. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48657. */
  48658. static readonly MODE_SIDEBYSIDE: number;
  48659. private _useDirectMapping;
  48660. /**
  48661. * The texture being displayed on the sphere
  48662. */
  48663. protected _photoTexture: Texture;
  48664. /**
  48665. * Gets or sets the texture being displayed on the sphere
  48666. */
  48667. photoTexture: Texture;
  48668. /**
  48669. * Observable raised when an error occured while loading the 360 image
  48670. */
  48671. onLoadErrorObservable: Observable<string>;
  48672. /**
  48673. * The skybox material
  48674. */
  48675. protected _material: BackgroundMaterial;
  48676. /**
  48677. * The surface used for the skybox
  48678. */
  48679. protected _mesh: Mesh;
  48680. /**
  48681. * Gets the mesh used for the skybox.
  48682. */
  48683. readonly mesh: Mesh;
  48684. /**
  48685. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48686. * Also see the options.resolution property.
  48687. */
  48688. fovMultiplier: number;
  48689. private _imageMode;
  48690. /**
  48691. * Gets or set the current video mode for the video. It can be:
  48692. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48693. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48694. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48695. */
  48696. imageMode: number;
  48697. /**
  48698. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48699. * @param name Element's name, child elements will append suffixes for their own names.
  48700. * @param urlsOfPhoto defines the url of the photo to display
  48701. * @param options defines an object containing optional or exposed sub element properties
  48702. * @param onError defines a callback called when an error occured while loading the texture
  48703. */
  48704. constructor(name: string, urlOfPhoto: string, options: {
  48705. resolution?: number;
  48706. size?: number;
  48707. useDirectMapping?: boolean;
  48708. faceForward?: boolean;
  48709. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48710. private _onBeforeCameraRenderObserver;
  48711. private _changeImageMode;
  48712. /**
  48713. * Releases resources associated with this node.
  48714. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48715. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48716. */
  48717. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48718. }
  48719. }
  48720. declare module "babylonjs/Misc/rgbdTextureTools" {
  48721. import "babylonjs/Shaders/rgbdDecode.fragment";
  48722. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48723. import { Texture } from "babylonjs/Materials/Textures/texture";
  48724. /**
  48725. * Class used to host RGBD texture specific utilities
  48726. */
  48727. export class RGBDTextureTools {
  48728. /**
  48729. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48730. * @param texture the texture to expand.
  48731. */
  48732. static ExpandRGBDTexture(texture: Texture): void;
  48733. }
  48734. }
  48735. declare module "babylonjs/Misc/brdfTextureTools" {
  48736. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48737. import { Scene } from "babylonjs/scene";
  48738. /**
  48739. * Class used to host texture specific utilities
  48740. */
  48741. export class BRDFTextureTools {
  48742. /**
  48743. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48744. * @param scene defines the hosting scene
  48745. * @returns the environment BRDF texture
  48746. */
  48747. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48748. private static _environmentBRDFBase64Texture;
  48749. }
  48750. }
  48751. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48752. import { Nullable } from "babylonjs/types";
  48753. import { Color3 } from "babylonjs/Maths/math.color";
  48754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48755. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48756. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48757. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48758. import { Engine } from "babylonjs/Engines/engine";
  48759. import { Scene } from "babylonjs/scene";
  48760. /**
  48761. * @hidden
  48762. */
  48763. export interface IMaterialClearCoatDefines {
  48764. CLEARCOAT: boolean;
  48765. CLEARCOAT_DEFAULTIOR: boolean;
  48766. CLEARCOAT_TEXTURE: boolean;
  48767. CLEARCOAT_TEXTUREDIRECTUV: number;
  48768. CLEARCOAT_BUMP: boolean;
  48769. CLEARCOAT_BUMPDIRECTUV: number;
  48770. CLEARCOAT_TINT: boolean;
  48771. CLEARCOAT_TINT_TEXTURE: boolean;
  48772. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48773. /** @hidden */
  48774. _areTexturesDirty: boolean;
  48775. }
  48776. /**
  48777. * Define the code related to the clear coat parameters of the pbr material.
  48778. */
  48779. export class PBRClearCoatConfiguration {
  48780. /**
  48781. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48782. * The default fits with a polyurethane material.
  48783. */
  48784. private static readonly _DefaultIndexOfRefraction;
  48785. private _isEnabled;
  48786. /**
  48787. * Defines if the clear coat is enabled in the material.
  48788. */
  48789. isEnabled: boolean;
  48790. /**
  48791. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48792. */
  48793. intensity: number;
  48794. /**
  48795. * Defines the clear coat layer roughness.
  48796. */
  48797. roughness: number;
  48798. private _indexOfRefraction;
  48799. /**
  48800. * Defines the index of refraction of the clear coat.
  48801. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48802. * The default fits with a polyurethane material.
  48803. * Changing the default value is more performance intensive.
  48804. */
  48805. indexOfRefraction: number;
  48806. private _texture;
  48807. /**
  48808. * Stores the clear coat values in a texture.
  48809. */
  48810. texture: Nullable<BaseTexture>;
  48811. private _bumpTexture;
  48812. /**
  48813. * Define the clear coat specific bump texture.
  48814. */
  48815. bumpTexture: Nullable<BaseTexture>;
  48816. private _isTintEnabled;
  48817. /**
  48818. * Defines if the clear coat tint is enabled in the material.
  48819. */
  48820. isTintEnabled: boolean;
  48821. /**
  48822. * Defines the clear coat tint of the material.
  48823. * This is only use if tint is enabled
  48824. */
  48825. tintColor: Color3;
  48826. /**
  48827. * Defines the distance at which the tint color should be found in the
  48828. * clear coat media.
  48829. * This is only use if tint is enabled
  48830. */
  48831. tintColorAtDistance: number;
  48832. /**
  48833. * Defines the clear coat layer thickness.
  48834. * This is only use if tint is enabled
  48835. */
  48836. tintThickness: number;
  48837. private _tintTexture;
  48838. /**
  48839. * Stores the clear tint values in a texture.
  48840. * rgb is tint
  48841. * a is a thickness factor
  48842. */
  48843. tintTexture: Nullable<BaseTexture>;
  48844. /** @hidden */
  48845. private _internalMarkAllSubMeshesAsTexturesDirty;
  48846. /** @hidden */
  48847. _markAllSubMeshesAsTexturesDirty(): void;
  48848. /**
  48849. * Instantiate a new istance of clear coat configuration.
  48850. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48851. */
  48852. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48853. /**
  48854. * Gets wehter the submesh is ready to be used or not.
  48855. * @param defines the list of "defines" to update.
  48856. * @param scene defines the scene the material belongs to.
  48857. * @param engine defines the engine the material belongs to.
  48858. * @param disableBumpMap defines wether the material disables bump or not.
  48859. * @returns - boolean indicating that the submesh is ready or not.
  48860. */
  48861. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48862. /**
  48863. * Checks to see if a texture is used in the material.
  48864. * @param defines the list of "defines" to update.
  48865. * @param scene defines the scene to the material belongs to.
  48866. */
  48867. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48868. /**
  48869. * Binds the material data.
  48870. * @param uniformBuffer defines the Uniform buffer to fill in.
  48871. * @param scene defines the scene the material belongs to.
  48872. * @param engine defines the engine the material belongs to.
  48873. * @param disableBumpMap defines wether the material disables bump or not.
  48874. * @param isFrozen defines wether the material is frozen or not.
  48875. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48876. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48877. */
  48878. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48879. /**
  48880. * Checks to see if a texture is used in the material.
  48881. * @param texture - Base texture to use.
  48882. * @returns - Boolean specifying if a texture is used in the material.
  48883. */
  48884. hasTexture(texture: BaseTexture): boolean;
  48885. /**
  48886. * Returns an array of the actively used textures.
  48887. * @param activeTextures Array of BaseTextures
  48888. */
  48889. getActiveTextures(activeTextures: BaseTexture[]): void;
  48890. /**
  48891. * Returns the animatable textures.
  48892. * @param animatables Array of animatable textures.
  48893. */
  48894. getAnimatables(animatables: IAnimatable[]): void;
  48895. /**
  48896. * Disposes the resources of the material.
  48897. * @param forceDisposeTextures - Forces the disposal of all textures.
  48898. */
  48899. dispose(forceDisposeTextures?: boolean): void;
  48900. /**
  48901. * Get the current class name of the texture useful for serialization or dynamic coding.
  48902. * @returns "PBRClearCoatConfiguration"
  48903. */
  48904. getClassName(): string;
  48905. /**
  48906. * Add fallbacks to the effect fallbacks list.
  48907. * @param defines defines the Base texture to use.
  48908. * @param fallbacks defines the current fallback list.
  48909. * @param currentRank defines the current fallback rank.
  48910. * @returns the new fallback rank.
  48911. */
  48912. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48913. /**
  48914. * Add the required uniforms to the current list.
  48915. * @param uniforms defines the current uniform list.
  48916. */
  48917. static AddUniforms(uniforms: string[]): void;
  48918. /**
  48919. * Add the required samplers to the current list.
  48920. * @param samplers defines the current sampler list.
  48921. */
  48922. static AddSamplers(samplers: string[]): void;
  48923. /**
  48924. * Add the required uniforms to the current buffer.
  48925. * @param uniformBuffer defines the current uniform buffer.
  48926. */
  48927. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48928. /**
  48929. * Makes a duplicate of the current configuration into another one.
  48930. * @param clearCoatConfiguration define the config where to copy the info
  48931. */
  48932. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48933. /**
  48934. * Serializes this clear coat configuration.
  48935. * @returns - An object with the serialized config.
  48936. */
  48937. serialize(): any;
  48938. /**
  48939. * Parses a anisotropy Configuration from a serialized object.
  48940. * @param source - Serialized object.
  48941. * @param scene Defines the scene we are parsing for
  48942. * @param rootUrl Defines the rootUrl to load from
  48943. */
  48944. parse(source: any, scene: Scene, rootUrl: string): void;
  48945. }
  48946. }
  48947. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48948. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48950. import { Vector2 } from "babylonjs/Maths/math.vector";
  48951. import { Scene } from "babylonjs/scene";
  48952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48953. import { Nullable } from "babylonjs/types";
  48954. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48955. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48956. /**
  48957. * @hidden
  48958. */
  48959. export interface IMaterialAnisotropicDefines {
  48960. ANISOTROPIC: boolean;
  48961. ANISOTROPIC_TEXTURE: boolean;
  48962. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48963. MAINUV1: boolean;
  48964. _areTexturesDirty: boolean;
  48965. _needUVs: boolean;
  48966. }
  48967. /**
  48968. * Define the code related to the anisotropic parameters of the pbr material.
  48969. */
  48970. export class PBRAnisotropicConfiguration {
  48971. private _isEnabled;
  48972. /**
  48973. * Defines if the anisotropy is enabled in the material.
  48974. */
  48975. isEnabled: boolean;
  48976. /**
  48977. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48978. */
  48979. intensity: number;
  48980. /**
  48981. * Defines if the effect is along the tangents, bitangents or in between.
  48982. * By default, the effect is "strectching" the highlights along the tangents.
  48983. */
  48984. direction: Vector2;
  48985. private _texture;
  48986. /**
  48987. * Stores the anisotropy values in a texture.
  48988. * rg is direction (like normal from -1 to 1)
  48989. * b is a intensity
  48990. */
  48991. texture: Nullable<BaseTexture>;
  48992. /** @hidden */
  48993. private _internalMarkAllSubMeshesAsTexturesDirty;
  48994. /** @hidden */
  48995. _markAllSubMeshesAsTexturesDirty(): void;
  48996. /**
  48997. * Instantiate a new istance of anisotropy configuration.
  48998. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48999. */
  49000. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49001. /**
  49002. * Specifies that the submesh is ready to be used.
  49003. * @param defines the list of "defines" to update.
  49004. * @param scene defines the scene the material belongs to.
  49005. * @returns - boolean indicating that the submesh is ready or not.
  49006. */
  49007. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49008. /**
  49009. * Checks to see if a texture is used in the material.
  49010. * @param defines the list of "defines" to update.
  49011. * @param mesh the mesh we are preparing the defines for.
  49012. * @param scene defines the scene the material belongs to.
  49013. */
  49014. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49015. /**
  49016. * Binds the material data.
  49017. * @param uniformBuffer defines the Uniform buffer to fill in.
  49018. * @param scene defines the scene the material belongs to.
  49019. * @param isFrozen defines wether the material is frozen or not.
  49020. */
  49021. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49022. /**
  49023. * Checks to see if a texture is used in the material.
  49024. * @param texture - Base texture to use.
  49025. * @returns - Boolean specifying if a texture is used in the material.
  49026. */
  49027. hasTexture(texture: BaseTexture): boolean;
  49028. /**
  49029. * Returns an array of the actively used textures.
  49030. * @param activeTextures Array of BaseTextures
  49031. */
  49032. getActiveTextures(activeTextures: BaseTexture[]): void;
  49033. /**
  49034. * Returns the animatable textures.
  49035. * @param animatables Array of animatable textures.
  49036. */
  49037. getAnimatables(animatables: IAnimatable[]): void;
  49038. /**
  49039. * Disposes the resources of the material.
  49040. * @param forceDisposeTextures - Forces the disposal of all textures.
  49041. */
  49042. dispose(forceDisposeTextures?: boolean): void;
  49043. /**
  49044. * Get the current class name of the texture useful for serialization or dynamic coding.
  49045. * @returns "PBRAnisotropicConfiguration"
  49046. */
  49047. getClassName(): string;
  49048. /**
  49049. * Add fallbacks to the effect fallbacks list.
  49050. * @param defines defines the Base texture to use.
  49051. * @param fallbacks defines the current fallback list.
  49052. * @param currentRank defines the current fallback rank.
  49053. * @returns the new fallback rank.
  49054. */
  49055. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49056. /**
  49057. * Add the required uniforms to the current list.
  49058. * @param uniforms defines the current uniform list.
  49059. */
  49060. static AddUniforms(uniforms: string[]): void;
  49061. /**
  49062. * Add the required uniforms to the current buffer.
  49063. * @param uniformBuffer defines the current uniform buffer.
  49064. */
  49065. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49066. /**
  49067. * Add the required samplers to the current list.
  49068. * @param samplers defines the current sampler list.
  49069. */
  49070. static AddSamplers(samplers: string[]): void;
  49071. /**
  49072. * Makes a duplicate of the current configuration into another one.
  49073. * @param anisotropicConfiguration define the config where to copy the info
  49074. */
  49075. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49076. /**
  49077. * Serializes this anisotropy configuration.
  49078. * @returns - An object with the serialized config.
  49079. */
  49080. serialize(): any;
  49081. /**
  49082. * Parses a anisotropy Configuration from a serialized object.
  49083. * @param source - Serialized object.
  49084. * @param scene Defines the scene we are parsing for
  49085. * @param rootUrl Defines the rootUrl to load from
  49086. */
  49087. parse(source: any, scene: Scene, rootUrl: string): void;
  49088. }
  49089. }
  49090. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49091. import { Scene } from "babylonjs/scene";
  49092. /**
  49093. * @hidden
  49094. */
  49095. export interface IMaterialBRDFDefines {
  49096. BRDF_V_HEIGHT_CORRELATED: boolean;
  49097. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49098. SPHERICAL_HARMONICS: boolean;
  49099. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49100. /** @hidden */
  49101. _areMiscDirty: boolean;
  49102. }
  49103. /**
  49104. * Define the code related to the BRDF parameters of the pbr material.
  49105. */
  49106. export class PBRBRDFConfiguration {
  49107. /**
  49108. * Default value used for the energy conservation.
  49109. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49110. */
  49111. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49112. /**
  49113. * Default value used for the Smith Visibility Height Correlated mode.
  49114. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49115. */
  49116. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49117. /**
  49118. * Default value used for the IBL diffuse part.
  49119. * This can help switching back to the polynomials mode globally which is a tiny bit
  49120. * less GPU intensive at the drawback of a lower quality.
  49121. */
  49122. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49123. /**
  49124. * Default value used for activating energy conservation for the specular workflow.
  49125. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49126. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49127. */
  49128. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49129. private _useEnergyConservation;
  49130. /**
  49131. * Defines if the material uses energy conservation.
  49132. */
  49133. useEnergyConservation: boolean;
  49134. private _useSmithVisibilityHeightCorrelated;
  49135. /**
  49136. * LEGACY Mode set to false
  49137. * Defines if the material uses height smith correlated visibility term.
  49138. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49139. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49140. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49141. * Not relying on height correlated will also disable energy conservation.
  49142. */
  49143. useSmithVisibilityHeightCorrelated: boolean;
  49144. private _useSphericalHarmonics;
  49145. /**
  49146. * LEGACY Mode set to false
  49147. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49148. * diffuse part of the IBL.
  49149. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49150. * to the ground truth.
  49151. */
  49152. useSphericalHarmonics: boolean;
  49153. private _useSpecularGlossinessInputEnergyConservation;
  49154. /**
  49155. * Defines if the material uses energy conservation, when the specular workflow is active.
  49156. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49157. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49158. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49159. */
  49160. useSpecularGlossinessInputEnergyConservation: boolean;
  49161. /** @hidden */
  49162. private _internalMarkAllSubMeshesAsMiscDirty;
  49163. /** @hidden */
  49164. _markAllSubMeshesAsMiscDirty(): void;
  49165. /**
  49166. * Instantiate a new istance of clear coat configuration.
  49167. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49168. */
  49169. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49170. /**
  49171. * Checks to see if a texture is used in the material.
  49172. * @param defines the list of "defines" to update.
  49173. */
  49174. prepareDefines(defines: IMaterialBRDFDefines): void;
  49175. /**
  49176. * Get the current class name of the texture useful for serialization or dynamic coding.
  49177. * @returns "PBRClearCoatConfiguration"
  49178. */
  49179. getClassName(): string;
  49180. /**
  49181. * Makes a duplicate of the current configuration into another one.
  49182. * @param brdfConfiguration define the config where to copy the info
  49183. */
  49184. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49185. /**
  49186. * Serializes this BRDF configuration.
  49187. * @returns - An object with the serialized config.
  49188. */
  49189. serialize(): any;
  49190. /**
  49191. * Parses a anisotropy Configuration from a serialized object.
  49192. * @param source - Serialized object.
  49193. * @param scene Defines the scene we are parsing for
  49194. * @param rootUrl Defines the rootUrl to load from
  49195. */
  49196. parse(source: any, scene: Scene, rootUrl: string): void;
  49197. }
  49198. }
  49199. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49200. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49201. import { Color3 } from "babylonjs/Maths/math.color";
  49202. import { Scene } from "babylonjs/scene";
  49203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49204. import { Nullable } from "babylonjs/types";
  49205. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49206. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49207. /**
  49208. * @hidden
  49209. */
  49210. export interface IMaterialSheenDefines {
  49211. SHEEN: boolean;
  49212. SHEEN_TEXTURE: boolean;
  49213. SHEEN_TEXTUREDIRECTUV: number;
  49214. SHEEN_LINKWITHALBEDO: boolean;
  49215. /** @hidden */
  49216. _areTexturesDirty: boolean;
  49217. }
  49218. /**
  49219. * Define the code related to the Sheen parameters of the pbr material.
  49220. */
  49221. export class PBRSheenConfiguration {
  49222. private _isEnabled;
  49223. /**
  49224. * Defines if the material uses sheen.
  49225. */
  49226. isEnabled: boolean;
  49227. private _linkSheenWithAlbedo;
  49228. /**
  49229. * Defines if the sheen is linked to the sheen color.
  49230. */
  49231. linkSheenWithAlbedo: boolean;
  49232. /**
  49233. * Defines the sheen intensity.
  49234. */
  49235. intensity: number;
  49236. /**
  49237. * Defines the sheen color.
  49238. */
  49239. color: Color3;
  49240. private _texture;
  49241. /**
  49242. * Stores the sheen tint values in a texture.
  49243. * rgb is tint
  49244. * a is a intensity
  49245. */
  49246. texture: Nullable<BaseTexture>;
  49247. /** @hidden */
  49248. private _internalMarkAllSubMeshesAsTexturesDirty;
  49249. /** @hidden */
  49250. _markAllSubMeshesAsTexturesDirty(): void;
  49251. /**
  49252. * Instantiate a new istance of clear coat configuration.
  49253. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49254. */
  49255. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49256. /**
  49257. * Specifies that the submesh is ready to be used.
  49258. * @param defines the list of "defines" to update.
  49259. * @param scene defines the scene the material belongs to.
  49260. * @returns - boolean indicating that the submesh is ready or not.
  49261. */
  49262. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49263. /**
  49264. * Checks to see if a texture is used in the material.
  49265. * @param defines the list of "defines" to update.
  49266. * @param scene defines the scene the material belongs to.
  49267. */
  49268. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49269. /**
  49270. * Binds the material data.
  49271. * @param uniformBuffer defines the Uniform buffer to fill in.
  49272. * @param scene defines the scene the material belongs to.
  49273. * @param isFrozen defines wether the material is frozen or not.
  49274. */
  49275. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49276. /**
  49277. * Checks to see if a texture is used in the material.
  49278. * @param texture - Base texture to use.
  49279. * @returns - Boolean specifying if a texture is used in the material.
  49280. */
  49281. hasTexture(texture: BaseTexture): boolean;
  49282. /**
  49283. * Returns an array of the actively used textures.
  49284. * @param activeTextures Array of BaseTextures
  49285. */
  49286. getActiveTextures(activeTextures: BaseTexture[]): void;
  49287. /**
  49288. * Returns the animatable textures.
  49289. * @param animatables Array of animatable textures.
  49290. */
  49291. getAnimatables(animatables: IAnimatable[]): void;
  49292. /**
  49293. * Disposes the resources of the material.
  49294. * @param forceDisposeTextures - Forces the disposal of all textures.
  49295. */
  49296. dispose(forceDisposeTextures?: boolean): void;
  49297. /**
  49298. * Get the current class name of the texture useful for serialization or dynamic coding.
  49299. * @returns "PBRSheenConfiguration"
  49300. */
  49301. getClassName(): string;
  49302. /**
  49303. * Add fallbacks to the effect fallbacks list.
  49304. * @param defines defines the Base texture to use.
  49305. * @param fallbacks defines the current fallback list.
  49306. * @param currentRank defines the current fallback rank.
  49307. * @returns the new fallback rank.
  49308. */
  49309. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49310. /**
  49311. * Add the required uniforms to the current list.
  49312. * @param uniforms defines the current uniform list.
  49313. */
  49314. static AddUniforms(uniforms: string[]): void;
  49315. /**
  49316. * Add the required uniforms to the current buffer.
  49317. * @param uniformBuffer defines the current uniform buffer.
  49318. */
  49319. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49320. /**
  49321. * Add the required samplers to the current list.
  49322. * @param samplers defines the current sampler list.
  49323. */
  49324. static AddSamplers(samplers: string[]): void;
  49325. /**
  49326. * Makes a duplicate of the current configuration into another one.
  49327. * @param sheenConfiguration define the config where to copy the info
  49328. */
  49329. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49330. /**
  49331. * Serializes this BRDF configuration.
  49332. * @returns - An object with the serialized config.
  49333. */
  49334. serialize(): any;
  49335. /**
  49336. * Parses a anisotropy Configuration from a serialized object.
  49337. * @param source - Serialized object.
  49338. * @param scene Defines the scene we are parsing for
  49339. * @param rootUrl Defines the rootUrl to load from
  49340. */
  49341. parse(source: any, scene: Scene, rootUrl: string): void;
  49342. }
  49343. }
  49344. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49345. import { Nullable } from "babylonjs/types";
  49346. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49347. import { Color3 } from "babylonjs/Maths/math.color";
  49348. import { SmartArray } from "babylonjs/Misc/smartArray";
  49349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49351. import { Effect } from "babylonjs/Materials/effect";
  49352. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49353. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49354. import { Engine } from "babylonjs/Engines/engine";
  49355. import { Scene } from "babylonjs/scene";
  49356. /**
  49357. * @hidden
  49358. */
  49359. export interface IMaterialSubSurfaceDefines {
  49360. SUBSURFACE: boolean;
  49361. SS_REFRACTION: boolean;
  49362. SS_TRANSLUCENCY: boolean;
  49363. SS_SCATERRING: boolean;
  49364. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49365. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49366. SS_REFRACTIONMAP_3D: boolean;
  49367. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49368. SS_LODINREFRACTIONALPHA: boolean;
  49369. SS_GAMMAREFRACTION: boolean;
  49370. SS_RGBDREFRACTION: boolean;
  49371. SS_LINEARSPECULARREFRACTION: boolean;
  49372. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49373. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49374. /** @hidden */
  49375. _areTexturesDirty: boolean;
  49376. }
  49377. /**
  49378. * Define the code related to the sub surface parameters of the pbr material.
  49379. */
  49380. export class PBRSubSurfaceConfiguration {
  49381. private _isRefractionEnabled;
  49382. /**
  49383. * Defines if the refraction is enabled in the material.
  49384. */
  49385. isRefractionEnabled: boolean;
  49386. private _isTranslucencyEnabled;
  49387. /**
  49388. * Defines if the translucency is enabled in the material.
  49389. */
  49390. isTranslucencyEnabled: boolean;
  49391. private _isScatteringEnabled;
  49392. /**
  49393. * Defines the refraction intensity of the material.
  49394. * The refraction when enabled replaces the Diffuse part of the material.
  49395. * The intensity helps transitionning between diffuse and refraction.
  49396. */
  49397. refractionIntensity: number;
  49398. /**
  49399. * Defines the translucency intensity of the material.
  49400. * When translucency has been enabled, this defines how much of the "translucency"
  49401. * is addded to the diffuse part of the material.
  49402. */
  49403. translucencyIntensity: number;
  49404. /**
  49405. * Defines the scattering intensity of the material.
  49406. * When scattering has been enabled, this defines how much of the "scattered light"
  49407. * is addded to the diffuse part of the material.
  49408. */
  49409. scatteringIntensity: number;
  49410. private _thicknessTexture;
  49411. /**
  49412. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49413. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49414. * 0 would mean minimumThickness
  49415. * 1 would mean maximumThickness
  49416. * The other channels might be use as a mask to vary the different effects intensity.
  49417. */
  49418. thicknessTexture: Nullable<BaseTexture>;
  49419. private _refractionTexture;
  49420. /**
  49421. * Defines the texture to use for refraction.
  49422. */
  49423. refractionTexture: Nullable<BaseTexture>;
  49424. private _indexOfRefraction;
  49425. /**
  49426. * Defines the index of refraction used in the material.
  49427. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49428. */
  49429. indexOfRefraction: number;
  49430. private _invertRefractionY;
  49431. /**
  49432. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49433. */
  49434. invertRefractionY: boolean;
  49435. private _linkRefractionWithTransparency;
  49436. /**
  49437. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49438. * Materials half opaque for instance using refraction could benefit from this control.
  49439. */
  49440. linkRefractionWithTransparency: boolean;
  49441. /**
  49442. * Defines the minimum thickness stored in the thickness map.
  49443. * If no thickness map is defined, this value will be used to simulate thickness.
  49444. */
  49445. minimumThickness: number;
  49446. /**
  49447. * Defines the maximum thickness stored in the thickness map.
  49448. */
  49449. maximumThickness: number;
  49450. /**
  49451. * Defines the volume tint of the material.
  49452. * This is used for both translucency and scattering.
  49453. */
  49454. tintColor: Color3;
  49455. /**
  49456. * Defines the distance at which the tint color should be found in the media.
  49457. * This is used for refraction only.
  49458. */
  49459. tintColorAtDistance: number;
  49460. /**
  49461. * Defines how far each channel transmit through the media.
  49462. * It is defined as a color to simplify it selection.
  49463. */
  49464. diffusionDistance: Color3;
  49465. private _useMaskFromThicknessTexture;
  49466. /**
  49467. * Stores the intensity of the different subsurface effects in the thickness texture.
  49468. * * the green channel is the translucency intensity.
  49469. * * the blue channel is the scattering intensity.
  49470. * * the alpha channel is the refraction intensity.
  49471. */
  49472. useMaskFromThicknessTexture: boolean;
  49473. /** @hidden */
  49474. private _internalMarkAllSubMeshesAsTexturesDirty;
  49475. /** @hidden */
  49476. _markAllSubMeshesAsTexturesDirty(): void;
  49477. /**
  49478. * Instantiate a new istance of sub surface configuration.
  49479. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49480. */
  49481. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49482. /**
  49483. * Gets wehter the submesh is ready to be used or not.
  49484. * @param defines the list of "defines" to update.
  49485. * @param scene defines the scene the material belongs to.
  49486. * @returns - boolean indicating that the submesh is ready or not.
  49487. */
  49488. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49489. /**
  49490. * Checks to see if a texture is used in the material.
  49491. * @param defines the list of "defines" to update.
  49492. * @param scene defines the scene to the material belongs to.
  49493. */
  49494. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49495. /**
  49496. * Binds the material data.
  49497. * @param uniformBuffer defines the Uniform buffer to fill in.
  49498. * @param scene defines the scene the material belongs to.
  49499. * @param engine defines the engine the material belongs to.
  49500. * @param isFrozen defines wether the material is frozen or not.
  49501. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49502. */
  49503. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49504. /**
  49505. * Unbinds the material from the mesh.
  49506. * @param activeEffect defines the effect that should be unbound from.
  49507. * @returns true if unbound, otherwise false
  49508. */
  49509. unbind(activeEffect: Effect): boolean;
  49510. /**
  49511. * Returns the texture used for refraction or null if none is used.
  49512. * @param scene defines the scene the material belongs to.
  49513. * @returns - Refraction texture if present. If no refraction texture and refraction
  49514. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49515. */
  49516. private _getRefractionTexture;
  49517. /**
  49518. * Returns true if alpha blending should be disabled.
  49519. */
  49520. readonly disableAlphaBlending: boolean;
  49521. /**
  49522. * Fills the list of render target textures.
  49523. * @param renderTargets the list of render targets to update
  49524. */
  49525. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49526. /**
  49527. * Checks to see if a texture is used in the material.
  49528. * @param texture - Base texture to use.
  49529. * @returns - Boolean specifying if a texture is used in the material.
  49530. */
  49531. hasTexture(texture: BaseTexture): boolean;
  49532. /**
  49533. * Gets a boolean indicating that current material needs to register RTT
  49534. * @returns true if this uses a render target otherwise false.
  49535. */
  49536. hasRenderTargetTextures(): boolean;
  49537. /**
  49538. * Returns an array of the actively used textures.
  49539. * @param activeTextures Array of BaseTextures
  49540. */
  49541. getActiveTextures(activeTextures: BaseTexture[]): void;
  49542. /**
  49543. * Returns the animatable textures.
  49544. * @param animatables Array of animatable textures.
  49545. */
  49546. getAnimatables(animatables: IAnimatable[]): void;
  49547. /**
  49548. * Disposes the resources of the material.
  49549. * @param forceDisposeTextures - Forces the disposal of all textures.
  49550. */
  49551. dispose(forceDisposeTextures?: boolean): void;
  49552. /**
  49553. * Get the current class name of the texture useful for serialization or dynamic coding.
  49554. * @returns "PBRSubSurfaceConfiguration"
  49555. */
  49556. getClassName(): string;
  49557. /**
  49558. * Add fallbacks to the effect fallbacks list.
  49559. * @param defines defines the Base texture to use.
  49560. * @param fallbacks defines the current fallback list.
  49561. * @param currentRank defines the current fallback rank.
  49562. * @returns the new fallback rank.
  49563. */
  49564. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49565. /**
  49566. * Add the required uniforms to the current list.
  49567. * @param uniforms defines the current uniform list.
  49568. */
  49569. static AddUniforms(uniforms: string[]): void;
  49570. /**
  49571. * Add the required samplers to the current list.
  49572. * @param samplers defines the current sampler list.
  49573. */
  49574. static AddSamplers(samplers: string[]): void;
  49575. /**
  49576. * Add the required uniforms to the current buffer.
  49577. * @param uniformBuffer defines the current uniform buffer.
  49578. */
  49579. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49580. /**
  49581. * Makes a duplicate of the current configuration into another one.
  49582. * @param configuration define the config where to copy the info
  49583. */
  49584. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49585. /**
  49586. * Serializes this Sub Surface configuration.
  49587. * @returns - An object with the serialized config.
  49588. */
  49589. serialize(): any;
  49590. /**
  49591. * Parses a anisotropy Configuration from a serialized object.
  49592. * @param source - Serialized object.
  49593. * @param scene Defines the scene we are parsing for
  49594. * @param rootUrl Defines the rootUrl to load from
  49595. */
  49596. parse(source: any, scene: Scene, rootUrl: string): void;
  49597. }
  49598. }
  49599. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49600. /** @hidden */
  49601. export var pbrFragmentDeclaration: {
  49602. name: string;
  49603. shader: string;
  49604. };
  49605. }
  49606. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49607. /** @hidden */
  49608. export var pbrUboDeclaration: {
  49609. name: string;
  49610. shader: string;
  49611. };
  49612. }
  49613. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49614. /** @hidden */
  49615. export var pbrFragmentExtraDeclaration: {
  49616. name: string;
  49617. shader: string;
  49618. };
  49619. }
  49620. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49621. /** @hidden */
  49622. export var pbrFragmentSamplersDeclaration: {
  49623. name: string;
  49624. shader: string;
  49625. };
  49626. }
  49627. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49628. /** @hidden */
  49629. export var pbrHelperFunctions: {
  49630. name: string;
  49631. shader: string;
  49632. };
  49633. }
  49634. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49635. /** @hidden */
  49636. export var harmonicsFunctions: {
  49637. name: string;
  49638. shader: string;
  49639. };
  49640. }
  49641. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49642. /** @hidden */
  49643. export var pbrDirectLightingSetupFunctions: {
  49644. name: string;
  49645. shader: string;
  49646. };
  49647. }
  49648. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49649. /** @hidden */
  49650. export var pbrDirectLightingFalloffFunctions: {
  49651. name: string;
  49652. shader: string;
  49653. };
  49654. }
  49655. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49656. /** @hidden */
  49657. export var pbrBRDFFunctions: {
  49658. name: string;
  49659. shader: string;
  49660. };
  49661. }
  49662. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49663. /** @hidden */
  49664. export var pbrDirectLightingFunctions: {
  49665. name: string;
  49666. shader: string;
  49667. };
  49668. }
  49669. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49670. /** @hidden */
  49671. export var pbrIBLFunctions: {
  49672. name: string;
  49673. shader: string;
  49674. };
  49675. }
  49676. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49677. /** @hidden */
  49678. export var pbrDebug: {
  49679. name: string;
  49680. shader: string;
  49681. };
  49682. }
  49683. declare module "babylonjs/Shaders/pbr.fragment" {
  49684. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49685. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49686. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49687. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49688. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49689. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49690. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49691. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49692. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49693. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49694. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49695. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49696. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49697. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49698. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49699. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49700. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49701. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49702. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49703. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49704. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49705. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49706. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49707. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49708. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49709. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49710. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49711. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49712. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49713. /** @hidden */
  49714. export var pbrPixelShader: {
  49715. name: string;
  49716. shader: string;
  49717. };
  49718. }
  49719. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49720. /** @hidden */
  49721. export var pbrVertexDeclaration: {
  49722. name: string;
  49723. shader: string;
  49724. };
  49725. }
  49726. declare module "babylonjs/Shaders/pbr.vertex" {
  49727. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49728. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49729. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49730. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49731. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49732. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49733. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49734. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49735. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49736. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49737. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49738. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49739. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49740. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49742. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49743. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49744. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49745. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49746. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49747. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49748. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49749. /** @hidden */
  49750. export var pbrVertexShader: {
  49751. name: string;
  49752. shader: string;
  49753. };
  49754. }
  49755. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49756. import { Nullable } from "babylonjs/types";
  49757. import { Scene } from "babylonjs/scene";
  49758. import { Matrix } from "babylonjs/Maths/math.vector";
  49759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49761. import { Mesh } from "babylonjs/Meshes/mesh";
  49762. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49763. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49764. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49765. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49766. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49767. import { Color3 } from "babylonjs/Maths/math.color";
  49768. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49769. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  49770. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49771. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49772. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49773. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49774. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49775. import "babylonjs/Shaders/pbr.fragment";
  49776. import "babylonjs/Shaders/pbr.vertex";
  49777. /**
  49778. * Manages the defines for the PBR Material.
  49779. * @hidden
  49780. */
  49781. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49782. PBR: boolean;
  49783. MAINUV1: boolean;
  49784. MAINUV2: boolean;
  49785. UV1: boolean;
  49786. UV2: boolean;
  49787. ALBEDO: boolean;
  49788. ALBEDODIRECTUV: number;
  49789. VERTEXCOLOR: boolean;
  49790. AMBIENT: boolean;
  49791. AMBIENTDIRECTUV: number;
  49792. AMBIENTINGRAYSCALE: boolean;
  49793. OPACITY: boolean;
  49794. VERTEXALPHA: boolean;
  49795. OPACITYDIRECTUV: number;
  49796. OPACITYRGB: boolean;
  49797. ALPHATEST: boolean;
  49798. DEPTHPREPASS: boolean;
  49799. ALPHABLEND: boolean;
  49800. ALPHAFROMALBEDO: boolean;
  49801. ALPHATESTVALUE: string;
  49802. SPECULAROVERALPHA: boolean;
  49803. RADIANCEOVERALPHA: boolean;
  49804. ALPHAFRESNEL: boolean;
  49805. LINEARALPHAFRESNEL: boolean;
  49806. PREMULTIPLYALPHA: boolean;
  49807. EMISSIVE: boolean;
  49808. EMISSIVEDIRECTUV: number;
  49809. REFLECTIVITY: boolean;
  49810. REFLECTIVITYDIRECTUV: number;
  49811. SPECULARTERM: boolean;
  49812. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49813. MICROSURFACEAUTOMATIC: boolean;
  49814. LODBASEDMICROSFURACE: boolean;
  49815. MICROSURFACEMAP: boolean;
  49816. MICROSURFACEMAPDIRECTUV: number;
  49817. METALLICWORKFLOW: boolean;
  49818. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49819. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49820. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49821. AOSTOREINMETALMAPRED: boolean;
  49822. ENVIRONMENTBRDF: boolean;
  49823. ENVIRONMENTBRDF_RGBD: boolean;
  49824. NORMAL: boolean;
  49825. TANGENT: boolean;
  49826. BUMP: boolean;
  49827. BUMPDIRECTUV: number;
  49828. OBJECTSPACE_NORMALMAP: boolean;
  49829. PARALLAX: boolean;
  49830. PARALLAXOCCLUSION: boolean;
  49831. NORMALXYSCALE: boolean;
  49832. LIGHTMAP: boolean;
  49833. LIGHTMAPDIRECTUV: number;
  49834. USELIGHTMAPASSHADOWMAP: boolean;
  49835. GAMMALIGHTMAP: boolean;
  49836. RGBDLIGHTMAP: boolean;
  49837. REFLECTION: boolean;
  49838. REFLECTIONMAP_3D: boolean;
  49839. REFLECTIONMAP_SPHERICAL: boolean;
  49840. REFLECTIONMAP_PLANAR: boolean;
  49841. REFLECTIONMAP_CUBIC: boolean;
  49842. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49843. REFLECTIONMAP_PROJECTION: boolean;
  49844. REFLECTIONMAP_SKYBOX: boolean;
  49845. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49846. REFLECTIONMAP_EXPLICIT: boolean;
  49847. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49848. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49849. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49850. INVERTCUBICMAP: boolean;
  49851. USESPHERICALFROMREFLECTIONMAP: boolean;
  49852. USEIRRADIANCEMAP: boolean;
  49853. SPHERICAL_HARMONICS: boolean;
  49854. USESPHERICALINVERTEX: boolean;
  49855. REFLECTIONMAP_OPPOSITEZ: boolean;
  49856. LODINREFLECTIONALPHA: boolean;
  49857. GAMMAREFLECTION: boolean;
  49858. RGBDREFLECTION: boolean;
  49859. LINEARSPECULARREFLECTION: boolean;
  49860. RADIANCEOCCLUSION: boolean;
  49861. HORIZONOCCLUSION: boolean;
  49862. INSTANCES: boolean;
  49863. NUM_BONE_INFLUENCERS: number;
  49864. BonesPerMesh: number;
  49865. BONETEXTURE: boolean;
  49866. NONUNIFORMSCALING: boolean;
  49867. MORPHTARGETS: boolean;
  49868. MORPHTARGETS_NORMAL: boolean;
  49869. MORPHTARGETS_TANGENT: boolean;
  49870. MORPHTARGETS_UV: boolean;
  49871. NUM_MORPH_INFLUENCERS: number;
  49872. IMAGEPROCESSING: boolean;
  49873. VIGNETTE: boolean;
  49874. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49875. VIGNETTEBLENDMODEOPAQUE: boolean;
  49876. TONEMAPPING: boolean;
  49877. TONEMAPPING_ACES: boolean;
  49878. CONTRAST: boolean;
  49879. COLORCURVES: boolean;
  49880. COLORGRADING: boolean;
  49881. COLORGRADING3D: boolean;
  49882. SAMPLER3DGREENDEPTH: boolean;
  49883. SAMPLER3DBGRMAP: boolean;
  49884. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49885. EXPOSURE: boolean;
  49886. MULTIVIEW: boolean;
  49887. USEPHYSICALLIGHTFALLOFF: boolean;
  49888. USEGLTFLIGHTFALLOFF: boolean;
  49889. TWOSIDEDLIGHTING: boolean;
  49890. SHADOWFLOAT: boolean;
  49891. CLIPPLANE: boolean;
  49892. CLIPPLANE2: boolean;
  49893. CLIPPLANE3: boolean;
  49894. CLIPPLANE4: boolean;
  49895. POINTSIZE: boolean;
  49896. FOG: boolean;
  49897. LOGARITHMICDEPTH: boolean;
  49898. FORCENORMALFORWARD: boolean;
  49899. SPECULARAA: boolean;
  49900. CLEARCOAT: boolean;
  49901. CLEARCOAT_DEFAULTIOR: boolean;
  49902. CLEARCOAT_TEXTURE: boolean;
  49903. CLEARCOAT_TEXTUREDIRECTUV: number;
  49904. CLEARCOAT_BUMP: boolean;
  49905. CLEARCOAT_BUMPDIRECTUV: number;
  49906. CLEARCOAT_TINT: boolean;
  49907. CLEARCOAT_TINT_TEXTURE: boolean;
  49908. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49909. ANISOTROPIC: boolean;
  49910. ANISOTROPIC_TEXTURE: boolean;
  49911. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49912. BRDF_V_HEIGHT_CORRELATED: boolean;
  49913. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49914. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49915. SHEEN: boolean;
  49916. SHEEN_TEXTURE: boolean;
  49917. SHEEN_TEXTUREDIRECTUV: number;
  49918. SHEEN_LINKWITHALBEDO: boolean;
  49919. SUBSURFACE: boolean;
  49920. SS_REFRACTION: boolean;
  49921. SS_TRANSLUCENCY: boolean;
  49922. SS_SCATERRING: boolean;
  49923. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49924. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49925. SS_REFRACTIONMAP_3D: boolean;
  49926. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49927. SS_LODINREFRACTIONALPHA: boolean;
  49928. SS_GAMMAREFRACTION: boolean;
  49929. SS_RGBDREFRACTION: boolean;
  49930. SS_LINEARSPECULARREFRACTION: boolean;
  49931. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49932. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49933. UNLIT: boolean;
  49934. DEBUGMODE: number;
  49935. /**
  49936. * Initializes the PBR Material defines.
  49937. */
  49938. constructor();
  49939. /**
  49940. * Resets the PBR Material defines.
  49941. */
  49942. reset(): void;
  49943. }
  49944. /**
  49945. * The Physically based material base class of BJS.
  49946. *
  49947. * This offers the main features of a standard PBR material.
  49948. * For more information, please refer to the documentation :
  49949. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49950. */
  49951. export abstract class PBRBaseMaterial extends PushMaterial {
  49952. /**
  49953. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49954. */
  49955. static readonly PBRMATERIAL_OPAQUE: number;
  49956. /**
  49957. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49958. */
  49959. static readonly PBRMATERIAL_ALPHATEST: number;
  49960. /**
  49961. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49962. */
  49963. static readonly PBRMATERIAL_ALPHABLEND: number;
  49964. /**
  49965. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49966. * They are also discarded below the alpha cutoff threshold to improve performances.
  49967. */
  49968. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49969. /**
  49970. * Defines the default value of how much AO map is occluding the analytical lights
  49971. * (point spot...).
  49972. */
  49973. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49974. /**
  49975. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49976. */
  49977. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49978. /**
  49979. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49980. * to enhance interoperability with other engines.
  49981. */
  49982. static readonly LIGHTFALLOFF_GLTF: number;
  49983. /**
  49984. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49985. * to enhance interoperability with other materials.
  49986. */
  49987. static readonly LIGHTFALLOFF_STANDARD: number;
  49988. /**
  49989. * Intensity of the direct lights e.g. the four lights available in your scene.
  49990. * This impacts both the direct diffuse and specular highlights.
  49991. */
  49992. protected _directIntensity: number;
  49993. /**
  49994. * Intensity of the emissive part of the material.
  49995. * This helps controlling the emissive effect without modifying the emissive color.
  49996. */
  49997. protected _emissiveIntensity: number;
  49998. /**
  49999. * Intensity of the environment e.g. how much the environment will light the object
  50000. * either through harmonics for rough material or through the refelction for shiny ones.
  50001. */
  50002. protected _environmentIntensity: number;
  50003. /**
  50004. * This is a special control allowing the reduction of the specular highlights coming from the
  50005. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50006. */
  50007. protected _specularIntensity: number;
  50008. /**
  50009. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50010. */
  50011. private _lightingInfos;
  50012. /**
  50013. * Debug Control allowing disabling the bump map on this material.
  50014. */
  50015. protected _disableBumpMap: boolean;
  50016. /**
  50017. * AKA Diffuse Texture in standard nomenclature.
  50018. */
  50019. protected _albedoTexture: Nullable<BaseTexture>;
  50020. /**
  50021. * AKA Occlusion Texture in other nomenclature.
  50022. */
  50023. protected _ambientTexture: Nullable<BaseTexture>;
  50024. /**
  50025. * AKA Occlusion Texture Intensity in other nomenclature.
  50026. */
  50027. protected _ambientTextureStrength: number;
  50028. /**
  50029. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50030. * 1 means it completely occludes it
  50031. * 0 mean it has no impact
  50032. */
  50033. protected _ambientTextureImpactOnAnalyticalLights: number;
  50034. /**
  50035. * Stores the alpha values in a texture.
  50036. */
  50037. protected _opacityTexture: Nullable<BaseTexture>;
  50038. /**
  50039. * Stores the reflection values in a texture.
  50040. */
  50041. protected _reflectionTexture: Nullable<BaseTexture>;
  50042. /**
  50043. * Stores the emissive values in a texture.
  50044. */
  50045. protected _emissiveTexture: Nullable<BaseTexture>;
  50046. /**
  50047. * AKA Specular texture in other nomenclature.
  50048. */
  50049. protected _reflectivityTexture: Nullable<BaseTexture>;
  50050. /**
  50051. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50052. */
  50053. protected _metallicTexture: Nullable<BaseTexture>;
  50054. /**
  50055. * Specifies the metallic scalar of the metallic/roughness workflow.
  50056. * Can also be used to scale the metalness values of the metallic texture.
  50057. */
  50058. protected _metallic: Nullable<number>;
  50059. /**
  50060. * Specifies the roughness scalar of the metallic/roughness workflow.
  50061. * Can also be used to scale the roughness values of the metallic texture.
  50062. */
  50063. protected _roughness: Nullable<number>;
  50064. /**
  50065. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50066. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50067. */
  50068. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50069. /**
  50070. * Stores surface normal data used to displace a mesh in a texture.
  50071. */
  50072. protected _bumpTexture: Nullable<BaseTexture>;
  50073. /**
  50074. * Stores the pre-calculated light information of a mesh in a texture.
  50075. */
  50076. protected _lightmapTexture: Nullable<BaseTexture>;
  50077. /**
  50078. * The color of a material in ambient lighting.
  50079. */
  50080. protected _ambientColor: Color3;
  50081. /**
  50082. * AKA Diffuse Color in other nomenclature.
  50083. */
  50084. protected _albedoColor: Color3;
  50085. /**
  50086. * AKA Specular Color in other nomenclature.
  50087. */
  50088. protected _reflectivityColor: Color3;
  50089. /**
  50090. * The color applied when light is reflected from a material.
  50091. */
  50092. protected _reflectionColor: Color3;
  50093. /**
  50094. * The color applied when light is emitted from a material.
  50095. */
  50096. protected _emissiveColor: Color3;
  50097. /**
  50098. * AKA Glossiness in other nomenclature.
  50099. */
  50100. protected _microSurface: number;
  50101. /**
  50102. * Specifies that the material will use the light map as a show map.
  50103. */
  50104. protected _useLightmapAsShadowmap: boolean;
  50105. /**
  50106. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50107. * makes the reflect vector face the model (under horizon).
  50108. */
  50109. protected _useHorizonOcclusion: boolean;
  50110. /**
  50111. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50112. * too much the area relying on ambient texture to define their ambient occlusion.
  50113. */
  50114. protected _useRadianceOcclusion: boolean;
  50115. /**
  50116. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50117. */
  50118. protected _useAlphaFromAlbedoTexture: boolean;
  50119. /**
  50120. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50121. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50122. */
  50123. protected _useSpecularOverAlpha: boolean;
  50124. /**
  50125. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50126. */
  50127. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50128. /**
  50129. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50130. */
  50131. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50132. /**
  50133. * Specifies if the metallic texture contains the roughness information in its green channel.
  50134. */
  50135. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50136. /**
  50137. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50138. */
  50139. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50140. /**
  50141. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50142. */
  50143. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50144. /**
  50145. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50146. */
  50147. protected _useAmbientInGrayScale: boolean;
  50148. /**
  50149. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50150. * The material will try to infer what glossiness each pixel should be.
  50151. */
  50152. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50153. /**
  50154. * Defines the falloff type used in this material.
  50155. * It by default is Physical.
  50156. */
  50157. protected _lightFalloff: number;
  50158. /**
  50159. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50160. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50161. */
  50162. protected _useRadianceOverAlpha: boolean;
  50163. /**
  50164. * Allows using an object space normal map (instead of tangent space).
  50165. */
  50166. protected _useObjectSpaceNormalMap: boolean;
  50167. /**
  50168. * Allows using the bump map in parallax mode.
  50169. */
  50170. protected _useParallax: boolean;
  50171. /**
  50172. * Allows using the bump map in parallax occlusion mode.
  50173. */
  50174. protected _useParallaxOcclusion: boolean;
  50175. /**
  50176. * Controls the scale bias of the parallax mode.
  50177. */
  50178. protected _parallaxScaleBias: number;
  50179. /**
  50180. * If sets to true, disables all the lights affecting the material.
  50181. */
  50182. protected _disableLighting: boolean;
  50183. /**
  50184. * Number of Simultaneous lights allowed on the material.
  50185. */
  50186. protected _maxSimultaneousLights: number;
  50187. /**
  50188. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50189. */
  50190. protected _invertNormalMapX: boolean;
  50191. /**
  50192. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50193. */
  50194. protected _invertNormalMapY: boolean;
  50195. /**
  50196. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50197. */
  50198. protected _twoSidedLighting: boolean;
  50199. /**
  50200. * Defines the alpha limits in alpha test mode.
  50201. */
  50202. protected _alphaCutOff: number;
  50203. /**
  50204. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50205. */
  50206. protected _forceAlphaTest: boolean;
  50207. /**
  50208. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50209. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50210. */
  50211. protected _useAlphaFresnel: boolean;
  50212. /**
  50213. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50214. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50215. */
  50216. protected _useLinearAlphaFresnel: boolean;
  50217. /**
  50218. * The transparency mode of the material.
  50219. */
  50220. protected _transparencyMode: Nullable<number>;
  50221. /**
  50222. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50223. * from cos thetav and roughness:
  50224. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50225. */
  50226. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50227. /**
  50228. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50229. */
  50230. protected _forceIrradianceInFragment: boolean;
  50231. /**
  50232. * Force normal to face away from face.
  50233. */
  50234. protected _forceNormalForward: boolean;
  50235. /**
  50236. * Enables specular anti aliasing in the PBR shader.
  50237. * It will both interacts on the Geometry for analytical and IBL lighting.
  50238. * It also prefilter the roughness map based on the bump values.
  50239. */
  50240. protected _enableSpecularAntiAliasing: boolean;
  50241. /**
  50242. * Default configuration related to image processing available in the PBR Material.
  50243. */
  50244. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50245. /**
  50246. * Keep track of the image processing observer to allow dispose and replace.
  50247. */
  50248. private _imageProcessingObserver;
  50249. /**
  50250. * Attaches a new image processing configuration to the PBR Material.
  50251. * @param configuration
  50252. */
  50253. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50254. /**
  50255. * Stores the available render targets.
  50256. */
  50257. private _renderTargets;
  50258. /**
  50259. * Sets the global ambient color for the material used in lighting calculations.
  50260. */
  50261. private _globalAmbientColor;
  50262. /**
  50263. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50264. */
  50265. private _useLogarithmicDepth;
  50266. /**
  50267. * If set to true, no lighting calculations will be applied.
  50268. */
  50269. private _unlit;
  50270. private _debugMode;
  50271. /**
  50272. * @hidden
  50273. * This is reserved for the inspector.
  50274. * Defines the material debug mode.
  50275. * It helps seeing only some components of the material while troubleshooting.
  50276. */
  50277. debugMode: number;
  50278. /**
  50279. * @hidden
  50280. * This is reserved for the inspector.
  50281. * Specify from where on screen the debug mode should start.
  50282. * The value goes from -1 (full screen) to 1 (not visible)
  50283. * It helps with side by side comparison against the final render
  50284. * This defaults to -1
  50285. */
  50286. private debugLimit;
  50287. /**
  50288. * @hidden
  50289. * This is reserved for the inspector.
  50290. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50291. * You can use the factor to better multiply the final value.
  50292. */
  50293. private debugFactor;
  50294. /**
  50295. * Defines the clear coat layer parameters for the material.
  50296. */
  50297. readonly clearCoat: PBRClearCoatConfiguration;
  50298. /**
  50299. * Defines the anisotropic parameters for the material.
  50300. */
  50301. readonly anisotropy: PBRAnisotropicConfiguration;
  50302. /**
  50303. * Defines the BRDF parameters for the material.
  50304. */
  50305. readonly brdf: PBRBRDFConfiguration;
  50306. /**
  50307. * Defines the Sheen parameters for the material.
  50308. */
  50309. readonly sheen: PBRSheenConfiguration;
  50310. /**
  50311. * Defines the SubSurface parameters for the material.
  50312. */
  50313. readonly subSurface: PBRSubSurfaceConfiguration;
  50314. /**
  50315. * Custom callback helping to override the default shader used in the material.
  50316. */
  50317. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50318. protected _rebuildInParallel: boolean;
  50319. /**
  50320. * Instantiates a new PBRMaterial instance.
  50321. *
  50322. * @param name The material name
  50323. * @param scene The scene the material will be use in.
  50324. */
  50325. constructor(name: string, scene: Scene);
  50326. /**
  50327. * Gets a boolean indicating that current material needs to register RTT
  50328. */
  50329. readonly hasRenderTargetTextures: boolean;
  50330. /**
  50331. * Gets the name of the material class.
  50332. */
  50333. getClassName(): string;
  50334. /**
  50335. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50336. */
  50337. /**
  50338. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50339. */
  50340. useLogarithmicDepth: boolean;
  50341. /**
  50342. * Gets the current transparency mode.
  50343. */
  50344. /**
  50345. * Sets the transparency mode of the material.
  50346. *
  50347. * | Value | Type | Description |
  50348. * | ----- | ----------------------------------- | ----------- |
  50349. * | 0 | OPAQUE | |
  50350. * | 1 | ALPHATEST | |
  50351. * | 2 | ALPHABLEND | |
  50352. * | 3 | ALPHATESTANDBLEND | |
  50353. *
  50354. */
  50355. transparencyMode: Nullable<number>;
  50356. /**
  50357. * Returns true if alpha blending should be disabled.
  50358. */
  50359. private readonly _disableAlphaBlending;
  50360. /**
  50361. * Specifies whether or not this material should be rendered in alpha blend mode.
  50362. */
  50363. needAlphaBlending(): boolean;
  50364. /**
  50365. * Specifies if the mesh will require alpha blending.
  50366. * @param mesh - BJS mesh.
  50367. */
  50368. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50369. /**
  50370. * Specifies whether or not this material should be rendered in alpha test mode.
  50371. */
  50372. needAlphaTesting(): boolean;
  50373. /**
  50374. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50375. */
  50376. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50377. /**
  50378. * Gets the texture used for the alpha test.
  50379. */
  50380. getAlphaTestTexture(): Nullable<BaseTexture>;
  50381. /**
  50382. * Specifies that the submesh is ready to be used.
  50383. * @param mesh - BJS mesh.
  50384. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50385. * @param useInstances - Specifies that instances should be used.
  50386. * @returns - boolean indicating that the submesh is ready or not.
  50387. */
  50388. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50389. /**
  50390. * Specifies if the material uses metallic roughness workflow.
  50391. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50392. */
  50393. isMetallicWorkflow(): boolean;
  50394. private _prepareEffect;
  50395. private _prepareDefines;
  50396. /**
  50397. * Force shader compilation
  50398. */
  50399. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50400. /**
  50401. * Initializes the uniform buffer layout for the shader.
  50402. */
  50403. buildUniformLayout(): void;
  50404. /**
  50405. * Unbinds the material from the mesh
  50406. */
  50407. unbind(): void;
  50408. /**
  50409. * Binds the submesh data.
  50410. * @param world - The world matrix.
  50411. * @param mesh - The BJS mesh.
  50412. * @param subMesh - A submesh of the BJS mesh.
  50413. */
  50414. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50415. /**
  50416. * Returns the animatable textures.
  50417. * @returns - Array of animatable textures.
  50418. */
  50419. getAnimatables(): IAnimatable[];
  50420. /**
  50421. * Returns the texture used for reflections.
  50422. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50423. */
  50424. private _getReflectionTexture;
  50425. /**
  50426. * Returns an array of the actively used textures.
  50427. * @returns - Array of BaseTextures
  50428. */
  50429. getActiveTextures(): BaseTexture[];
  50430. /**
  50431. * Checks to see if a texture is used in the material.
  50432. * @param texture - Base texture to use.
  50433. * @returns - Boolean specifying if a texture is used in the material.
  50434. */
  50435. hasTexture(texture: BaseTexture): boolean;
  50436. /**
  50437. * Disposes the resources of the material.
  50438. * @param forceDisposeEffect - Forces the disposal of effects.
  50439. * @param forceDisposeTextures - Forces the disposal of all textures.
  50440. */
  50441. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50442. }
  50443. }
  50444. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50445. import { Nullable } from "babylonjs/types";
  50446. import { Scene } from "babylonjs/scene";
  50447. import { Color3 } from "babylonjs/Maths/math.color";
  50448. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50449. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50451. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50452. /**
  50453. * The Physically based material of BJS.
  50454. *
  50455. * This offers the main features of a standard PBR material.
  50456. * For more information, please refer to the documentation :
  50457. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50458. */
  50459. export class PBRMaterial extends PBRBaseMaterial {
  50460. /**
  50461. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50462. */
  50463. static readonly PBRMATERIAL_OPAQUE: number;
  50464. /**
  50465. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50466. */
  50467. static readonly PBRMATERIAL_ALPHATEST: number;
  50468. /**
  50469. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50470. */
  50471. static readonly PBRMATERIAL_ALPHABLEND: number;
  50472. /**
  50473. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50474. * They are also discarded below the alpha cutoff threshold to improve performances.
  50475. */
  50476. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50477. /**
  50478. * Defines the default value of how much AO map is occluding the analytical lights
  50479. * (point spot...).
  50480. */
  50481. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50482. /**
  50483. * Intensity of the direct lights e.g. the four lights available in your scene.
  50484. * This impacts both the direct diffuse and specular highlights.
  50485. */
  50486. directIntensity: number;
  50487. /**
  50488. * Intensity of the emissive part of the material.
  50489. * This helps controlling the emissive effect without modifying the emissive color.
  50490. */
  50491. emissiveIntensity: number;
  50492. /**
  50493. * Intensity of the environment e.g. how much the environment will light the object
  50494. * either through harmonics for rough material or through the refelction for shiny ones.
  50495. */
  50496. environmentIntensity: number;
  50497. /**
  50498. * This is a special control allowing the reduction of the specular highlights coming from the
  50499. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50500. */
  50501. specularIntensity: number;
  50502. /**
  50503. * Debug Control allowing disabling the bump map on this material.
  50504. */
  50505. disableBumpMap: boolean;
  50506. /**
  50507. * AKA Diffuse Texture in standard nomenclature.
  50508. */
  50509. albedoTexture: BaseTexture;
  50510. /**
  50511. * AKA Occlusion Texture in other nomenclature.
  50512. */
  50513. ambientTexture: BaseTexture;
  50514. /**
  50515. * AKA Occlusion Texture Intensity in other nomenclature.
  50516. */
  50517. ambientTextureStrength: number;
  50518. /**
  50519. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50520. * 1 means it completely occludes it
  50521. * 0 mean it has no impact
  50522. */
  50523. ambientTextureImpactOnAnalyticalLights: number;
  50524. /**
  50525. * Stores the alpha values in a texture.
  50526. */
  50527. opacityTexture: BaseTexture;
  50528. /**
  50529. * Stores the reflection values in a texture.
  50530. */
  50531. reflectionTexture: Nullable<BaseTexture>;
  50532. /**
  50533. * Stores the emissive values in a texture.
  50534. */
  50535. emissiveTexture: BaseTexture;
  50536. /**
  50537. * AKA Specular texture in other nomenclature.
  50538. */
  50539. reflectivityTexture: BaseTexture;
  50540. /**
  50541. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50542. */
  50543. metallicTexture: BaseTexture;
  50544. /**
  50545. * Specifies the metallic scalar of the metallic/roughness workflow.
  50546. * Can also be used to scale the metalness values of the metallic texture.
  50547. */
  50548. metallic: Nullable<number>;
  50549. /**
  50550. * Specifies the roughness scalar of the metallic/roughness workflow.
  50551. * Can also be used to scale the roughness values of the metallic texture.
  50552. */
  50553. roughness: Nullable<number>;
  50554. /**
  50555. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50556. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50557. */
  50558. microSurfaceTexture: BaseTexture;
  50559. /**
  50560. * Stores surface normal data used to displace a mesh in a texture.
  50561. */
  50562. bumpTexture: BaseTexture;
  50563. /**
  50564. * Stores the pre-calculated light information of a mesh in a texture.
  50565. */
  50566. lightmapTexture: BaseTexture;
  50567. /**
  50568. * Stores the refracted light information in a texture.
  50569. */
  50570. refractionTexture: Nullable<BaseTexture>;
  50571. /**
  50572. * The color of a material in ambient lighting.
  50573. */
  50574. ambientColor: Color3;
  50575. /**
  50576. * AKA Diffuse Color in other nomenclature.
  50577. */
  50578. albedoColor: Color3;
  50579. /**
  50580. * AKA Specular Color in other nomenclature.
  50581. */
  50582. reflectivityColor: Color3;
  50583. /**
  50584. * The color reflected from the material.
  50585. */
  50586. reflectionColor: Color3;
  50587. /**
  50588. * The color emitted from the material.
  50589. */
  50590. emissiveColor: Color3;
  50591. /**
  50592. * AKA Glossiness in other nomenclature.
  50593. */
  50594. microSurface: number;
  50595. /**
  50596. * source material index of refraction (IOR)' / 'destination material IOR.
  50597. */
  50598. indexOfRefraction: number;
  50599. /**
  50600. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50601. */
  50602. invertRefractionY: boolean;
  50603. /**
  50604. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50605. * Materials half opaque for instance using refraction could benefit from this control.
  50606. */
  50607. linkRefractionWithTransparency: boolean;
  50608. /**
  50609. * If true, the light map contains occlusion information instead of lighting info.
  50610. */
  50611. useLightmapAsShadowmap: boolean;
  50612. /**
  50613. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50614. */
  50615. useAlphaFromAlbedoTexture: boolean;
  50616. /**
  50617. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50618. */
  50619. forceAlphaTest: boolean;
  50620. /**
  50621. * Defines the alpha limits in alpha test mode.
  50622. */
  50623. alphaCutOff: number;
  50624. /**
  50625. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50626. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50627. */
  50628. useSpecularOverAlpha: boolean;
  50629. /**
  50630. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50631. */
  50632. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50633. /**
  50634. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50635. */
  50636. useRoughnessFromMetallicTextureAlpha: boolean;
  50637. /**
  50638. * Specifies if the metallic texture contains the roughness information in its green channel.
  50639. */
  50640. useRoughnessFromMetallicTextureGreen: boolean;
  50641. /**
  50642. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50643. */
  50644. useMetallnessFromMetallicTextureBlue: boolean;
  50645. /**
  50646. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50647. */
  50648. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50649. /**
  50650. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50651. */
  50652. useAmbientInGrayScale: boolean;
  50653. /**
  50654. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50655. * The material will try to infer what glossiness each pixel should be.
  50656. */
  50657. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50658. /**
  50659. * BJS is using an harcoded light falloff based on a manually sets up range.
  50660. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50661. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50662. */
  50663. /**
  50664. * BJS is using an harcoded light falloff based on a manually sets up range.
  50665. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50666. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50667. */
  50668. usePhysicalLightFalloff: boolean;
  50669. /**
  50670. * In order to support the falloff compatibility with gltf, a special mode has been added
  50671. * to reproduce the gltf light falloff.
  50672. */
  50673. /**
  50674. * In order to support the falloff compatibility with gltf, a special mode has been added
  50675. * to reproduce the gltf light falloff.
  50676. */
  50677. useGLTFLightFalloff: boolean;
  50678. /**
  50679. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50680. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50681. */
  50682. useRadianceOverAlpha: boolean;
  50683. /**
  50684. * Allows using an object space normal map (instead of tangent space).
  50685. */
  50686. useObjectSpaceNormalMap: boolean;
  50687. /**
  50688. * Allows using the bump map in parallax mode.
  50689. */
  50690. useParallax: boolean;
  50691. /**
  50692. * Allows using the bump map in parallax occlusion mode.
  50693. */
  50694. useParallaxOcclusion: boolean;
  50695. /**
  50696. * Controls the scale bias of the parallax mode.
  50697. */
  50698. parallaxScaleBias: number;
  50699. /**
  50700. * If sets to true, disables all the lights affecting the material.
  50701. */
  50702. disableLighting: boolean;
  50703. /**
  50704. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50705. */
  50706. forceIrradianceInFragment: boolean;
  50707. /**
  50708. * Number of Simultaneous lights allowed on the material.
  50709. */
  50710. maxSimultaneousLights: number;
  50711. /**
  50712. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50713. */
  50714. invertNormalMapX: boolean;
  50715. /**
  50716. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50717. */
  50718. invertNormalMapY: boolean;
  50719. /**
  50720. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50721. */
  50722. twoSidedLighting: boolean;
  50723. /**
  50724. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50725. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50726. */
  50727. useAlphaFresnel: boolean;
  50728. /**
  50729. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50730. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50731. */
  50732. useLinearAlphaFresnel: boolean;
  50733. /**
  50734. * Let user defines the brdf lookup texture used for IBL.
  50735. * A default 8bit version is embedded but you could point at :
  50736. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50737. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50738. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50739. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50740. */
  50741. environmentBRDFTexture: Nullable<BaseTexture>;
  50742. /**
  50743. * Force normal to face away from face.
  50744. */
  50745. forceNormalForward: boolean;
  50746. /**
  50747. * Enables specular anti aliasing in the PBR shader.
  50748. * It will both interacts on the Geometry for analytical and IBL lighting.
  50749. * It also prefilter the roughness map based on the bump values.
  50750. */
  50751. enableSpecularAntiAliasing: boolean;
  50752. /**
  50753. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50754. * makes the reflect vector face the model (under horizon).
  50755. */
  50756. useHorizonOcclusion: boolean;
  50757. /**
  50758. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50759. * too much the area relying on ambient texture to define their ambient occlusion.
  50760. */
  50761. useRadianceOcclusion: boolean;
  50762. /**
  50763. * If set to true, no lighting calculations will be applied.
  50764. */
  50765. unlit: boolean;
  50766. /**
  50767. * Gets the image processing configuration used either in this material.
  50768. */
  50769. /**
  50770. * Sets the Default image processing configuration used either in the this material.
  50771. *
  50772. * If sets to null, the scene one is in use.
  50773. */
  50774. imageProcessingConfiguration: ImageProcessingConfiguration;
  50775. /**
  50776. * Gets wether the color curves effect is enabled.
  50777. */
  50778. /**
  50779. * Sets wether the color curves effect is enabled.
  50780. */
  50781. cameraColorCurvesEnabled: boolean;
  50782. /**
  50783. * Gets wether the color grading effect is enabled.
  50784. */
  50785. /**
  50786. * Gets wether the color grading effect is enabled.
  50787. */
  50788. cameraColorGradingEnabled: boolean;
  50789. /**
  50790. * Gets wether tonemapping is enabled or not.
  50791. */
  50792. /**
  50793. * Sets wether tonemapping is enabled or not
  50794. */
  50795. cameraToneMappingEnabled: boolean;
  50796. /**
  50797. * The camera exposure used on this material.
  50798. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50799. * This corresponds to a photographic exposure.
  50800. */
  50801. /**
  50802. * The camera exposure used on this material.
  50803. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50804. * This corresponds to a photographic exposure.
  50805. */
  50806. cameraExposure: number;
  50807. /**
  50808. * Gets The camera contrast used on this material.
  50809. */
  50810. /**
  50811. * Sets The camera contrast used on this material.
  50812. */
  50813. cameraContrast: number;
  50814. /**
  50815. * Gets the Color Grading 2D Lookup Texture.
  50816. */
  50817. /**
  50818. * Sets the Color Grading 2D Lookup Texture.
  50819. */
  50820. cameraColorGradingTexture: Nullable<BaseTexture>;
  50821. /**
  50822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50824. * 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;
  50825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50826. */
  50827. /**
  50828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50830. * 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;
  50831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50832. */
  50833. cameraColorCurves: Nullable<ColorCurves>;
  50834. /**
  50835. * Instantiates a new PBRMaterial instance.
  50836. *
  50837. * @param name The material name
  50838. * @param scene The scene the material will be use in.
  50839. */
  50840. constructor(name: string, scene: Scene);
  50841. /**
  50842. * Returns the name of this material class.
  50843. */
  50844. getClassName(): string;
  50845. /**
  50846. * Makes a duplicate of the current material.
  50847. * @param name - name to use for the new material.
  50848. */
  50849. clone(name: string): PBRMaterial;
  50850. /**
  50851. * Serializes this PBR Material.
  50852. * @returns - An object with the serialized material.
  50853. */
  50854. serialize(): any;
  50855. /**
  50856. * Parses a PBR Material from a serialized object.
  50857. * @param source - Serialized object.
  50858. * @param scene - BJS scene instance.
  50859. * @param rootUrl - url for the scene object
  50860. * @returns - PBRMaterial
  50861. */
  50862. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50863. }
  50864. }
  50865. declare module "babylonjs/Misc/dds" {
  50866. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50868. import { Nullable } from "babylonjs/types";
  50869. import { Scene } from "babylonjs/scene";
  50870. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50871. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50872. /**
  50873. * Direct draw surface info
  50874. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50875. */
  50876. export interface DDSInfo {
  50877. /**
  50878. * Width of the texture
  50879. */
  50880. width: number;
  50881. /**
  50882. * Width of the texture
  50883. */
  50884. height: number;
  50885. /**
  50886. * Number of Mipmaps for the texture
  50887. * @see https://en.wikipedia.org/wiki/Mipmap
  50888. */
  50889. mipmapCount: number;
  50890. /**
  50891. * If the textures format is a known fourCC format
  50892. * @see https://www.fourcc.org/
  50893. */
  50894. isFourCC: boolean;
  50895. /**
  50896. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50897. */
  50898. isRGB: boolean;
  50899. /**
  50900. * If the texture is a lumincance format
  50901. */
  50902. isLuminance: boolean;
  50903. /**
  50904. * If this is a cube texture
  50905. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50906. */
  50907. isCube: boolean;
  50908. /**
  50909. * If the texture is a compressed format eg. FOURCC_DXT1
  50910. */
  50911. isCompressed: boolean;
  50912. /**
  50913. * The dxgiFormat of the texture
  50914. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50915. */
  50916. dxgiFormat: number;
  50917. /**
  50918. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50919. */
  50920. textureType: number;
  50921. /**
  50922. * Sphericle polynomial created for the dds texture
  50923. */
  50924. sphericalPolynomial?: SphericalPolynomial;
  50925. }
  50926. /**
  50927. * Class used to provide DDS decompression tools
  50928. */
  50929. export class DDSTools {
  50930. /**
  50931. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50932. */
  50933. static StoreLODInAlphaChannel: boolean;
  50934. /**
  50935. * Gets DDS information from an array buffer
  50936. * @param arrayBuffer defines the array buffer to read data from
  50937. * @returns the DDS information
  50938. */
  50939. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50940. private static _FloatView;
  50941. private static _Int32View;
  50942. private static _ToHalfFloat;
  50943. private static _FromHalfFloat;
  50944. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50945. private static _GetHalfFloatRGBAArrayBuffer;
  50946. private static _GetFloatRGBAArrayBuffer;
  50947. private static _GetFloatAsUIntRGBAArrayBuffer;
  50948. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50949. private static _GetRGBAArrayBuffer;
  50950. private static _ExtractLongWordOrder;
  50951. private static _GetRGBArrayBuffer;
  50952. private static _GetLuminanceArrayBuffer;
  50953. /**
  50954. * Uploads DDS Levels to a Babylon Texture
  50955. * @hidden
  50956. */
  50957. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50958. }
  50959. module "babylonjs/Engines/thinEngine" {
  50960. interface ThinEngine {
  50961. /**
  50962. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50963. * @param rootUrl defines the url where the file to load is located
  50964. * @param scene defines the current scene
  50965. * @param lodScale defines scale to apply to the mip map selection
  50966. * @param lodOffset defines offset to apply to the mip map selection
  50967. * @param onLoad defines an optional callback raised when the texture is loaded
  50968. * @param onError defines an optional callback raised if there is an issue to load the texture
  50969. * @param format defines the format of the data
  50970. * @param forcedExtension defines the extension to use to pick the right loader
  50971. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50972. * @returns the cube texture as an InternalTexture
  50973. */
  50974. 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;
  50975. }
  50976. }
  50977. }
  50978. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50979. import { Nullable } from "babylonjs/types";
  50980. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50981. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50982. /**
  50983. * Implementation of the DDS Texture Loader.
  50984. * @hidden
  50985. */
  50986. export class _DDSTextureLoader implements IInternalTextureLoader {
  50987. /**
  50988. * Defines wether the loader supports cascade loading the different faces.
  50989. */
  50990. readonly supportCascades: boolean;
  50991. /**
  50992. * This returns if the loader support the current file information.
  50993. * @param extension defines the file extension of the file being loaded
  50994. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50995. * @param fallback defines the fallback internal texture if any
  50996. * @param isBase64 defines whether the texture is encoded as a base64
  50997. * @param isBuffer defines whether the texture data are stored as a buffer
  50998. * @returns true if the loader can load the specified file
  50999. */
  51000. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51001. /**
  51002. * Transform the url before loading if required.
  51003. * @param rootUrl the url of the texture
  51004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51005. * @returns the transformed texture
  51006. */
  51007. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51008. /**
  51009. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51010. * @param rootUrl the url of the texture
  51011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51012. * @returns the fallback texture
  51013. */
  51014. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51015. /**
  51016. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51017. * @param data contains the texture data
  51018. * @param texture defines the BabylonJS internal texture
  51019. * @param createPolynomials will be true if polynomials have been requested
  51020. * @param onLoad defines the callback to trigger once the texture is ready
  51021. * @param onError defines the callback to trigger in case of error
  51022. */
  51023. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51024. /**
  51025. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51026. * @param data contains the texture data
  51027. * @param texture defines the BabylonJS internal texture
  51028. * @param callback defines the method to call once ready to upload
  51029. */
  51030. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51031. }
  51032. }
  51033. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51034. import { Nullable } from "babylonjs/types";
  51035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51036. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51037. /**
  51038. * Implementation of the ENV Texture Loader.
  51039. * @hidden
  51040. */
  51041. export class _ENVTextureLoader implements IInternalTextureLoader {
  51042. /**
  51043. * Defines wether the loader supports cascade loading the different faces.
  51044. */
  51045. readonly supportCascades: boolean;
  51046. /**
  51047. * This returns if the loader support the current file information.
  51048. * @param extension defines the file extension of the file being loaded
  51049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51050. * @param fallback defines the fallback internal texture if any
  51051. * @param isBase64 defines whether the texture is encoded as a base64
  51052. * @param isBuffer defines whether the texture data are stored as a buffer
  51053. * @returns true if the loader can load the specified file
  51054. */
  51055. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51056. /**
  51057. * Transform the url before loading if required.
  51058. * @param rootUrl the url of the texture
  51059. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51060. * @returns the transformed texture
  51061. */
  51062. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51063. /**
  51064. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51065. * @param rootUrl the url of the texture
  51066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51067. * @returns the fallback texture
  51068. */
  51069. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51070. /**
  51071. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51072. * @param data contains the texture data
  51073. * @param texture defines the BabylonJS internal texture
  51074. * @param createPolynomials will be true if polynomials have been requested
  51075. * @param onLoad defines the callback to trigger once the texture is ready
  51076. * @param onError defines the callback to trigger in case of error
  51077. */
  51078. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51079. /**
  51080. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51081. * @param data contains the texture data
  51082. * @param texture defines the BabylonJS internal texture
  51083. * @param callback defines the method to call once ready to upload
  51084. */
  51085. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51086. }
  51087. }
  51088. declare module "babylonjs/Misc/khronosTextureContainer" {
  51089. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51090. /**
  51091. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51092. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51093. */
  51094. export class KhronosTextureContainer {
  51095. /** contents of the KTX container file */
  51096. arrayBuffer: any;
  51097. private static HEADER_LEN;
  51098. private static COMPRESSED_2D;
  51099. private static COMPRESSED_3D;
  51100. private static TEX_2D;
  51101. private static TEX_3D;
  51102. /**
  51103. * Gets the openGL type
  51104. */
  51105. glType: number;
  51106. /**
  51107. * Gets the openGL type size
  51108. */
  51109. glTypeSize: number;
  51110. /**
  51111. * Gets the openGL format
  51112. */
  51113. glFormat: number;
  51114. /**
  51115. * Gets the openGL internal format
  51116. */
  51117. glInternalFormat: number;
  51118. /**
  51119. * Gets the base internal format
  51120. */
  51121. glBaseInternalFormat: number;
  51122. /**
  51123. * Gets image width in pixel
  51124. */
  51125. pixelWidth: number;
  51126. /**
  51127. * Gets image height in pixel
  51128. */
  51129. pixelHeight: number;
  51130. /**
  51131. * Gets image depth in pixels
  51132. */
  51133. pixelDepth: number;
  51134. /**
  51135. * Gets the number of array elements
  51136. */
  51137. numberOfArrayElements: number;
  51138. /**
  51139. * Gets the number of faces
  51140. */
  51141. numberOfFaces: number;
  51142. /**
  51143. * Gets the number of mipmap levels
  51144. */
  51145. numberOfMipmapLevels: number;
  51146. /**
  51147. * Gets the bytes of key value data
  51148. */
  51149. bytesOfKeyValueData: number;
  51150. /**
  51151. * Gets the load type
  51152. */
  51153. loadType: number;
  51154. /**
  51155. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51156. */
  51157. isInvalid: boolean;
  51158. /**
  51159. * Creates a new KhronosTextureContainer
  51160. * @param arrayBuffer contents of the KTX container file
  51161. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51162. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51163. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51164. */
  51165. constructor(
  51166. /** contents of the KTX container file */
  51167. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51168. /**
  51169. * Uploads KTX content to a Babylon Texture.
  51170. * It is assumed that the texture has already been created & is currently bound
  51171. * @hidden
  51172. */
  51173. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51174. private _upload2DCompressedLevels;
  51175. }
  51176. }
  51177. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51178. import { Nullable } from "babylonjs/types";
  51179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51180. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51181. /**
  51182. * Implementation of the KTX Texture Loader.
  51183. * @hidden
  51184. */
  51185. export class _KTXTextureLoader implements IInternalTextureLoader {
  51186. /**
  51187. * Defines wether the loader supports cascade loading the different faces.
  51188. */
  51189. readonly supportCascades: boolean;
  51190. /**
  51191. * This returns if the loader support the current file information.
  51192. * @param extension defines the file extension of the file being loaded
  51193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51194. * @param fallback defines the fallback internal texture if any
  51195. * @param isBase64 defines whether the texture is encoded as a base64
  51196. * @param isBuffer defines whether the texture data are stored as a buffer
  51197. * @returns true if the loader can load the specified file
  51198. */
  51199. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51200. /**
  51201. * Transform the url before loading if required.
  51202. * @param rootUrl the url of the texture
  51203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51204. * @returns the transformed texture
  51205. */
  51206. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51207. /**
  51208. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51209. * @param rootUrl the url of the texture
  51210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51211. * @returns the fallback texture
  51212. */
  51213. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51214. /**
  51215. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51216. * @param data contains the texture data
  51217. * @param texture defines the BabylonJS internal texture
  51218. * @param createPolynomials will be true if polynomials have been requested
  51219. * @param onLoad defines the callback to trigger once the texture is ready
  51220. * @param onError defines the callback to trigger in case of error
  51221. */
  51222. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51223. /**
  51224. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51225. * @param data contains the texture data
  51226. * @param texture defines the BabylonJS internal texture
  51227. * @param callback defines the method to call once ready to upload
  51228. */
  51229. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51230. }
  51231. }
  51232. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  51233. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  51234. import { Scene } from "babylonjs/scene";
  51235. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  51236. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  51237. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  51238. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  51239. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  51240. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  51241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51242. /**
  51243. * Options for the default xr helper
  51244. */
  51245. export class WebXRDefaultExperienceOptions {
  51246. /**
  51247. * Floor meshes that should be used for teleporting
  51248. */
  51249. floorMeshes: Array<AbstractMesh>;
  51250. /**
  51251. * Enable or disable default UI to enter XR
  51252. */
  51253. disableDefaultUI: boolean;
  51254. }
  51255. /**
  51256. * Default experience which provides a similar setup to the previous webVRExperience
  51257. */
  51258. export class WebXRDefaultExperience {
  51259. /**
  51260. * Base experience
  51261. */
  51262. baseExperience: WebXRExperienceHelper;
  51263. /**
  51264. * Input experience extension
  51265. */
  51266. input: WebXRInput;
  51267. /**
  51268. * Loads the controller models
  51269. */
  51270. controllerModelLoader: WebXRControllerModelLoader;
  51271. /**
  51272. * Enables laser pointer and selection
  51273. */
  51274. pointerSelection: WebXRControllerPointerSelection;
  51275. /**
  51276. * Enables teleportation
  51277. */
  51278. teleportation: WebXRControllerTeleportation;
  51279. /**
  51280. * Enables ui for enetering/exiting xr
  51281. */
  51282. enterExitUI: WebXREnterExitUI;
  51283. /**
  51284. * Default target xr should render to
  51285. */
  51286. renderTarget: WebXRRenderTarget;
  51287. /**
  51288. * Creates the default xr experience
  51289. * @param scene scene
  51290. * @param options options for basic configuration
  51291. * @returns resulting WebXRDefaultExperience
  51292. */
  51293. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51294. private constructor();
  51295. /**
  51296. * DIsposes of the experience helper
  51297. */
  51298. dispose(): void;
  51299. }
  51300. }
  51301. declare module "babylonjs/Helpers/sceneHelpers" {
  51302. import { Nullable } from "babylonjs/types";
  51303. import { Mesh } from "babylonjs/Meshes/mesh";
  51304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51305. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51306. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51307. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51308. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51309. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51310. import "babylonjs/Meshes/Builders/boxBuilder";
  51311. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51312. /** @hidden */
  51313. export var _forceSceneHelpersToBundle: boolean;
  51314. module "babylonjs/scene" {
  51315. interface Scene {
  51316. /**
  51317. * Creates a default light for the scene.
  51318. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51319. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51320. */
  51321. createDefaultLight(replace?: boolean): void;
  51322. /**
  51323. * Creates a default camera for the scene.
  51324. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51325. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51326. * @param replace has default false, when true replaces the active camera in the scene
  51327. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51328. */
  51329. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51330. /**
  51331. * Creates a default camera and a default light.
  51332. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51333. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51334. * @param replace has the default false, when true replaces the active camera/light in the scene
  51335. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51336. */
  51337. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51338. /**
  51339. * Creates a new sky box
  51340. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51341. * @param environmentTexture defines the texture to use as environment texture
  51342. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51343. * @param scale defines the overall scale of the skybox
  51344. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51345. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51346. * @returns a new mesh holding the sky box
  51347. */
  51348. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51349. /**
  51350. * Creates a new environment
  51351. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51352. * @param options defines the options you can use to configure the environment
  51353. * @returns the new EnvironmentHelper
  51354. */
  51355. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51356. /**
  51357. * Creates a new VREXperienceHelper
  51358. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51359. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51360. * @returns a new VREXperienceHelper
  51361. */
  51362. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51363. /**
  51364. * Creates a new WebXRDefaultExperience
  51365. * @see http://doc.babylonjs.com/how_to/webxr
  51366. * @param options experience options
  51367. * @returns a promise for a new WebXRDefaultExperience
  51368. */
  51369. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51370. }
  51371. }
  51372. }
  51373. declare module "babylonjs/Helpers/videoDome" {
  51374. import { Scene } from "babylonjs/scene";
  51375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51376. import { Mesh } from "babylonjs/Meshes/mesh";
  51377. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51378. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51379. import "babylonjs/Meshes/Builders/sphereBuilder";
  51380. /**
  51381. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51382. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51383. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51384. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51385. */
  51386. export class VideoDome extends TransformNode {
  51387. /**
  51388. * Define the video source as a Monoscopic panoramic 360 video.
  51389. */
  51390. static readonly MODE_MONOSCOPIC: number;
  51391. /**
  51392. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51393. */
  51394. static readonly MODE_TOPBOTTOM: number;
  51395. /**
  51396. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51397. */
  51398. static readonly MODE_SIDEBYSIDE: number;
  51399. private _halfDome;
  51400. private _useDirectMapping;
  51401. /**
  51402. * The video texture being displayed on the sphere
  51403. */
  51404. protected _videoTexture: VideoTexture;
  51405. /**
  51406. * Gets the video texture being displayed on the sphere
  51407. */
  51408. readonly videoTexture: VideoTexture;
  51409. /**
  51410. * The skybox material
  51411. */
  51412. protected _material: BackgroundMaterial;
  51413. /**
  51414. * The surface used for the skybox
  51415. */
  51416. protected _mesh: Mesh;
  51417. /**
  51418. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51419. */
  51420. private _halfDomeMask;
  51421. /**
  51422. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51423. * Also see the options.resolution property.
  51424. */
  51425. fovMultiplier: number;
  51426. private _videoMode;
  51427. /**
  51428. * Gets or set the current video mode for the video. It can be:
  51429. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51430. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51431. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51432. */
  51433. videoMode: number;
  51434. /**
  51435. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51436. *
  51437. */
  51438. /**
  51439. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51440. */
  51441. halfDome: boolean;
  51442. /**
  51443. * Oberserver used in Stereoscopic VR Mode.
  51444. */
  51445. private _onBeforeCameraRenderObserver;
  51446. /**
  51447. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51448. * @param name Element's name, child elements will append suffixes for their own names.
  51449. * @param urlsOrVideo defines the url(s) or the video element to use
  51450. * @param options An object containing optional or exposed sub element properties
  51451. */
  51452. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51453. resolution?: number;
  51454. clickToPlay?: boolean;
  51455. autoPlay?: boolean;
  51456. loop?: boolean;
  51457. size?: number;
  51458. poster?: string;
  51459. faceForward?: boolean;
  51460. useDirectMapping?: boolean;
  51461. halfDomeMode?: boolean;
  51462. }, scene: Scene);
  51463. private _changeVideoMode;
  51464. /**
  51465. * Releases resources associated with this node.
  51466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51468. */
  51469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51470. }
  51471. }
  51472. declare module "babylonjs/Helpers/index" {
  51473. export * from "babylonjs/Helpers/environmentHelper";
  51474. export * from "babylonjs/Helpers/photoDome";
  51475. export * from "babylonjs/Helpers/sceneHelpers";
  51476. export * from "babylonjs/Helpers/videoDome";
  51477. }
  51478. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51479. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51480. import { IDisposable } from "babylonjs/scene";
  51481. import { Engine } from "babylonjs/Engines/engine";
  51482. /**
  51483. * This class can be used to get instrumentation data from a Babylon engine
  51484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51485. */
  51486. export class EngineInstrumentation implements IDisposable {
  51487. /**
  51488. * Define the instrumented engine.
  51489. */
  51490. engine: Engine;
  51491. private _captureGPUFrameTime;
  51492. private _gpuFrameTimeToken;
  51493. private _gpuFrameTime;
  51494. private _captureShaderCompilationTime;
  51495. private _shaderCompilationTime;
  51496. private _onBeginFrameObserver;
  51497. private _onEndFrameObserver;
  51498. private _onBeforeShaderCompilationObserver;
  51499. private _onAfterShaderCompilationObserver;
  51500. /**
  51501. * Gets the perf counter used for GPU frame time
  51502. */
  51503. readonly gpuFrameTimeCounter: PerfCounter;
  51504. /**
  51505. * Gets the GPU frame time capture status
  51506. */
  51507. /**
  51508. * Enable or disable the GPU frame time capture
  51509. */
  51510. captureGPUFrameTime: boolean;
  51511. /**
  51512. * Gets the perf counter used for shader compilation time
  51513. */
  51514. readonly shaderCompilationTimeCounter: PerfCounter;
  51515. /**
  51516. * Gets the shader compilation time capture status
  51517. */
  51518. /**
  51519. * Enable or disable the shader compilation time capture
  51520. */
  51521. captureShaderCompilationTime: boolean;
  51522. /**
  51523. * Instantiates a new engine instrumentation.
  51524. * This class can be used to get instrumentation data from a Babylon engine
  51525. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51526. * @param engine Defines the engine to instrument
  51527. */
  51528. constructor(
  51529. /**
  51530. * Define the instrumented engine.
  51531. */
  51532. engine: Engine);
  51533. /**
  51534. * Dispose and release associated resources.
  51535. */
  51536. dispose(): void;
  51537. }
  51538. }
  51539. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51540. import { Scene, IDisposable } from "babylonjs/scene";
  51541. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51542. /**
  51543. * This class can be used to get instrumentation data from a Babylon engine
  51544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51545. */
  51546. export class SceneInstrumentation implements IDisposable {
  51547. /**
  51548. * Defines the scene to instrument
  51549. */
  51550. scene: Scene;
  51551. private _captureActiveMeshesEvaluationTime;
  51552. private _activeMeshesEvaluationTime;
  51553. private _captureRenderTargetsRenderTime;
  51554. private _renderTargetsRenderTime;
  51555. private _captureFrameTime;
  51556. private _frameTime;
  51557. private _captureRenderTime;
  51558. private _renderTime;
  51559. private _captureInterFrameTime;
  51560. private _interFrameTime;
  51561. private _captureParticlesRenderTime;
  51562. private _particlesRenderTime;
  51563. private _captureSpritesRenderTime;
  51564. private _spritesRenderTime;
  51565. private _capturePhysicsTime;
  51566. private _physicsTime;
  51567. private _captureAnimationsTime;
  51568. private _animationsTime;
  51569. private _captureCameraRenderTime;
  51570. private _cameraRenderTime;
  51571. private _onBeforeActiveMeshesEvaluationObserver;
  51572. private _onAfterActiveMeshesEvaluationObserver;
  51573. private _onBeforeRenderTargetsRenderObserver;
  51574. private _onAfterRenderTargetsRenderObserver;
  51575. private _onAfterRenderObserver;
  51576. private _onBeforeDrawPhaseObserver;
  51577. private _onAfterDrawPhaseObserver;
  51578. private _onBeforeAnimationsObserver;
  51579. private _onBeforeParticlesRenderingObserver;
  51580. private _onAfterParticlesRenderingObserver;
  51581. private _onBeforeSpritesRenderingObserver;
  51582. private _onAfterSpritesRenderingObserver;
  51583. private _onBeforePhysicsObserver;
  51584. private _onAfterPhysicsObserver;
  51585. private _onAfterAnimationsObserver;
  51586. private _onBeforeCameraRenderObserver;
  51587. private _onAfterCameraRenderObserver;
  51588. /**
  51589. * Gets the perf counter used for active meshes evaluation time
  51590. */
  51591. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51592. /**
  51593. * Gets the active meshes evaluation time capture status
  51594. */
  51595. /**
  51596. * Enable or disable the active meshes evaluation time capture
  51597. */
  51598. captureActiveMeshesEvaluationTime: boolean;
  51599. /**
  51600. * Gets the perf counter used for render targets render time
  51601. */
  51602. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51603. /**
  51604. * Gets the render targets render time capture status
  51605. */
  51606. /**
  51607. * Enable or disable the render targets render time capture
  51608. */
  51609. captureRenderTargetsRenderTime: boolean;
  51610. /**
  51611. * Gets the perf counter used for particles render time
  51612. */
  51613. readonly particlesRenderTimeCounter: PerfCounter;
  51614. /**
  51615. * Gets the particles render time capture status
  51616. */
  51617. /**
  51618. * Enable or disable the particles render time capture
  51619. */
  51620. captureParticlesRenderTime: boolean;
  51621. /**
  51622. * Gets the perf counter used for sprites render time
  51623. */
  51624. readonly spritesRenderTimeCounter: PerfCounter;
  51625. /**
  51626. * Gets the sprites render time capture status
  51627. */
  51628. /**
  51629. * Enable or disable the sprites render time capture
  51630. */
  51631. captureSpritesRenderTime: boolean;
  51632. /**
  51633. * Gets the perf counter used for physics time
  51634. */
  51635. readonly physicsTimeCounter: PerfCounter;
  51636. /**
  51637. * Gets the physics time capture status
  51638. */
  51639. /**
  51640. * Enable or disable the physics time capture
  51641. */
  51642. capturePhysicsTime: boolean;
  51643. /**
  51644. * Gets the perf counter used for animations time
  51645. */
  51646. readonly animationsTimeCounter: PerfCounter;
  51647. /**
  51648. * Gets the animations time capture status
  51649. */
  51650. /**
  51651. * Enable or disable the animations time capture
  51652. */
  51653. captureAnimationsTime: boolean;
  51654. /**
  51655. * Gets the perf counter used for frame time capture
  51656. */
  51657. readonly frameTimeCounter: PerfCounter;
  51658. /**
  51659. * Gets the frame time capture status
  51660. */
  51661. /**
  51662. * Enable or disable the frame time capture
  51663. */
  51664. captureFrameTime: boolean;
  51665. /**
  51666. * Gets the perf counter used for inter-frames time capture
  51667. */
  51668. readonly interFrameTimeCounter: PerfCounter;
  51669. /**
  51670. * Gets the inter-frames time capture status
  51671. */
  51672. /**
  51673. * Enable or disable the inter-frames time capture
  51674. */
  51675. captureInterFrameTime: boolean;
  51676. /**
  51677. * Gets the perf counter used for render time capture
  51678. */
  51679. readonly renderTimeCounter: PerfCounter;
  51680. /**
  51681. * Gets the render time capture status
  51682. */
  51683. /**
  51684. * Enable or disable the render time capture
  51685. */
  51686. captureRenderTime: boolean;
  51687. /**
  51688. * Gets the perf counter used for camera render time capture
  51689. */
  51690. readonly cameraRenderTimeCounter: PerfCounter;
  51691. /**
  51692. * Gets the camera render time capture status
  51693. */
  51694. /**
  51695. * Enable or disable the camera render time capture
  51696. */
  51697. captureCameraRenderTime: boolean;
  51698. /**
  51699. * Gets the perf counter used for draw calls
  51700. */
  51701. readonly drawCallsCounter: PerfCounter;
  51702. /**
  51703. * Instantiates a new scene instrumentation.
  51704. * This class can be used to get instrumentation data from a Babylon engine
  51705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51706. * @param scene Defines the scene to instrument
  51707. */
  51708. constructor(
  51709. /**
  51710. * Defines the scene to instrument
  51711. */
  51712. scene: Scene);
  51713. /**
  51714. * Dispose and release associated resources.
  51715. */
  51716. dispose(): void;
  51717. }
  51718. }
  51719. declare module "babylonjs/Instrumentation/index" {
  51720. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51721. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51722. export * from "babylonjs/Instrumentation/timeToken";
  51723. }
  51724. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51725. /** @hidden */
  51726. export var glowMapGenerationPixelShader: {
  51727. name: string;
  51728. shader: string;
  51729. };
  51730. }
  51731. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51732. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51733. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51735. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51736. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51737. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51738. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51739. /** @hidden */
  51740. export var glowMapGenerationVertexShader: {
  51741. name: string;
  51742. shader: string;
  51743. };
  51744. }
  51745. declare module "babylonjs/Layers/effectLayer" {
  51746. import { Observable } from "babylonjs/Misc/observable";
  51747. import { Nullable } from "babylonjs/types";
  51748. import { Camera } from "babylonjs/Cameras/camera";
  51749. import { Scene } from "babylonjs/scene";
  51750. import { ISize } from "babylonjs/Maths/math.size";
  51751. import { Color4 } from "babylonjs/Maths/math.color";
  51752. import { Engine } from "babylonjs/Engines/engine";
  51753. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51755. import { Mesh } from "babylonjs/Meshes/mesh";
  51756. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51758. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51759. import { Effect } from "babylonjs/Materials/effect";
  51760. import { Material } from "babylonjs/Materials/material";
  51761. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51762. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51763. /**
  51764. * Effect layer options. This helps customizing the behaviour
  51765. * of the effect layer.
  51766. */
  51767. export interface IEffectLayerOptions {
  51768. /**
  51769. * Multiplication factor apply to the canvas size to compute the render target size
  51770. * used to generated the objects (the smaller the faster).
  51771. */
  51772. mainTextureRatio: number;
  51773. /**
  51774. * Enforces a fixed size texture to ensure effect stability across devices.
  51775. */
  51776. mainTextureFixedSize?: number;
  51777. /**
  51778. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51779. */
  51780. alphaBlendingMode: number;
  51781. /**
  51782. * The camera attached to the layer.
  51783. */
  51784. camera: Nullable<Camera>;
  51785. /**
  51786. * The rendering group to draw the layer in.
  51787. */
  51788. renderingGroupId: number;
  51789. }
  51790. /**
  51791. * The effect layer Helps adding post process effect blended with the main pass.
  51792. *
  51793. * This can be for instance use to generate glow or higlight effects on the scene.
  51794. *
  51795. * The effect layer class can not be used directly and is intented to inherited from to be
  51796. * customized per effects.
  51797. */
  51798. export abstract class EffectLayer {
  51799. private _vertexBuffers;
  51800. private _indexBuffer;
  51801. private _cachedDefines;
  51802. private _effectLayerMapGenerationEffect;
  51803. private _effectLayerOptions;
  51804. private _mergeEffect;
  51805. protected _scene: Scene;
  51806. protected _engine: Engine;
  51807. protected _maxSize: number;
  51808. protected _mainTextureDesiredSize: ISize;
  51809. protected _mainTexture: RenderTargetTexture;
  51810. protected _shouldRender: boolean;
  51811. protected _postProcesses: PostProcess[];
  51812. protected _textures: BaseTexture[];
  51813. protected _emissiveTextureAndColor: {
  51814. texture: Nullable<BaseTexture>;
  51815. color: Color4;
  51816. };
  51817. /**
  51818. * The name of the layer
  51819. */
  51820. name: string;
  51821. /**
  51822. * The clear color of the texture used to generate the glow map.
  51823. */
  51824. neutralColor: Color4;
  51825. /**
  51826. * Specifies wether the highlight layer is enabled or not.
  51827. */
  51828. isEnabled: boolean;
  51829. /**
  51830. * Gets the camera attached to the layer.
  51831. */
  51832. readonly camera: Nullable<Camera>;
  51833. /**
  51834. * Gets the rendering group id the layer should render in.
  51835. */
  51836. renderingGroupId: number;
  51837. /**
  51838. * An event triggered when the effect layer has been disposed.
  51839. */
  51840. onDisposeObservable: Observable<EffectLayer>;
  51841. /**
  51842. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51843. */
  51844. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51845. /**
  51846. * An event triggered when the generated texture is being merged in the scene.
  51847. */
  51848. onBeforeComposeObservable: Observable<EffectLayer>;
  51849. /**
  51850. * An event triggered when the mesh is rendered into the effect render target.
  51851. */
  51852. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  51853. /**
  51854. * An event triggered after the mesh has been rendered into the effect render target.
  51855. */
  51856. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  51857. /**
  51858. * An event triggered when the generated texture has been merged in the scene.
  51859. */
  51860. onAfterComposeObservable: Observable<EffectLayer>;
  51861. /**
  51862. * An event triggered when the efffect layer changes its size.
  51863. */
  51864. onSizeChangedObservable: Observable<EffectLayer>;
  51865. /** @hidden */
  51866. static _SceneComponentInitialization: (scene: Scene) => void;
  51867. /**
  51868. * Instantiates a new effect Layer and references it in the scene.
  51869. * @param name The name of the layer
  51870. * @param scene The scene to use the layer in
  51871. */
  51872. constructor(
  51873. /** The Friendly of the effect in the scene */
  51874. name: string, scene: Scene);
  51875. /**
  51876. * Get the effect name of the layer.
  51877. * @return The effect name
  51878. */
  51879. abstract getEffectName(): string;
  51880. /**
  51881. * Checks for the readiness of the element composing the layer.
  51882. * @param subMesh the mesh to check for
  51883. * @param useInstances specify wether or not to use instances to render the mesh
  51884. * @return true if ready otherwise, false
  51885. */
  51886. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51887. /**
  51888. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51889. * @returns true if the effect requires stencil during the main canvas render pass.
  51890. */
  51891. abstract needStencil(): boolean;
  51892. /**
  51893. * Create the merge effect. This is the shader use to blit the information back
  51894. * to the main canvas at the end of the scene rendering.
  51895. * @returns The effect containing the shader used to merge the effect on the main canvas
  51896. */
  51897. protected abstract _createMergeEffect(): Effect;
  51898. /**
  51899. * Creates the render target textures and post processes used in the effect layer.
  51900. */
  51901. protected abstract _createTextureAndPostProcesses(): void;
  51902. /**
  51903. * Implementation specific of rendering the generating effect on the main canvas.
  51904. * @param effect The effect used to render through
  51905. */
  51906. protected abstract _internalRender(effect: Effect): void;
  51907. /**
  51908. * Sets the required values for both the emissive texture and and the main color.
  51909. */
  51910. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51911. /**
  51912. * Free any resources and references associated to a mesh.
  51913. * Internal use
  51914. * @param mesh The mesh to free.
  51915. */
  51916. abstract _disposeMesh(mesh: Mesh): void;
  51917. /**
  51918. * Serializes this layer (Glow or Highlight for example)
  51919. * @returns a serialized layer object
  51920. */
  51921. abstract serialize?(): any;
  51922. /**
  51923. * Initializes the effect layer with the required options.
  51924. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51925. */
  51926. protected _init(options: Partial<IEffectLayerOptions>): void;
  51927. /**
  51928. * Generates the index buffer of the full screen quad blending to the main canvas.
  51929. */
  51930. private _generateIndexBuffer;
  51931. /**
  51932. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51933. */
  51934. private _generateVertexBuffer;
  51935. /**
  51936. * Sets the main texture desired size which is the closest power of two
  51937. * of the engine canvas size.
  51938. */
  51939. private _setMainTextureSize;
  51940. /**
  51941. * Creates the main texture for the effect layer.
  51942. */
  51943. protected _createMainTexture(): void;
  51944. /**
  51945. * Adds specific effects defines.
  51946. * @param defines The defines to add specifics to.
  51947. */
  51948. protected _addCustomEffectDefines(defines: string[]): void;
  51949. /**
  51950. * Checks for the readiness of the element composing the layer.
  51951. * @param subMesh the mesh to check for
  51952. * @param useInstances specify wether or not to use instances to render the mesh
  51953. * @param emissiveTexture the associated emissive texture used to generate the glow
  51954. * @return true if ready otherwise, false
  51955. */
  51956. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51957. /**
  51958. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51959. */
  51960. render(): void;
  51961. /**
  51962. * Determine if a given mesh will be used in the current effect.
  51963. * @param mesh mesh to test
  51964. * @returns true if the mesh will be used
  51965. */
  51966. hasMesh(mesh: AbstractMesh): boolean;
  51967. /**
  51968. * Returns true if the layer contains information to display, otherwise false.
  51969. * @returns true if the glow layer should be rendered
  51970. */
  51971. shouldRender(): boolean;
  51972. /**
  51973. * Returns true if the mesh should render, otherwise false.
  51974. * @param mesh The mesh to render
  51975. * @returns true if it should render otherwise false
  51976. */
  51977. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51978. /**
  51979. * Returns true if the mesh can be rendered, otherwise false.
  51980. * @param mesh The mesh to render
  51981. * @param material The material used on the mesh
  51982. * @returns true if it can be rendered otherwise false
  51983. */
  51984. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51985. /**
  51986. * Returns true if the mesh should render, otherwise false.
  51987. * @param mesh The mesh to render
  51988. * @returns true if it should render otherwise false
  51989. */
  51990. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51991. /**
  51992. * Renders the submesh passed in parameter to the generation map.
  51993. */
  51994. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51995. /**
  51996. * Defines wether the current material of the mesh should be use to render the effect.
  51997. * @param mesh defines the current mesh to render
  51998. */
  51999. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52000. /**
  52001. * Rebuild the required buffers.
  52002. * @hidden Internal use only.
  52003. */
  52004. _rebuild(): void;
  52005. /**
  52006. * Dispose only the render target textures and post process.
  52007. */
  52008. private _disposeTextureAndPostProcesses;
  52009. /**
  52010. * Dispose the highlight layer and free resources.
  52011. */
  52012. dispose(): void;
  52013. /**
  52014. * Gets the class name of the effect layer
  52015. * @returns the string with the class name of the effect layer
  52016. */
  52017. getClassName(): string;
  52018. /**
  52019. * Creates an effect layer from parsed effect layer data
  52020. * @param parsedEffectLayer defines effect layer data
  52021. * @param scene defines the current scene
  52022. * @param rootUrl defines the root URL containing the effect layer information
  52023. * @returns a parsed effect Layer
  52024. */
  52025. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52026. }
  52027. }
  52028. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52029. import { Scene } from "babylonjs/scene";
  52030. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52031. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52032. import { AbstractScene } from "babylonjs/abstractScene";
  52033. module "babylonjs/abstractScene" {
  52034. interface AbstractScene {
  52035. /**
  52036. * The list of effect layers (highlights/glow) added to the scene
  52037. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52038. * @see http://doc.babylonjs.com/how_to/glow_layer
  52039. */
  52040. effectLayers: Array<EffectLayer>;
  52041. /**
  52042. * Removes the given effect layer from this scene.
  52043. * @param toRemove defines the effect layer to remove
  52044. * @returns the index of the removed effect layer
  52045. */
  52046. removeEffectLayer(toRemove: EffectLayer): number;
  52047. /**
  52048. * Adds the given effect layer to this scene
  52049. * @param newEffectLayer defines the effect layer to add
  52050. */
  52051. addEffectLayer(newEffectLayer: EffectLayer): void;
  52052. }
  52053. }
  52054. /**
  52055. * Defines the layer scene component responsible to manage any effect layers
  52056. * in a given scene.
  52057. */
  52058. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52059. /**
  52060. * The component name helpfull to identify the component in the list of scene components.
  52061. */
  52062. readonly name: string;
  52063. /**
  52064. * The scene the component belongs to.
  52065. */
  52066. scene: Scene;
  52067. private _engine;
  52068. private _renderEffects;
  52069. private _needStencil;
  52070. private _previousStencilState;
  52071. /**
  52072. * Creates a new instance of the component for the given scene
  52073. * @param scene Defines the scene to register the component in
  52074. */
  52075. constructor(scene: Scene);
  52076. /**
  52077. * Registers the component in a given scene
  52078. */
  52079. register(): void;
  52080. /**
  52081. * Rebuilds the elements related to this component in case of
  52082. * context lost for instance.
  52083. */
  52084. rebuild(): void;
  52085. /**
  52086. * Serializes the component data to the specified json object
  52087. * @param serializationObject The object to serialize to
  52088. */
  52089. serialize(serializationObject: any): void;
  52090. /**
  52091. * Adds all the elements from the container to the scene
  52092. * @param container the container holding the elements
  52093. */
  52094. addFromContainer(container: AbstractScene): void;
  52095. /**
  52096. * Removes all the elements in the container from the scene
  52097. * @param container contains the elements to remove
  52098. * @param dispose if the removed element should be disposed (default: false)
  52099. */
  52100. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52101. /**
  52102. * Disposes the component and the associated ressources.
  52103. */
  52104. dispose(): void;
  52105. private _isReadyForMesh;
  52106. private _renderMainTexture;
  52107. private _setStencil;
  52108. private _setStencilBack;
  52109. private _draw;
  52110. private _drawCamera;
  52111. private _drawRenderingGroup;
  52112. }
  52113. }
  52114. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52115. /** @hidden */
  52116. export var glowMapMergePixelShader: {
  52117. name: string;
  52118. shader: string;
  52119. };
  52120. }
  52121. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52122. /** @hidden */
  52123. export var glowMapMergeVertexShader: {
  52124. name: string;
  52125. shader: string;
  52126. };
  52127. }
  52128. declare module "babylonjs/Layers/glowLayer" {
  52129. import { Nullable } from "babylonjs/types";
  52130. import { Camera } from "babylonjs/Cameras/camera";
  52131. import { Scene } from "babylonjs/scene";
  52132. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52134. import { Mesh } from "babylonjs/Meshes/mesh";
  52135. import { Texture } from "babylonjs/Materials/Textures/texture";
  52136. import { Effect } from "babylonjs/Materials/effect";
  52137. import { Material } from "babylonjs/Materials/material";
  52138. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52139. import { Color4 } from "babylonjs/Maths/math.color";
  52140. import "babylonjs/Shaders/glowMapMerge.fragment";
  52141. import "babylonjs/Shaders/glowMapMerge.vertex";
  52142. import "babylonjs/Layers/effectLayerSceneComponent";
  52143. module "babylonjs/abstractScene" {
  52144. interface AbstractScene {
  52145. /**
  52146. * Return a the first highlight layer of the scene with a given name.
  52147. * @param name The name of the highlight layer to look for.
  52148. * @return The highlight layer if found otherwise null.
  52149. */
  52150. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52151. }
  52152. }
  52153. /**
  52154. * Glow layer options. This helps customizing the behaviour
  52155. * of the glow layer.
  52156. */
  52157. export interface IGlowLayerOptions {
  52158. /**
  52159. * Multiplication factor apply to the canvas size to compute the render target size
  52160. * used to generated the glowing objects (the smaller the faster).
  52161. */
  52162. mainTextureRatio: number;
  52163. /**
  52164. * Enforces a fixed size texture to ensure resize independant blur.
  52165. */
  52166. mainTextureFixedSize?: number;
  52167. /**
  52168. * How big is the kernel of the blur texture.
  52169. */
  52170. blurKernelSize: number;
  52171. /**
  52172. * The camera attached to the layer.
  52173. */
  52174. camera: Nullable<Camera>;
  52175. /**
  52176. * Enable MSAA by chosing the number of samples.
  52177. */
  52178. mainTextureSamples?: number;
  52179. /**
  52180. * The rendering group to draw the layer in.
  52181. */
  52182. renderingGroupId: number;
  52183. }
  52184. /**
  52185. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52186. *
  52187. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52188. *
  52189. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52190. */
  52191. export class GlowLayer extends EffectLayer {
  52192. /**
  52193. * Effect Name of the layer.
  52194. */
  52195. static readonly EffectName: string;
  52196. /**
  52197. * The default blur kernel size used for the glow.
  52198. */
  52199. static DefaultBlurKernelSize: number;
  52200. /**
  52201. * The default texture size ratio used for the glow.
  52202. */
  52203. static DefaultTextureRatio: number;
  52204. /**
  52205. * Sets the kernel size of the blur.
  52206. */
  52207. /**
  52208. * Gets the kernel size of the blur.
  52209. */
  52210. blurKernelSize: number;
  52211. /**
  52212. * Sets the glow intensity.
  52213. */
  52214. /**
  52215. * Gets the glow intensity.
  52216. */
  52217. intensity: number;
  52218. private _options;
  52219. private _intensity;
  52220. private _horizontalBlurPostprocess1;
  52221. private _verticalBlurPostprocess1;
  52222. private _horizontalBlurPostprocess2;
  52223. private _verticalBlurPostprocess2;
  52224. private _blurTexture1;
  52225. private _blurTexture2;
  52226. private _postProcesses1;
  52227. private _postProcesses2;
  52228. private _includedOnlyMeshes;
  52229. private _excludedMeshes;
  52230. private _meshesUsingTheirOwnMaterials;
  52231. /**
  52232. * Callback used to let the user override the color selection on a per mesh basis
  52233. */
  52234. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52235. /**
  52236. * Callback used to let the user override the texture selection on a per mesh basis
  52237. */
  52238. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52239. /**
  52240. * Instantiates a new glow Layer and references it to the scene.
  52241. * @param name The name of the layer
  52242. * @param scene The scene to use the layer in
  52243. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52244. */
  52245. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52246. /**
  52247. * Get the effect name of the layer.
  52248. * @return The effect name
  52249. */
  52250. getEffectName(): string;
  52251. /**
  52252. * Create the merge effect. This is the shader use to blit the information back
  52253. * to the main canvas at the end of the scene rendering.
  52254. */
  52255. protected _createMergeEffect(): Effect;
  52256. /**
  52257. * Creates the render target textures and post processes used in the glow layer.
  52258. */
  52259. protected _createTextureAndPostProcesses(): void;
  52260. /**
  52261. * Checks for the readiness of the element composing the layer.
  52262. * @param subMesh the mesh to check for
  52263. * @param useInstances specify wether or not to use instances to render the mesh
  52264. * @param emissiveTexture the associated emissive texture used to generate the glow
  52265. * @return true if ready otherwise, false
  52266. */
  52267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52268. /**
  52269. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52270. */
  52271. needStencil(): boolean;
  52272. /**
  52273. * Returns true if the mesh can be rendered, otherwise false.
  52274. * @param mesh The mesh to render
  52275. * @param material The material used on the mesh
  52276. * @returns true if it can be rendered otherwise false
  52277. */
  52278. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52279. /**
  52280. * Implementation specific of rendering the generating effect on the main canvas.
  52281. * @param effect The effect used to render through
  52282. */
  52283. protected _internalRender(effect: Effect): void;
  52284. /**
  52285. * Sets the required values for both the emissive texture and and the main color.
  52286. */
  52287. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52288. /**
  52289. * Returns true if the mesh should render, otherwise false.
  52290. * @param mesh The mesh to render
  52291. * @returns true if it should render otherwise false
  52292. */
  52293. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52294. /**
  52295. * Adds specific effects defines.
  52296. * @param defines The defines to add specifics to.
  52297. */
  52298. protected _addCustomEffectDefines(defines: string[]): void;
  52299. /**
  52300. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52301. * @param mesh The mesh to exclude from the glow layer
  52302. */
  52303. addExcludedMesh(mesh: Mesh): void;
  52304. /**
  52305. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52306. * @param mesh The mesh to remove
  52307. */
  52308. removeExcludedMesh(mesh: Mesh): void;
  52309. /**
  52310. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52311. * @param mesh The mesh to include in the glow layer
  52312. */
  52313. addIncludedOnlyMesh(mesh: Mesh): void;
  52314. /**
  52315. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52316. * @param mesh The mesh to remove
  52317. */
  52318. removeIncludedOnlyMesh(mesh: Mesh): void;
  52319. /**
  52320. * Determine if a given mesh will be used in the glow layer
  52321. * @param mesh The mesh to test
  52322. * @returns true if the mesh will be highlighted by the current glow layer
  52323. */
  52324. hasMesh(mesh: AbstractMesh): boolean;
  52325. /**
  52326. * Defines wether the current material of the mesh should be use to render the effect.
  52327. * @param mesh defines the current mesh to render
  52328. */
  52329. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52330. /**
  52331. * Add a mesh to be rendered through its own material and not with emissive only.
  52332. * @param mesh The mesh for which we need to use its material
  52333. */
  52334. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52335. /**
  52336. * Remove a mesh from being rendered through its own material and not with emissive only.
  52337. * @param mesh The mesh for which we need to not use its material
  52338. */
  52339. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52340. /**
  52341. * Free any resources and references associated to a mesh.
  52342. * Internal use
  52343. * @param mesh The mesh to free.
  52344. * @hidden
  52345. */
  52346. _disposeMesh(mesh: Mesh): void;
  52347. /**
  52348. * Gets the class name of the effect layer
  52349. * @returns the string with the class name of the effect layer
  52350. */
  52351. getClassName(): string;
  52352. /**
  52353. * Serializes this glow layer
  52354. * @returns a serialized glow layer object
  52355. */
  52356. serialize(): any;
  52357. /**
  52358. * Creates a Glow Layer from parsed glow layer data
  52359. * @param parsedGlowLayer defines glow layer data
  52360. * @param scene defines the current scene
  52361. * @param rootUrl defines the root URL containing the glow layer information
  52362. * @returns a parsed Glow Layer
  52363. */
  52364. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52365. }
  52366. }
  52367. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52368. /** @hidden */
  52369. export var glowBlurPostProcessPixelShader: {
  52370. name: string;
  52371. shader: string;
  52372. };
  52373. }
  52374. declare module "babylonjs/Layers/highlightLayer" {
  52375. import { Observable } from "babylonjs/Misc/observable";
  52376. import { Nullable } from "babylonjs/types";
  52377. import { Camera } from "babylonjs/Cameras/camera";
  52378. import { Scene } from "babylonjs/scene";
  52379. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52381. import { Mesh } from "babylonjs/Meshes/mesh";
  52382. import { Effect } from "babylonjs/Materials/effect";
  52383. import { Material } from "babylonjs/Materials/material";
  52384. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52385. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52386. import "babylonjs/Shaders/glowMapMerge.fragment";
  52387. import "babylonjs/Shaders/glowMapMerge.vertex";
  52388. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52389. module "babylonjs/abstractScene" {
  52390. interface AbstractScene {
  52391. /**
  52392. * Return a the first highlight layer of the scene with a given name.
  52393. * @param name The name of the highlight layer to look for.
  52394. * @return The highlight layer if found otherwise null.
  52395. */
  52396. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52397. }
  52398. }
  52399. /**
  52400. * Highlight layer options. This helps customizing the behaviour
  52401. * of the highlight layer.
  52402. */
  52403. export interface IHighlightLayerOptions {
  52404. /**
  52405. * Multiplication factor apply to the canvas size to compute the render target size
  52406. * used to generated the glowing objects (the smaller the faster).
  52407. */
  52408. mainTextureRatio: number;
  52409. /**
  52410. * Enforces a fixed size texture to ensure resize independant blur.
  52411. */
  52412. mainTextureFixedSize?: number;
  52413. /**
  52414. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52415. * of the picture to blur (the smaller the faster).
  52416. */
  52417. blurTextureSizeRatio: number;
  52418. /**
  52419. * How big in texel of the blur texture is the vertical blur.
  52420. */
  52421. blurVerticalSize: number;
  52422. /**
  52423. * How big in texel of the blur texture is the horizontal blur.
  52424. */
  52425. blurHorizontalSize: number;
  52426. /**
  52427. * Alpha blending mode used to apply the blur. Default is combine.
  52428. */
  52429. alphaBlendingMode: number;
  52430. /**
  52431. * The camera attached to the layer.
  52432. */
  52433. camera: Nullable<Camera>;
  52434. /**
  52435. * Should we display highlight as a solid stroke?
  52436. */
  52437. isStroke?: boolean;
  52438. /**
  52439. * The rendering group to draw the layer in.
  52440. */
  52441. renderingGroupId: number;
  52442. }
  52443. /**
  52444. * The highlight layer Helps adding a glow effect around a mesh.
  52445. *
  52446. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52447. * glowy meshes to your scene.
  52448. *
  52449. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52450. */
  52451. export class HighlightLayer extends EffectLayer {
  52452. name: string;
  52453. /**
  52454. * Effect Name of the highlight layer.
  52455. */
  52456. static readonly EffectName: string;
  52457. /**
  52458. * The neutral color used during the preparation of the glow effect.
  52459. * This is black by default as the blend operation is a blend operation.
  52460. */
  52461. static NeutralColor: Color4;
  52462. /**
  52463. * Stencil value used for glowing meshes.
  52464. */
  52465. static GlowingMeshStencilReference: number;
  52466. /**
  52467. * Stencil value used for the other meshes in the scene.
  52468. */
  52469. static NormalMeshStencilReference: number;
  52470. /**
  52471. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52472. */
  52473. innerGlow: boolean;
  52474. /**
  52475. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52476. */
  52477. outerGlow: boolean;
  52478. /**
  52479. * Specifies the horizontal size of the blur.
  52480. */
  52481. /**
  52482. * Gets the horizontal size of the blur.
  52483. */
  52484. blurHorizontalSize: number;
  52485. /**
  52486. * Specifies the vertical size of the blur.
  52487. */
  52488. /**
  52489. * Gets the vertical size of the blur.
  52490. */
  52491. blurVerticalSize: number;
  52492. /**
  52493. * An event triggered when the highlight layer is being blurred.
  52494. */
  52495. onBeforeBlurObservable: Observable<HighlightLayer>;
  52496. /**
  52497. * An event triggered when the highlight layer has been blurred.
  52498. */
  52499. onAfterBlurObservable: Observable<HighlightLayer>;
  52500. private _instanceGlowingMeshStencilReference;
  52501. private _options;
  52502. private _downSamplePostprocess;
  52503. private _horizontalBlurPostprocess;
  52504. private _verticalBlurPostprocess;
  52505. private _blurTexture;
  52506. private _meshes;
  52507. private _excludedMeshes;
  52508. /**
  52509. * Instantiates a new highlight Layer and references it to the scene..
  52510. * @param name The name of the layer
  52511. * @param scene The scene to use the layer in
  52512. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52513. */
  52514. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52515. /**
  52516. * Get the effect name of the layer.
  52517. * @return The effect name
  52518. */
  52519. getEffectName(): string;
  52520. /**
  52521. * Create the merge effect. This is the shader use to blit the information back
  52522. * to the main canvas at the end of the scene rendering.
  52523. */
  52524. protected _createMergeEffect(): Effect;
  52525. /**
  52526. * Creates the render target textures and post processes used in the highlight layer.
  52527. */
  52528. protected _createTextureAndPostProcesses(): void;
  52529. /**
  52530. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52531. */
  52532. needStencil(): boolean;
  52533. /**
  52534. * Checks for the readiness of the element composing the layer.
  52535. * @param subMesh the mesh to check for
  52536. * @param useInstances specify wether or not to use instances to render the mesh
  52537. * @param emissiveTexture the associated emissive texture used to generate the glow
  52538. * @return true if ready otherwise, false
  52539. */
  52540. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52541. /**
  52542. * Implementation specific of rendering the generating effect on the main canvas.
  52543. * @param effect The effect used to render through
  52544. */
  52545. protected _internalRender(effect: Effect): void;
  52546. /**
  52547. * Returns true if the layer contains information to display, otherwise false.
  52548. */
  52549. shouldRender(): boolean;
  52550. /**
  52551. * Returns true if the mesh should render, otherwise false.
  52552. * @param mesh The mesh to render
  52553. * @returns true if it should render otherwise false
  52554. */
  52555. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52556. /**
  52557. * Sets the required values for both the emissive texture and and the main color.
  52558. */
  52559. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52560. /**
  52561. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52562. * @param mesh The mesh to exclude from the highlight layer
  52563. */
  52564. addExcludedMesh(mesh: Mesh): void;
  52565. /**
  52566. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52567. * @param mesh The mesh to highlight
  52568. */
  52569. removeExcludedMesh(mesh: Mesh): void;
  52570. /**
  52571. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52572. * @param mesh mesh to test
  52573. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52574. */
  52575. hasMesh(mesh: AbstractMesh): boolean;
  52576. /**
  52577. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52578. * @param mesh The mesh to highlight
  52579. * @param color The color of the highlight
  52580. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52581. */
  52582. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52583. /**
  52584. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52585. * @param mesh The mesh to highlight
  52586. */
  52587. removeMesh(mesh: Mesh): void;
  52588. /**
  52589. * Force the stencil to the normal expected value for none glowing parts
  52590. */
  52591. private _defaultStencilReference;
  52592. /**
  52593. * Free any resources and references associated to a mesh.
  52594. * Internal use
  52595. * @param mesh The mesh to free.
  52596. * @hidden
  52597. */
  52598. _disposeMesh(mesh: Mesh): void;
  52599. /**
  52600. * Dispose the highlight layer and free resources.
  52601. */
  52602. dispose(): void;
  52603. /**
  52604. * Gets the class name of the effect layer
  52605. * @returns the string with the class name of the effect layer
  52606. */
  52607. getClassName(): string;
  52608. /**
  52609. * Serializes this Highlight layer
  52610. * @returns a serialized Highlight layer object
  52611. */
  52612. serialize(): any;
  52613. /**
  52614. * Creates a Highlight layer from parsed Highlight layer data
  52615. * @param parsedHightlightLayer defines the Highlight layer data
  52616. * @param scene defines the current scene
  52617. * @param rootUrl defines the root URL containing the Highlight layer information
  52618. * @returns a parsed Highlight layer
  52619. */
  52620. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52621. }
  52622. }
  52623. declare module "babylonjs/Layers/layerSceneComponent" {
  52624. import { Scene } from "babylonjs/scene";
  52625. import { ISceneComponent } from "babylonjs/sceneComponent";
  52626. import { Layer } from "babylonjs/Layers/layer";
  52627. import { AbstractScene } from "babylonjs/abstractScene";
  52628. module "babylonjs/abstractScene" {
  52629. interface AbstractScene {
  52630. /**
  52631. * The list of layers (background and foreground) of the scene
  52632. */
  52633. layers: Array<Layer>;
  52634. }
  52635. }
  52636. /**
  52637. * Defines the layer scene component responsible to manage any layers
  52638. * in a given scene.
  52639. */
  52640. export class LayerSceneComponent implements ISceneComponent {
  52641. /**
  52642. * The component name helpfull to identify the component in the list of scene components.
  52643. */
  52644. readonly name: string;
  52645. /**
  52646. * The scene the component belongs to.
  52647. */
  52648. scene: Scene;
  52649. private _engine;
  52650. /**
  52651. * Creates a new instance of the component for the given scene
  52652. * @param scene Defines the scene to register the component in
  52653. */
  52654. constructor(scene: Scene);
  52655. /**
  52656. * Registers the component in a given scene
  52657. */
  52658. register(): void;
  52659. /**
  52660. * Rebuilds the elements related to this component in case of
  52661. * context lost for instance.
  52662. */
  52663. rebuild(): void;
  52664. /**
  52665. * Disposes the component and the associated ressources.
  52666. */
  52667. dispose(): void;
  52668. private _draw;
  52669. private _drawCameraPredicate;
  52670. private _drawCameraBackground;
  52671. private _drawCameraForeground;
  52672. private _drawRenderTargetPredicate;
  52673. private _drawRenderTargetBackground;
  52674. private _drawRenderTargetForeground;
  52675. /**
  52676. * Adds all the elements from the container to the scene
  52677. * @param container the container holding the elements
  52678. */
  52679. addFromContainer(container: AbstractScene): void;
  52680. /**
  52681. * Removes all the elements in the container from the scene
  52682. * @param container contains the elements to remove
  52683. * @param dispose if the removed element should be disposed (default: false)
  52684. */
  52685. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52686. }
  52687. }
  52688. declare module "babylonjs/Shaders/layer.fragment" {
  52689. /** @hidden */
  52690. export var layerPixelShader: {
  52691. name: string;
  52692. shader: string;
  52693. };
  52694. }
  52695. declare module "babylonjs/Shaders/layer.vertex" {
  52696. /** @hidden */
  52697. export var layerVertexShader: {
  52698. name: string;
  52699. shader: string;
  52700. };
  52701. }
  52702. declare module "babylonjs/Layers/layer" {
  52703. import { Observable } from "babylonjs/Misc/observable";
  52704. import { Nullable } from "babylonjs/types";
  52705. import { Scene } from "babylonjs/scene";
  52706. import { Vector2 } from "babylonjs/Maths/math.vector";
  52707. import { Color4 } from "babylonjs/Maths/math.color";
  52708. import { Texture } from "babylonjs/Materials/Textures/texture";
  52709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52710. import "babylonjs/Shaders/layer.fragment";
  52711. import "babylonjs/Shaders/layer.vertex";
  52712. /**
  52713. * This represents a full screen 2d layer.
  52714. * This can be useful to display a picture in the background of your scene for instance.
  52715. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52716. */
  52717. export class Layer {
  52718. /**
  52719. * Define the name of the layer.
  52720. */
  52721. name: string;
  52722. /**
  52723. * Define the texture the layer should display.
  52724. */
  52725. texture: Nullable<Texture>;
  52726. /**
  52727. * Is the layer in background or foreground.
  52728. */
  52729. isBackground: boolean;
  52730. /**
  52731. * Define the color of the layer (instead of texture).
  52732. */
  52733. color: Color4;
  52734. /**
  52735. * Define the scale of the layer in order to zoom in out of the texture.
  52736. */
  52737. scale: Vector2;
  52738. /**
  52739. * Define an offset for the layer in order to shift the texture.
  52740. */
  52741. offset: Vector2;
  52742. /**
  52743. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52744. */
  52745. alphaBlendingMode: number;
  52746. /**
  52747. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52748. * Alpha test will not mix with the background color in case of transparency.
  52749. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52750. */
  52751. alphaTest: boolean;
  52752. /**
  52753. * Define a mask to restrict the layer to only some of the scene cameras.
  52754. */
  52755. layerMask: number;
  52756. /**
  52757. * Define the list of render target the layer is visible into.
  52758. */
  52759. renderTargetTextures: RenderTargetTexture[];
  52760. /**
  52761. * Define if the layer is only used in renderTarget or if it also
  52762. * renders in the main frame buffer of the canvas.
  52763. */
  52764. renderOnlyInRenderTargetTextures: boolean;
  52765. private _scene;
  52766. private _vertexBuffers;
  52767. private _indexBuffer;
  52768. private _effect;
  52769. private _alphaTestEffect;
  52770. /**
  52771. * An event triggered when the layer is disposed.
  52772. */
  52773. onDisposeObservable: Observable<Layer>;
  52774. private _onDisposeObserver;
  52775. /**
  52776. * Back compatibility with callback before the onDisposeObservable existed.
  52777. * The set callback will be triggered when the layer has been disposed.
  52778. */
  52779. onDispose: () => void;
  52780. /**
  52781. * An event triggered before rendering the scene
  52782. */
  52783. onBeforeRenderObservable: Observable<Layer>;
  52784. private _onBeforeRenderObserver;
  52785. /**
  52786. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52787. * The set callback will be triggered just before rendering the layer.
  52788. */
  52789. onBeforeRender: () => void;
  52790. /**
  52791. * An event triggered after rendering the scene
  52792. */
  52793. onAfterRenderObservable: Observable<Layer>;
  52794. private _onAfterRenderObserver;
  52795. /**
  52796. * Back compatibility with callback before the onAfterRenderObservable existed.
  52797. * The set callback will be triggered just after rendering the layer.
  52798. */
  52799. onAfterRender: () => void;
  52800. /**
  52801. * Instantiates a new layer.
  52802. * This represents a full screen 2d layer.
  52803. * This can be useful to display a picture in the background of your scene for instance.
  52804. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52805. * @param name Define the name of the layer in the scene
  52806. * @param imgUrl Define the url of the texture to display in the layer
  52807. * @param scene Define the scene the layer belongs to
  52808. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52809. * @param color Defines a color for the layer
  52810. */
  52811. constructor(
  52812. /**
  52813. * Define the name of the layer.
  52814. */
  52815. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52816. private _createIndexBuffer;
  52817. /** @hidden */
  52818. _rebuild(): void;
  52819. /**
  52820. * Renders the layer in the scene.
  52821. */
  52822. render(): void;
  52823. /**
  52824. * Disposes and releases the associated ressources.
  52825. */
  52826. dispose(): void;
  52827. }
  52828. }
  52829. declare module "babylonjs/Layers/index" {
  52830. export * from "babylonjs/Layers/effectLayer";
  52831. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52832. export * from "babylonjs/Layers/glowLayer";
  52833. export * from "babylonjs/Layers/highlightLayer";
  52834. export * from "babylonjs/Layers/layer";
  52835. export * from "babylonjs/Layers/layerSceneComponent";
  52836. }
  52837. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52838. /** @hidden */
  52839. export var lensFlarePixelShader: {
  52840. name: string;
  52841. shader: string;
  52842. };
  52843. }
  52844. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52845. /** @hidden */
  52846. export var lensFlareVertexShader: {
  52847. name: string;
  52848. shader: string;
  52849. };
  52850. }
  52851. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52852. import { Scene } from "babylonjs/scene";
  52853. import { Vector3 } from "babylonjs/Maths/math.vector";
  52854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52855. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52856. import "babylonjs/Shaders/lensFlare.fragment";
  52857. import "babylonjs/Shaders/lensFlare.vertex";
  52858. import { Viewport } from "babylonjs/Maths/math.viewport";
  52859. /**
  52860. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52861. * It is usually composed of several `lensFlare`.
  52862. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52863. */
  52864. export class LensFlareSystem {
  52865. /**
  52866. * Define the name of the lens flare system
  52867. */
  52868. name: string;
  52869. /**
  52870. * List of lens flares used in this system.
  52871. */
  52872. lensFlares: LensFlare[];
  52873. /**
  52874. * Define a limit from the border the lens flare can be visible.
  52875. */
  52876. borderLimit: number;
  52877. /**
  52878. * Define a viewport border we do not want to see the lens flare in.
  52879. */
  52880. viewportBorder: number;
  52881. /**
  52882. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52883. */
  52884. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52885. /**
  52886. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52887. */
  52888. layerMask: number;
  52889. /**
  52890. * Define the id of the lens flare system in the scene.
  52891. * (equal to name by default)
  52892. */
  52893. id: string;
  52894. private _scene;
  52895. private _emitter;
  52896. private _vertexBuffers;
  52897. private _indexBuffer;
  52898. private _effect;
  52899. private _positionX;
  52900. private _positionY;
  52901. private _isEnabled;
  52902. /** @hidden */
  52903. static _SceneComponentInitialization: (scene: Scene) => void;
  52904. /**
  52905. * Instantiates a lens flare system.
  52906. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52907. * It is usually composed of several `lensFlare`.
  52908. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52909. * @param name Define the name of the lens flare system in the scene
  52910. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52911. * @param scene Define the scene the lens flare system belongs to
  52912. */
  52913. constructor(
  52914. /**
  52915. * Define the name of the lens flare system
  52916. */
  52917. name: string, emitter: any, scene: Scene);
  52918. /**
  52919. * Define if the lens flare system is enabled.
  52920. */
  52921. isEnabled: boolean;
  52922. /**
  52923. * Get the scene the effects belongs to.
  52924. * @returns the scene holding the lens flare system
  52925. */
  52926. getScene(): Scene;
  52927. /**
  52928. * Get the emitter of the lens flare system.
  52929. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52930. * @returns the emitter of the lens flare system
  52931. */
  52932. getEmitter(): any;
  52933. /**
  52934. * Set the emitter of the lens flare system.
  52935. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52936. * @param newEmitter Define the new emitter of the system
  52937. */
  52938. setEmitter(newEmitter: any): void;
  52939. /**
  52940. * Get the lens flare system emitter position.
  52941. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52942. * @returns the position
  52943. */
  52944. getEmitterPosition(): Vector3;
  52945. /**
  52946. * @hidden
  52947. */
  52948. computeEffectivePosition(globalViewport: Viewport): boolean;
  52949. /** @hidden */
  52950. _isVisible(): boolean;
  52951. /**
  52952. * @hidden
  52953. */
  52954. render(): boolean;
  52955. /**
  52956. * Dispose and release the lens flare with its associated resources.
  52957. */
  52958. dispose(): void;
  52959. /**
  52960. * Parse a lens flare system from a JSON repressentation
  52961. * @param parsedLensFlareSystem Define the JSON to parse
  52962. * @param scene Define the scene the parsed system should be instantiated in
  52963. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52964. * @returns the parsed system
  52965. */
  52966. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52967. /**
  52968. * Serialize the current Lens Flare System into a JSON representation.
  52969. * @returns the serialized JSON
  52970. */
  52971. serialize(): any;
  52972. }
  52973. }
  52974. declare module "babylonjs/LensFlares/lensFlare" {
  52975. import { Nullable } from "babylonjs/types";
  52976. import { Color3 } from "babylonjs/Maths/math.color";
  52977. import { Texture } from "babylonjs/Materials/Textures/texture";
  52978. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52979. /**
  52980. * This represents one of the lens effect in a `lensFlareSystem`.
  52981. * It controls one of the indiviual texture used in the effect.
  52982. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52983. */
  52984. export class LensFlare {
  52985. /**
  52986. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52987. */
  52988. size: number;
  52989. /**
  52990. * 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.
  52991. */
  52992. position: number;
  52993. /**
  52994. * Define the lens color.
  52995. */
  52996. color: Color3;
  52997. /**
  52998. * Define the lens texture.
  52999. */
  53000. texture: Nullable<Texture>;
  53001. /**
  53002. * Define the alpha mode to render this particular lens.
  53003. */
  53004. alphaMode: number;
  53005. private _system;
  53006. /**
  53007. * Creates a new Lens Flare.
  53008. * This represents one of the lens effect in a `lensFlareSystem`.
  53009. * It controls one of the indiviual texture used in the effect.
  53010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53011. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53012. * @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.
  53013. * @param color Define the lens color
  53014. * @param imgUrl Define the lens texture url
  53015. * @param system Define the `lensFlareSystem` this flare is part of
  53016. * @returns The newly created Lens Flare
  53017. */
  53018. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53019. /**
  53020. * Instantiates a new Lens Flare.
  53021. * This represents one of the lens effect in a `lensFlareSystem`.
  53022. * It controls one of the indiviual texture used in the effect.
  53023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53024. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53025. * @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.
  53026. * @param color Define the lens color
  53027. * @param imgUrl Define the lens texture url
  53028. * @param system Define the `lensFlareSystem` this flare is part of
  53029. */
  53030. constructor(
  53031. /**
  53032. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53033. */
  53034. size: number,
  53035. /**
  53036. * 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.
  53037. */
  53038. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53039. /**
  53040. * Dispose and release the lens flare with its associated resources.
  53041. */
  53042. dispose(): void;
  53043. }
  53044. }
  53045. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53046. import { Nullable } from "babylonjs/types";
  53047. import { Scene } from "babylonjs/scene";
  53048. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53049. import { AbstractScene } from "babylonjs/abstractScene";
  53050. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53051. module "babylonjs/abstractScene" {
  53052. interface AbstractScene {
  53053. /**
  53054. * The list of lens flare system added to the scene
  53055. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53056. */
  53057. lensFlareSystems: Array<LensFlareSystem>;
  53058. /**
  53059. * Removes the given lens flare system from this scene.
  53060. * @param toRemove The lens flare system to remove
  53061. * @returns The index of the removed lens flare system
  53062. */
  53063. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53064. /**
  53065. * Adds the given lens flare system to this scene
  53066. * @param newLensFlareSystem The lens flare system to add
  53067. */
  53068. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53069. /**
  53070. * Gets a lens flare system using its name
  53071. * @param name defines the name to look for
  53072. * @returns the lens flare system or null if not found
  53073. */
  53074. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53075. /**
  53076. * Gets a lens flare system using its id
  53077. * @param id defines the id to look for
  53078. * @returns the lens flare system or null if not found
  53079. */
  53080. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53081. }
  53082. }
  53083. /**
  53084. * Defines the lens flare scene component responsible to manage any lens flares
  53085. * in a given scene.
  53086. */
  53087. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53088. /**
  53089. * The component name helpfull to identify the component in the list of scene components.
  53090. */
  53091. readonly name: string;
  53092. /**
  53093. * The scene the component belongs to.
  53094. */
  53095. scene: Scene;
  53096. /**
  53097. * Creates a new instance of the component for the given scene
  53098. * @param scene Defines the scene to register the component in
  53099. */
  53100. constructor(scene: Scene);
  53101. /**
  53102. * Registers the component in a given scene
  53103. */
  53104. register(): void;
  53105. /**
  53106. * Rebuilds the elements related to this component in case of
  53107. * context lost for instance.
  53108. */
  53109. rebuild(): void;
  53110. /**
  53111. * Adds all the elements from the container to the scene
  53112. * @param container the container holding the elements
  53113. */
  53114. addFromContainer(container: AbstractScene): void;
  53115. /**
  53116. * Removes all the elements in the container from the scene
  53117. * @param container contains the elements to remove
  53118. * @param dispose if the removed element should be disposed (default: false)
  53119. */
  53120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53121. /**
  53122. * Serializes the component data to the specified json object
  53123. * @param serializationObject The object to serialize to
  53124. */
  53125. serialize(serializationObject: any): void;
  53126. /**
  53127. * Disposes the component and the associated ressources.
  53128. */
  53129. dispose(): void;
  53130. private _draw;
  53131. }
  53132. }
  53133. declare module "babylonjs/LensFlares/index" {
  53134. export * from "babylonjs/LensFlares/lensFlare";
  53135. export * from "babylonjs/LensFlares/lensFlareSystem";
  53136. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53137. }
  53138. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53139. import { Scene } from "babylonjs/scene";
  53140. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53141. import { AbstractScene } from "babylonjs/abstractScene";
  53142. /**
  53143. * Defines the shadow generator component responsible to manage any shadow generators
  53144. * in a given scene.
  53145. */
  53146. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53147. /**
  53148. * The component name helpfull to identify the component in the list of scene components.
  53149. */
  53150. readonly name: string;
  53151. /**
  53152. * The scene the component belongs to.
  53153. */
  53154. scene: Scene;
  53155. /**
  53156. * Creates a new instance of the component for the given scene
  53157. * @param scene Defines the scene to register the component in
  53158. */
  53159. constructor(scene: Scene);
  53160. /**
  53161. * Registers the component in a given scene
  53162. */
  53163. register(): void;
  53164. /**
  53165. * Rebuilds the elements related to this component in case of
  53166. * context lost for instance.
  53167. */
  53168. rebuild(): void;
  53169. /**
  53170. * Serializes the component data to the specified json object
  53171. * @param serializationObject The object to serialize to
  53172. */
  53173. serialize(serializationObject: any): void;
  53174. /**
  53175. * Adds all the elements from the container to the scene
  53176. * @param container the container holding the elements
  53177. */
  53178. addFromContainer(container: AbstractScene): void;
  53179. /**
  53180. * Removes all the elements in the container from the scene
  53181. * @param container contains the elements to remove
  53182. * @param dispose if the removed element should be disposed (default: false)
  53183. */
  53184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53185. /**
  53186. * Rebuilds the elements related to this component in case of
  53187. * context lost for instance.
  53188. */
  53189. dispose(): void;
  53190. private _gatherRenderTargets;
  53191. }
  53192. }
  53193. declare module "babylonjs/Lights/Shadows/index" {
  53194. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53195. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53196. }
  53197. declare module "babylonjs/Lights/pointLight" {
  53198. import { Scene } from "babylonjs/scene";
  53199. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53201. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53202. import { Effect } from "babylonjs/Materials/effect";
  53203. /**
  53204. * A point light is a light defined by an unique point in world space.
  53205. * The light is emitted in every direction from this point.
  53206. * A good example of a point light is a standard light bulb.
  53207. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53208. */
  53209. export class PointLight extends ShadowLight {
  53210. private _shadowAngle;
  53211. /**
  53212. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53213. * This specifies what angle the shadow will use to be created.
  53214. *
  53215. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53216. */
  53217. /**
  53218. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53219. * This specifies what angle the shadow will use to be created.
  53220. *
  53221. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53222. */
  53223. shadowAngle: number;
  53224. /**
  53225. * Gets the direction if it has been set.
  53226. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53227. */
  53228. /**
  53229. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53230. */
  53231. direction: Vector3;
  53232. /**
  53233. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53234. * A PointLight emits the light in every direction.
  53235. * It can cast shadows.
  53236. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53237. * ```javascript
  53238. * var pointLight = new PointLight("pl", camera.position, scene);
  53239. * ```
  53240. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53241. * @param name The light friendly name
  53242. * @param position The position of the point light in the scene
  53243. * @param scene The scene the lights belongs to
  53244. */
  53245. constructor(name: string, position: Vector3, scene: Scene);
  53246. /**
  53247. * Returns the string "PointLight"
  53248. * @returns the class name
  53249. */
  53250. getClassName(): string;
  53251. /**
  53252. * Returns the integer 0.
  53253. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53254. */
  53255. getTypeID(): number;
  53256. /**
  53257. * Specifies wether or not the shadowmap should be a cube texture.
  53258. * @returns true if the shadowmap needs to be a cube texture.
  53259. */
  53260. needCube(): boolean;
  53261. /**
  53262. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53263. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53264. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53265. */
  53266. getShadowDirection(faceIndex?: number): Vector3;
  53267. /**
  53268. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53269. * - fov = PI / 2
  53270. * - aspect ratio : 1.0
  53271. * - z-near and far equal to the active camera minZ and maxZ.
  53272. * Returns the PointLight.
  53273. */
  53274. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53275. protected _buildUniformLayout(): void;
  53276. /**
  53277. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53278. * @param effect The effect to update
  53279. * @param lightIndex The index of the light in the effect to update
  53280. * @returns The point light
  53281. */
  53282. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53283. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53284. /**
  53285. * Prepares the list of defines specific to the light type.
  53286. * @param defines the list of defines
  53287. * @param lightIndex defines the index of the light for the effect
  53288. */
  53289. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53290. }
  53291. }
  53292. declare module "babylonjs/Lights/index" {
  53293. export * from "babylonjs/Lights/light";
  53294. export * from "babylonjs/Lights/shadowLight";
  53295. export * from "babylonjs/Lights/Shadows/index";
  53296. export * from "babylonjs/Lights/directionalLight";
  53297. export * from "babylonjs/Lights/hemisphericLight";
  53298. export * from "babylonjs/Lights/pointLight";
  53299. export * from "babylonjs/Lights/spotLight";
  53300. }
  53301. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53302. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53303. /**
  53304. * Header information of HDR texture files.
  53305. */
  53306. export interface HDRInfo {
  53307. /**
  53308. * The height of the texture in pixels.
  53309. */
  53310. height: number;
  53311. /**
  53312. * The width of the texture in pixels.
  53313. */
  53314. width: number;
  53315. /**
  53316. * The index of the beginning of the data in the binary file.
  53317. */
  53318. dataPosition: number;
  53319. }
  53320. /**
  53321. * This groups tools to convert HDR texture to native colors array.
  53322. */
  53323. export class HDRTools {
  53324. private static Ldexp;
  53325. private static Rgbe2float;
  53326. private static readStringLine;
  53327. /**
  53328. * Reads header information from an RGBE texture stored in a native array.
  53329. * More information on this format are available here:
  53330. * https://en.wikipedia.org/wiki/RGBE_image_format
  53331. *
  53332. * @param uint8array The binary file stored in native array.
  53333. * @return The header information.
  53334. */
  53335. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53336. /**
  53337. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53338. * This RGBE texture needs to store the information as a panorama.
  53339. *
  53340. * More information on this format are available here:
  53341. * https://en.wikipedia.org/wiki/RGBE_image_format
  53342. *
  53343. * @param buffer The binary file stored in an array buffer.
  53344. * @param size The expected size of the extracted cubemap.
  53345. * @return The Cube Map information.
  53346. */
  53347. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53348. /**
  53349. * Returns the pixels data extracted from an RGBE texture.
  53350. * This pixels will be stored left to right up to down in the R G B order in one array.
  53351. *
  53352. * More information on this format are available here:
  53353. * https://en.wikipedia.org/wiki/RGBE_image_format
  53354. *
  53355. * @param uint8array The binary file stored in an array buffer.
  53356. * @param hdrInfo The header information of the file.
  53357. * @return The pixels data in RGB right to left up to down order.
  53358. */
  53359. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53360. private static RGBE_ReadPixels_RLE;
  53361. }
  53362. }
  53363. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53364. import { Nullable } from "babylonjs/types";
  53365. import { Scene } from "babylonjs/scene";
  53366. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53367. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53368. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53369. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53370. /**
  53371. * This represents a texture coming from an HDR input.
  53372. *
  53373. * The only supported format is currently panorama picture stored in RGBE format.
  53374. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53375. */
  53376. export class HDRCubeTexture extends BaseTexture {
  53377. private static _facesMapping;
  53378. private _generateHarmonics;
  53379. private _noMipmap;
  53380. private _textureMatrix;
  53381. private _size;
  53382. private _onLoad;
  53383. private _onError;
  53384. /**
  53385. * The texture URL.
  53386. */
  53387. url: string;
  53388. /**
  53389. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53390. */
  53391. coordinatesMode: number;
  53392. protected _isBlocking: boolean;
  53393. /**
  53394. * Sets wether or not the texture is blocking during loading.
  53395. */
  53396. /**
  53397. * Gets wether or not the texture is blocking during loading.
  53398. */
  53399. isBlocking: boolean;
  53400. protected _rotationY: number;
  53401. /**
  53402. * Sets texture matrix rotation angle around Y axis in radians.
  53403. */
  53404. /**
  53405. * Gets texture matrix rotation angle around Y axis radians.
  53406. */
  53407. rotationY: number;
  53408. /**
  53409. * Gets or sets the center of the bounding box associated with the cube texture
  53410. * It must define where the camera used to render the texture was set
  53411. */
  53412. boundingBoxPosition: Vector3;
  53413. private _boundingBoxSize;
  53414. /**
  53415. * Gets or sets the size of the bounding box associated with the cube texture
  53416. * When defined, the cubemap will switch to local mode
  53417. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53418. * @example https://www.babylonjs-playground.com/#RNASML
  53419. */
  53420. boundingBoxSize: Vector3;
  53421. /**
  53422. * Instantiates an HDRTexture from the following parameters.
  53423. *
  53424. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53425. * @param scene The scene the texture will be used in
  53426. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53427. * @param noMipmap Forces to not generate the mipmap if true
  53428. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53429. * @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)
  53430. * @param reserved Reserved flag for internal use.
  53431. */
  53432. 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>);
  53433. /**
  53434. * Get the current class name of the texture useful for serialization or dynamic coding.
  53435. * @returns "HDRCubeTexture"
  53436. */
  53437. getClassName(): string;
  53438. /**
  53439. * Occurs when the file is raw .hdr file.
  53440. */
  53441. private loadTexture;
  53442. clone(): HDRCubeTexture;
  53443. delayLoad(): void;
  53444. /**
  53445. * Get the texture reflection matrix used to rotate/transform the reflection.
  53446. * @returns the reflection matrix
  53447. */
  53448. getReflectionTextureMatrix(): Matrix;
  53449. /**
  53450. * Set the texture reflection matrix used to rotate/transform the reflection.
  53451. * @param value Define the reflection matrix to set
  53452. */
  53453. setReflectionTextureMatrix(value: Matrix): void;
  53454. /**
  53455. * Parses a JSON representation of an HDR Texture in order to create the texture
  53456. * @param parsedTexture Define the JSON representation
  53457. * @param scene Define the scene the texture should be created in
  53458. * @param rootUrl Define the root url in case we need to load relative dependencies
  53459. * @returns the newly created texture after parsing
  53460. */
  53461. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53462. serialize(): any;
  53463. }
  53464. }
  53465. declare module "babylonjs/Physics/physicsEngine" {
  53466. import { Nullable } from "babylonjs/types";
  53467. import { Vector3 } from "babylonjs/Maths/math.vector";
  53468. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53469. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53470. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53471. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53472. /**
  53473. * Class used to control physics engine
  53474. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53475. */
  53476. export class PhysicsEngine implements IPhysicsEngine {
  53477. private _physicsPlugin;
  53478. /**
  53479. * Global value used to control the smallest number supported by the simulation
  53480. */
  53481. static Epsilon: number;
  53482. private _impostors;
  53483. private _joints;
  53484. /**
  53485. * Gets the gravity vector used by the simulation
  53486. */
  53487. gravity: Vector3;
  53488. /**
  53489. * Factory used to create the default physics plugin.
  53490. * @returns The default physics plugin
  53491. */
  53492. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53493. /**
  53494. * Creates a new Physics Engine
  53495. * @param gravity defines the gravity vector used by the simulation
  53496. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53497. */
  53498. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53499. /**
  53500. * Sets the gravity vector used by the simulation
  53501. * @param gravity defines the gravity vector to use
  53502. */
  53503. setGravity(gravity: Vector3): void;
  53504. /**
  53505. * Set the time step of the physics engine.
  53506. * Default is 1/60.
  53507. * To slow it down, enter 1/600 for example.
  53508. * To speed it up, 1/30
  53509. * @param newTimeStep defines the new timestep to apply to this world.
  53510. */
  53511. setTimeStep(newTimeStep?: number): void;
  53512. /**
  53513. * Get the time step of the physics engine.
  53514. * @returns the current time step
  53515. */
  53516. getTimeStep(): number;
  53517. /**
  53518. * Release all resources
  53519. */
  53520. dispose(): void;
  53521. /**
  53522. * Gets the name of the current physics plugin
  53523. * @returns the name of the plugin
  53524. */
  53525. getPhysicsPluginName(): string;
  53526. /**
  53527. * Adding a new impostor for the impostor tracking.
  53528. * This will be done by the impostor itself.
  53529. * @param impostor the impostor to add
  53530. */
  53531. addImpostor(impostor: PhysicsImpostor): void;
  53532. /**
  53533. * Remove an impostor from the engine.
  53534. * This impostor and its mesh will not longer be updated by the physics engine.
  53535. * @param impostor the impostor to remove
  53536. */
  53537. removeImpostor(impostor: PhysicsImpostor): void;
  53538. /**
  53539. * Add a joint to the physics engine
  53540. * @param mainImpostor defines the main impostor to which the joint is added.
  53541. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53542. * @param joint defines the joint that will connect both impostors.
  53543. */
  53544. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53545. /**
  53546. * Removes a joint from the simulation
  53547. * @param mainImpostor defines the impostor used with the joint
  53548. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53549. * @param joint defines the joint to remove
  53550. */
  53551. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53552. /**
  53553. * Called by the scene. No need to call it.
  53554. * @param delta defines the timespam between frames
  53555. */
  53556. _step(delta: number): void;
  53557. /**
  53558. * Gets the current plugin used to run the simulation
  53559. * @returns current plugin
  53560. */
  53561. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53562. /**
  53563. * Gets the list of physic impostors
  53564. * @returns an array of PhysicsImpostor
  53565. */
  53566. getImpostors(): Array<PhysicsImpostor>;
  53567. /**
  53568. * Gets the impostor for a physics enabled object
  53569. * @param object defines the object impersonated by the impostor
  53570. * @returns the PhysicsImpostor or null if not found
  53571. */
  53572. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53573. /**
  53574. * Gets the impostor for a physics body object
  53575. * @param body defines physics body used by the impostor
  53576. * @returns the PhysicsImpostor or null if not found
  53577. */
  53578. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53579. /**
  53580. * Does a raycast in the physics world
  53581. * @param from when should the ray start?
  53582. * @param to when should the ray end?
  53583. * @returns PhysicsRaycastResult
  53584. */
  53585. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53586. }
  53587. }
  53588. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53589. import { Nullable } from "babylonjs/types";
  53590. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53592. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53593. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53594. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53595. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53596. /** @hidden */
  53597. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53598. private _useDeltaForWorldStep;
  53599. world: any;
  53600. name: string;
  53601. private _physicsMaterials;
  53602. private _fixedTimeStep;
  53603. private _cannonRaycastResult;
  53604. private _raycastResult;
  53605. private _physicsBodysToRemoveAfterStep;
  53606. BJSCANNON: any;
  53607. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53608. setGravity(gravity: Vector3): void;
  53609. setTimeStep(timeStep: number): void;
  53610. getTimeStep(): number;
  53611. executeStep(delta: number): void;
  53612. private _removeMarkedPhysicsBodiesFromWorld;
  53613. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53614. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53615. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53616. private _processChildMeshes;
  53617. removePhysicsBody(impostor: PhysicsImpostor): void;
  53618. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53619. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53620. private _addMaterial;
  53621. private _checkWithEpsilon;
  53622. private _createShape;
  53623. private _createHeightmap;
  53624. private _minus90X;
  53625. private _plus90X;
  53626. private _tmpPosition;
  53627. private _tmpDeltaPosition;
  53628. private _tmpUnityRotation;
  53629. private _updatePhysicsBodyTransformation;
  53630. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53631. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53632. isSupported(): boolean;
  53633. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53634. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53635. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53636. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53637. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53638. getBodyMass(impostor: PhysicsImpostor): number;
  53639. getBodyFriction(impostor: PhysicsImpostor): number;
  53640. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53641. getBodyRestitution(impostor: PhysicsImpostor): number;
  53642. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53643. sleepBody(impostor: PhysicsImpostor): void;
  53644. wakeUpBody(impostor: PhysicsImpostor): void;
  53645. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53646. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53647. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53648. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53649. getRadius(impostor: PhysicsImpostor): number;
  53650. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53651. dispose(): void;
  53652. private _extendNamespace;
  53653. /**
  53654. * Does a raycast in the physics world
  53655. * @param from when should the ray start?
  53656. * @param to when should the ray end?
  53657. * @returns PhysicsRaycastResult
  53658. */
  53659. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53660. }
  53661. }
  53662. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53663. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53664. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53665. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53667. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53668. import { Nullable } from "babylonjs/types";
  53669. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53670. /** @hidden */
  53671. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53672. world: any;
  53673. name: string;
  53674. BJSOIMO: any;
  53675. private _raycastResult;
  53676. constructor(iterations?: number, oimoInjection?: any);
  53677. setGravity(gravity: Vector3): void;
  53678. setTimeStep(timeStep: number): void;
  53679. getTimeStep(): number;
  53680. private _tmpImpostorsArray;
  53681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53685. private _tmpPositionVector;
  53686. removePhysicsBody(impostor: PhysicsImpostor): void;
  53687. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53688. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53689. isSupported(): boolean;
  53690. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53691. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53692. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53693. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53694. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53695. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53696. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53697. getBodyMass(impostor: PhysicsImpostor): number;
  53698. getBodyFriction(impostor: PhysicsImpostor): number;
  53699. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53700. getBodyRestitution(impostor: PhysicsImpostor): number;
  53701. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53702. sleepBody(impostor: PhysicsImpostor): void;
  53703. wakeUpBody(impostor: PhysicsImpostor): void;
  53704. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53705. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53706. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53707. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53708. getRadius(impostor: PhysicsImpostor): number;
  53709. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53710. dispose(): void;
  53711. /**
  53712. * Does a raycast in the physics world
  53713. * @param from when should the ray start?
  53714. * @param to when should the ray end?
  53715. * @returns PhysicsRaycastResult
  53716. */
  53717. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53718. }
  53719. }
  53720. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53721. import { Nullable } from "babylonjs/types";
  53722. import { Scene } from "babylonjs/scene";
  53723. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53724. import { Color4 } from "babylonjs/Maths/math.color";
  53725. import { Mesh } from "babylonjs/Meshes/mesh";
  53726. /**
  53727. * Class containing static functions to help procedurally build meshes
  53728. */
  53729. export class RibbonBuilder {
  53730. /**
  53731. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53732. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53733. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53734. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53735. * * 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
  53736. * * 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
  53737. * * 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
  53738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53740. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53741. * * 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
  53742. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53743. * * 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
  53744. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53746. * @param name defines the name of the mesh
  53747. * @param options defines the options used to create the mesh
  53748. * @param scene defines the hosting scene
  53749. * @returns the ribbon mesh
  53750. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53751. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53752. */
  53753. static CreateRibbon(name: string, options: {
  53754. pathArray: Vector3[][];
  53755. closeArray?: boolean;
  53756. closePath?: boolean;
  53757. offset?: number;
  53758. updatable?: boolean;
  53759. sideOrientation?: number;
  53760. frontUVs?: Vector4;
  53761. backUVs?: Vector4;
  53762. instance?: Mesh;
  53763. invertUV?: boolean;
  53764. uvs?: Vector2[];
  53765. colors?: Color4[];
  53766. }, scene?: Nullable<Scene>): Mesh;
  53767. }
  53768. }
  53769. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53770. import { Nullable } from "babylonjs/types";
  53771. import { Scene } from "babylonjs/scene";
  53772. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53773. import { Mesh } from "babylonjs/Meshes/mesh";
  53774. /**
  53775. * Class containing static functions to help procedurally build meshes
  53776. */
  53777. export class ShapeBuilder {
  53778. /**
  53779. * 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.
  53780. * * 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.
  53781. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53782. * * 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.
  53783. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53784. * * 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
  53785. * * 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
  53786. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53789. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53791. * @param name defines the name of the mesh
  53792. * @param options defines the options used to create the mesh
  53793. * @param scene defines the hosting scene
  53794. * @returns the extruded shape mesh
  53795. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53797. */
  53798. static ExtrudeShape(name: string, options: {
  53799. shape: Vector3[];
  53800. path: Vector3[];
  53801. scale?: number;
  53802. rotation?: number;
  53803. cap?: number;
  53804. updatable?: boolean;
  53805. sideOrientation?: number;
  53806. frontUVs?: Vector4;
  53807. backUVs?: Vector4;
  53808. instance?: Mesh;
  53809. invertUV?: boolean;
  53810. }, scene?: Nullable<Scene>): Mesh;
  53811. /**
  53812. * Creates an custom extruded shape mesh.
  53813. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53814. * * 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.
  53815. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53816. * * 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
  53817. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53818. * * 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
  53819. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53820. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53821. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53822. * * 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
  53823. * * 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
  53824. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53829. * @param name defines the name of the mesh
  53830. * @param options defines the options used to create the mesh
  53831. * @param scene defines the hosting scene
  53832. * @returns the custom extruded shape mesh
  53833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53834. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53836. */
  53837. static ExtrudeShapeCustom(name: string, options: {
  53838. shape: Vector3[];
  53839. path: Vector3[];
  53840. scaleFunction?: any;
  53841. rotationFunction?: any;
  53842. ribbonCloseArray?: boolean;
  53843. ribbonClosePath?: boolean;
  53844. cap?: number;
  53845. updatable?: boolean;
  53846. sideOrientation?: number;
  53847. frontUVs?: Vector4;
  53848. backUVs?: Vector4;
  53849. instance?: Mesh;
  53850. invertUV?: boolean;
  53851. }, scene?: Nullable<Scene>): Mesh;
  53852. private static _ExtrudeShapeGeneric;
  53853. }
  53854. }
  53855. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53856. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53857. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53858. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53859. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53860. import { Nullable } from "babylonjs/types";
  53861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53862. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53863. /**
  53864. * AmmoJS Physics plugin
  53865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53866. * @see https://github.com/kripken/ammo.js/
  53867. */
  53868. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53869. private _useDeltaForWorldStep;
  53870. /**
  53871. * Reference to the Ammo library
  53872. */
  53873. bjsAMMO: any;
  53874. /**
  53875. * Created ammoJS world which physics bodies are added to
  53876. */
  53877. world: any;
  53878. /**
  53879. * Name of the plugin
  53880. */
  53881. name: string;
  53882. private _timeStep;
  53883. private _fixedTimeStep;
  53884. private _maxSteps;
  53885. private _tmpQuaternion;
  53886. private _tmpAmmoTransform;
  53887. private _tmpAmmoQuaternion;
  53888. private _tmpAmmoConcreteContactResultCallback;
  53889. private _collisionConfiguration;
  53890. private _dispatcher;
  53891. private _overlappingPairCache;
  53892. private _solver;
  53893. private _softBodySolver;
  53894. private _tmpAmmoVectorA;
  53895. private _tmpAmmoVectorB;
  53896. private _tmpAmmoVectorC;
  53897. private _tmpAmmoVectorD;
  53898. private _tmpContactCallbackResult;
  53899. private _tmpAmmoVectorRCA;
  53900. private _tmpAmmoVectorRCB;
  53901. private _raycastResult;
  53902. private static readonly DISABLE_COLLISION_FLAG;
  53903. private static readonly KINEMATIC_FLAG;
  53904. private static readonly DISABLE_DEACTIVATION_FLAG;
  53905. /**
  53906. * Initializes the ammoJS plugin
  53907. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53908. * @param ammoInjection can be used to inject your own ammo reference
  53909. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53910. */
  53911. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53912. /**
  53913. * Sets the gravity of the physics world (m/(s^2))
  53914. * @param gravity Gravity to set
  53915. */
  53916. setGravity(gravity: Vector3): void;
  53917. /**
  53918. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53919. * @param timeStep timestep to use in seconds
  53920. */
  53921. setTimeStep(timeStep: number): void;
  53922. /**
  53923. * 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)
  53924. * @param fixedTimeStep fixedTimeStep to use in seconds
  53925. */
  53926. setFixedTimeStep(fixedTimeStep: number): void;
  53927. /**
  53928. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53929. * @param maxSteps the maximum number of steps by the physics engine per frame
  53930. */
  53931. setMaxSteps(maxSteps: number): void;
  53932. /**
  53933. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53934. * @returns the current timestep in seconds
  53935. */
  53936. getTimeStep(): number;
  53937. private _isImpostorInContact;
  53938. private _isImpostorPairInContact;
  53939. private _stepSimulation;
  53940. /**
  53941. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53942. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53943. * After the step the babylon meshes are set to the position of the physics imposters
  53944. * @param delta amount of time to step forward
  53945. * @param impostors array of imposters to update before/after the step
  53946. */
  53947. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53948. /**
  53949. * Update babylon mesh to match physics world object
  53950. * @param impostor imposter to match
  53951. */
  53952. private _afterSoftStep;
  53953. /**
  53954. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53955. * @param impostor imposter to match
  53956. */
  53957. private _ropeStep;
  53958. /**
  53959. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53960. * @param impostor imposter to match
  53961. */
  53962. private _softbodyOrClothStep;
  53963. private _tmpVector;
  53964. private _tmpMatrix;
  53965. /**
  53966. * Applies an impulse on the imposter
  53967. * @param impostor imposter to apply impulse to
  53968. * @param force amount of force to be applied to the imposter
  53969. * @param contactPoint the location to apply the impulse on the imposter
  53970. */
  53971. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53972. /**
  53973. * Applies a force on the imposter
  53974. * @param impostor imposter to apply force
  53975. * @param force amount of force to be applied to the imposter
  53976. * @param contactPoint the location to apply the force on the imposter
  53977. */
  53978. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53979. /**
  53980. * Creates a physics body using the plugin
  53981. * @param impostor the imposter to create the physics body on
  53982. */
  53983. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53984. /**
  53985. * Removes the physics body from the imposter and disposes of the body's memory
  53986. * @param impostor imposter to remove the physics body from
  53987. */
  53988. removePhysicsBody(impostor: PhysicsImpostor): void;
  53989. /**
  53990. * Generates a joint
  53991. * @param impostorJoint the imposter joint to create the joint with
  53992. */
  53993. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53994. /**
  53995. * Removes a joint
  53996. * @param impostorJoint the imposter joint to remove the joint from
  53997. */
  53998. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53999. private _addMeshVerts;
  54000. /**
  54001. * Initialise the soft body vertices to match its object's (mesh) vertices
  54002. * Softbody vertices (nodes) are in world space and to match this
  54003. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54004. * @param impostor to create the softbody for
  54005. */
  54006. private _softVertexData;
  54007. /**
  54008. * Create an impostor's soft body
  54009. * @param impostor to create the softbody for
  54010. */
  54011. private _createSoftbody;
  54012. /**
  54013. * Create cloth for an impostor
  54014. * @param impostor to create the softbody for
  54015. */
  54016. private _createCloth;
  54017. /**
  54018. * Create rope for an impostor
  54019. * @param impostor to create the softbody for
  54020. */
  54021. private _createRope;
  54022. private _addHullVerts;
  54023. private _createShape;
  54024. /**
  54025. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54026. * @param impostor imposter containing the physics body and babylon object
  54027. */
  54028. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54029. /**
  54030. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54031. * @param impostor imposter containing the physics body and babylon object
  54032. * @param newPosition new position
  54033. * @param newRotation new rotation
  54034. */
  54035. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54036. /**
  54037. * If this plugin is supported
  54038. * @returns true if its supported
  54039. */
  54040. isSupported(): boolean;
  54041. /**
  54042. * Sets the linear velocity of the physics body
  54043. * @param impostor imposter to set the velocity on
  54044. * @param velocity velocity to set
  54045. */
  54046. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54047. /**
  54048. * Sets the angular velocity of the physics body
  54049. * @param impostor imposter to set the velocity on
  54050. * @param velocity velocity to set
  54051. */
  54052. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54053. /**
  54054. * gets the linear velocity
  54055. * @param impostor imposter to get linear velocity from
  54056. * @returns linear velocity
  54057. */
  54058. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54059. /**
  54060. * gets the angular velocity
  54061. * @param impostor imposter to get angular velocity from
  54062. * @returns angular velocity
  54063. */
  54064. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54065. /**
  54066. * Sets the mass of physics body
  54067. * @param impostor imposter to set the mass on
  54068. * @param mass mass to set
  54069. */
  54070. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54071. /**
  54072. * Gets the mass of the physics body
  54073. * @param impostor imposter to get the mass from
  54074. * @returns mass
  54075. */
  54076. getBodyMass(impostor: PhysicsImpostor): number;
  54077. /**
  54078. * Gets friction of the impostor
  54079. * @param impostor impostor to get friction from
  54080. * @returns friction value
  54081. */
  54082. getBodyFriction(impostor: PhysicsImpostor): number;
  54083. /**
  54084. * Sets friction of the impostor
  54085. * @param impostor impostor to set friction on
  54086. * @param friction friction value
  54087. */
  54088. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54089. /**
  54090. * Gets restitution of the impostor
  54091. * @param impostor impostor to get restitution from
  54092. * @returns restitution value
  54093. */
  54094. getBodyRestitution(impostor: PhysicsImpostor): number;
  54095. /**
  54096. * Sets resitution of the impostor
  54097. * @param impostor impostor to set resitution on
  54098. * @param restitution resitution value
  54099. */
  54100. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54101. /**
  54102. * Gets pressure inside the impostor
  54103. * @param impostor impostor to get pressure from
  54104. * @returns pressure value
  54105. */
  54106. getBodyPressure(impostor: PhysicsImpostor): number;
  54107. /**
  54108. * Sets pressure inside a soft body impostor
  54109. * Cloth and rope must remain 0 pressure
  54110. * @param impostor impostor to set pressure on
  54111. * @param pressure pressure value
  54112. */
  54113. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54114. /**
  54115. * Gets stiffness of the impostor
  54116. * @param impostor impostor to get stiffness from
  54117. * @returns pressure value
  54118. */
  54119. getBodyStiffness(impostor: PhysicsImpostor): number;
  54120. /**
  54121. * Sets stiffness of the impostor
  54122. * @param impostor impostor to set stiffness on
  54123. * @param stiffness stiffness value from 0 to 1
  54124. */
  54125. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54126. /**
  54127. * Gets velocityIterations of the impostor
  54128. * @param impostor impostor to get velocity iterations from
  54129. * @returns velocityIterations value
  54130. */
  54131. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54132. /**
  54133. * Sets velocityIterations of the impostor
  54134. * @param impostor impostor to set velocity iterations on
  54135. * @param velocityIterations velocityIterations value
  54136. */
  54137. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54138. /**
  54139. * Gets positionIterations of the impostor
  54140. * @param impostor impostor to get position iterations from
  54141. * @returns positionIterations value
  54142. */
  54143. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54144. /**
  54145. * Sets positionIterations of the impostor
  54146. * @param impostor impostor to set position on
  54147. * @param positionIterations positionIterations value
  54148. */
  54149. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54150. /**
  54151. * Append an anchor to a cloth object
  54152. * @param impostor is the cloth impostor to add anchor to
  54153. * @param otherImpostor is the rigid impostor to anchor to
  54154. * @param width ratio across width from 0 to 1
  54155. * @param height ratio up height from 0 to 1
  54156. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54157. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54158. */
  54159. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54160. /**
  54161. * Append an hook to a rope object
  54162. * @param impostor is the rope impostor to add hook to
  54163. * @param otherImpostor is the rigid impostor to hook to
  54164. * @param length ratio along the rope from 0 to 1
  54165. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54166. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54167. */
  54168. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54169. /**
  54170. * Sleeps the physics body and stops it from being active
  54171. * @param impostor impostor to sleep
  54172. */
  54173. sleepBody(impostor: PhysicsImpostor): void;
  54174. /**
  54175. * Activates the physics body
  54176. * @param impostor impostor to activate
  54177. */
  54178. wakeUpBody(impostor: PhysicsImpostor): void;
  54179. /**
  54180. * Updates the distance parameters of the joint
  54181. * @param joint joint to update
  54182. * @param maxDistance maximum distance of the joint
  54183. * @param minDistance minimum distance of the joint
  54184. */
  54185. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54186. /**
  54187. * Sets a motor on the joint
  54188. * @param joint joint to set motor on
  54189. * @param speed speed of the motor
  54190. * @param maxForce maximum force of the motor
  54191. * @param motorIndex index of the motor
  54192. */
  54193. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54194. /**
  54195. * Sets the motors limit
  54196. * @param joint joint to set limit on
  54197. * @param upperLimit upper limit
  54198. * @param lowerLimit lower limit
  54199. */
  54200. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54201. /**
  54202. * Syncs the position and rotation of a mesh with the impostor
  54203. * @param mesh mesh to sync
  54204. * @param impostor impostor to update the mesh with
  54205. */
  54206. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54207. /**
  54208. * Gets the radius of the impostor
  54209. * @param impostor impostor to get radius from
  54210. * @returns the radius
  54211. */
  54212. getRadius(impostor: PhysicsImpostor): number;
  54213. /**
  54214. * Gets the box size of the impostor
  54215. * @param impostor impostor to get box size from
  54216. * @param result the resulting box size
  54217. */
  54218. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54219. /**
  54220. * Disposes of the impostor
  54221. */
  54222. dispose(): void;
  54223. /**
  54224. * Does a raycast in the physics world
  54225. * @param from when should the ray start?
  54226. * @param to when should the ray end?
  54227. * @returns PhysicsRaycastResult
  54228. */
  54229. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54230. }
  54231. }
  54232. declare module "babylonjs/Probes/reflectionProbe" {
  54233. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54234. import { Vector3 } from "babylonjs/Maths/math.vector";
  54235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54236. import { Nullable } from "babylonjs/types";
  54237. import { Scene } from "babylonjs/scene";
  54238. module "babylonjs/abstractScene" {
  54239. interface AbstractScene {
  54240. /**
  54241. * The list of reflection probes added to the scene
  54242. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54243. */
  54244. reflectionProbes: Array<ReflectionProbe>;
  54245. /**
  54246. * Removes the given reflection probe from this scene.
  54247. * @param toRemove The reflection probe to remove
  54248. * @returns The index of the removed reflection probe
  54249. */
  54250. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54251. /**
  54252. * Adds the given reflection probe to this scene.
  54253. * @param newReflectionProbe The reflection probe to add
  54254. */
  54255. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54256. }
  54257. }
  54258. /**
  54259. * Class used to generate realtime reflection / refraction cube textures
  54260. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54261. */
  54262. export class ReflectionProbe {
  54263. /** defines the name of the probe */
  54264. name: string;
  54265. private _scene;
  54266. private _renderTargetTexture;
  54267. private _projectionMatrix;
  54268. private _viewMatrix;
  54269. private _target;
  54270. private _add;
  54271. private _attachedMesh;
  54272. private _invertYAxis;
  54273. /** Gets or sets probe position (center of the cube map) */
  54274. position: Vector3;
  54275. /**
  54276. * Creates a new reflection probe
  54277. * @param name defines the name of the probe
  54278. * @param size defines the texture resolution (for each face)
  54279. * @param scene defines the hosting scene
  54280. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54281. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54282. */
  54283. constructor(
  54284. /** defines the name of the probe */
  54285. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54286. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54287. samples: number;
  54288. /** Gets or sets the refresh rate to use (on every frame by default) */
  54289. refreshRate: number;
  54290. /**
  54291. * Gets the hosting scene
  54292. * @returns a Scene
  54293. */
  54294. getScene(): Scene;
  54295. /** Gets the internal CubeTexture used to render to */
  54296. readonly cubeTexture: RenderTargetTexture;
  54297. /** Gets the list of meshes to render */
  54298. readonly renderList: Nullable<AbstractMesh[]>;
  54299. /**
  54300. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54301. * @param mesh defines the mesh to attach to
  54302. */
  54303. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54304. /**
  54305. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54306. * @param renderingGroupId The rendering group id corresponding to its index
  54307. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54308. */
  54309. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54310. /**
  54311. * Clean all associated resources
  54312. */
  54313. dispose(): void;
  54314. /**
  54315. * Converts the reflection probe information to a readable string for debug purpose.
  54316. * @param fullDetails Supports for multiple levels of logging within scene loading
  54317. * @returns the human readable reflection probe info
  54318. */
  54319. toString(fullDetails?: boolean): string;
  54320. /**
  54321. * Get the class name of the relfection probe.
  54322. * @returns "ReflectionProbe"
  54323. */
  54324. getClassName(): string;
  54325. /**
  54326. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54327. * @returns The JSON representation of the texture
  54328. */
  54329. serialize(): any;
  54330. /**
  54331. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54332. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54333. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54334. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54335. * @returns The parsed reflection probe if successful
  54336. */
  54337. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54338. }
  54339. }
  54340. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54341. /** @hidden */
  54342. export var _BabylonLoaderRegistered: boolean;
  54343. }
  54344. declare module "babylonjs/Loading/Plugins/index" {
  54345. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54346. }
  54347. declare module "babylonjs/Loading/index" {
  54348. export * from "babylonjs/Loading/loadingScreen";
  54349. export * from "babylonjs/Loading/Plugins/index";
  54350. export * from "babylonjs/Loading/sceneLoader";
  54351. export * from "babylonjs/Loading/sceneLoaderFlags";
  54352. }
  54353. declare module "babylonjs/Materials/Background/index" {
  54354. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54355. }
  54356. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54357. import { Scene } from "babylonjs/scene";
  54358. import { Color3 } from "babylonjs/Maths/math.color";
  54359. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54361. /**
  54362. * The Physically based simple base material of BJS.
  54363. *
  54364. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54365. * It is used as the base class for both the specGloss and metalRough conventions.
  54366. */
  54367. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54368. /**
  54369. * Number of Simultaneous lights allowed on the material.
  54370. */
  54371. maxSimultaneousLights: number;
  54372. /**
  54373. * If sets to true, disables all the lights affecting the material.
  54374. */
  54375. disableLighting: boolean;
  54376. /**
  54377. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54378. */
  54379. environmentTexture: BaseTexture;
  54380. /**
  54381. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54382. */
  54383. invertNormalMapX: boolean;
  54384. /**
  54385. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54386. */
  54387. invertNormalMapY: boolean;
  54388. /**
  54389. * Normal map used in the model.
  54390. */
  54391. normalTexture: BaseTexture;
  54392. /**
  54393. * Emissivie color used to self-illuminate the model.
  54394. */
  54395. emissiveColor: Color3;
  54396. /**
  54397. * Emissivie texture used to self-illuminate the model.
  54398. */
  54399. emissiveTexture: BaseTexture;
  54400. /**
  54401. * Occlusion Channel Strenght.
  54402. */
  54403. occlusionStrength: number;
  54404. /**
  54405. * Occlusion Texture of the material (adding extra occlusion effects).
  54406. */
  54407. occlusionTexture: BaseTexture;
  54408. /**
  54409. * Defines the alpha limits in alpha test mode.
  54410. */
  54411. alphaCutOff: number;
  54412. /**
  54413. * Gets the current double sided mode.
  54414. */
  54415. /**
  54416. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54417. */
  54418. doubleSided: boolean;
  54419. /**
  54420. * Stores the pre-calculated light information of a mesh in a texture.
  54421. */
  54422. lightmapTexture: BaseTexture;
  54423. /**
  54424. * If true, the light map contains occlusion information instead of lighting info.
  54425. */
  54426. useLightmapAsShadowmap: boolean;
  54427. /**
  54428. * Instantiates a new PBRMaterial instance.
  54429. *
  54430. * @param name The material name
  54431. * @param scene The scene the material will be use in.
  54432. */
  54433. constructor(name: string, scene: Scene);
  54434. getClassName(): string;
  54435. }
  54436. }
  54437. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54438. import { Scene } from "babylonjs/scene";
  54439. import { Color3 } from "babylonjs/Maths/math.color";
  54440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54441. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54442. /**
  54443. * The PBR material of BJS following the metal roughness convention.
  54444. *
  54445. * This fits to the PBR convention in the GLTF definition:
  54446. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54447. */
  54448. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54449. /**
  54450. * The base color has two different interpretations depending on the value of metalness.
  54451. * When the material is a metal, the base color is the specific measured reflectance value
  54452. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54453. * of the material.
  54454. */
  54455. baseColor: Color3;
  54456. /**
  54457. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54458. * well as opacity information in the alpha channel.
  54459. */
  54460. baseTexture: BaseTexture;
  54461. /**
  54462. * Specifies the metallic scalar value of the material.
  54463. * Can also be used to scale the metalness values of the metallic texture.
  54464. */
  54465. metallic: number;
  54466. /**
  54467. * Specifies the roughness scalar value of the material.
  54468. * Can also be used to scale the roughness values of the metallic texture.
  54469. */
  54470. roughness: number;
  54471. /**
  54472. * Texture containing both the metallic value in the B channel and the
  54473. * roughness value in the G channel to keep better precision.
  54474. */
  54475. metallicRoughnessTexture: BaseTexture;
  54476. /**
  54477. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54478. *
  54479. * @param name The material name
  54480. * @param scene The scene the material will be use in.
  54481. */
  54482. constructor(name: string, scene: Scene);
  54483. /**
  54484. * Return the currrent class name of the material.
  54485. */
  54486. getClassName(): string;
  54487. /**
  54488. * Makes a duplicate of the current material.
  54489. * @param name - name to use for the new material.
  54490. */
  54491. clone(name: string): PBRMetallicRoughnessMaterial;
  54492. /**
  54493. * Serialize the material to a parsable JSON object.
  54494. */
  54495. serialize(): any;
  54496. /**
  54497. * Parses a JSON object correponding to the serialize function.
  54498. */
  54499. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54500. }
  54501. }
  54502. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54503. import { Scene } from "babylonjs/scene";
  54504. import { Color3 } from "babylonjs/Maths/math.color";
  54505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54506. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54507. /**
  54508. * The PBR material of BJS following the specular glossiness convention.
  54509. *
  54510. * This fits to the PBR convention in the GLTF definition:
  54511. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54512. */
  54513. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54514. /**
  54515. * Specifies the diffuse color of the material.
  54516. */
  54517. diffuseColor: Color3;
  54518. /**
  54519. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54520. * channel.
  54521. */
  54522. diffuseTexture: BaseTexture;
  54523. /**
  54524. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54525. */
  54526. specularColor: Color3;
  54527. /**
  54528. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54529. */
  54530. glossiness: number;
  54531. /**
  54532. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54533. */
  54534. specularGlossinessTexture: BaseTexture;
  54535. /**
  54536. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54537. *
  54538. * @param name The material name
  54539. * @param scene The scene the material will be use in.
  54540. */
  54541. constructor(name: string, scene: Scene);
  54542. /**
  54543. * Return the currrent class name of the material.
  54544. */
  54545. getClassName(): string;
  54546. /**
  54547. * Makes a duplicate of the current material.
  54548. * @param name - name to use for the new material.
  54549. */
  54550. clone(name: string): PBRSpecularGlossinessMaterial;
  54551. /**
  54552. * Serialize the material to a parsable JSON object.
  54553. */
  54554. serialize(): any;
  54555. /**
  54556. * Parses a JSON object correponding to the serialize function.
  54557. */
  54558. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54559. }
  54560. }
  54561. declare module "babylonjs/Materials/PBR/index" {
  54562. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54563. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54564. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54565. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54566. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54567. }
  54568. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54569. import { Nullable } from "babylonjs/types";
  54570. import { Scene } from "babylonjs/scene";
  54571. import { Matrix } from "babylonjs/Maths/math.vector";
  54572. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54573. /**
  54574. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54575. * It can help converting any input color in a desired output one. This can then be used to create effects
  54576. * from sepia, black and white to sixties or futuristic rendering...
  54577. *
  54578. * The only supported format is currently 3dl.
  54579. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54580. */
  54581. export class ColorGradingTexture extends BaseTexture {
  54582. /**
  54583. * The current texture matrix. (will always be identity in color grading texture)
  54584. */
  54585. private _textureMatrix;
  54586. /**
  54587. * The texture URL.
  54588. */
  54589. url: string;
  54590. /**
  54591. * Empty line regex stored for GC.
  54592. */
  54593. private static _noneEmptyLineRegex;
  54594. private _engine;
  54595. /**
  54596. * Instantiates a ColorGradingTexture from the following parameters.
  54597. *
  54598. * @param url The location of the color gradind data (currently only supporting 3dl)
  54599. * @param scene The scene the texture will be used in
  54600. */
  54601. constructor(url: string, scene: Scene);
  54602. /**
  54603. * Returns the texture matrix used in most of the material.
  54604. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54605. */
  54606. getTextureMatrix(): Matrix;
  54607. /**
  54608. * Occurs when the file being loaded is a .3dl LUT file.
  54609. */
  54610. private load3dlTexture;
  54611. /**
  54612. * Starts the loading process of the texture.
  54613. */
  54614. private loadTexture;
  54615. /**
  54616. * Clones the color gradind texture.
  54617. */
  54618. clone(): ColorGradingTexture;
  54619. /**
  54620. * Called during delayed load for textures.
  54621. */
  54622. delayLoad(): void;
  54623. /**
  54624. * Parses a color grading texture serialized by Babylon.
  54625. * @param parsedTexture The texture information being parsedTexture
  54626. * @param scene The scene to load the texture in
  54627. * @param rootUrl The root url of the data assets to load
  54628. * @return A color gradind texture
  54629. */
  54630. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54631. /**
  54632. * Serializes the LUT texture to json format.
  54633. */
  54634. serialize(): any;
  54635. }
  54636. }
  54637. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54639. import { Scene } from "babylonjs/scene";
  54640. import { Nullable } from "babylonjs/types";
  54641. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54642. /**
  54643. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54644. */
  54645. export class EquiRectangularCubeTexture extends BaseTexture {
  54646. /** The six faces of the cube. */
  54647. private static _FacesMapping;
  54648. private _noMipmap;
  54649. private _onLoad;
  54650. private _onError;
  54651. /** The size of the cubemap. */
  54652. private _size;
  54653. /** The buffer of the image. */
  54654. private _buffer;
  54655. /** The width of the input image. */
  54656. private _width;
  54657. /** The height of the input image. */
  54658. private _height;
  54659. /** The URL to the image. */
  54660. url: string;
  54661. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54662. coordinatesMode: number;
  54663. /**
  54664. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54665. * @param url The location of the image
  54666. * @param scene The scene the texture will be used in
  54667. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54668. * @param noMipmap Forces to not generate the mipmap if true
  54669. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54670. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54671. * @param onLoad — defines a callback called when texture is loaded
  54672. * @param onError — defines a callback called if there is an error
  54673. */
  54674. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54675. /**
  54676. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54677. */
  54678. private loadImage;
  54679. /**
  54680. * Convert the image buffer into a cubemap and create a CubeTexture.
  54681. */
  54682. private loadTexture;
  54683. /**
  54684. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54685. * @param buffer The ArrayBuffer that should be converted.
  54686. * @returns The buffer as Float32Array.
  54687. */
  54688. private getFloat32ArrayFromArrayBuffer;
  54689. /**
  54690. * Get the current class name of the texture useful for serialization or dynamic coding.
  54691. * @returns "EquiRectangularCubeTexture"
  54692. */
  54693. getClassName(): string;
  54694. /**
  54695. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54696. * @returns A clone of the current EquiRectangularCubeTexture.
  54697. */
  54698. clone(): EquiRectangularCubeTexture;
  54699. }
  54700. }
  54701. declare module "babylonjs/Misc/tga" {
  54702. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54703. /**
  54704. * Based on jsTGALoader - Javascript loader for TGA file
  54705. * By Vincent Thibault
  54706. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54707. */
  54708. export class TGATools {
  54709. private static _TYPE_INDEXED;
  54710. private static _TYPE_RGB;
  54711. private static _TYPE_GREY;
  54712. private static _TYPE_RLE_INDEXED;
  54713. private static _TYPE_RLE_RGB;
  54714. private static _TYPE_RLE_GREY;
  54715. private static _ORIGIN_MASK;
  54716. private static _ORIGIN_SHIFT;
  54717. private static _ORIGIN_BL;
  54718. private static _ORIGIN_BR;
  54719. private static _ORIGIN_UL;
  54720. private static _ORIGIN_UR;
  54721. /**
  54722. * Gets the header of a TGA file
  54723. * @param data defines the TGA data
  54724. * @returns the header
  54725. */
  54726. static GetTGAHeader(data: Uint8Array): any;
  54727. /**
  54728. * Uploads TGA content to a Babylon Texture
  54729. * @hidden
  54730. */
  54731. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54732. /** @hidden */
  54733. 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;
  54734. /** @hidden */
  54735. 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;
  54736. /** @hidden */
  54737. 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;
  54738. /** @hidden */
  54739. 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;
  54740. /** @hidden */
  54741. 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;
  54742. /** @hidden */
  54743. 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;
  54744. }
  54745. }
  54746. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54747. import { Nullable } from "babylonjs/types";
  54748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54749. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54750. /**
  54751. * Implementation of the TGA Texture Loader.
  54752. * @hidden
  54753. */
  54754. export class _TGATextureLoader implements IInternalTextureLoader {
  54755. /**
  54756. * Defines wether the loader supports cascade loading the different faces.
  54757. */
  54758. readonly supportCascades: boolean;
  54759. /**
  54760. * This returns if the loader support the current file information.
  54761. * @param extension defines the file extension of the file being loaded
  54762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54763. * @param fallback defines the fallback internal texture if any
  54764. * @param isBase64 defines whether the texture is encoded as a base64
  54765. * @param isBuffer defines whether the texture data are stored as a buffer
  54766. * @returns true if the loader can load the specified file
  54767. */
  54768. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54769. /**
  54770. * Transform the url before loading if required.
  54771. * @param rootUrl the url of the texture
  54772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54773. * @returns the transformed texture
  54774. */
  54775. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54776. /**
  54777. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54778. * @param rootUrl the url of the texture
  54779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54780. * @returns the fallback texture
  54781. */
  54782. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54783. /**
  54784. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54785. * @param data contains the texture data
  54786. * @param texture defines the BabylonJS internal texture
  54787. * @param createPolynomials will be true if polynomials have been requested
  54788. * @param onLoad defines the callback to trigger once the texture is ready
  54789. * @param onError defines the callback to trigger in case of error
  54790. */
  54791. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54792. /**
  54793. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54794. * @param data contains the texture data
  54795. * @param texture defines the BabylonJS internal texture
  54796. * @param callback defines the method to call once ready to upload
  54797. */
  54798. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54799. }
  54800. }
  54801. declare module "babylonjs/Misc/basis" {
  54802. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54803. /**
  54804. * Info about the .basis files
  54805. */
  54806. class BasisFileInfo {
  54807. /**
  54808. * If the file has alpha
  54809. */
  54810. hasAlpha: boolean;
  54811. /**
  54812. * Info about each image of the basis file
  54813. */
  54814. images: Array<{
  54815. levels: Array<{
  54816. width: number;
  54817. height: number;
  54818. transcodedPixels: ArrayBufferView;
  54819. }>;
  54820. }>;
  54821. }
  54822. /**
  54823. * Result of transcoding a basis file
  54824. */
  54825. class TranscodeResult {
  54826. /**
  54827. * Info about the .basis file
  54828. */
  54829. fileInfo: BasisFileInfo;
  54830. /**
  54831. * Format to use when loading the file
  54832. */
  54833. format: number;
  54834. }
  54835. /**
  54836. * Configuration options for the Basis transcoder
  54837. */
  54838. export class BasisTranscodeConfiguration {
  54839. /**
  54840. * Supported compression formats used to determine the supported output format of the transcoder
  54841. */
  54842. supportedCompressionFormats?: {
  54843. /**
  54844. * etc1 compression format
  54845. */
  54846. etc1?: boolean;
  54847. /**
  54848. * s3tc compression format
  54849. */
  54850. s3tc?: boolean;
  54851. /**
  54852. * pvrtc compression format
  54853. */
  54854. pvrtc?: boolean;
  54855. /**
  54856. * etc2 compression format
  54857. */
  54858. etc2?: boolean;
  54859. };
  54860. /**
  54861. * If mipmap levels should be loaded for transcoded images (Default: true)
  54862. */
  54863. loadMipmapLevels?: boolean;
  54864. /**
  54865. * Index of a single image to load (Default: all images)
  54866. */
  54867. loadSingleImage?: number;
  54868. }
  54869. /**
  54870. * Used to load .Basis files
  54871. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54872. */
  54873. export class BasisTools {
  54874. private static _IgnoreSupportedFormats;
  54875. /**
  54876. * URL to use when loading the basis transcoder
  54877. */
  54878. static JSModuleURL: string;
  54879. /**
  54880. * URL to use when loading the wasm module for the transcoder
  54881. */
  54882. static WasmModuleURL: string;
  54883. /**
  54884. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54885. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54886. * @returns internal format corresponding to the Basis format
  54887. */
  54888. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54889. private static _WorkerPromise;
  54890. private static _Worker;
  54891. private static _actionId;
  54892. private static _CreateWorkerAsync;
  54893. /**
  54894. * Transcodes a loaded image file to compressed pixel data
  54895. * @param imageData image data to transcode
  54896. * @param config configuration options for the transcoding
  54897. * @returns a promise resulting in the transcoded image
  54898. */
  54899. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54900. /**
  54901. * Loads a texture from the transcode result
  54902. * @param texture texture load to
  54903. * @param transcodeResult the result of transcoding the basis file to load from
  54904. */
  54905. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54906. }
  54907. }
  54908. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54909. import { Nullable } from "babylonjs/types";
  54910. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54911. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54912. /**
  54913. * Loader for .basis file format
  54914. */
  54915. export class _BasisTextureLoader implements IInternalTextureLoader {
  54916. /**
  54917. * Defines whether the loader supports cascade loading the different faces.
  54918. */
  54919. readonly supportCascades: boolean;
  54920. /**
  54921. * This returns if the loader support the current file information.
  54922. * @param extension defines the file extension of the file being loaded
  54923. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54924. * @param fallback defines the fallback internal texture if any
  54925. * @param isBase64 defines whether the texture is encoded as a base64
  54926. * @param isBuffer defines whether the texture data are stored as a buffer
  54927. * @returns true if the loader can load the specified file
  54928. */
  54929. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54930. /**
  54931. * Transform the url before loading if required.
  54932. * @param rootUrl the url of the texture
  54933. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54934. * @returns the transformed texture
  54935. */
  54936. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54937. /**
  54938. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54939. * @param rootUrl the url of the texture
  54940. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54941. * @returns the fallback texture
  54942. */
  54943. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54944. /**
  54945. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54946. * @param data contains the texture data
  54947. * @param texture defines the BabylonJS internal texture
  54948. * @param createPolynomials will be true if polynomials have been requested
  54949. * @param onLoad defines the callback to trigger once the texture is ready
  54950. * @param onError defines the callback to trigger in case of error
  54951. */
  54952. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54953. /**
  54954. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54955. * @param data contains the texture data
  54956. * @param texture defines the BabylonJS internal texture
  54957. * @param callback defines the method to call once ready to upload
  54958. */
  54959. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54960. }
  54961. }
  54962. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54963. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54964. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54965. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54966. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54967. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54968. }
  54969. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54970. import { Scene } from "babylonjs/scene";
  54971. import { Texture } from "babylonjs/Materials/Textures/texture";
  54972. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54973. /**
  54974. * 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.
  54975. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54976. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54977. */
  54978. export class CustomProceduralTexture extends ProceduralTexture {
  54979. private _animate;
  54980. private _time;
  54981. private _config;
  54982. private _texturePath;
  54983. /**
  54984. * Instantiates a new Custom Procedural Texture.
  54985. * 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.
  54986. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54987. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54988. * @param name Define the name of the texture
  54989. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54990. * @param size Define the size of the texture to create
  54991. * @param scene Define the scene the texture belongs to
  54992. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54993. * @param generateMipMaps Define if the texture should creates mip maps or not
  54994. */
  54995. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54996. private _loadJson;
  54997. /**
  54998. * Is the texture ready to be used ? (rendered at least once)
  54999. * @returns true if ready, otherwise, false.
  55000. */
  55001. isReady(): boolean;
  55002. /**
  55003. * Render the texture to its associated render target.
  55004. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55005. */
  55006. render(useCameraPostProcess?: boolean): void;
  55007. /**
  55008. * Update the list of dependant textures samplers in the shader.
  55009. */
  55010. updateTextures(): void;
  55011. /**
  55012. * Update the uniform values of the procedural texture in the shader.
  55013. */
  55014. updateShaderUniforms(): void;
  55015. /**
  55016. * Define if the texture animates or not.
  55017. */
  55018. animate: boolean;
  55019. }
  55020. }
  55021. declare module "babylonjs/Shaders/noise.fragment" {
  55022. /** @hidden */
  55023. export var noisePixelShader: {
  55024. name: string;
  55025. shader: string;
  55026. };
  55027. }
  55028. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55029. import { Nullable } from "babylonjs/types";
  55030. import { Scene } from "babylonjs/scene";
  55031. import { Texture } from "babylonjs/Materials/Textures/texture";
  55032. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55033. import "babylonjs/Shaders/noise.fragment";
  55034. /**
  55035. * Class used to generate noise procedural textures
  55036. */
  55037. export class NoiseProceduralTexture extends ProceduralTexture {
  55038. private _time;
  55039. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55040. brightness: number;
  55041. /** Defines the number of octaves to process */
  55042. octaves: number;
  55043. /** Defines the level of persistence (0.8 by default) */
  55044. persistence: number;
  55045. /** Gets or sets animation speed factor (default is 1) */
  55046. animationSpeedFactor: number;
  55047. /**
  55048. * Creates a new NoiseProceduralTexture
  55049. * @param name defines the name fo the texture
  55050. * @param size defines the size of the texture (default is 256)
  55051. * @param scene defines the hosting scene
  55052. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55053. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55054. */
  55055. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55056. private _updateShaderUniforms;
  55057. protected _getDefines(): string;
  55058. /** Generate the current state of the procedural texture */
  55059. render(useCameraPostProcess?: boolean): void;
  55060. /**
  55061. * Serializes this noise procedural texture
  55062. * @returns a serialized noise procedural texture object
  55063. */
  55064. serialize(): any;
  55065. /**
  55066. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55067. * @param parsedTexture defines parsed texture data
  55068. * @param scene defines the current scene
  55069. * @param rootUrl defines the root URL containing noise procedural texture information
  55070. * @returns a parsed NoiseProceduralTexture
  55071. */
  55072. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55073. }
  55074. }
  55075. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55076. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55077. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55078. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55079. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55080. }
  55081. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55082. import { Nullable } from "babylonjs/types";
  55083. import { Scene } from "babylonjs/scene";
  55084. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55085. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55086. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55087. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55088. /**
  55089. * Raw cube texture where the raw buffers are passed in
  55090. */
  55091. export class RawCubeTexture extends CubeTexture {
  55092. /**
  55093. * Creates a cube texture where the raw buffers are passed in.
  55094. * @param scene defines the scene the texture is attached to
  55095. * @param data defines the array of data to use to create each face
  55096. * @param size defines the size of the textures
  55097. * @param format defines the format of the data
  55098. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55099. * @param generateMipMaps defines if the engine should generate the mip levels
  55100. * @param invertY defines if data must be stored with Y axis inverted
  55101. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55102. * @param compression defines the compression used (null by default)
  55103. */
  55104. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55105. /**
  55106. * Updates the raw cube texture.
  55107. * @param data defines the data to store
  55108. * @param format defines the data format
  55109. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55110. * @param invertY defines if data must be stored with Y axis inverted
  55111. * @param compression defines the compression used (null by default)
  55112. * @param level defines which level of the texture to update
  55113. */
  55114. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55115. /**
  55116. * Updates a raw cube texture with RGBD encoded data.
  55117. * @param data defines the array of data [mipmap][face] to use to create each face
  55118. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55119. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55120. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55121. * @returns a promsie that resolves when the operation is complete
  55122. */
  55123. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55124. /**
  55125. * Clones the raw cube texture.
  55126. * @return a new cube texture
  55127. */
  55128. clone(): CubeTexture;
  55129. /** @hidden */
  55130. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55131. }
  55132. }
  55133. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55134. import { Scene } from "babylonjs/scene";
  55135. import { Texture } from "babylonjs/Materials/Textures/texture";
  55136. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55137. /**
  55138. * Class used to store 3D textures containing user data
  55139. */
  55140. export class RawTexture3D extends Texture {
  55141. /** Gets or sets the texture format to use */
  55142. format: number;
  55143. private _engine;
  55144. /**
  55145. * Create a new RawTexture3D
  55146. * @param data defines the data of the texture
  55147. * @param width defines the width of the texture
  55148. * @param height defines the height of the texture
  55149. * @param depth defines the depth of the texture
  55150. * @param format defines the texture format to use
  55151. * @param scene defines the hosting scene
  55152. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55153. * @param invertY defines if texture must be stored with Y axis inverted
  55154. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55155. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55156. */
  55157. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55158. /** Gets or sets the texture format to use */
  55159. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55160. /**
  55161. * Update the texture with new data
  55162. * @param data defines the data to store in the texture
  55163. */
  55164. update(data: ArrayBufferView): void;
  55165. }
  55166. }
  55167. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55168. import { Scene } from "babylonjs/scene";
  55169. import { Plane } from "babylonjs/Maths/math.plane";
  55170. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55171. /**
  55172. * Creates a refraction texture used by refraction channel of the standard material.
  55173. * It is like a mirror but to see through a material.
  55174. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55175. */
  55176. export class RefractionTexture extends RenderTargetTexture {
  55177. /**
  55178. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55179. * 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.
  55180. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55181. */
  55182. refractionPlane: Plane;
  55183. /**
  55184. * Define how deep under the surface we should see.
  55185. */
  55186. depth: number;
  55187. /**
  55188. * Creates a refraction texture used by refraction channel of the standard material.
  55189. * It is like a mirror but to see through a material.
  55190. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55191. * @param name Define the texture name
  55192. * @param size Define the size of the underlying texture
  55193. * @param scene Define the scene the refraction belongs to
  55194. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55195. */
  55196. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55197. /**
  55198. * Clone the refraction texture.
  55199. * @returns the cloned texture
  55200. */
  55201. clone(): RefractionTexture;
  55202. /**
  55203. * Serialize the texture to a JSON representation you could use in Parse later on
  55204. * @returns the serialized JSON representation
  55205. */
  55206. serialize(): any;
  55207. }
  55208. }
  55209. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55210. import { Nullable } from "babylonjs/types";
  55211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55212. import { Matrix } from "babylonjs/Maths/math.vector";
  55213. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55214. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55215. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55216. import { Scene } from "babylonjs/scene";
  55217. /**
  55218. * Defines the options related to the creation of an HtmlElementTexture
  55219. */
  55220. export interface IHtmlElementTextureOptions {
  55221. /**
  55222. * Defines wether mip maps should be created or not.
  55223. */
  55224. generateMipMaps?: boolean;
  55225. /**
  55226. * Defines the sampling mode of the texture.
  55227. */
  55228. samplingMode?: number;
  55229. /**
  55230. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55231. */
  55232. engine: Nullable<ThinEngine>;
  55233. /**
  55234. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55235. */
  55236. scene: Nullable<Scene>;
  55237. }
  55238. /**
  55239. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55240. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55241. * is automatically managed.
  55242. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55243. * in your application.
  55244. *
  55245. * As the update is not automatic, you need to call them manually.
  55246. */
  55247. export class HtmlElementTexture extends BaseTexture {
  55248. /**
  55249. * The texture URL.
  55250. */
  55251. element: HTMLVideoElement | HTMLCanvasElement;
  55252. private static readonly DefaultOptions;
  55253. private _textureMatrix;
  55254. private _engine;
  55255. private _isVideo;
  55256. private _generateMipMaps;
  55257. private _samplingMode;
  55258. /**
  55259. * Instantiates a HtmlElementTexture from the following parameters.
  55260. *
  55261. * @param name Defines the name of the texture
  55262. * @param element Defines the video or canvas the texture is filled with
  55263. * @param options Defines the other none mandatory texture creation options
  55264. */
  55265. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55266. private _createInternalTexture;
  55267. /**
  55268. * Returns the texture matrix used in most of the material.
  55269. */
  55270. getTextureMatrix(): Matrix;
  55271. /**
  55272. * Updates the content of the texture.
  55273. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55274. */
  55275. update(invertY?: Nullable<boolean>): void;
  55276. }
  55277. }
  55278. declare module "babylonjs/Materials/Textures/index" {
  55279. export * from "babylonjs/Materials/Textures/baseTexture";
  55280. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55281. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55282. export * from "babylonjs/Materials/Textures/cubeTexture";
  55283. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55284. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55285. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55286. export * from "babylonjs/Materials/Textures/internalTexture";
  55287. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55288. export * from "babylonjs/Materials/Textures/Loaders/index";
  55289. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55290. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55291. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55292. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55293. export * from "babylonjs/Materials/Textures/rawTexture";
  55294. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55295. export * from "babylonjs/Materials/Textures/refractionTexture";
  55296. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55297. export * from "babylonjs/Materials/Textures/texture";
  55298. export * from "babylonjs/Materials/Textures/videoTexture";
  55299. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55300. }
  55301. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55302. /**
  55303. * Enum used to define the target of a block
  55304. */
  55305. export enum NodeMaterialBlockTargets {
  55306. /** Vertex shader */
  55307. Vertex = 1,
  55308. /** Fragment shader */
  55309. Fragment = 2,
  55310. /** Neutral */
  55311. Neutral = 4,
  55312. /** Vertex and Fragment */
  55313. VertexAndFragment = 3
  55314. }
  55315. }
  55316. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55317. /**
  55318. * Defines the kind of connection point for node based material
  55319. */
  55320. export enum NodeMaterialBlockConnectionPointTypes {
  55321. /** Float */
  55322. Float = 1,
  55323. /** Int */
  55324. Int = 2,
  55325. /** Vector2 */
  55326. Vector2 = 4,
  55327. /** Vector3 */
  55328. Vector3 = 8,
  55329. /** Vector4 */
  55330. Vector4 = 16,
  55331. /** Color3 */
  55332. Color3 = 32,
  55333. /** Color4 */
  55334. Color4 = 64,
  55335. /** Matrix */
  55336. Matrix = 128,
  55337. /** Detect type based on connection */
  55338. AutoDetect = 1024,
  55339. /** Output type that will be defined by input type */
  55340. BasedOnInput = 2048
  55341. }
  55342. }
  55343. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55344. /**
  55345. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55346. */
  55347. export enum NodeMaterialBlockConnectionPointMode {
  55348. /** Value is an uniform */
  55349. Uniform = 0,
  55350. /** Value is a mesh attribute */
  55351. Attribute = 1,
  55352. /** Value is a varying between vertex and fragment shaders */
  55353. Varying = 2,
  55354. /** Mode is undefined */
  55355. Undefined = 3
  55356. }
  55357. }
  55358. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55359. /**
  55360. * Enum used to define system values e.g. values automatically provided by the system
  55361. */
  55362. export enum NodeMaterialSystemValues {
  55363. /** World */
  55364. World = 1,
  55365. /** View */
  55366. View = 2,
  55367. /** Projection */
  55368. Projection = 3,
  55369. /** ViewProjection */
  55370. ViewProjection = 4,
  55371. /** WorldView */
  55372. WorldView = 5,
  55373. /** WorldViewProjection */
  55374. WorldViewProjection = 6,
  55375. /** CameraPosition */
  55376. CameraPosition = 7,
  55377. /** Fog Color */
  55378. FogColor = 8,
  55379. /** Delta time */
  55380. DeltaTime = 9
  55381. }
  55382. }
  55383. declare module "babylonjs/Materials/Node/Enums/index" {
  55384. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55385. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55386. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55387. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55388. }
  55389. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55391. /**
  55392. * Root class for all node material optimizers
  55393. */
  55394. export class NodeMaterialOptimizer {
  55395. /**
  55396. * Function used to optimize a NodeMaterial graph
  55397. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55398. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55399. */
  55400. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55401. }
  55402. }
  55403. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55407. import { Scene } from "babylonjs/scene";
  55408. /**
  55409. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55410. */
  55411. export class TransformBlock extends NodeMaterialBlock {
  55412. /**
  55413. * Defines the value to use to complement W value to transform it to a Vector4
  55414. */
  55415. complementW: number;
  55416. /**
  55417. * Defines the value to use to complement z value to transform it to a Vector4
  55418. */
  55419. complementZ: number;
  55420. /**
  55421. * Creates a new TransformBlock
  55422. * @param name defines the block name
  55423. */
  55424. constructor(name: string);
  55425. /**
  55426. * Gets the current class name
  55427. * @returns the class name
  55428. */
  55429. getClassName(): string;
  55430. /**
  55431. * Gets the vector input
  55432. */
  55433. readonly vector: NodeMaterialConnectionPoint;
  55434. /**
  55435. * Gets the output component
  55436. */
  55437. readonly output: NodeMaterialConnectionPoint;
  55438. /**
  55439. * Gets the matrix transform input
  55440. */
  55441. readonly transform: NodeMaterialConnectionPoint;
  55442. protected _buildBlock(state: NodeMaterialBuildState): this;
  55443. serialize(): any;
  55444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55445. protected _dumpPropertiesCode(): string;
  55446. }
  55447. }
  55448. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55452. /**
  55453. * Block used to output the vertex position
  55454. */
  55455. export class VertexOutputBlock extends NodeMaterialBlock {
  55456. /**
  55457. * Creates a new VertexOutputBlock
  55458. * @param name defines the block name
  55459. */
  55460. constructor(name: string);
  55461. /**
  55462. * Gets the current class name
  55463. * @returns the class name
  55464. */
  55465. getClassName(): string;
  55466. /**
  55467. * Gets the vector input component
  55468. */
  55469. readonly vector: NodeMaterialConnectionPoint;
  55470. protected _buildBlock(state: NodeMaterialBuildState): this;
  55471. }
  55472. }
  55473. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55477. /**
  55478. * Block used to output the final color
  55479. */
  55480. export class FragmentOutputBlock extends NodeMaterialBlock {
  55481. /**
  55482. * Create a new FragmentOutputBlock
  55483. * @param name defines the block name
  55484. */
  55485. constructor(name: string);
  55486. /**
  55487. * Gets the current class name
  55488. * @returns the class name
  55489. */
  55490. getClassName(): string;
  55491. /**
  55492. * Gets the rgba input component
  55493. */
  55494. readonly rgba: NodeMaterialConnectionPoint;
  55495. /**
  55496. * Gets the rgb input component
  55497. */
  55498. readonly rgb: NodeMaterialConnectionPoint;
  55499. /**
  55500. * Gets the a input component
  55501. */
  55502. readonly a: NodeMaterialConnectionPoint;
  55503. protected _buildBlock(state: NodeMaterialBuildState): this;
  55504. }
  55505. }
  55506. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55512. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55513. import { Effect } from "babylonjs/Materials/effect";
  55514. import { Mesh } from "babylonjs/Meshes/mesh";
  55515. import { Nullable } from "babylonjs/types";
  55516. import { Scene } from "babylonjs/scene";
  55517. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55518. /**
  55519. * Block used to read a reflection texture from a sampler
  55520. */
  55521. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55522. private _define3DName;
  55523. private _defineCubicName;
  55524. private _defineExplicitName;
  55525. private _defineProjectionName;
  55526. private _defineLocalCubicName;
  55527. private _defineSphericalName;
  55528. private _definePlanarName;
  55529. private _defineEquirectangularName;
  55530. private _defineMirroredEquirectangularFixedName;
  55531. private _defineEquirectangularFixedName;
  55532. private _defineSkyboxName;
  55533. private _cubeSamplerName;
  55534. private _2DSamplerName;
  55535. private _positionUVWName;
  55536. private _directionWName;
  55537. private _reflectionCoordsName;
  55538. private _reflection2DCoordsName;
  55539. private _reflectionColorName;
  55540. private _reflectionMatrixName;
  55541. /**
  55542. * Gets or sets the texture associated with the node
  55543. */
  55544. texture: Nullable<BaseTexture>;
  55545. /**
  55546. * Create a new TextureBlock
  55547. * @param name defines the block name
  55548. */
  55549. constructor(name: string);
  55550. /**
  55551. * Gets the current class name
  55552. * @returns the class name
  55553. */
  55554. getClassName(): string;
  55555. /**
  55556. * Gets the world position input component
  55557. */
  55558. readonly position: NodeMaterialConnectionPoint;
  55559. /**
  55560. * Gets the world position input component
  55561. */
  55562. readonly worldPosition: NodeMaterialConnectionPoint;
  55563. /**
  55564. * Gets the world normal input component
  55565. */
  55566. readonly worldNormal: NodeMaterialConnectionPoint;
  55567. /**
  55568. * Gets the world input component
  55569. */
  55570. readonly world: NodeMaterialConnectionPoint;
  55571. /**
  55572. * Gets the camera (or eye) position component
  55573. */
  55574. readonly cameraPosition: NodeMaterialConnectionPoint;
  55575. /**
  55576. * Gets the view input component
  55577. */
  55578. readonly view: NodeMaterialConnectionPoint;
  55579. /**
  55580. * Gets the rgb output component
  55581. */
  55582. readonly rgb: NodeMaterialConnectionPoint;
  55583. /**
  55584. * Gets the r output component
  55585. */
  55586. readonly r: NodeMaterialConnectionPoint;
  55587. /**
  55588. * Gets the g output component
  55589. */
  55590. readonly g: NodeMaterialConnectionPoint;
  55591. /**
  55592. * Gets the b output component
  55593. */
  55594. readonly b: NodeMaterialConnectionPoint;
  55595. autoConfigure(material: NodeMaterial): void;
  55596. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55597. isReady(): boolean;
  55598. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55599. private _injectVertexCode;
  55600. private _writeOutput;
  55601. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55602. serialize(): any;
  55603. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55604. }
  55605. }
  55606. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55608. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55609. import { Scene } from "babylonjs/scene";
  55610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55611. import { Matrix } from "babylonjs/Maths/math.vector";
  55612. import { Mesh } from "babylonjs/Meshes/mesh";
  55613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55614. import { Observable } from "babylonjs/Misc/observable";
  55615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55616. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55617. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55618. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55619. import { Nullable } from "babylonjs/types";
  55620. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55621. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55622. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55623. /**
  55624. * Interface used to configure the node material editor
  55625. */
  55626. export interface INodeMaterialEditorOptions {
  55627. /** Define the URl to load node editor script */
  55628. editorURL?: string;
  55629. }
  55630. /** @hidden */
  55631. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55632. /** BONES */
  55633. NUM_BONE_INFLUENCERS: number;
  55634. BonesPerMesh: number;
  55635. BONETEXTURE: boolean;
  55636. /** MORPH TARGETS */
  55637. MORPHTARGETS: boolean;
  55638. MORPHTARGETS_NORMAL: boolean;
  55639. MORPHTARGETS_TANGENT: boolean;
  55640. MORPHTARGETS_UV: boolean;
  55641. NUM_MORPH_INFLUENCERS: number;
  55642. /** IMAGE PROCESSING */
  55643. IMAGEPROCESSING: boolean;
  55644. VIGNETTE: boolean;
  55645. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55646. VIGNETTEBLENDMODEOPAQUE: boolean;
  55647. TONEMAPPING: boolean;
  55648. TONEMAPPING_ACES: boolean;
  55649. CONTRAST: boolean;
  55650. EXPOSURE: boolean;
  55651. COLORCURVES: boolean;
  55652. COLORGRADING: boolean;
  55653. COLORGRADING3D: boolean;
  55654. SAMPLER3DGREENDEPTH: boolean;
  55655. SAMPLER3DBGRMAP: boolean;
  55656. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55657. /** MISC. */
  55658. BUMPDIRECTUV: number;
  55659. constructor();
  55660. setValue(name: string, value: boolean): void;
  55661. }
  55662. /**
  55663. * Class used to configure NodeMaterial
  55664. */
  55665. export interface INodeMaterialOptions {
  55666. /**
  55667. * Defines if blocks should emit comments
  55668. */
  55669. emitComments: boolean;
  55670. }
  55671. /**
  55672. * Class used to create a node based material built by assembling shader blocks
  55673. */
  55674. export class NodeMaterial extends PushMaterial {
  55675. private static _BuildIdGenerator;
  55676. private _options;
  55677. private _vertexCompilationState;
  55678. private _fragmentCompilationState;
  55679. private _sharedData;
  55680. private _buildId;
  55681. private _buildWasSuccessful;
  55682. private _cachedWorldViewMatrix;
  55683. private _cachedWorldViewProjectionMatrix;
  55684. private _optimizers;
  55685. private _animationFrame;
  55686. /** Define the URl to load node editor script */
  55687. static EditorURL: string;
  55688. private BJSNODEMATERIALEDITOR;
  55689. /** Get the inspector from bundle or global */
  55690. private _getGlobalNodeMaterialEditor;
  55691. /**
  55692. * 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)
  55693. */
  55694. ignoreAlpha: boolean;
  55695. /**
  55696. * Defines the maximum number of lights that can be used in the material
  55697. */
  55698. maxSimultaneousLights: number;
  55699. /**
  55700. * Observable raised when the material is built
  55701. */
  55702. onBuildObservable: Observable<NodeMaterial>;
  55703. /**
  55704. * Gets or sets the root nodes of the material vertex shader
  55705. */
  55706. _vertexOutputNodes: NodeMaterialBlock[];
  55707. /**
  55708. * Gets or sets the root nodes of the material fragment (pixel) shader
  55709. */
  55710. _fragmentOutputNodes: NodeMaterialBlock[];
  55711. /** Gets or sets options to control the node material overall behavior */
  55712. options: INodeMaterialOptions;
  55713. /**
  55714. * Default configuration related to image processing available in the standard Material.
  55715. */
  55716. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55717. /**
  55718. * Gets the image processing configuration used either in this material.
  55719. */
  55720. /**
  55721. * Sets the Default image processing configuration used either in the this material.
  55722. *
  55723. * If sets to null, the scene one is in use.
  55724. */
  55725. imageProcessingConfiguration: ImageProcessingConfiguration;
  55726. /**
  55727. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55728. */
  55729. attachedBlocks: NodeMaterialBlock[];
  55730. /**
  55731. * Create a new node based material
  55732. * @param name defines the material name
  55733. * @param scene defines the hosting scene
  55734. * @param options defines creation option
  55735. */
  55736. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55737. /**
  55738. * Gets the current class name of the material e.g. "NodeMaterial"
  55739. * @returns the class name
  55740. */
  55741. getClassName(): string;
  55742. /**
  55743. * Keep track of the image processing observer to allow dispose and replace.
  55744. */
  55745. private _imageProcessingObserver;
  55746. /**
  55747. * Attaches a new image processing configuration to the Standard Material.
  55748. * @param configuration
  55749. */
  55750. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55751. /**
  55752. * Get a block by its name
  55753. * @param name defines the name of the block to retrieve
  55754. * @returns the required block or null if not found
  55755. */
  55756. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55757. /**
  55758. * Get a block by its name
  55759. * @param predicate defines the predicate used to find the good candidate
  55760. * @returns the required block or null if not found
  55761. */
  55762. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55763. /**
  55764. * Get an input block by its name
  55765. * @param predicate defines the predicate used to find the good candidate
  55766. * @returns the required input block or null if not found
  55767. */
  55768. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55769. /**
  55770. * Gets the list of input blocks attached to this material
  55771. * @returns an array of InputBlocks
  55772. */
  55773. getInputBlocks(): InputBlock[];
  55774. /**
  55775. * Adds a new optimizer to the list of optimizers
  55776. * @param optimizer defines the optimizers to add
  55777. * @returns the current material
  55778. */
  55779. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55780. /**
  55781. * Remove an optimizer from the list of optimizers
  55782. * @param optimizer defines the optimizers to remove
  55783. * @returns the current material
  55784. */
  55785. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55786. /**
  55787. * Add a new block to the list of output nodes
  55788. * @param node defines the node to add
  55789. * @returns the current material
  55790. */
  55791. addOutputNode(node: NodeMaterialBlock): this;
  55792. /**
  55793. * Remove a block from the list of root nodes
  55794. * @param node defines the node to remove
  55795. * @returns the current material
  55796. */
  55797. removeOutputNode(node: NodeMaterialBlock): this;
  55798. private _addVertexOutputNode;
  55799. private _removeVertexOutputNode;
  55800. private _addFragmentOutputNode;
  55801. private _removeFragmentOutputNode;
  55802. /**
  55803. * Specifies if the material will require alpha blending
  55804. * @returns a boolean specifying if alpha blending is needed
  55805. */
  55806. needAlphaBlending(): boolean;
  55807. /**
  55808. * Specifies if this material should be rendered in alpha test mode
  55809. * @returns a boolean specifying if an alpha test is needed.
  55810. */
  55811. needAlphaTesting(): boolean;
  55812. private _initializeBlock;
  55813. private _resetDualBlocks;
  55814. /**
  55815. * Build the material and generates the inner effect
  55816. * @param verbose defines if the build should log activity
  55817. */
  55818. build(verbose?: boolean): void;
  55819. /**
  55820. * Runs an otpimization phase to try to improve the shader code
  55821. */
  55822. optimize(): void;
  55823. private _prepareDefinesForAttributes;
  55824. /**
  55825. * Get if the submesh is ready to be used and all its information available.
  55826. * Child classes can use it to update shaders
  55827. * @param mesh defines the mesh to check
  55828. * @param subMesh defines which submesh to check
  55829. * @param useInstances specifies that instances should be used
  55830. * @returns a boolean indicating that the submesh is ready or not
  55831. */
  55832. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55833. /**
  55834. * Get a string representing the shaders built by the current node graph
  55835. */
  55836. readonly compiledShaders: string;
  55837. /**
  55838. * Binds the world matrix to the material
  55839. * @param world defines the world transformation matrix
  55840. */
  55841. bindOnlyWorldMatrix(world: Matrix): void;
  55842. /**
  55843. * Binds the submesh to this material by preparing the effect and shader to draw
  55844. * @param world defines the world transformation matrix
  55845. * @param mesh defines the mesh containing the submesh
  55846. * @param subMesh defines the submesh to bind the material to
  55847. */
  55848. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55849. /**
  55850. * Gets the active textures from the material
  55851. * @returns an array of textures
  55852. */
  55853. getActiveTextures(): BaseTexture[];
  55854. /**
  55855. * Gets the list of texture blocks
  55856. * @returns an array of texture blocks
  55857. */
  55858. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55859. /**
  55860. * Specifies if the material uses a texture
  55861. * @param texture defines the texture to check against the material
  55862. * @returns a boolean specifying if the material uses the texture
  55863. */
  55864. hasTexture(texture: BaseTexture): boolean;
  55865. /**
  55866. * Disposes the material
  55867. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55868. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55869. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55870. */
  55871. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55872. /** Creates the node editor window. */
  55873. private _createNodeEditor;
  55874. /**
  55875. * Launch the node material editor
  55876. * @param config Define the configuration of the editor
  55877. * @return a promise fulfilled when the node editor is visible
  55878. */
  55879. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55880. /**
  55881. * Clear the current material
  55882. */
  55883. clear(): void;
  55884. /**
  55885. * Clear the current material and set it to a default state
  55886. */
  55887. setToDefault(): void;
  55888. /**
  55889. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55890. * @param url defines the url to load from
  55891. * @returns a promise that will fullfil when the material is fully loaded
  55892. */
  55893. loadAsync(url: string): Promise<void>;
  55894. private _gatherBlocks;
  55895. /**
  55896. * Generate a string containing the code declaration required to create an equivalent of this material
  55897. * @returns a string
  55898. */
  55899. generateCode(): string;
  55900. /**
  55901. * Serializes this material in a JSON representation
  55902. * @returns the serialized material object
  55903. */
  55904. serialize(): any;
  55905. private _restoreConnections;
  55906. /**
  55907. * Clear the current graph and load a new one from a serialization object
  55908. * @param source defines the JSON representation of the material
  55909. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55910. */
  55911. loadFromSerialization(source: any, rootUrl?: string): void;
  55912. /**
  55913. * Creates a node material from parsed material data
  55914. * @param source defines the JSON representation of the material
  55915. * @param scene defines the hosting scene
  55916. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55917. * @returns a new node material
  55918. */
  55919. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55920. /**
  55921. * Creates a new node material set to default basic configuration
  55922. * @param name defines the name of the material
  55923. * @param scene defines the hosting scene
  55924. * @returns a new NodeMaterial
  55925. */
  55926. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55927. }
  55928. }
  55929. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55932. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55935. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55936. import { Effect } from "babylonjs/Materials/effect";
  55937. import { Mesh } from "babylonjs/Meshes/mesh";
  55938. import { Nullable } from "babylonjs/types";
  55939. import { Texture } from "babylonjs/Materials/Textures/texture";
  55940. import { Scene } from "babylonjs/scene";
  55941. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55942. /**
  55943. * Block used to read a texture from a sampler
  55944. */
  55945. export class TextureBlock extends NodeMaterialBlock {
  55946. private _defineName;
  55947. private _linearDefineName;
  55948. private _samplerName;
  55949. private _transformedUVName;
  55950. private _textureTransformName;
  55951. private _textureInfoName;
  55952. private _mainUVName;
  55953. private _mainUVDefineName;
  55954. /**
  55955. * Gets or sets the texture associated with the node
  55956. */
  55957. texture: Nullable<Texture>;
  55958. /**
  55959. * Create a new TextureBlock
  55960. * @param name defines the block name
  55961. */
  55962. constructor(name: string);
  55963. /**
  55964. * Gets the current class name
  55965. * @returns the class name
  55966. */
  55967. getClassName(): string;
  55968. /**
  55969. * Gets the uv input component
  55970. */
  55971. readonly uv: NodeMaterialConnectionPoint;
  55972. /**
  55973. * Gets the rgba output component
  55974. */
  55975. readonly rgba: NodeMaterialConnectionPoint;
  55976. /**
  55977. * Gets the rgb output component
  55978. */
  55979. readonly rgb: NodeMaterialConnectionPoint;
  55980. /**
  55981. * Gets the r output component
  55982. */
  55983. readonly r: NodeMaterialConnectionPoint;
  55984. /**
  55985. * Gets the g output component
  55986. */
  55987. readonly g: NodeMaterialConnectionPoint;
  55988. /**
  55989. * Gets the b output component
  55990. */
  55991. readonly b: NodeMaterialConnectionPoint;
  55992. /**
  55993. * Gets the a output component
  55994. */
  55995. readonly a: NodeMaterialConnectionPoint;
  55996. readonly target: NodeMaterialBlockTargets;
  55997. autoConfigure(material: NodeMaterial): void;
  55998. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56000. isReady(): boolean;
  56001. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56002. private readonly _isMixed;
  56003. private _injectVertexCode;
  56004. private _writeOutput;
  56005. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56006. protected _dumpPropertiesCode(): string;
  56007. serialize(): any;
  56008. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56009. }
  56010. }
  56011. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56014. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56015. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56016. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56017. import { Scene } from "babylonjs/scene";
  56018. /**
  56019. * Class used to store shared data between 2 NodeMaterialBuildState
  56020. */
  56021. export class NodeMaterialBuildStateSharedData {
  56022. /**
  56023. * Gets the list of emitted varyings
  56024. */
  56025. temps: string[];
  56026. /**
  56027. * Gets the list of emitted varyings
  56028. */
  56029. varyings: string[];
  56030. /**
  56031. * Gets the varying declaration string
  56032. */
  56033. varyingDeclaration: string;
  56034. /**
  56035. * Input blocks
  56036. */
  56037. inputBlocks: InputBlock[];
  56038. /**
  56039. * Input blocks
  56040. */
  56041. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56042. /**
  56043. * Bindable blocks (Blocks that need to set data to the effect)
  56044. */
  56045. bindableBlocks: NodeMaterialBlock[];
  56046. /**
  56047. * List of blocks that can provide a compilation fallback
  56048. */
  56049. blocksWithFallbacks: NodeMaterialBlock[];
  56050. /**
  56051. * List of blocks that can provide a define update
  56052. */
  56053. blocksWithDefines: NodeMaterialBlock[];
  56054. /**
  56055. * List of blocks that can provide a repeatable content
  56056. */
  56057. repeatableContentBlocks: NodeMaterialBlock[];
  56058. /**
  56059. * List of blocks that can provide a dynamic list of uniforms
  56060. */
  56061. dynamicUniformBlocks: NodeMaterialBlock[];
  56062. /**
  56063. * List of blocks that can block the isReady function for the material
  56064. */
  56065. blockingBlocks: NodeMaterialBlock[];
  56066. /**
  56067. * Gets the list of animated inputs
  56068. */
  56069. animatedInputs: InputBlock[];
  56070. /**
  56071. * Build Id used to avoid multiple recompilations
  56072. */
  56073. buildId: number;
  56074. /** List of emitted variables */
  56075. variableNames: {
  56076. [key: string]: number;
  56077. };
  56078. /** List of emitted defines */
  56079. defineNames: {
  56080. [key: string]: number;
  56081. };
  56082. /** Should emit comments? */
  56083. emitComments: boolean;
  56084. /** Emit build activity */
  56085. verbose: boolean;
  56086. /** Gets or sets the hosting scene */
  56087. scene: Scene;
  56088. /**
  56089. * Gets the compilation hints emitted at compilation time
  56090. */
  56091. hints: {
  56092. needWorldViewMatrix: boolean;
  56093. needWorldViewProjectionMatrix: boolean;
  56094. needAlphaBlending: boolean;
  56095. needAlphaTesting: boolean;
  56096. };
  56097. /**
  56098. * List of compilation checks
  56099. */
  56100. checks: {
  56101. emitVertex: boolean;
  56102. emitFragment: boolean;
  56103. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56104. };
  56105. /** Creates a new shared data */
  56106. constructor();
  56107. /**
  56108. * Emits console errors and exceptions if there is a failing check
  56109. */
  56110. emitErrors(): void;
  56111. }
  56112. }
  56113. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56114. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56115. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56116. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56117. /**
  56118. * Class used to store node based material build state
  56119. */
  56120. export class NodeMaterialBuildState {
  56121. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56122. supportUniformBuffers: boolean;
  56123. /**
  56124. * Gets the list of emitted attributes
  56125. */
  56126. attributes: string[];
  56127. /**
  56128. * Gets the list of emitted uniforms
  56129. */
  56130. uniforms: string[];
  56131. /**
  56132. * Gets the list of emitted constants
  56133. */
  56134. constants: string[];
  56135. /**
  56136. * Gets the list of emitted samplers
  56137. */
  56138. samplers: string[];
  56139. /**
  56140. * Gets the list of emitted functions
  56141. */
  56142. functions: {
  56143. [key: string]: string;
  56144. };
  56145. /**
  56146. * Gets the list of emitted extensions
  56147. */
  56148. extensions: {
  56149. [key: string]: string;
  56150. };
  56151. /**
  56152. * Gets the target of the compilation state
  56153. */
  56154. target: NodeMaterialBlockTargets;
  56155. /**
  56156. * Gets the list of emitted counters
  56157. */
  56158. counters: {
  56159. [key: string]: number;
  56160. };
  56161. /**
  56162. * Shared data between multiple NodeMaterialBuildState instances
  56163. */
  56164. sharedData: NodeMaterialBuildStateSharedData;
  56165. /** @hidden */
  56166. _vertexState: NodeMaterialBuildState;
  56167. /** @hidden */
  56168. _attributeDeclaration: string;
  56169. /** @hidden */
  56170. _uniformDeclaration: string;
  56171. /** @hidden */
  56172. _constantDeclaration: string;
  56173. /** @hidden */
  56174. _samplerDeclaration: string;
  56175. /** @hidden */
  56176. _varyingTransfer: string;
  56177. private _repeatableContentAnchorIndex;
  56178. /** @hidden */
  56179. _builtCompilationString: string;
  56180. /**
  56181. * Gets the emitted compilation strings
  56182. */
  56183. compilationString: string;
  56184. /**
  56185. * Finalize the compilation strings
  56186. * @param state defines the current compilation state
  56187. */
  56188. finalize(state: NodeMaterialBuildState): void;
  56189. /** @hidden */
  56190. readonly _repeatableContentAnchor: string;
  56191. /** @hidden */
  56192. _getFreeVariableName(prefix: string): string;
  56193. /** @hidden */
  56194. _getFreeDefineName(prefix: string): string;
  56195. /** @hidden */
  56196. _excludeVariableName(name: string): void;
  56197. /** @hidden */
  56198. _emit2DSampler(name: string): void;
  56199. /** @hidden */
  56200. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56201. /** @hidden */
  56202. _emitExtension(name: string, extension: string): void;
  56203. /** @hidden */
  56204. _emitFunction(name: string, code: string, comments: string): void;
  56205. /** @hidden */
  56206. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56207. replaceStrings?: {
  56208. search: RegExp;
  56209. replace: string;
  56210. }[];
  56211. repeatKey?: string;
  56212. }): string;
  56213. /** @hidden */
  56214. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56215. repeatKey?: string;
  56216. removeAttributes?: boolean;
  56217. removeUniforms?: boolean;
  56218. removeVaryings?: boolean;
  56219. removeIfDef?: boolean;
  56220. replaceStrings?: {
  56221. search: RegExp;
  56222. replace: string;
  56223. }[];
  56224. }, storeKey?: string): void;
  56225. /** @hidden */
  56226. _registerTempVariable(name: string): boolean;
  56227. /** @hidden */
  56228. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56229. /** @hidden */
  56230. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56231. /** @hidden */
  56232. _emitFloat(value: number): string;
  56233. }
  56234. }
  56235. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56236. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56238. import { Nullable } from "babylonjs/types";
  56239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56240. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56241. import { Effect } from "babylonjs/Materials/effect";
  56242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56243. import { Mesh } from "babylonjs/Meshes/mesh";
  56244. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56245. import { Scene } from "babylonjs/scene";
  56246. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56247. /**
  56248. * Defines a block that can be used inside a node based material
  56249. */
  56250. export class NodeMaterialBlock {
  56251. private _buildId;
  56252. private _buildTarget;
  56253. private _target;
  56254. private _isFinalMerger;
  56255. private _isInput;
  56256. /** @hidden */
  56257. _codeVariableName: string;
  56258. /** @hidden */
  56259. _inputs: NodeMaterialConnectionPoint[];
  56260. /** @hidden */
  56261. _outputs: NodeMaterialConnectionPoint[];
  56262. /** @hidden */
  56263. _preparationId: number;
  56264. /**
  56265. * Gets or sets the name of the block
  56266. */
  56267. name: string;
  56268. /**
  56269. * Gets or sets the unique id of the node
  56270. */
  56271. uniqueId: number;
  56272. /**
  56273. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56274. */
  56275. readonly isFinalMerger: boolean;
  56276. /**
  56277. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56278. */
  56279. readonly isInput: boolean;
  56280. /**
  56281. * Gets or sets the build Id
  56282. */
  56283. buildId: number;
  56284. /**
  56285. * Gets or sets the target of the block
  56286. */
  56287. target: NodeMaterialBlockTargets;
  56288. /**
  56289. * Gets the list of input points
  56290. */
  56291. readonly inputs: NodeMaterialConnectionPoint[];
  56292. /** Gets the list of output points */
  56293. readonly outputs: NodeMaterialConnectionPoint[];
  56294. /**
  56295. * Find an input by its name
  56296. * @param name defines the name of the input to look for
  56297. * @returns the input or null if not found
  56298. */
  56299. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56300. /**
  56301. * Find an output by its name
  56302. * @param name defines the name of the outputto look for
  56303. * @returns the output or null if not found
  56304. */
  56305. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56306. /**
  56307. * Creates a new NodeMaterialBlock
  56308. * @param name defines the block name
  56309. * @param target defines the target of that block (Vertex by default)
  56310. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56311. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56312. */
  56313. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56314. /**
  56315. * Initialize the block and prepare the context for build
  56316. * @param state defines the state that will be used for the build
  56317. */
  56318. initialize(state: NodeMaterialBuildState): void;
  56319. /**
  56320. * Bind data to effect. Will only be called for blocks with isBindable === true
  56321. * @param effect defines the effect to bind data to
  56322. * @param nodeMaterial defines the hosting NodeMaterial
  56323. * @param mesh defines the mesh that will be rendered
  56324. */
  56325. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56326. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56327. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56328. protected _writeFloat(value: number): string;
  56329. /**
  56330. * Gets the current class name e.g. "NodeMaterialBlock"
  56331. * @returns the class name
  56332. */
  56333. getClassName(): string;
  56334. /**
  56335. * Register a new input. Must be called inside a block constructor
  56336. * @param name defines the connection point name
  56337. * @param type defines the connection point type
  56338. * @param isOptional defines a boolean indicating that this input can be omitted
  56339. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56340. * @returns the current block
  56341. */
  56342. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56343. /**
  56344. * Register a new output. Must be called inside a block constructor
  56345. * @param name defines the connection point name
  56346. * @param type defines the connection point type
  56347. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56348. * @returns the current block
  56349. */
  56350. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56351. /**
  56352. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56353. * @param forOutput defines an optional connection point to check compatibility with
  56354. * @returns the first available input or null
  56355. */
  56356. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56357. /**
  56358. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56359. * @param forBlock defines an optional block to check compatibility with
  56360. * @returns the first available input or null
  56361. */
  56362. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56363. /**
  56364. * Gets the sibling of the given output
  56365. * @param current defines the current output
  56366. * @returns the next output in the list or null
  56367. */
  56368. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56369. /**
  56370. * Connect current block with another block
  56371. * @param other defines the block to connect with
  56372. * @param options define the various options to help pick the right connections
  56373. * @returns the current block
  56374. */
  56375. connectTo(other: NodeMaterialBlock, options?: {
  56376. input?: string;
  56377. output?: string;
  56378. outputSwizzle?: string;
  56379. }): this | undefined;
  56380. protected _buildBlock(state: NodeMaterialBuildState): void;
  56381. /**
  56382. * Add uniforms, samplers and uniform buffers at compilation time
  56383. * @param state defines the state to update
  56384. * @param nodeMaterial defines the node material requesting the update
  56385. * @param defines defines the material defines to update
  56386. * @param uniformBuffers defines the list of uniform buffer names
  56387. */
  56388. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56389. /**
  56390. * Add potential fallbacks if shader compilation fails
  56391. * @param mesh defines the mesh to be rendered
  56392. * @param fallbacks defines the current prioritized list of fallbacks
  56393. */
  56394. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56395. /**
  56396. * Initialize defines for shader compilation
  56397. * @param mesh defines the mesh to be rendered
  56398. * @param nodeMaterial defines the node material requesting the update
  56399. * @param defines defines the material defines to update
  56400. * @param useInstances specifies that instances should be used
  56401. */
  56402. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56403. /**
  56404. * Update defines for shader compilation
  56405. * @param mesh defines the mesh to be rendered
  56406. * @param nodeMaterial defines the node material requesting the update
  56407. * @param defines defines the material defines to update
  56408. * @param useInstances specifies that instances should be used
  56409. */
  56410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56411. /**
  56412. * Lets the block try to connect some inputs automatically
  56413. * @param material defines the hosting NodeMaterial
  56414. */
  56415. autoConfigure(material: NodeMaterial): void;
  56416. /**
  56417. * Function called when a block is declared as repeatable content generator
  56418. * @param vertexShaderState defines the current compilation state for the vertex shader
  56419. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56420. * @param mesh defines the mesh to be rendered
  56421. * @param defines defines the material defines to update
  56422. */
  56423. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56424. /**
  56425. * Checks if the block is ready
  56426. * @param mesh defines the mesh to be rendered
  56427. * @param nodeMaterial defines the node material requesting the update
  56428. * @param defines defines the material defines to update
  56429. * @param useInstances specifies that instances should be used
  56430. * @returns true if the block is ready
  56431. */
  56432. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56433. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56434. private _processBuild;
  56435. /**
  56436. * Compile the current node and generate the shader code
  56437. * @param state defines the current compilation state (uniforms, samplers, current string)
  56438. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56439. * @returns true if already built
  56440. */
  56441. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56442. protected _inputRename(name: string): string;
  56443. protected _outputRename(name: string): string;
  56444. protected _dumpPropertiesCode(): string;
  56445. /** @hidden */
  56446. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56447. /**
  56448. * Clone the current block to a new identical block
  56449. * @param scene defines the hosting scene
  56450. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56451. * @returns a copy of the current block
  56452. */
  56453. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56454. /**
  56455. * Serializes this block in a JSON representation
  56456. * @returns the serialized block object
  56457. */
  56458. serialize(): any;
  56459. /** @hidden */
  56460. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56461. /**
  56462. * Release resources
  56463. */
  56464. dispose(): void;
  56465. }
  56466. }
  56467. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56468. /**
  56469. * Enum defining the type of animations supported by InputBlock
  56470. */
  56471. export enum AnimatedInputBlockTypes {
  56472. /** No animation */
  56473. None = 0,
  56474. /** Time based animation. Will only work for floats */
  56475. Time = 1
  56476. }
  56477. }
  56478. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56480. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56481. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56482. import { Nullable } from "babylonjs/types";
  56483. import { Effect } from "babylonjs/Materials/effect";
  56484. import { Matrix } from "babylonjs/Maths/math.vector";
  56485. import { Scene } from "babylonjs/scene";
  56486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56488. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56489. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56490. /**
  56491. * Block used to expose an input value
  56492. */
  56493. export class InputBlock extends NodeMaterialBlock {
  56494. private _mode;
  56495. private _associatedVariableName;
  56496. private _storedValue;
  56497. private _valueCallback;
  56498. private _type;
  56499. private _animationType;
  56500. /** Gets or set a value used to limit the range of float values */
  56501. min: number;
  56502. /** Gets or set a value used to limit the range of float values */
  56503. max: number;
  56504. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56505. matrixMode: number;
  56506. /** @hidden */
  56507. _systemValue: Nullable<NodeMaterialSystemValues>;
  56508. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56509. visibleInInspector: boolean;
  56510. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56511. isConstant: boolean;
  56512. /**
  56513. * Gets or sets the connection point type (default is float)
  56514. */
  56515. readonly type: NodeMaterialBlockConnectionPointTypes;
  56516. /**
  56517. * Creates a new InputBlock
  56518. * @param name defines the block name
  56519. * @param target defines the target of that block (Vertex by default)
  56520. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56521. */
  56522. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56523. /**
  56524. * Gets the output component
  56525. */
  56526. readonly output: NodeMaterialConnectionPoint;
  56527. /**
  56528. * Set the source of this connection point to a vertex attribute
  56529. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56530. * @returns the current connection point
  56531. */
  56532. setAsAttribute(attributeName?: string): InputBlock;
  56533. /**
  56534. * Set the source of this connection point to a system value
  56535. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56536. * @returns the current connection point
  56537. */
  56538. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56539. /**
  56540. * Gets or sets the value of that point.
  56541. * Please note that this value will be ignored if valueCallback is defined
  56542. */
  56543. value: any;
  56544. /**
  56545. * Gets or sets a callback used to get the value of that point.
  56546. * Please note that setting this value will force the connection point to ignore the value property
  56547. */
  56548. valueCallback: () => any;
  56549. /**
  56550. * Gets or sets the associated variable name in the shader
  56551. */
  56552. associatedVariableName: string;
  56553. /** Gets or sets the type of animation applied to the input */
  56554. animationType: AnimatedInputBlockTypes;
  56555. /**
  56556. * Gets a boolean indicating that this connection point not defined yet
  56557. */
  56558. readonly isUndefined: boolean;
  56559. /**
  56560. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56561. * In this case the connection point name must be the name of the uniform to use.
  56562. * Can only be set on inputs
  56563. */
  56564. isUniform: boolean;
  56565. /**
  56566. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56567. * In this case the connection point name must be the name of the attribute to use
  56568. * Can only be set on inputs
  56569. */
  56570. isAttribute: boolean;
  56571. /**
  56572. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56573. * Can only be set on exit points
  56574. */
  56575. isVarying: boolean;
  56576. /**
  56577. * Gets a boolean indicating that the current connection point is a system value
  56578. */
  56579. readonly isSystemValue: boolean;
  56580. /**
  56581. * Gets or sets the current well known value or null if not defined as a system value
  56582. */
  56583. systemValue: Nullable<NodeMaterialSystemValues>;
  56584. /**
  56585. * Gets the current class name
  56586. * @returns the class name
  56587. */
  56588. getClassName(): string;
  56589. /**
  56590. * Animate the input if animationType !== None
  56591. * @param scene defines the rendering scene
  56592. */
  56593. animate(scene: Scene): void;
  56594. private _emitDefine;
  56595. initialize(state: NodeMaterialBuildState): void;
  56596. /**
  56597. * Set the input block to its default value (based on its type)
  56598. */
  56599. setDefaultValue(): void;
  56600. private _emitConstant;
  56601. private _emit;
  56602. /** @hidden */
  56603. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56604. /** @hidden */
  56605. _transmit(effect: Effect, scene: Scene): void;
  56606. protected _buildBlock(state: NodeMaterialBuildState): void;
  56607. protected _dumpPropertiesCode(): string;
  56608. serialize(): any;
  56609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56610. }
  56611. }
  56612. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56613. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56614. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56615. import { Nullable } from "babylonjs/types";
  56616. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56617. import { Observable } from "babylonjs/Misc/observable";
  56618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56619. /**
  56620. * Defines a connection point for a block
  56621. */
  56622. export class NodeMaterialConnectionPoint {
  56623. /** @hidden */
  56624. _ownerBlock: NodeMaterialBlock;
  56625. /** @hidden */
  56626. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56627. private _endpoints;
  56628. private _associatedVariableName;
  56629. /** @hidden */
  56630. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56631. /** @hidden */
  56632. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56633. private _type;
  56634. /** @hidden */
  56635. _enforceAssociatedVariableName: boolean;
  56636. /**
  56637. * Gets or sets the additional types supported by this connection point
  56638. */
  56639. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56640. /**
  56641. * Gets or sets the additional types excluded by this connection point
  56642. */
  56643. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56644. /**
  56645. * Observable triggered when this point is connected
  56646. */
  56647. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  56648. /**
  56649. * Gets or sets the associated variable name in the shader
  56650. */
  56651. associatedVariableName: string;
  56652. /**
  56653. * Gets or sets the connection point type (default is float)
  56654. */
  56655. type: NodeMaterialBlockConnectionPointTypes;
  56656. /**
  56657. * Gets or sets the connection point name
  56658. */
  56659. name: string;
  56660. /**
  56661. * Gets or sets a boolean indicating that this connection point can be omitted
  56662. */
  56663. isOptional: boolean;
  56664. /**
  56665. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56666. */
  56667. define: string;
  56668. /** @hidden */
  56669. _prioritizeVertex: boolean;
  56670. private _target;
  56671. /** Gets or sets the target of that connection point */
  56672. target: NodeMaterialBlockTargets;
  56673. /**
  56674. * Gets a boolean indicating that the current point is connected
  56675. */
  56676. readonly isConnected: boolean;
  56677. /**
  56678. * Gets a boolean indicating that the current point is connected to an input block
  56679. */
  56680. readonly isConnectedToInputBlock: boolean;
  56681. /**
  56682. * Gets a the connected input block (if any)
  56683. */
  56684. readonly connectInputBlock: Nullable<InputBlock>;
  56685. /** Get the other side of the connection (if any) */
  56686. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56687. /** Get the block that owns this connection point */
  56688. readonly ownerBlock: NodeMaterialBlock;
  56689. /** Get the block connected on the other side of this connection (if any) */
  56690. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56691. /** Get the block connected on the endpoints of this connection (if any) */
  56692. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56693. /** Gets the list of connected endpoints */
  56694. readonly endpoints: NodeMaterialConnectionPoint[];
  56695. /** Gets a boolean indicating if that output point is connected to at least one input */
  56696. readonly hasEndpoints: boolean;
  56697. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56698. readonly isConnectedInVertexShader: boolean;
  56699. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56700. readonly isConnectedInFragmentShader: boolean;
  56701. /**
  56702. * Creates a new connection point
  56703. * @param name defines the connection point name
  56704. * @param ownerBlock defines the block hosting this connection point
  56705. */
  56706. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56707. /**
  56708. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56709. * @returns the class name
  56710. */
  56711. getClassName(): string;
  56712. /**
  56713. * Gets an boolean indicating if the current point can be connected to another point
  56714. * @param connectionPoint defines the other connection point
  56715. * @returns true if the connection is possible
  56716. */
  56717. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56718. /**
  56719. * Connect this point to another connection point
  56720. * @param connectionPoint defines the other connection point
  56721. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56722. * @returns the current connection point
  56723. */
  56724. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56725. /**
  56726. * Disconnect this point from one of his endpoint
  56727. * @param endpoint defines the other connection point
  56728. * @returns the current connection point
  56729. */
  56730. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56731. /**
  56732. * Serializes this point in a JSON representation
  56733. * @returns the serialized point object
  56734. */
  56735. serialize(): any;
  56736. /**
  56737. * Release resources
  56738. */
  56739. dispose(): void;
  56740. }
  56741. }
  56742. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56746. import { Mesh } from "babylonjs/Meshes/mesh";
  56747. import { Effect } from "babylonjs/Materials/effect";
  56748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56749. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56750. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56751. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56752. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56753. /**
  56754. * Block used to add support for vertex skinning (bones)
  56755. */
  56756. export class BonesBlock extends NodeMaterialBlock {
  56757. /**
  56758. * Creates a new BonesBlock
  56759. * @param name defines the block name
  56760. */
  56761. constructor(name: string);
  56762. /**
  56763. * Initialize the block and prepare the context for build
  56764. * @param state defines the state that will be used for the build
  56765. */
  56766. initialize(state: NodeMaterialBuildState): void;
  56767. /**
  56768. * Gets the current class name
  56769. * @returns the class name
  56770. */
  56771. getClassName(): string;
  56772. /**
  56773. * Gets the matrix indices input component
  56774. */
  56775. readonly matricesIndices: NodeMaterialConnectionPoint;
  56776. /**
  56777. * Gets the matrix weights input component
  56778. */
  56779. readonly matricesWeights: NodeMaterialConnectionPoint;
  56780. /**
  56781. * Gets the extra matrix indices input component
  56782. */
  56783. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56784. /**
  56785. * Gets the extra matrix weights input component
  56786. */
  56787. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56788. /**
  56789. * Gets the world input component
  56790. */
  56791. readonly world: NodeMaterialConnectionPoint;
  56792. /**
  56793. * Gets the output component
  56794. */
  56795. readonly output: NodeMaterialConnectionPoint;
  56796. autoConfigure(material: NodeMaterial): void;
  56797. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56800. protected _buildBlock(state: NodeMaterialBuildState): this;
  56801. }
  56802. }
  56803. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56808. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56809. /**
  56810. * Block used to add support for instances
  56811. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56812. */
  56813. export class InstancesBlock extends NodeMaterialBlock {
  56814. /**
  56815. * Creates a new InstancesBlock
  56816. * @param name defines the block name
  56817. */
  56818. constructor(name: string);
  56819. /**
  56820. * Gets the current class name
  56821. * @returns the class name
  56822. */
  56823. getClassName(): string;
  56824. /**
  56825. * Gets the first world row input component
  56826. */
  56827. readonly world0: NodeMaterialConnectionPoint;
  56828. /**
  56829. * Gets the second world row input component
  56830. */
  56831. readonly world1: NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the third world row input component
  56834. */
  56835. readonly world2: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the forth world row input component
  56838. */
  56839. readonly world3: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the world input component
  56842. */
  56843. readonly world: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the output component
  56846. */
  56847. readonly output: NodeMaterialConnectionPoint;
  56848. autoConfigure(material: NodeMaterial): void;
  56849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56850. protected _buildBlock(state: NodeMaterialBuildState): this;
  56851. }
  56852. }
  56853. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56854. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56858. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56859. import { Effect } from "babylonjs/Materials/effect";
  56860. import { Mesh } from "babylonjs/Meshes/mesh";
  56861. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56862. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56863. /**
  56864. * Block used to add morph targets support to vertex shader
  56865. */
  56866. export class MorphTargetsBlock extends NodeMaterialBlock {
  56867. private _repeatableContentAnchor;
  56868. private _repeatebleContentGenerated;
  56869. /**
  56870. * Create a new MorphTargetsBlock
  56871. * @param name defines the block name
  56872. */
  56873. constructor(name: string);
  56874. /**
  56875. * Gets the current class name
  56876. * @returns the class name
  56877. */
  56878. getClassName(): string;
  56879. /**
  56880. * Gets the position input component
  56881. */
  56882. readonly position: NodeMaterialConnectionPoint;
  56883. /**
  56884. * Gets the normal input component
  56885. */
  56886. readonly normal: NodeMaterialConnectionPoint;
  56887. /**
  56888. * Gets the tangent input component
  56889. */
  56890. readonly tangent: NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the tangent input component
  56893. */
  56894. readonly uv: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the position output component
  56897. */
  56898. readonly positionOutput: NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the normal output component
  56901. */
  56902. readonly normalOutput: NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the tangent output component
  56905. */
  56906. readonly tangentOutput: NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the tangent output component
  56909. */
  56910. readonly uvOutput: NodeMaterialConnectionPoint;
  56911. initialize(state: NodeMaterialBuildState): void;
  56912. autoConfigure(material: NodeMaterial): void;
  56913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56914. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56915. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56916. protected _buildBlock(state: NodeMaterialBuildState): this;
  56917. }
  56918. }
  56919. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56923. import { Nullable } from "babylonjs/types";
  56924. import { Scene } from "babylonjs/scene";
  56925. import { Effect } from "babylonjs/Materials/effect";
  56926. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56927. import { Mesh } from "babylonjs/Meshes/mesh";
  56928. import { Light } from "babylonjs/Lights/light";
  56929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56930. /**
  56931. * Block used to get data information from a light
  56932. */
  56933. export class LightInformationBlock extends NodeMaterialBlock {
  56934. private _lightDataUniformName;
  56935. private _lightColorUniformName;
  56936. private _lightTypeDefineName;
  56937. /**
  56938. * Gets or sets the light associated with this block
  56939. */
  56940. light: Nullable<Light>;
  56941. /**
  56942. * Creates a new LightInformationBlock
  56943. * @param name defines the block name
  56944. */
  56945. constructor(name: string);
  56946. /**
  56947. * Gets the current class name
  56948. * @returns the class name
  56949. */
  56950. getClassName(): string;
  56951. /**
  56952. * Gets the world position input component
  56953. */
  56954. readonly worldPosition: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the direction output component
  56957. */
  56958. readonly direction: NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the direction output component
  56961. */
  56962. readonly color: NodeMaterialConnectionPoint;
  56963. /**
  56964. * Gets the direction output component
  56965. */
  56966. readonly intensity: NodeMaterialConnectionPoint;
  56967. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56969. protected _buildBlock(state: NodeMaterialBuildState): this;
  56970. serialize(): any;
  56971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56972. }
  56973. }
  56974. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56975. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56976. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56977. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56978. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56979. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56980. }
  56981. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56986. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56987. import { Effect } from "babylonjs/Materials/effect";
  56988. import { Mesh } from "babylonjs/Meshes/mesh";
  56989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56991. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56992. /**
  56993. * Block used to add image processing support to fragment shader
  56994. */
  56995. export class ImageProcessingBlock extends NodeMaterialBlock {
  56996. /**
  56997. * Create a new ImageProcessingBlock
  56998. * @param name defines the block name
  56999. */
  57000. constructor(name: string);
  57001. /**
  57002. * Gets the current class name
  57003. * @returns the class name
  57004. */
  57005. getClassName(): string;
  57006. /**
  57007. * Gets the color input component
  57008. */
  57009. readonly color: NodeMaterialConnectionPoint;
  57010. /**
  57011. * Gets the output component
  57012. */
  57013. readonly output: NodeMaterialConnectionPoint;
  57014. /**
  57015. * Initialize the block and prepare the context for build
  57016. * @param state defines the state that will be used for the build
  57017. */
  57018. initialize(state: NodeMaterialBuildState): void;
  57019. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57022. protected _buildBlock(state: NodeMaterialBuildState): this;
  57023. }
  57024. }
  57025. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57026. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57027. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57029. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57031. import { Effect } from "babylonjs/Materials/effect";
  57032. import { Mesh } from "babylonjs/Meshes/mesh";
  57033. import { Scene } from "babylonjs/scene";
  57034. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57035. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57036. /**
  57037. * Block used to pertub normals based on a normal map
  57038. */
  57039. export class PerturbNormalBlock extends NodeMaterialBlock {
  57040. private _tangentSpaceParameterName;
  57041. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57042. invertX: boolean;
  57043. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57044. invertY: boolean;
  57045. /**
  57046. * Create a new PerturbNormalBlock
  57047. * @param name defines the block name
  57048. */
  57049. constructor(name: string);
  57050. /**
  57051. * Gets the current class name
  57052. * @returns the class name
  57053. */
  57054. getClassName(): string;
  57055. /**
  57056. * Gets the world position input component
  57057. */
  57058. readonly worldPosition: NodeMaterialConnectionPoint;
  57059. /**
  57060. * Gets the world normal input component
  57061. */
  57062. readonly worldNormal: NodeMaterialConnectionPoint;
  57063. /**
  57064. * Gets the uv input component
  57065. */
  57066. readonly uv: NodeMaterialConnectionPoint;
  57067. /**
  57068. * Gets the normal map color input component
  57069. */
  57070. readonly normalMapColor: NodeMaterialConnectionPoint;
  57071. /**
  57072. * Gets the strength input component
  57073. */
  57074. readonly strength: NodeMaterialConnectionPoint;
  57075. /**
  57076. * Gets the output component
  57077. */
  57078. readonly output: NodeMaterialConnectionPoint;
  57079. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57080. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57081. autoConfigure(material: NodeMaterial): void;
  57082. protected _buildBlock(state: NodeMaterialBuildState): this;
  57083. protected _dumpPropertiesCode(): string;
  57084. serialize(): any;
  57085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57086. }
  57087. }
  57088. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57092. /**
  57093. * Block used to discard a pixel if a value is smaller than a cutoff
  57094. */
  57095. export class DiscardBlock extends NodeMaterialBlock {
  57096. /**
  57097. * Create a new DiscardBlock
  57098. * @param name defines the block name
  57099. */
  57100. constructor(name: string);
  57101. /**
  57102. * Gets the current class name
  57103. * @returns the class name
  57104. */
  57105. getClassName(): string;
  57106. /**
  57107. * Gets the color input component
  57108. */
  57109. readonly value: NodeMaterialConnectionPoint;
  57110. /**
  57111. * Gets the cutoff input component
  57112. */
  57113. readonly cutoff: NodeMaterialConnectionPoint;
  57114. protected _buildBlock(state: NodeMaterialBuildState): this;
  57115. }
  57116. }
  57117. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57118. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57119. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57120. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57121. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57122. }
  57123. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57126. import { Mesh } from "babylonjs/Meshes/mesh";
  57127. import { Effect } from "babylonjs/Materials/effect";
  57128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57130. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57131. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57132. /**
  57133. * Block used to add support for scene fog
  57134. */
  57135. export class FogBlock extends NodeMaterialBlock {
  57136. private _fogDistanceName;
  57137. private _fogParameters;
  57138. /**
  57139. * Create a new FogBlock
  57140. * @param name defines the block name
  57141. */
  57142. constructor(name: string);
  57143. /**
  57144. * Gets the current class name
  57145. * @returns the class name
  57146. */
  57147. getClassName(): string;
  57148. /**
  57149. * Gets the world position input component
  57150. */
  57151. readonly worldPosition: NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the view input component
  57154. */
  57155. readonly view: NodeMaterialConnectionPoint;
  57156. /**
  57157. * Gets the color input component
  57158. */
  57159. readonly input: NodeMaterialConnectionPoint;
  57160. /**
  57161. * Gets the fog color input component
  57162. */
  57163. readonly fogColor: NodeMaterialConnectionPoint;
  57164. /**
  57165. * Gets the output component
  57166. */
  57167. readonly output: NodeMaterialConnectionPoint;
  57168. autoConfigure(material: NodeMaterial): void;
  57169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57171. protected _buildBlock(state: NodeMaterialBuildState): this;
  57172. }
  57173. }
  57174. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57179. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57180. import { Effect } from "babylonjs/Materials/effect";
  57181. import { Mesh } from "babylonjs/Meshes/mesh";
  57182. import { Light } from "babylonjs/Lights/light";
  57183. import { Nullable } from "babylonjs/types";
  57184. import { Scene } from "babylonjs/scene";
  57185. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57186. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57187. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57188. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57189. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57190. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57191. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57192. /**
  57193. * Block used to add light in the fragment shader
  57194. */
  57195. export class LightBlock extends NodeMaterialBlock {
  57196. private _lightId;
  57197. /**
  57198. * Gets or sets the light associated with this block
  57199. */
  57200. light: Nullable<Light>;
  57201. /**
  57202. * Create a new LightBlock
  57203. * @param name defines the block name
  57204. */
  57205. constructor(name: string);
  57206. /**
  57207. * Gets the current class name
  57208. * @returns the class name
  57209. */
  57210. getClassName(): string;
  57211. /**
  57212. * Gets the world position input component
  57213. */
  57214. readonly worldPosition: NodeMaterialConnectionPoint;
  57215. /**
  57216. * Gets the world normal input component
  57217. */
  57218. readonly worldNormal: NodeMaterialConnectionPoint;
  57219. /**
  57220. * Gets the camera (or eye) position component
  57221. */
  57222. readonly cameraPosition: NodeMaterialConnectionPoint;
  57223. /**
  57224. * Gets the glossiness component
  57225. */
  57226. readonly glossiness: NodeMaterialConnectionPoint;
  57227. /**
  57228. * Gets the glossinness power component
  57229. */
  57230. readonly glossPower: NodeMaterialConnectionPoint;
  57231. /**
  57232. * Gets the diffuse color component
  57233. */
  57234. readonly diffuseColor: NodeMaterialConnectionPoint;
  57235. /**
  57236. * Gets the specular color component
  57237. */
  57238. readonly specularColor: NodeMaterialConnectionPoint;
  57239. /**
  57240. * Gets the diffuse output component
  57241. */
  57242. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57243. /**
  57244. * Gets the specular output component
  57245. */
  57246. readonly specularOutput: NodeMaterialConnectionPoint;
  57247. autoConfigure(material: NodeMaterial): void;
  57248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57249. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57250. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57251. private _injectVertexCode;
  57252. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57253. serialize(): any;
  57254. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57255. }
  57256. }
  57257. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57258. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57259. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57260. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57261. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57262. }
  57263. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57264. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57265. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57266. }
  57267. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57271. /**
  57272. * Block used to multiply 2 values
  57273. */
  57274. export class MultiplyBlock extends NodeMaterialBlock {
  57275. /**
  57276. * Creates a new MultiplyBlock
  57277. * @param name defines the block name
  57278. */
  57279. constructor(name: string);
  57280. /**
  57281. * Gets the current class name
  57282. * @returns the class name
  57283. */
  57284. getClassName(): string;
  57285. /**
  57286. * Gets the left operand input component
  57287. */
  57288. readonly left: NodeMaterialConnectionPoint;
  57289. /**
  57290. * Gets the right operand input component
  57291. */
  57292. readonly right: NodeMaterialConnectionPoint;
  57293. /**
  57294. * Gets the output component
  57295. */
  57296. readonly output: NodeMaterialConnectionPoint;
  57297. protected _buildBlock(state: NodeMaterialBuildState): this;
  57298. }
  57299. }
  57300. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57304. /**
  57305. * Block used to add 2 vectors
  57306. */
  57307. export class AddBlock extends NodeMaterialBlock {
  57308. /**
  57309. * Creates a new AddBlock
  57310. * @param name defines the block name
  57311. */
  57312. constructor(name: string);
  57313. /**
  57314. * Gets the current class name
  57315. * @returns the class name
  57316. */
  57317. getClassName(): string;
  57318. /**
  57319. * Gets the left operand input component
  57320. */
  57321. readonly left: NodeMaterialConnectionPoint;
  57322. /**
  57323. * Gets the right operand input component
  57324. */
  57325. readonly right: NodeMaterialConnectionPoint;
  57326. /**
  57327. * Gets the output component
  57328. */
  57329. readonly output: NodeMaterialConnectionPoint;
  57330. protected _buildBlock(state: NodeMaterialBuildState): this;
  57331. }
  57332. }
  57333. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57337. /**
  57338. * Block used to scale a vector by a float
  57339. */
  57340. export class ScaleBlock extends NodeMaterialBlock {
  57341. /**
  57342. * Creates a new ScaleBlock
  57343. * @param name defines the block name
  57344. */
  57345. constructor(name: string);
  57346. /**
  57347. * Gets the current class name
  57348. * @returns the class name
  57349. */
  57350. getClassName(): string;
  57351. /**
  57352. * Gets the input component
  57353. */
  57354. readonly input: NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the factor input component
  57357. */
  57358. readonly factor: NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the output component
  57361. */
  57362. readonly output: NodeMaterialConnectionPoint;
  57363. protected _buildBlock(state: NodeMaterialBuildState): this;
  57364. }
  57365. }
  57366. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57370. import { Scene } from "babylonjs/scene";
  57371. /**
  57372. * Block used to clamp a float
  57373. */
  57374. export class ClampBlock extends NodeMaterialBlock {
  57375. /** Gets or sets the minimum range */
  57376. minimum: number;
  57377. /** Gets or sets the maximum range */
  57378. maximum: number;
  57379. /**
  57380. * Creates a new ClampBlock
  57381. * @param name defines the block name
  57382. */
  57383. constructor(name: string);
  57384. /**
  57385. * Gets the current class name
  57386. * @returns the class name
  57387. */
  57388. getClassName(): string;
  57389. /**
  57390. * Gets the value input component
  57391. */
  57392. readonly value: NodeMaterialConnectionPoint;
  57393. /**
  57394. * Gets the output component
  57395. */
  57396. readonly output: NodeMaterialConnectionPoint;
  57397. protected _buildBlock(state: NodeMaterialBuildState): this;
  57398. protected _dumpPropertiesCode(): string;
  57399. serialize(): any;
  57400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57401. }
  57402. }
  57403. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57406. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57407. /**
  57408. * Block used to apply a cross product between 2 vectors
  57409. */
  57410. export class CrossBlock extends NodeMaterialBlock {
  57411. /**
  57412. * Creates a new CrossBlock
  57413. * @param name defines the block name
  57414. */
  57415. constructor(name: string);
  57416. /**
  57417. * Gets the current class name
  57418. * @returns the class name
  57419. */
  57420. getClassName(): string;
  57421. /**
  57422. * Gets the left operand input component
  57423. */
  57424. readonly left: NodeMaterialConnectionPoint;
  57425. /**
  57426. * Gets the right operand input component
  57427. */
  57428. readonly right: NodeMaterialConnectionPoint;
  57429. /**
  57430. * Gets the output component
  57431. */
  57432. readonly output: NodeMaterialConnectionPoint;
  57433. protected _buildBlock(state: NodeMaterialBuildState): this;
  57434. }
  57435. }
  57436. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57440. /**
  57441. * Block used to apply a dot product between 2 vectors
  57442. */
  57443. export class DotBlock extends NodeMaterialBlock {
  57444. /**
  57445. * Creates a new DotBlock
  57446. * @param name defines the block name
  57447. */
  57448. constructor(name: string);
  57449. /**
  57450. * Gets the current class name
  57451. * @returns the class name
  57452. */
  57453. getClassName(): string;
  57454. /**
  57455. * Gets the left operand input component
  57456. */
  57457. readonly left: NodeMaterialConnectionPoint;
  57458. /**
  57459. * Gets the right operand input component
  57460. */
  57461. readonly right: NodeMaterialConnectionPoint;
  57462. /**
  57463. * Gets the output component
  57464. */
  57465. readonly output: NodeMaterialConnectionPoint;
  57466. protected _buildBlock(state: NodeMaterialBuildState): this;
  57467. }
  57468. }
  57469. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57473. import { Vector2 } from "babylonjs/Maths/math.vector";
  57474. import { Scene } from "babylonjs/scene";
  57475. /**
  57476. * Block used to remap a float from a range to a new one
  57477. */
  57478. export class RemapBlock extends NodeMaterialBlock {
  57479. /**
  57480. * Gets or sets the source range
  57481. */
  57482. sourceRange: Vector2;
  57483. /**
  57484. * Gets or sets the target range
  57485. */
  57486. targetRange: Vector2;
  57487. /**
  57488. * Creates a new RemapBlock
  57489. * @param name defines the block name
  57490. */
  57491. constructor(name: string);
  57492. /**
  57493. * Gets the current class name
  57494. * @returns the class name
  57495. */
  57496. getClassName(): string;
  57497. /**
  57498. * Gets the input component
  57499. */
  57500. readonly input: NodeMaterialConnectionPoint;
  57501. /**
  57502. * Gets the source min input component
  57503. */
  57504. readonly sourceMin: NodeMaterialConnectionPoint;
  57505. /**
  57506. * Gets the source max input component
  57507. */
  57508. readonly sourceMax: NodeMaterialConnectionPoint;
  57509. /**
  57510. * Gets the target min input component
  57511. */
  57512. readonly targetMin: NodeMaterialConnectionPoint;
  57513. /**
  57514. * Gets the target max input component
  57515. */
  57516. readonly targetMax: NodeMaterialConnectionPoint;
  57517. /**
  57518. * Gets the output component
  57519. */
  57520. readonly output: NodeMaterialConnectionPoint;
  57521. protected _buildBlock(state: NodeMaterialBuildState): this;
  57522. protected _dumpPropertiesCode(): string;
  57523. serialize(): any;
  57524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57525. }
  57526. }
  57527. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57531. /**
  57532. * Block used to normalize a vector
  57533. */
  57534. export class NormalizeBlock extends NodeMaterialBlock {
  57535. /**
  57536. * Creates a new NormalizeBlock
  57537. * @param name defines the block name
  57538. */
  57539. constructor(name: string);
  57540. /**
  57541. * Gets the current class name
  57542. * @returns the class name
  57543. */
  57544. getClassName(): string;
  57545. /**
  57546. * Gets the input component
  57547. */
  57548. readonly input: NodeMaterialConnectionPoint;
  57549. /**
  57550. * Gets the output component
  57551. */
  57552. readonly output: NodeMaterialConnectionPoint;
  57553. protected _buildBlock(state: NodeMaterialBuildState): this;
  57554. }
  57555. }
  57556. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57560. import { Scene } from "babylonjs/scene";
  57561. /**
  57562. * Operations supported by the Trigonometry block
  57563. */
  57564. export enum TrigonometryBlockOperations {
  57565. /** Cos */
  57566. Cos = 0,
  57567. /** Sin */
  57568. Sin = 1,
  57569. /** Abs */
  57570. Abs = 2,
  57571. /** Exp */
  57572. Exp = 3,
  57573. /** Exp2 */
  57574. Exp2 = 4,
  57575. /** Round */
  57576. Round = 5,
  57577. /** Floor */
  57578. Floor = 6,
  57579. /** Ceiling */
  57580. Ceiling = 7,
  57581. /** Square root */
  57582. Sqrt = 8,
  57583. /** Log */
  57584. Log = 9,
  57585. /** Tangent */
  57586. Tan = 10,
  57587. /** Arc tangent */
  57588. ArcTan = 11,
  57589. /** Arc cosinus */
  57590. ArcCos = 12,
  57591. /** Arc sinus */
  57592. ArcSin = 13,
  57593. /** Fraction */
  57594. Fract = 14,
  57595. /** Sign */
  57596. Sign = 15,
  57597. /** To radians (from degrees) */
  57598. Radians = 16,
  57599. /** To degrees (from radians) */
  57600. Degrees = 17
  57601. }
  57602. /**
  57603. * Block used to apply trigonometry operation to floats
  57604. */
  57605. export class TrigonometryBlock extends NodeMaterialBlock {
  57606. /**
  57607. * Gets or sets the operation applied by the block
  57608. */
  57609. operation: TrigonometryBlockOperations;
  57610. /**
  57611. * Creates a new TrigonometryBlock
  57612. * @param name defines the block name
  57613. */
  57614. constructor(name: string);
  57615. /**
  57616. * Gets the current class name
  57617. * @returns the class name
  57618. */
  57619. getClassName(): string;
  57620. /**
  57621. * Gets the input component
  57622. */
  57623. readonly input: NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the output component
  57626. */
  57627. readonly output: NodeMaterialConnectionPoint;
  57628. protected _buildBlock(state: NodeMaterialBuildState): this;
  57629. serialize(): any;
  57630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57631. }
  57632. }
  57633. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57637. /**
  57638. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57639. */
  57640. export class ColorMergerBlock extends NodeMaterialBlock {
  57641. /**
  57642. * Create a new ColorMergerBlock
  57643. * @param name defines the block name
  57644. */
  57645. constructor(name: string);
  57646. /**
  57647. * Gets the current class name
  57648. * @returns the class name
  57649. */
  57650. getClassName(): string;
  57651. /**
  57652. * Gets the r component (input)
  57653. */
  57654. readonly r: NodeMaterialConnectionPoint;
  57655. /**
  57656. * Gets the g component (input)
  57657. */
  57658. readonly g: NodeMaterialConnectionPoint;
  57659. /**
  57660. * Gets the b component (input)
  57661. */
  57662. readonly b: NodeMaterialConnectionPoint;
  57663. /**
  57664. * Gets the a component (input)
  57665. */
  57666. readonly a: NodeMaterialConnectionPoint;
  57667. /**
  57668. * Gets the rgba component (output)
  57669. */
  57670. readonly rgba: NodeMaterialConnectionPoint;
  57671. /**
  57672. * Gets the rgb component (output)
  57673. */
  57674. readonly rgb: NodeMaterialConnectionPoint;
  57675. protected _buildBlock(state: NodeMaterialBuildState): this;
  57676. }
  57677. }
  57678. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57679. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57680. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57681. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57682. /**
  57683. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57684. */
  57685. export class VectorMergerBlock extends NodeMaterialBlock {
  57686. /**
  57687. * Create a new VectorMergerBlock
  57688. * @param name defines the block name
  57689. */
  57690. constructor(name: string);
  57691. /**
  57692. * Gets the current class name
  57693. * @returns the class name
  57694. */
  57695. getClassName(): string;
  57696. /**
  57697. * Gets the x component (input)
  57698. */
  57699. readonly x: NodeMaterialConnectionPoint;
  57700. /**
  57701. * Gets the y component (input)
  57702. */
  57703. readonly y: NodeMaterialConnectionPoint;
  57704. /**
  57705. * Gets the z component (input)
  57706. */
  57707. readonly z: NodeMaterialConnectionPoint;
  57708. /**
  57709. * Gets the w component (input)
  57710. */
  57711. readonly w: NodeMaterialConnectionPoint;
  57712. /**
  57713. * Gets the xyzw component (output)
  57714. */
  57715. readonly xyzw: NodeMaterialConnectionPoint;
  57716. /**
  57717. * Gets the xyz component (output)
  57718. */
  57719. readonly xyz: NodeMaterialConnectionPoint;
  57720. /**
  57721. * Gets the xy component (output)
  57722. */
  57723. readonly xy: NodeMaterialConnectionPoint;
  57724. protected _buildBlock(state: NodeMaterialBuildState): this;
  57725. }
  57726. }
  57727. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57731. /**
  57732. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57733. */
  57734. export class ColorSplitterBlock extends NodeMaterialBlock {
  57735. /**
  57736. * Create a new ColorSplitterBlock
  57737. * @param name defines the block name
  57738. */
  57739. constructor(name: string);
  57740. /**
  57741. * Gets the current class name
  57742. * @returns the class name
  57743. */
  57744. getClassName(): string;
  57745. /**
  57746. * Gets the rgba component (input)
  57747. */
  57748. readonly rgba: NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the rgb component (input)
  57751. */
  57752. readonly rgbIn: NodeMaterialConnectionPoint;
  57753. /**
  57754. * Gets the rgb component (output)
  57755. */
  57756. readonly rgbOut: NodeMaterialConnectionPoint;
  57757. /**
  57758. * Gets the r component (output)
  57759. */
  57760. readonly r: NodeMaterialConnectionPoint;
  57761. /**
  57762. * Gets the g component (output)
  57763. */
  57764. readonly g: NodeMaterialConnectionPoint;
  57765. /**
  57766. * Gets the b component (output)
  57767. */
  57768. readonly b: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the a component (output)
  57771. */
  57772. readonly a: NodeMaterialConnectionPoint;
  57773. protected _inputRename(name: string): string;
  57774. protected _outputRename(name: string): string;
  57775. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57776. }
  57777. }
  57778. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57782. /**
  57783. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57784. */
  57785. export class VectorSplitterBlock extends NodeMaterialBlock {
  57786. /**
  57787. * Create a new VectorSplitterBlock
  57788. * @param name defines the block name
  57789. */
  57790. constructor(name: string);
  57791. /**
  57792. * Gets the current class name
  57793. * @returns the class name
  57794. */
  57795. getClassName(): string;
  57796. /**
  57797. * Gets the xyzw component (input)
  57798. */
  57799. readonly xyzw: NodeMaterialConnectionPoint;
  57800. /**
  57801. * Gets the xyz component (input)
  57802. */
  57803. readonly xyzIn: NodeMaterialConnectionPoint;
  57804. /**
  57805. * Gets the xy component (input)
  57806. */
  57807. readonly xyIn: NodeMaterialConnectionPoint;
  57808. /**
  57809. * Gets the xyz component (output)
  57810. */
  57811. readonly xyzOut: NodeMaterialConnectionPoint;
  57812. /**
  57813. * Gets the xy component (output)
  57814. */
  57815. readonly xyOut: NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the x component (output)
  57818. */
  57819. readonly x: NodeMaterialConnectionPoint;
  57820. /**
  57821. * Gets the y component (output)
  57822. */
  57823. readonly y: NodeMaterialConnectionPoint;
  57824. /**
  57825. * Gets the z component (output)
  57826. */
  57827. readonly z: NodeMaterialConnectionPoint;
  57828. /**
  57829. * Gets the w component (output)
  57830. */
  57831. readonly w: NodeMaterialConnectionPoint;
  57832. protected _inputRename(name: string): string;
  57833. protected _outputRename(name: string): string;
  57834. protected _buildBlock(state: NodeMaterialBuildState): this;
  57835. }
  57836. }
  57837. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57841. /**
  57842. * Block used to lerp between 2 values
  57843. */
  57844. export class LerpBlock extends NodeMaterialBlock {
  57845. /**
  57846. * Creates a new LerpBlock
  57847. * @param name defines the block name
  57848. */
  57849. constructor(name: string);
  57850. /**
  57851. * Gets the current class name
  57852. * @returns the class name
  57853. */
  57854. getClassName(): string;
  57855. /**
  57856. * Gets the left operand input component
  57857. */
  57858. readonly left: NodeMaterialConnectionPoint;
  57859. /**
  57860. * Gets the right operand input component
  57861. */
  57862. readonly right: NodeMaterialConnectionPoint;
  57863. /**
  57864. * Gets the gradient operand input component
  57865. */
  57866. readonly gradient: NodeMaterialConnectionPoint;
  57867. /**
  57868. * Gets the output component
  57869. */
  57870. readonly output: NodeMaterialConnectionPoint;
  57871. protected _buildBlock(state: NodeMaterialBuildState): this;
  57872. }
  57873. }
  57874. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57878. /**
  57879. * Block used to divide 2 vectors
  57880. */
  57881. export class DivideBlock extends NodeMaterialBlock {
  57882. /**
  57883. * Creates a new DivideBlock
  57884. * @param name defines the block name
  57885. */
  57886. constructor(name: string);
  57887. /**
  57888. * Gets the current class name
  57889. * @returns the class name
  57890. */
  57891. getClassName(): string;
  57892. /**
  57893. * Gets the left operand input component
  57894. */
  57895. readonly left: NodeMaterialConnectionPoint;
  57896. /**
  57897. * Gets the right operand input component
  57898. */
  57899. readonly right: NodeMaterialConnectionPoint;
  57900. /**
  57901. * Gets the output component
  57902. */
  57903. readonly output: NodeMaterialConnectionPoint;
  57904. protected _buildBlock(state: NodeMaterialBuildState): this;
  57905. }
  57906. }
  57907. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57911. /**
  57912. * Block used to subtract 2 vectors
  57913. */
  57914. export class SubtractBlock extends NodeMaterialBlock {
  57915. /**
  57916. * Creates a new SubtractBlock
  57917. * @param name defines the block name
  57918. */
  57919. constructor(name: string);
  57920. /**
  57921. * Gets the current class name
  57922. * @returns the class name
  57923. */
  57924. getClassName(): string;
  57925. /**
  57926. * Gets the left operand input component
  57927. */
  57928. readonly left: NodeMaterialConnectionPoint;
  57929. /**
  57930. * Gets the right operand input component
  57931. */
  57932. readonly right: NodeMaterialConnectionPoint;
  57933. /**
  57934. * Gets the output component
  57935. */
  57936. readonly output: NodeMaterialConnectionPoint;
  57937. protected _buildBlock(state: NodeMaterialBuildState): this;
  57938. }
  57939. }
  57940. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57944. /**
  57945. * Block used to step a value
  57946. */
  57947. export class StepBlock extends NodeMaterialBlock {
  57948. /**
  57949. * Creates a new StepBlock
  57950. * @param name defines the block name
  57951. */
  57952. constructor(name: string);
  57953. /**
  57954. * Gets the current class name
  57955. * @returns the class name
  57956. */
  57957. getClassName(): string;
  57958. /**
  57959. * Gets the value operand input component
  57960. */
  57961. readonly value: NodeMaterialConnectionPoint;
  57962. /**
  57963. * Gets the edge operand input component
  57964. */
  57965. readonly edge: NodeMaterialConnectionPoint;
  57966. /**
  57967. * Gets the output component
  57968. */
  57969. readonly output: NodeMaterialConnectionPoint;
  57970. protected _buildBlock(state: NodeMaterialBuildState): this;
  57971. }
  57972. }
  57973. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57976. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57977. /**
  57978. * Block used to get the opposite (1 - x) of a value
  57979. */
  57980. export class OneMinusBlock extends NodeMaterialBlock {
  57981. /**
  57982. * Creates a new OneMinusBlock
  57983. * @param name defines the block name
  57984. */
  57985. constructor(name: string);
  57986. /**
  57987. * Gets the current class name
  57988. * @returns the class name
  57989. */
  57990. getClassName(): string;
  57991. /**
  57992. * Gets the input component
  57993. */
  57994. readonly input: NodeMaterialConnectionPoint;
  57995. /**
  57996. * Gets the output component
  57997. */
  57998. readonly output: NodeMaterialConnectionPoint;
  57999. protected _buildBlock(state: NodeMaterialBuildState): this;
  58000. }
  58001. }
  58002. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58006. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58007. /**
  58008. * Block used to get the view direction
  58009. */
  58010. export class ViewDirectionBlock extends NodeMaterialBlock {
  58011. /**
  58012. * Creates a new ViewDirectionBlock
  58013. * @param name defines the block name
  58014. */
  58015. constructor(name: string);
  58016. /**
  58017. * Gets the current class name
  58018. * @returns the class name
  58019. */
  58020. getClassName(): string;
  58021. /**
  58022. * Gets the world position component
  58023. */
  58024. readonly worldPosition: NodeMaterialConnectionPoint;
  58025. /**
  58026. * Gets the camera position component
  58027. */
  58028. readonly cameraPosition: NodeMaterialConnectionPoint;
  58029. /**
  58030. * Gets the output component
  58031. */
  58032. readonly output: NodeMaterialConnectionPoint;
  58033. autoConfigure(material: NodeMaterial): void;
  58034. protected _buildBlock(state: NodeMaterialBuildState): this;
  58035. }
  58036. }
  58037. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58041. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58042. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58043. /**
  58044. * Block used to compute fresnel value
  58045. */
  58046. export class FresnelBlock extends NodeMaterialBlock {
  58047. /**
  58048. * Create a new FresnelBlock
  58049. * @param name defines the block name
  58050. */
  58051. constructor(name: string);
  58052. /**
  58053. * Gets the current class name
  58054. * @returns the class name
  58055. */
  58056. getClassName(): string;
  58057. /**
  58058. * Gets the world normal input component
  58059. */
  58060. readonly worldNormal: NodeMaterialConnectionPoint;
  58061. /**
  58062. * Gets the view direction input component
  58063. */
  58064. readonly viewDirection: NodeMaterialConnectionPoint;
  58065. /**
  58066. * Gets the bias input component
  58067. */
  58068. readonly bias: NodeMaterialConnectionPoint;
  58069. /**
  58070. * Gets the camera (or eye) position component
  58071. */
  58072. readonly power: NodeMaterialConnectionPoint;
  58073. /**
  58074. * Gets the fresnel output component
  58075. */
  58076. readonly fresnel: NodeMaterialConnectionPoint;
  58077. autoConfigure(material: NodeMaterial): void;
  58078. protected _buildBlock(state: NodeMaterialBuildState): this;
  58079. }
  58080. }
  58081. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58085. /**
  58086. * Block used to get the max of 2 values
  58087. */
  58088. export class MaxBlock extends NodeMaterialBlock {
  58089. /**
  58090. * Creates a new MaxBlock
  58091. * @param name defines the block name
  58092. */
  58093. constructor(name: string);
  58094. /**
  58095. * Gets the current class name
  58096. * @returns the class name
  58097. */
  58098. getClassName(): string;
  58099. /**
  58100. * Gets the left operand input component
  58101. */
  58102. readonly left: NodeMaterialConnectionPoint;
  58103. /**
  58104. * Gets the right operand input component
  58105. */
  58106. readonly right: NodeMaterialConnectionPoint;
  58107. /**
  58108. * Gets the output component
  58109. */
  58110. readonly output: NodeMaterialConnectionPoint;
  58111. protected _buildBlock(state: NodeMaterialBuildState): this;
  58112. }
  58113. }
  58114. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58118. /**
  58119. * Block used to get the min of 2 values
  58120. */
  58121. export class MinBlock extends NodeMaterialBlock {
  58122. /**
  58123. * Creates a new MinBlock
  58124. * @param name defines the block name
  58125. */
  58126. constructor(name: string);
  58127. /**
  58128. * Gets the current class name
  58129. * @returns the class name
  58130. */
  58131. getClassName(): string;
  58132. /**
  58133. * Gets the left operand input component
  58134. */
  58135. readonly left: NodeMaterialConnectionPoint;
  58136. /**
  58137. * Gets the right operand input component
  58138. */
  58139. readonly right: NodeMaterialConnectionPoint;
  58140. /**
  58141. * Gets the output component
  58142. */
  58143. readonly output: NodeMaterialConnectionPoint;
  58144. protected _buildBlock(state: NodeMaterialBuildState): this;
  58145. }
  58146. }
  58147. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58148. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58150. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58151. /**
  58152. * Block used to get the distance between 2 values
  58153. */
  58154. export class DistanceBlock extends NodeMaterialBlock {
  58155. /**
  58156. * Creates a new DistanceBlock
  58157. * @param name defines the block name
  58158. */
  58159. constructor(name: string);
  58160. /**
  58161. * Gets the current class name
  58162. * @returns the class name
  58163. */
  58164. getClassName(): string;
  58165. /**
  58166. * Gets the left operand input component
  58167. */
  58168. readonly left: NodeMaterialConnectionPoint;
  58169. /**
  58170. * Gets the right operand input component
  58171. */
  58172. readonly right: NodeMaterialConnectionPoint;
  58173. /**
  58174. * Gets the output component
  58175. */
  58176. readonly output: NodeMaterialConnectionPoint;
  58177. protected _buildBlock(state: NodeMaterialBuildState): this;
  58178. }
  58179. }
  58180. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58182. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58184. /**
  58185. * Block used to get the length of a vector
  58186. */
  58187. export class LengthBlock extends NodeMaterialBlock {
  58188. /**
  58189. * Creates a new LengthBlock
  58190. * @param name defines the block name
  58191. */
  58192. constructor(name: string);
  58193. /**
  58194. * Gets the current class name
  58195. * @returns the class name
  58196. */
  58197. getClassName(): string;
  58198. /**
  58199. * Gets the value input component
  58200. */
  58201. readonly value: NodeMaterialConnectionPoint;
  58202. /**
  58203. * Gets the output component
  58204. */
  58205. readonly output: NodeMaterialConnectionPoint;
  58206. protected _buildBlock(state: NodeMaterialBuildState): this;
  58207. }
  58208. }
  58209. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58213. /**
  58214. * Block used to get negative version of a value (i.e. x * -1)
  58215. */
  58216. export class NegateBlock extends NodeMaterialBlock {
  58217. /**
  58218. * Creates a new NegateBlock
  58219. * @param name defines the block name
  58220. */
  58221. constructor(name: string);
  58222. /**
  58223. * Gets the current class name
  58224. * @returns the class name
  58225. */
  58226. getClassName(): string;
  58227. /**
  58228. * Gets the value input component
  58229. */
  58230. readonly value: NodeMaterialConnectionPoint;
  58231. /**
  58232. * Gets the output component
  58233. */
  58234. readonly output: NodeMaterialConnectionPoint;
  58235. protected _buildBlock(state: NodeMaterialBuildState): this;
  58236. }
  58237. }
  58238. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58242. /**
  58243. * Block used to get the value of the first parameter raised to the power of the second
  58244. */
  58245. export class PowBlock extends NodeMaterialBlock {
  58246. /**
  58247. * Creates a new PowBlock
  58248. * @param name defines the block name
  58249. */
  58250. constructor(name: string);
  58251. /**
  58252. * Gets the current class name
  58253. * @returns the class name
  58254. */
  58255. getClassName(): string;
  58256. /**
  58257. * Gets the value operand input component
  58258. */
  58259. readonly value: NodeMaterialConnectionPoint;
  58260. /**
  58261. * Gets the power operand input component
  58262. */
  58263. readonly power: NodeMaterialConnectionPoint;
  58264. /**
  58265. * Gets the output component
  58266. */
  58267. readonly output: NodeMaterialConnectionPoint;
  58268. protected _buildBlock(state: NodeMaterialBuildState): this;
  58269. }
  58270. }
  58271. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58272. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58273. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58274. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58275. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58276. /**
  58277. * Block used to get a random number
  58278. */
  58279. export class RandomNumberBlock extends NodeMaterialBlock {
  58280. /**
  58281. * Creates a new RandomNumberBlock
  58282. * @param name defines the block name
  58283. */
  58284. constructor(name: string);
  58285. /**
  58286. * Gets the current class name
  58287. * @returns the class name
  58288. */
  58289. getClassName(): string;
  58290. /**
  58291. * Gets the seed input component
  58292. */
  58293. readonly seed: NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the output component
  58296. */
  58297. readonly output: NodeMaterialConnectionPoint;
  58298. protected _buildBlock(state: NodeMaterialBuildState): this;
  58299. }
  58300. }
  58301. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58305. /**
  58306. * Block used to compute arc tangent of 2 values
  58307. */
  58308. export class ArcTan2Block extends NodeMaterialBlock {
  58309. /**
  58310. * Creates a new ArcTan2Block
  58311. * @param name defines the block name
  58312. */
  58313. constructor(name: string);
  58314. /**
  58315. * Gets the current class name
  58316. * @returns the class name
  58317. */
  58318. getClassName(): string;
  58319. /**
  58320. * Gets the x operand input component
  58321. */
  58322. readonly x: NodeMaterialConnectionPoint;
  58323. /**
  58324. * Gets the y operand input component
  58325. */
  58326. readonly y: NodeMaterialConnectionPoint;
  58327. /**
  58328. * Gets the output component
  58329. */
  58330. readonly output: NodeMaterialConnectionPoint;
  58331. protected _buildBlock(state: NodeMaterialBuildState): this;
  58332. }
  58333. }
  58334. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58338. /**
  58339. * Block used to smooth step a value
  58340. */
  58341. export class SmoothStepBlock extends NodeMaterialBlock {
  58342. /**
  58343. * Creates a new SmoothStepBlock
  58344. * @param name defines the block name
  58345. */
  58346. constructor(name: string);
  58347. /**
  58348. * Gets the current class name
  58349. * @returns the class name
  58350. */
  58351. getClassName(): string;
  58352. /**
  58353. * Gets the value operand input component
  58354. */
  58355. readonly value: NodeMaterialConnectionPoint;
  58356. /**
  58357. * Gets the first edge operand input component
  58358. */
  58359. readonly edge0: NodeMaterialConnectionPoint;
  58360. /**
  58361. * Gets the second edge operand input component
  58362. */
  58363. readonly edge1: NodeMaterialConnectionPoint;
  58364. /**
  58365. * Gets the output component
  58366. */
  58367. readonly output: NodeMaterialConnectionPoint;
  58368. protected _buildBlock(state: NodeMaterialBuildState): this;
  58369. }
  58370. }
  58371. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58372. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58373. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58374. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58375. /**
  58376. * Block used to get the reciprocal (1 / x) of a value
  58377. */
  58378. export class ReciprocalBlock extends NodeMaterialBlock {
  58379. /**
  58380. * Creates a new ReciprocalBlock
  58381. * @param name defines the block name
  58382. */
  58383. constructor(name: string);
  58384. /**
  58385. * Gets the current class name
  58386. * @returns the class name
  58387. */
  58388. getClassName(): string;
  58389. /**
  58390. * Gets the input component
  58391. */
  58392. readonly input: NodeMaterialConnectionPoint;
  58393. /**
  58394. * Gets the output component
  58395. */
  58396. readonly output: NodeMaterialConnectionPoint;
  58397. protected _buildBlock(state: NodeMaterialBuildState): this;
  58398. }
  58399. }
  58400. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58404. /**
  58405. * Block used to replace a color by another one
  58406. */
  58407. export class ReplaceColorBlock extends NodeMaterialBlock {
  58408. /**
  58409. * Creates a new ReplaceColorBlock
  58410. * @param name defines the block name
  58411. */
  58412. constructor(name: string);
  58413. /**
  58414. * Gets the current class name
  58415. * @returns the class name
  58416. */
  58417. getClassName(): string;
  58418. /**
  58419. * Gets the value input component
  58420. */
  58421. readonly value: NodeMaterialConnectionPoint;
  58422. /**
  58423. * Gets the reference input component
  58424. */
  58425. readonly reference: NodeMaterialConnectionPoint;
  58426. /**
  58427. * Gets the distance input component
  58428. */
  58429. readonly distance: NodeMaterialConnectionPoint;
  58430. /**
  58431. * Gets the replacement input component
  58432. */
  58433. readonly replacement: NodeMaterialConnectionPoint;
  58434. /**
  58435. * Gets the output component
  58436. */
  58437. readonly output: NodeMaterialConnectionPoint;
  58438. protected _buildBlock(state: NodeMaterialBuildState): this;
  58439. }
  58440. }
  58441. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58442. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58443. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58444. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58445. /**
  58446. * Block used to posterize a value
  58447. * @see https://en.wikipedia.org/wiki/Posterization
  58448. */
  58449. export class PosterizeBlock extends NodeMaterialBlock {
  58450. /**
  58451. * Creates a new PosterizeBlock
  58452. * @param name defines the block name
  58453. */
  58454. constructor(name: string);
  58455. /**
  58456. * Gets the current class name
  58457. * @returns the class name
  58458. */
  58459. getClassName(): string;
  58460. /**
  58461. * Gets the value input component
  58462. */
  58463. readonly value: NodeMaterialConnectionPoint;
  58464. /**
  58465. * Gets the steps input component
  58466. */
  58467. readonly steps: NodeMaterialConnectionPoint;
  58468. /**
  58469. * Gets the output component
  58470. */
  58471. readonly output: NodeMaterialConnectionPoint;
  58472. protected _buildBlock(state: NodeMaterialBuildState): this;
  58473. }
  58474. }
  58475. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58479. import { Scene } from "babylonjs/scene";
  58480. /**
  58481. * Operations supported by the Wave block
  58482. */
  58483. export enum WaveBlockKind {
  58484. /** SawTooth */
  58485. SawTooth = 0,
  58486. /** Square */
  58487. Square = 1,
  58488. /** Triangle */
  58489. Triangle = 2
  58490. }
  58491. /**
  58492. * Block used to apply wave operation to floats
  58493. */
  58494. export class WaveBlock extends NodeMaterialBlock {
  58495. /**
  58496. * Gets or sets the kibnd of wave to be applied by the block
  58497. */
  58498. kind: WaveBlockKind;
  58499. /**
  58500. * Creates a new WaveBlock
  58501. * @param name defines the block name
  58502. */
  58503. constructor(name: string);
  58504. /**
  58505. * Gets the current class name
  58506. * @returns the class name
  58507. */
  58508. getClassName(): string;
  58509. /**
  58510. * Gets the input component
  58511. */
  58512. readonly input: NodeMaterialConnectionPoint;
  58513. /**
  58514. * Gets the output component
  58515. */
  58516. readonly output: NodeMaterialConnectionPoint;
  58517. protected _buildBlock(state: NodeMaterialBuildState): this;
  58518. serialize(): any;
  58519. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58520. }
  58521. }
  58522. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58526. import { Color3 } from "babylonjs/Maths/math.color";
  58527. import { Scene } from "babylonjs/scene";
  58528. /**
  58529. * Class used to store a color step for the GradientBlock
  58530. */
  58531. export class GradientBlockColorStep {
  58532. /**
  58533. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58534. */
  58535. step: number;
  58536. /**
  58537. * Gets or sets the color associated with this step
  58538. */
  58539. color: Color3;
  58540. /**
  58541. * Creates a new GradientBlockColorStep
  58542. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58543. * @param color defines the color associated with this step
  58544. */
  58545. constructor(
  58546. /**
  58547. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58548. */
  58549. step: number,
  58550. /**
  58551. * Gets or sets the color associated with this step
  58552. */
  58553. color: Color3);
  58554. }
  58555. /**
  58556. * Block used to return a color from a gradient based on an input value between 0 and 1
  58557. */
  58558. export class GradientBlock extends NodeMaterialBlock {
  58559. /**
  58560. * Gets or sets the list of color steps
  58561. */
  58562. colorSteps: GradientBlockColorStep[];
  58563. /**
  58564. * Creates a new GradientBlock
  58565. * @param name defines the block name
  58566. */
  58567. constructor(name: string);
  58568. /**
  58569. * Gets the current class name
  58570. * @returns the class name
  58571. */
  58572. getClassName(): string;
  58573. /**
  58574. * Gets the gradient input component
  58575. */
  58576. readonly gradient: NodeMaterialConnectionPoint;
  58577. /**
  58578. * Gets the output component
  58579. */
  58580. readonly output: NodeMaterialConnectionPoint;
  58581. private _writeColorConstant;
  58582. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58583. serialize(): any;
  58584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58585. protected _dumpPropertiesCode(): string;
  58586. }
  58587. }
  58588. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58592. /**
  58593. * Block used to normalize lerp between 2 values
  58594. */
  58595. export class NLerpBlock extends NodeMaterialBlock {
  58596. /**
  58597. * Creates a new NLerpBlock
  58598. * @param name defines the block name
  58599. */
  58600. constructor(name: string);
  58601. /**
  58602. * Gets the current class name
  58603. * @returns the class name
  58604. */
  58605. getClassName(): string;
  58606. /**
  58607. * Gets the left operand input component
  58608. */
  58609. readonly left: NodeMaterialConnectionPoint;
  58610. /**
  58611. * Gets the right operand input component
  58612. */
  58613. readonly right: NodeMaterialConnectionPoint;
  58614. /**
  58615. * Gets the gradient operand input component
  58616. */
  58617. readonly gradient: NodeMaterialConnectionPoint;
  58618. /**
  58619. * Gets the output component
  58620. */
  58621. readonly output: NodeMaterialConnectionPoint;
  58622. protected _buildBlock(state: NodeMaterialBuildState): this;
  58623. }
  58624. }
  58625. declare module "babylonjs/Materials/Node/Blocks/frontFacingBlock" {
  58626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58629. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58630. /**
  58631. * Block used to test if the fragment shader is front facing
  58632. */
  58633. export class FrontFacingBlock extends NodeMaterialBlock {
  58634. /**
  58635. * Creates a new FrontFacingBlock
  58636. * @param name defines the block name
  58637. */
  58638. constructor(name: string);
  58639. /**
  58640. * Gets the current class name
  58641. * @returns the class name
  58642. */
  58643. getClassName(): string;
  58644. /**
  58645. * Gets the world normal component
  58646. */
  58647. readonly worldNormal: NodeMaterialConnectionPoint;
  58648. /**
  58649. * Gets the view direction input component
  58650. */
  58651. readonly viewDirection: NodeMaterialConnectionPoint;
  58652. /**
  58653. * Gets the output component
  58654. */
  58655. readonly output: NodeMaterialConnectionPoint;
  58656. autoConfigure(material: NodeMaterial): void;
  58657. protected _buildBlock(state: NodeMaterialBuildState): this;
  58658. }
  58659. }
  58660. declare module "babylonjs/Materials/Node/Blocks/index" {
  58661. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58662. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58663. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58664. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58665. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58666. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58667. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58668. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58669. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58670. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58671. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58672. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58673. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58674. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58675. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58676. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58677. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58678. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58679. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58680. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58681. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58682. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58683. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58684. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58685. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58686. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58687. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58688. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58689. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58690. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58691. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58692. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58693. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58694. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58695. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58696. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58697. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58698. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58699. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58700. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58701. export * from "babylonjs/Materials/Node/Blocks/frontFacingBlock";
  58702. }
  58703. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58704. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58705. }
  58706. declare module "babylonjs/Materials/Node/index" {
  58707. export * from "babylonjs/Materials/Node/Enums/index";
  58708. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58709. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58710. export * from "babylonjs/Materials/Node/nodeMaterial";
  58711. export * from "babylonjs/Materials/Node/Blocks/index";
  58712. export * from "babylonjs/Materials/Node/Optimizers/index";
  58713. }
  58714. declare module "babylonjs/Materials/effectRenderer" {
  58715. import { Nullable } from "babylonjs/types";
  58716. import { Texture } from "babylonjs/Materials/Textures/texture";
  58717. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58718. import { Viewport } from "babylonjs/Maths/math.viewport";
  58719. import { Observable } from "babylonjs/Misc/observable";
  58720. import { Effect } from "babylonjs/Materials/effect";
  58721. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58722. import "babylonjs/Shaders/postprocess.vertex";
  58723. /**
  58724. * Effect Render Options
  58725. */
  58726. export interface IEffectRendererOptions {
  58727. /**
  58728. * Defines the vertices positions.
  58729. */
  58730. positions?: number[];
  58731. /**
  58732. * Defines the indices.
  58733. */
  58734. indices?: number[];
  58735. }
  58736. /**
  58737. * Helper class to render one or more effects
  58738. */
  58739. export class EffectRenderer {
  58740. private engine;
  58741. private static _DefaultOptions;
  58742. private _vertexBuffers;
  58743. private _indexBuffer;
  58744. private _ringBufferIndex;
  58745. private _ringScreenBuffer;
  58746. private _fullscreenViewport;
  58747. private _getNextFrameBuffer;
  58748. /**
  58749. * Creates an effect renderer
  58750. * @param engine the engine to use for rendering
  58751. * @param options defines the options of the effect renderer
  58752. */
  58753. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58754. /**
  58755. * Sets the current viewport in normalized coordinates 0-1
  58756. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58757. */
  58758. setViewport(viewport?: Viewport): void;
  58759. /**
  58760. * Binds the embedded attributes buffer to the effect.
  58761. * @param effect Defines the effect to bind the attributes for
  58762. */
  58763. bindBuffers(effect: Effect): void;
  58764. /**
  58765. * Sets the current effect wrapper to use during draw.
  58766. * The effect needs to be ready before calling this api.
  58767. * This also sets the default full screen position attribute.
  58768. * @param effectWrapper Defines the effect to draw with
  58769. */
  58770. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58771. /**
  58772. * Draws a full screen quad.
  58773. */
  58774. draw(): void;
  58775. /**
  58776. * renders one or more effects to a specified texture
  58777. * @param effectWrappers list of effects to renderer
  58778. * @param outputTexture texture to draw to, if null it will render to the screen
  58779. */
  58780. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58781. /**
  58782. * Disposes of the effect renderer
  58783. */
  58784. dispose(): void;
  58785. }
  58786. /**
  58787. * Options to create an EffectWrapper
  58788. */
  58789. interface EffectWrapperCreationOptions {
  58790. /**
  58791. * Engine to use to create the effect
  58792. */
  58793. engine: ThinEngine;
  58794. /**
  58795. * Fragment shader for the effect
  58796. */
  58797. fragmentShader: string;
  58798. /**
  58799. * Vertex shader for the effect
  58800. */
  58801. vertexShader?: string;
  58802. /**
  58803. * Attributes to use in the shader
  58804. */
  58805. attributeNames?: Array<string>;
  58806. /**
  58807. * Uniforms to use in the shader
  58808. */
  58809. uniformNames?: Array<string>;
  58810. /**
  58811. * Texture sampler names to use in the shader
  58812. */
  58813. samplerNames?: Array<string>;
  58814. /**
  58815. * The friendly name of the effect displayed in Spector.
  58816. */
  58817. name?: string;
  58818. }
  58819. /**
  58820. * Wraps an effect to be used for rendering
  58821. */
  58822. export class EffectWrapper {
  58823. /**
  58824. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58825. */
  58826. onApplyObservable: Observable<{}>;
  58827. /**
  58828. * The underlying effect
  58829. */
  58830. effect: Effect;
  58831. /**
  58832. * Creates an effect to be renderer
  58833. * @param creationOptions options to create the effect
  58834. */
  58835. constructor(creationOptions: EffectWrapperCreationOptions);
  58836. /**
  58837. * Disposes of the effect wrapper
  58838. */
  58839. dispose(): void;
  58840. }
  58841. }
  58842. declare module "babylonjs/Materials/index" {
  58843. export * from "babylonjs/Materials/Background/index";
  58844. export * from "babylonjs/Materials/colorCurves";
  58845. export * from "babylonjs/Materials/iEffectFallbacks";
  58846. export * from "babylonjs/Materials/effectFallbacks";
  58847. export * from "babylonjs/Materials/effect";
  58848. export * from "babylonjs/Materials/fresnelParameters";
  58849. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58850. export * from "babylonjs/Materials/material";
  58851. export * from "babylonjs/Materials/materialDefines";
  58852. export * from "babylonjs/Materials/materialHelper";
  58853. export * from "babylonjs/Materials/multiMaterial";
  58854. export * from "babylonjs/Materials/PBR/index";
  58855. export * from "babylonjs/Materials/pushMaterial";
  58856. export * from "babylonjs/Materials/shaderMaterial";
  58857. export * from "babylonjs/Materials/standardMaterial";
  58858. export * from "babylonjs/Materials/Textures/index";
  58859. export * from "babylonjs/Materials/uniformBuffer";
  58860. export * from "babylonjs/Materials/materialFlags";
  58861. export * from "babylonjs/Materials/Node/index";
  58862. export * from "babylonjs/Materials/effectRenderer";
  58863. }
  58864. declare module "babylonjs/Maths/index" {
  58865. export * from "babylonjs/Maths/math.scalar";
  58866. export * from "babylonjs/Maths/math";
  58867. export * from "babylonjs/Maths/sphericalPolynomial";
  58868. }
  58869. declare module "babylonjs/Misc/workerPool" {
  58870. import { IDisposable } from "babylonjs/scene";
  58871. /**
  58872. * Helper class to push actions to a pool of workers.
  58873. */
  58874. export class WorkerPool implements IDisposable {
  58875. private _workerInfos;
  58876. private _pendingActions;
  58877. /**
  58878. * Constructor
  58879. * @param workers Array of workers to use for actions
  58880. */
  58881. constructor(workers: Array<Worker>);
  58882. /**
  58883. * Terminates all workers and clears any pending actions.
  58884. */
  58885. dispose(): void;
  58886. /**
  58887. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58888. * pended until a worker has completed its action.
  58889. * @param action The action to perform. Call onComplete when the action is complete.
  58890. */
  58891. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58892. private _execute;
  58893. }
  58894. }
  58895. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58896. import { IDisposable } from "babylonjs/scene";
  58897. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58898. /**
  58899. * Configuration for Draco compression
  58900. */
  58901. export interface IDracoCompressionConfiguration {
  58902. /**
  58903. * Configuration for the decoder.
  58904. */
  58905. decoder: {
  58906. /**
  58907. * The url to the WebAssembly module.
  58908. */
  58909. wasmUrl?: string;
  58910. /**
  58911. * The url to the WebAssembly binary.
  58912. */
  58913. wasmBinaryUrl?: string;
  58914. /**
  58915. * The url to the fallback JavaScript module.
  58916. */
  58917. fallbackUrl?: string;
  58918. };
  58919. }
  58920. /**
  58921. * Draco compression (https://google.github.io/draco/)
  58922. *
  58923. * This class wraps the Draco module.
  58924. *
  58925. * **Encoder**
  58926. *
  58927. * The encoder is not currently implemented.
  58928. *
  58929. * **Decoder**
  58930. *
  58931. * 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.
  58932. *
  58933. * To update the configuration, use the following code:
  58934. * ```javascript
  58935. * DracoCompression.Configuration = {
  58936. * decoder: {
  58937. * wasmUrl: "<url to the WebAssembly library>",
  58938. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58939. * fallbackUrl: "<url to the fallback JavaScript library>",
  58940. * }
  58941. * };
  58942. * ```
  58943. *
  58944. * 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.
  58945. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58946. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58947. *
  58948. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58949. * ```javascript
  58950. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58951. * ```
  58952. *
  58953. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58954. */
  58955. export class DracoCompression implements IDisposable {
  58956. private _workerPoolPromise?;
  58957. private _decoderModulePromise?;
  58958. /**
  58959. * The configuration. Defaults to the following urls:
  58960. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58961. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58962. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58963. */
  58964. static Configuration: IDracoCompressionConfiguration;
  58965. /**
  58966. * Returns true if the decoder configuration is available.
  58967. */
  58968. static readonly DecoderAvailable: boolean;
  58969. /**
  58970. * Default number of workers to create when creating the draco compression object.
  58971. */
  58972. static DefaultNumWorkers: number;
  58973. private static GetDefaultNumWorkers;
  58974. private static _Default;
  58975. /**
  58976. * Default instance for the draco compression object.
  58977. */
  58978. static readonly Default: DracoCompression;
  58979. /**
  58980. * Constructor
  58981. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58982. */
  58983. constructor(numWorkers?: number);
  58984. /**
  58985. * Stop all async operations and release resources.
  58986. */
  58987. dispose(): void;
  58988. /**
  58989. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58990. * @returns a promise that resolves when ready
  58991. */
  58992. whenReadyAsync(): Promise<void>;
  58993. /**
  58994. * Decode Draco compressed mesh data to vertex data.
  58995. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58996. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58997. * @returns A promise that resolves with the decoded vertex data
  58998. */
  58999. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59000. [kind: string]: number;
  59001. }): Promise<VertexData>;
  59002. }
  59003. }
  59004. declare module "babylonjs/Meshes/Compression/index" {
  59005. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59006. }
  59007. declare module "babylonjs/Meshes/csg" {
  59008. import { Nullable } from "babylonjs/types";
  59009. import { Scene } from "babylonjs/scene";
  59010. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59011. import { Mesh } from "babylonjs/Meshes/mesh";
  59012. import { Material } from "babylonjs/Materials/material";
  59013. /**
  59014. * Class for building Constructive Solid Geometry
  59015. */
  59016. export class CSG {
  59017. private polygons;
  59018. /**
  59019. * The world matrix
  59020. */
  59021. matrix: Matrix;
  59022. /**
  59023. * Stores the position
  59024. */
  59025. position: Vector3;
  59026. /**
  59027. * Stores the rotation
  59028. */
  59029. rotation: Vector3;
  59030. /**
  59031. * Stores the rotation quaternion
  59032. */
  59033. rotationQuaternion: Nullable<Quaternion>;
  59034. /**
  59035. * Stores the scaling vector
  59036. */
  59037. scaling: Vector3;
  59038. /**
  59039. * Convert the Mesh to CSG
  59040. * @param mesh The Mesh to convert to CSG
  59041. * @returns A new CSG from the Mesh
  59042. */
  59043. static FromMesh(mesh: Mesh): CSG;
  59044. /**
  59045. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59046. * @param polygons Polygons used to construct a CSG solid
  59047. */
  59048. private static FromPolygons;
  59049. /**
  59050. * Clones, or makes a deep copy, of the CSG
  59051. * @returns A new CSG
  59052. */
  59053. clone(): CSG;
  59054. /**
  59055. * Unions this CSG with another CSG
  59056. * @param csg The CSG to union against this CSG
  59057. * @returns The unioned CSG
  59058. */
  59059. union(csg: CSG): CSG;
  59060. /**
  59061. * Unions this CSG with another CSG in place
  59062. * @param csg The CSG to union against this CSG
  59063. */
  59064. unionInPlace(csg: CSG): void;
  59065. /**
  59066. * Subtracts this CSG with another CSG
  59067. * @param csg The CSG to subtract against this CSG
  59068. * @returns A new CSG
  59069. */
  59070. subtract(csg: CSG): CSG;
  59071. /**
  59072. * Subtracts this CSG with another CSG in place
  59073. * @param csg The CSG to subtact against this CSG
  59074. */
  59075. subtractInPlace(csg: CSG): void;
  59076. /**
  59077. * Intersect this CSG with another CSG
  59078. * @param csg The CSG to intersect against this CSG
  59079. * @returns A new CSG
  59080. */
  59081. intersect(csg: CSG): CSG;
  59082. /**
  59083. * Intersects this CSG with another CSG in place
  59084. * @param csg The CSG to intersect against this CSG
  59085. */
  59086. intersectInPlace(csg: CSG): void;
  59087. /**
  59088. * Return a new CSG solid with solid and empty space switched. This solid is
  59089. * not modified.
  59090. * @returns A new CSG solid with solid and empty space switched
  59091. */
  59092. inverse(): CSG;
  59093. /**
  59094. * Inverses the CSG in place
  59095. */
  59096. inverseInPlace(): void;
  59097. /**
  59098. * This is used to keep meshes transformations so they can be restored
  59099. * when we build back a Babylon Mesh
  59100. * NB : All CSG operations are performed in world coordinates
  59101. * @param csg The CSG to copy the transform attributes from
  59102. * @returns This CSG
  59103. */
  59104. copyTransformAttributes(csg: CSG): CSG;
  59105. /**
  59106. * Build Raw mesh from CSG
  59107. * Coordinates here are in world space
  59108. * @param name The name of the mesh geometry
  59109. * @param scene The Scene
  59110. * @param keepSubMeshes Specifies if the submeshes should be kept
  59111. * @returns A new Mesh
  59112. */
  59113. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59114. /**
  59115. * Build Mesh from CSG taking material and transforms into account
  59116. * @param name The name of the Mesh
  59117. * @param material The material of the Mesh
  59118. * @param scene The Scene
  59119. * @param keepSubMeshes Specifies if submeshes should be kept
  59120. * @returns The new Mesh
  59121. */
  59122. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59123. }
  59124. }
  59125. declare module "babylonjs/Meshes/trailMesh" {
  59126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59127. import { Mesh } from "babylonjs/Meshes/mesh";
  59128. import { Scene } from "babylonjs/scene";
  59129. /**
  59130. * Class used to create a trail following a mesh
  59131. */
  59132. export class TrailMesh extends Mesh {
  59133. private _generator;
  59134. private _autoStart;
  59135. private _running;
  59136. private _diameter;
  59137. private _length;
  59138. private _sectionPolygonPointsCount;
  59139. private _sectionVectors;
  59140. private _sectionNormalVectors;
  59141. private _beforeRenderObserver;
  59142. /**
  59143. * @constructor
  59144. * @param name The value used by scene.getMeshByName() to do a lookup.
  59145. * @param generator The mesh to generate a trail.
  59146. * @param scene The scene to add this mesh to.
  59147. * @param diameter Diameter of trailing mesh. Default is 1.
  59148. * @param length Length of trailing mesh. Default is 60.
  59149. * @param autoStart Automatically start trailing mesh. Default true.
  59150. */
  59151. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59152. /**
  59153. * "TrailMesh"
  59154. * @returns "TrailMesh"
  59155. */
  59156. getClassName(): string;
  59157. private _createMesh;
  59158. /**
  59159. * Start trailing mesh.
  59160. */
  59161. start(): void;
  59162. /**
  59163. * Stop trailing mesh.
  59164. */
  59165. stop(): void;
  59166. /**
  59167. * Update trailing mesh geometry.
  59168. */
  59169. update(): void;
  59170. /**
  59171. * Returns a new TrailMesh object.
  59172. * @param name is a string, the name given to the new mesh
  59173. * @param newGenerator use new generator object for cloned trail mesh
  59174. * @returns a new mesh
  59175. */
  59176. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59177. /**
  59178. * Serializes this trail mesh
  59179. * @param serializationObject object to write serialization to
  59180. */
  59181. serialize(serializationObject: any): void;
  59182. /**
  59183. * Parses a serialized trail mesh
  59184. * @param parsedMesh the serialized mesh
  59185. * @param scene the scene to create the trail mesh in
  59186. * @returns the created trail mesh
  59187. */
  59188. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59189. }
  59190. }
  59191. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59192. import { Nullable } from "babylonjs/types";
  59193. import { Scene } from "babylonjs/scene";
  59194. import { Vector4 } from "babylonjs/Maths/math.vector";
  59195. import { Color4 } from "babylonjs/Maths/math.color";
  59196. import { Mesh } from "babylonjs/Meshes/mesh";
  59197. /**
  59198. * Class containing static functions to help procedurally build meshes
  59199. */
  59200. export class TiledBoxBuilder {
  59201. /**
  59202. * Creates a box mesh
  59203. * 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)
  59204. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59208. * @param name defines the name of the mesh
  59209. * @param options defines the options used to create the mesh
  59210. * @param scene defines the hosting scene
  59211. * @returns the box mesh
  59212. */
  59213. static CreateTiledBox(name: string, options: {
  59214. pattern?: number;
  59215. width?: number;
  59216. height?: number;
  59217. depth?: number;
  59218. tileSize?: number;
  59219. tileWidth?: number;
  59220. tileHeight?: number;
  59221. alignHorizontal?: number;
  59222. alignVertical?: number;
  59223. faceUV?: Vector4[];
  59224. faceColors?: Color4[];
  59225. sideOrientation?: number;
  59226. updatable?: boolean;
  59227. }, scene?: Nullable<Scene>): Mesh;
  59228. }
  59229. }
  59230. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59231. import { Vector4 } from "babylonjs/Maths/math.vector";
  59232. import { Mesh } from "babylonjs/Meshes/mesh";
  59233. /**
  59234. * Class containing static functions to help procedurally build meshes
  59235. */
  59236. export class TorusKnotBuilder {
  59237. /**
  59238. * Creates a torus knot mesh
  59239. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59240. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59241. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59242. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59246. * @param name defines the name of the mesh
  59247. * @param options defines the options used to create the mesh
  59248. * @param scene defines the hosting scene
  59249. * @returns the torus knot mesh
  59250. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59251. */
  59252. static CreateTorusKnot(name: string, options: {
  59253. radius?: number;
  59254. tube?: number;
  59255. radialSegments?: number;
  59256. tubularSegments?: number;
  59257. p?: number;
  59258. q?: number;
  59259. updatable?: boolean;
  59260. sideOrientation?: number;
  59261. frontUVs?: Vector4;
  59262. backUVs?: Vector4;
  59263. }, scene: any): Mesh;
  59264. }
  59265. }
  59266. declare module "babylonjs/Meshes/polygonMesh" {
  59267. import { Scene } from "babylonjs/scene";
  59268. import { Vector2 } from "babylonjs/Maths/math.vector";
  59269. import { Mesh } from "babylonjs/Meshes/mesh";
  59270. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59271. import { Path2 } from "babylonjs/Maths/math.path";
  59272. /**
  59273. * Polygon
  59274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59275. */
  59276. export class Polygon {
  59277. /**
  59278. * Creates a rectangle
  59279. * @param xmin bottom X coord
  59280. * @param ymin bottom Y coord
  59281. * @param xmax top X coord
  59282. * @param ymax top Y coord
  59283. * @returns points that make the resulting rectation
  59284. */
  59285. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  59286. /**
  59287. * Creates a circle
  59288. * @param radius radius of circle
  59289. * @param cx scale in x
  59290. * @param cy scale in y
  59291. * @param numberOfSides number of sides that make up the circle
  59292. * @returns points that make the resulting circle
  59293. */
  59294. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  59295. /**
  59296. * Creates a polygon from input string
  59297. * @param input Input polygon data
  59298. * @returns the parsed points
  59299. */
  59300. static Parse(input: string): Vector2[];
  59301. /**
  59302. * Starts building a polygon from x and y coordinates
  59303. * @param x x coordinate
  59304. * @param y y coordinate
  59305. * @returns the started path2
  59306. */
  59307. static StartingAt(x: number, y: number): Path2;
  59308. }
  59309. /**
  59310. * Builds a polygon
  59311. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  59312. */
  59313. export class PolygonMeshBuilder {
  59314. private _points;
  59315. private _outlinepoints;
  59316. private _holes;
  59317. private _name;
  59318. private _scene;
  59319. private _epoints;
  59320. private _eholes;
  59321. private _addToepoint;
  59322. /**
  59323. * Babylon reference to the earcut plugin.
  59324. */
  59325. bjsEarcut: any;
  59326. /**
  59327. * Creates a PolygonMeshBuilder
  59328. * @param name name of the builder
  59329. * @param contours Path of the polygon
  59330. * @param scene scene to add to when creating the mesh
  59331. * @param earcutInjection can be used to inject your own earcut reference
  59332. */
  59333. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  59334. /**
  59335. * Adds a whole within the polygon
  59336. * @param hole Array of points defining the hole
  59337. * @returns this
  59338. */
  59339. addHole(hole: Vector2[]): PolygonMeshBuilder;
  59340. /**
  59341. * Creates the polygon
  59342. * @param updatable If the mesh should be updatable
  59343. * @param depth The depth of the mesh created
  59344. * @returns the created mesh
  59345. */
  59346. build(updatable?: boolean, depth?: number): Mesh;
  59347. /**
  59348. * Creates the polygon
  59349. * @param depth The depth of the mesh created
  59350. * @returns the created VertexData
  59351. */
  59352. buildVertexData(depth?: number): VertexData;
  59353. /**
  59354. * Adds a side to the polygon
  59355. * @param positions points that make the polygon
  59356. * @param normals normals of the polygon
  59357. * @param uvs uvs of the polygon
  59358. * @param indices indices of the polygon
  59359. * @param bounds bounds of the polygon
  59360. * @param points points of the polygon
  59361. * @param depth depth of the polygon
  59362. * @param flip flip of the polygon
  59363. */
  59364. private addSide;
  59365. }
  59366. }
  59367. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59368. import { Scene } from "babylonjs/scene";
  59369. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59370. import { Color4 } from "babylonjs/Maths/math.color";
  59371. import { Mesh } from "babylonjs/Meshes/mesh";
  59372. import { Nullable } from "babylonjs/types";
  59373. /**
  59374. * Class containing static functions to help procedurally build meshes
  59375. */
  59376. export class PolygonBuilder {
  59377. /**
  59378. * Creates a polygon mesh
  59379. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59380. * * 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
  59381. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59384. * * Remember you can only change the shape positions, not their number when updating a polygon
  59385. * @param name defines the name of the mesh
  59386. * @param options defines the options used to create the mesh
  59387. * @param scene defines the hosting scene
  59388. * @param earcutInjection can be used to inject your own earcut reference
  59389. * @returns the polygon mesh
  59390. */
  59391. static CreatePolygon(name: string, options: {
  59392. shape: Vector3[];
  59393. holes?: Vector3[][];
  59394. depth?: number;
  59395. faceUV?: Vector4[];
  59396. faceColors?: Color4[];
  59397. updatable?: boolean;
  59398. sideOrientation?: number;
  59399. frontUVs?: Vector4;
  59400. backUVs?: Vector4;
  59401. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59402. /**
  59403. * Creates an extruded polygon mesh, with depth in the Y direction.
  59404. * * 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)
  59405. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59406. * @param name defines the name of the mesh
  59407. * @param options defines the options used to create the mesh
  59408. * @param scene defines the hosting scene
  59409. * @param earcutInjection can be used to inject your own earcut reference
  59410. * @returns the polygon mesh
  59411. */
  59412. static ExtrudePolygon(name: string, options: {
  59413. shape: Vector3[];
  59414. holes?: Vector3[][];
  59415. depth?: number;
  59416. faceUV?: Vector4[];
  59417. faceColors?: Color4[];
  59418. updatable?: boolean;
  59419. sideOrientation?: number;
  59420. frontUVs?: Vector4;
  59421. backUVs?: Vector4;
  59422. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59423. }
  59424. }
  59425. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59426. import { Scene } from "babylonjs/scene";
  59427. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59428. import { Mesh } from "babylonjs/Meshes/mesh";
  59429. import { Nullable } from "babylonjs/types";
  59430. /**
  59431. * Class containing static functions to help procedurally build meshes
  59432. */
  59433. export class LatheBuilder {
  59434. /**
  59435. * Creates lathe mesh.
  59436. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59437. * * 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
  59438. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59439. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59440. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59441. * * 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
  59442. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59443. * * 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
  59444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59446. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59448. * @param name defines the name of the mesh
  59449. * @param options defines the options used to create the mesh
  59450. * @param scene defines the hosting scene
  59451. * @returns the lathe mesh
  59452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59453. */
  59454. static CreateLathe(name: string, options: {
  59455. shape: Vector3[];
  59456. radius?: number;
  59457. tessellation?: number;
  59458. clip?: number;
  59459. arc?: number;
  59460. closed?: boolean;
  59461. updatable?: boolean;
  59462. sideOrientation?: number;
  59463. frontUVs?: Vector4;
  59464. backUVs?: Vector4;
  59465. cap?: number;
  59466. invertUV?: boolean;
  59467. }, scene?: Nullable<Scene>): Mesh;
  59468. }
  59469. }
  59470. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59471. import { Nullable } from "babylonjs/types";
  59472. import { Scene } from "babylonjs/scene";
  59473. import { Vector4 } from "babylonjs/Maths/math.vector";
  59474. import { Mesh } from "babylonjs/Meshes/mesh";
  59475. /**
  59476. * Class containing static functions to help procedurally build meshes
  59477. */
  59478. export class TiledPlaneBuilder {
  59479. /**
  59480. * Creates a tiled plane mesh
  59481. * * The parameter `pattern` will, depending on value, do nothing or
  59482. * * * flip (reflect about central vertical) alternate tiles across and up
  59483. * * * flip every tile on alternate rows
  59484. * * * rotate (180 degs) alternate tiles across and up
  59485. * * * rotate every tile on alternate rows
  59486. * * * flip and rotate alternate tiles across and up
  59487. * * * flip and rotate every tile on alternate rows
  59488. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59489. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59491. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59492. * * 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)
  59493. * * 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)
  59494. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59495. * @param name defines the name of the mesh
  59496. * @param options defines the options used to create the mesh
  59497. * @param scene defines the hosting scene
  59498. * @returns the box mesh
  59499. */
  59500. static CreateTiledPlane(name: string, options: {
  59501. pattern?: number;
  59502. tileSize?: number;
  59503. tileWidth?: number;
  59504. tileHeight?: number;
  59505. size?: number;
  59506. width?: number;
  59507. height?: number;
  59508. alignHorizontal?: number;
  59509. alignVertical?: number;
  59510. sideOrientation?: number;
  59511. frontUVs?: Vector4;
  59512. backUVs?: Vector4;
  59513. updatable?: boolean;
  59514. }, scene?: Nullable<Scene>): Mesh;
  59515. }
  59516. }
  59517. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59518. import { Nullable } from "babylonjs/types";
  59519. import { Scene } from "babylonjs/scene";
  59520. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59521. import { Mesh } from "babylonjs/Meshes/mesh";
  59522. /**
  59523. * Class containing static functions to help procedurally build meshes
  59524. */
  59525. export class TubeBuilder {
  59526. /**
  59527. * Creates a tube mesh.
  59528. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59529. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59530. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59531. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59532. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59533. * * 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)
  59534. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59535. * * 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
  59536. * * 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
  59537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59541. * @param name defines the name of the mesh
  59542. * @param options defines the options used to create the mesh
  59543. * @param scene defines the hosting scene
  59544. * @returns the tube mesh
  59545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59546. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59547. */
  59548. static CreateTube(name: string, options: {
  59549. path: Vector3[];
  59550. radius?: number;
  59551. tessellation?: number;
  59552. radiusFunction?: {
  59553. (i: number, distance: number): number;
  59554. };
  59555. cap?: number;
  59556. arc?: number;
  59557. updatable?: boolean;
  59558. sideOrientation?: number;
  59559. frontUVs?: Vector4;
  59560. backUVs?: Vector4;
  59561. instance?: Mesh;
  59562. invertUV?: boolean;
  59563. }, scene?: Nullable<Scene>): Mesh;
  59564. }
  59565. }
  59566. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59567. import { Scene } from "babylonjs/scene";
  59568. import { Vector4 } from "babylonjs/Maths/math.vector";
  59569. import { Mesh } from "babylonjs/Meshes/mesh";
  59570. import { Nullable } from "babylonjs/types";
  59571. /**
  59572. * Class containing static functions to help procedurally build meshes
  59573. */
  59574. export class IcoSphereBuilder {
  59575. /**
  59576. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59577. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59578. * * 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`)
  59579. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59580. * * 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
  59581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59584. * @param name defines the name of the mesh
  59585. * @param options defines the options used to create the mesh
  59586. * @param scene defines the hosting scene
  59587. * @returns the icosahedron mesh
  59588. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59589. */
  59590. static CreateIcoSphere(name: string, options: {
  59591. radius?: number;
  59592. radiusX?: number;
  59593. radiusY?: number;
  59594. radiusZ?: number;
  59595. flat?: boolean;
  59596. subdivisions?: number;
  59597. sideOrientation?: number;
  59598. frontUVs?: Vector4;
  59599. backUVs?: Vector4;
  59600. updatable?: boolean;
  59601. }, scene?: Nullable<Scene>): Mesh;
  59602. }
  59603. }
  59604. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59605. import { Vector3 } from "babylonjs/Maths/math.vector";
  59606. import { Mesh } from "babylonjs/Meshes/mesh";
  59607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59608. /**
  59609. * Class containing static functions to help procedurally build meshes
  59610. */
  59611. export class DecalBuilder {
  59612. /**
  59613. * Creates a decal mesh.
  59614. * 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
  59615. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59616. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59617. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59618. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59619. * @param name defines the name of the mesh
  59620. * @param sourceMesh defines the mesh where the decal must be applied
  59621. * @param options defines the options used to create the mesh
  59622. * @param scene defines the hosting scene
  59623. * @returns the decal mesh
  59624. * @see https://doc.babylonjs.com/how_to/decals
  59625. */
  59626. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59627. position?: Vector3;
  59628. normal?: Vector3;
  59629. size?: Vector3;
  59630. angle?: number;
  59631. }): Mesh;
  59632. }
  59633. }
  59634. declare module "babylonjs/Meshes/meshBuilder" {
  59635. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59636. import { Nullable } from "babylonjs/types";
  59637. import { Scene } from "babylonjs/scene";
  59638. import { Mesh } from "babylonjs/Meshes/mesh";
  59639. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59640. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59642. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59643. import { Plane } from "babylonjs/Maths/math.plane";
  59644. /**
  59645. * Class containing static functions to help procedurally build meshes
  59646. */
  59647. export class MeshBuilder {
  59648. /**
  59649. * Creates a box mesh
  59650. * * The parameter `size` sets the size (float) of each box side (default 1)
  59651. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59652. * * 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)
  59653. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59657. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59658. * @param name defines the name of the mesh
  59659. * @param options defines the options used to create the mesh
  59660. * @param scene defines the hosting scene
  59661. * @returns the box mesh
  59662. */
  59663. static CreateBox(name: string, options: {
  59664. size?: number;
  59665. width?: number;
  59666. height?: number;
  59667. depth?: number;
  59668. faceUV?: Vector4[];
  59669. faceColors?: Color4[];
  59670. sideOrientation?: number;
  59671. frontUVs?: Vector4;
  59672. backUVs?: Vector4;
  59673. updatable?: boolean;
  59674. }, scene?: Nullable<Scene>): Mesh;
  59675. /**
  59676. * Creates a tiled box mesh
  59677. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59679. * @param name defines the name of the mesh
  59680. * @param options defines the options used to create the mesh
  59681. * @param scene defines the hosting scene
  59682. * @returns the tiled box mesh
  59683. */
  59684. static CreateTiledBox(name: string, options: {
  59685. pattern?: number;
  59686. size?: number;
  59687. width?: number;
  59688. height?: number;
  59689. depth: number;
  59690. tileSize?: number;
  59691. tileWidth?: number;
  59692. tileHeight?: number;
  59693. faceUV?: Vector4[];
  59694. faceColors?: Color4[];
  59695. alignHorizontal?: number;
  59696. alignVertical?: number;
  59697. sideOrientation?: number;
  59698. updatable?: boolean;
  59699. }, scene?: Nullable<Scene>): Mesh;
  59700. /**
  59701. * Creates a sphere mesh
  59702. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59703. * * 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`)
  59704. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59705. * * 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
  59706. * * 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)
  59707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59710. * @param name defines the name of the mesh
  59711. * @param options defines the options used to create the mesh
  59712. * @param scene defines the hosting scene
  59713. * @returns the sphere mesh
  59714. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59715. */
  59716. static CreateSphere(name: string, options: {
  59717. segments?: number;
  59718. diameter?: number;
  59719. diameterX?: number;
  59720. diameterY?: number;
  59721. diameterZ?: number;
  59722. arc?: number;
  59723. slice?: number;
  59724. sideOrientation?: number;
  59725. frontUVs?: Vector4;
  59726. backUVs?: Vector4;
  59727. updatable?: boolean;
  59728. }, scene?: Nullable<Scene>): Mesh;
  59729. /**
  59730. * Creates a plane polygonal mesh. By default, this is a disc
  59731. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59732. * * 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
  59733. * * 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
  59734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59737. * @param name defines the name of the mesh
  59738. * @param options defines the options used to create the mesh
  59739. * @param scene defines the hosting scene
  59740. * @returns the plane polygonal mesh
  59741. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59742. */
  59743. static CreateDisc(name: string, options: {
  59744. radius?: number;
  59745. tessellation?: number;
  59746. arc?: number;
  59747. updatable?: boolean;
  59748. sideOrientation?: number;
  59749. frontUVs?: Vector4;
  59750. backUVs?: Vector4;
  59751. }, scene?: Nullable<Scene>): Mesh;
  59752. /**
  59753. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59754. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59755. * * 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`)
  59756. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59757. * * 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
  59758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59759. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59761. * @param name defines the name of the mesh
  59762. * @param options defines the options used to create the mesh
  59763. * @param scene defines the hosting scene
  59764. * @returns the icosahedron mesh
  59765. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59766. */
  59767. static CreateIcoSphere(name: string, options: {
  59768. radius?: number;
  59769. radiusX?: number;
  59770. radiusY?: number;
  59771. radiusZ?: number;
  59772. flat?: boolean;
  59773. subdivisions?: number;
  59774. sideOrientation?: number;
  59775. frontUVs?: Vector4;
  59776. backUVs?: Vector4;
  59777. updatable?: boolean;
  59778. }, scene?: Nullable<Scene>): Mesh;
  59779. /**
  59780. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59781. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59782. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59783. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59784. * * 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
  59785. * * 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
  59786. * * 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
  59787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59789. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59790. * * 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
  59791. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59792. * * 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
  59793. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59795. * @param name defines the name of the mesh
  59796. * @param options defines the options used to create the mesh
  59797. * @param scene defines the hosting scene
  59798. * @returns the ribbon mesh
  59799. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59800. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59801. */
  59802. static CreateRibbon(name: string, options: {
  59803. pathArray: Vector3[][];
  59804. closeArray?: boolean;
  59805. closePath?: boolean;
  59806. offset?: number;
  59807. updatable?: boolean;
  59808. sideOrientation?: number;
  59809. frontUVs?: Vector4;
  59810. backUVs?: Vector4;
  59811. instance?: Mesh;
  59812. invertUV?: boolean;
  59813. uvs?: Vector2[];
  59814. colors?: Color4[];
  59815. }, scene?: Nullable<Scene>): Mesh;
  59816. /**
  59817. * Creates a cylinder or a cone mesh
  59818. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59819. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59820. * * 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.
  59821. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59822. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59823. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59824. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59825. * * 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).
  59826. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59827. * * 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).
  59828. * * 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
  59829. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59830. * * 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
  59831. * * 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.
  59832. * * If `enclose` is false, a ring surface is one element.
  59833. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59834. * * 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
  59835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59838. * @param name defines the name of the mesh
  59839. * @param options defines the options used to create the mesh
  59840. * @param scene defines the hosting scene
  59841. * @returns the cylinder mesh
  59842. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59843. */
  59844. static CreateCylinder(name: string, options: {
  59845. height?: number;
  59846. diameterTop?: number;
  59847. diameterBottom?: number;
  59848. diameter?: number;
  59849. tessellation?: number;
  59850. subdivisions?: number;
  59851. arc?: number;
  59852. faceColors?: Color4[];
  59853. faceUV?: Vector4[];
  59854. updatable?: boolean;
  59855. hasRings?: boolean;
  59856. enclose?: boolean;
  59857. cap?: number;
  59858. sideOrientation?: number;
  59859. frontUVs?: Vector4;
  59860. backUVs?: Vector4;
  59861. }, scene?: Nullable<Scene>): Mesh;
  59862. /**
  59863. * Creates a torus mesh
  59864. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59865. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59866. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59870. * @param name defines the name of the mesh
  59871. * @param options defines the options used to create the mesh
  59872. * @param scene defines the hosting scene
  59873. * @returns the torus mesh
  59874. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59875. */
  59876. static CreateTorus(name: string, options: {
  59877. diameter?: number;
  59878. thickness?: number;
  59879. tessellation?: number;
  59880. updatable?: boolean;
  59881. sideOrientation?: number;
  59882. frontUVs?: Vector4;
  59883. backUVs?: Vector4;
  59884. }, scene?: Nullable<Scene>): Mesh;
  59885. /**
  59886. * Creates a torus knot mesh
  59887. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59888. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59889. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59890. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59894. * @param name defines the name of the mesh
  59895. * @param options defines the options used to create the mesh
  59896. * @param scene defines the hosting scene
  59897. * @returns the torus knot mesh
  59898. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59899. */
  59900. static CreateTorusKnot(name: string, options: {
  59901. radius?: number;
  59902. tube?: number;
  59903. radialSegments?: number;
  59904. tubularSegments?: number;
  59905. p?: number;
  59906. q?: number;
  59907. updatable?: boolean;
  59908. sideOrientation?: number;
  59909. frontUVs?: Vector4;
  59910. backUVs?: Vector4;
  59911. }, scene?: Nullable<Scene>): Mesh;
  59912. /**
  59913. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59914. * * 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
  59915. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59916. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59917. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59918. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59919. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59920. * * 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
  59921. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59924. * @param name defines the name of the new line system
  59925. * @param options defines the options used to create the line system
  59926. * @param scene defines the hosting scene
  59927. * @returns a new line system mesh
  59928. */
  59929. static CreateLineSystem(name: string, options: {
  59930. lines: Vector3[][];
  59931. updatable?: boolean;
  59932. instance?: Nullable<LinesMesh>;
  59933. colors?: Nullable<Color4[][]>;
  59934. useVertexAlpha?: boolean;
  59935. }, scene: Nullable<Scene>): LinesMesh;
  59936. /**
  59937. * Creates a line mesh
  59938. * 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
  59939. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59940. * * The parameter `points` is an array successive Vector3
  59941. * * 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
  59942. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59943. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59944. * * When updating an instance, remember that only point positions can change, not the number of points
  59945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59947. * @param name defines the name of the new line system
  59948. * @param options defines the options used to create the line system
  59949. * @param scene defines the hosting scene
  59950. * @returns a new line mesh
  59951. */
  59952. static CreateLines(name: string, options: {
  59953. points: Vector3[];
  59954. updatable?: boolean;
  59955. instance?: Nullable<LinesMesh>;
  59956. colors?: Color4[];
  59957. useVertexAlpha?: boolean;
  59958. }, scene?: Nullable<Scene>): LinesMesh;
  59959. /**
  59960. * Creates a dashed line mesh
  59961. * * 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
  59962. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59963. * * The parameter `points` is an array successive Vector3
  59964. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59965. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59966. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59967. * * 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
  59968. * * When updating an instance, remember that only point positions can change, not the number of points
  59969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59970. * @param name defines the name of the mesh
  59971. * @param options defines the options used to create the mesh
  59972. * @param scene defines the hosting scene
  59973. * @returns the dashed line mesh
  59974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59975. */
  59976. static CreateDashedLines(name: string, options: {
  59977. points: Vector3[];
  59978. dashSize?: number;
  59979. gapSize?: number;
  59980. dashNb?: number;
  59981. updatable?: boolean;
  59982. instance?: LinesMesh;
  59983. }, scene?: Nullable<Scene>): LinesMesh;
  59984. /**
  59985. * 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.
  59986. * * 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.
  59987. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59988. * * 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.
  59989. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59990. * * 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
  59991. * * 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
  59992. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59997. * @param name defines the name of the mesh
  59998. * @param options defines the options used to create the mesh
  59999. * @param scene defines the hosting scene
  60000. * @returns the extruded shape mesh
  60001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60003. */
  60004. static ExtrudeShape(name: string, options: {
  60005. shape: Vector3[];
  60006. path: Vector3[];
  60007. scale?: number;
  60008. rotation?: number;
  60009. cap?: number;
  60010. updatable?: boolean;
  60011. sideOrientation?: number;
  60012. frontUVs?: Vector4;
  60013. backUVs?: Vector4;
  60014. instance?: Mesh;
  60015. invertUV?: boolean;
  60016. }, scene?: Nullable<Scene>): Mesh;
  60017. /**
  60018. * Creates an custom extruded shape mesh.
  60019. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60020. * * 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.
  60021. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60022. * * 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
  60023. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60024. * * 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
  60025. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60026. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60027. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60028. * * 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
  60029. * * 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
  60030. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60033. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60035. * @param name defines the name of the mesh
  60036. * @param options defines the options used to create the mesh
  60037. * @param scene defines the hosting scene
  60038. * @returns the custom extruded shape mesh
  60039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60040. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60042. */
  60043. static ExtrudeShapeCustom(name: string, options: {
  60044. shape: Vector3[];
  60045. path: Vector3[];
  60046. scaleFunction?: any;
  60047. rotationFunction?: any;
  60048. ribbonCloseArray?: boolean;
  60049. ribbonClosePath?: boolean;
  60050. cap?: number;
  60051. updatable?: boolean;
  60052. sideOrientation?: number;
  60053. frontUVs?: Vector4;
  60054. backUVs?: Vector4;
  60055. instance?: Mesh;
  60056. invertUV?: boolean;
  60057. }, scene?: Nullable<Scene>): Mesh;
  60058. /**
  60059. * Creates lathe mesh.
  60060. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60061. * * 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
  60062. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60063. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60064. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60065. * * 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
  60066. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60067. * * 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
  60068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60072. * @param name defines the name of the mesh
  60073. * @param options defines the options used to create the mesh
  60074. * @param scene defines the hosting scene
  60075. * @returns the lathe mesh
  60076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60077. */
  60078. static CreateLathe(name: string, options: {
  60079. shape: Vector3[];
  60080. radius?: number;
  60081. tessellation?: number;
  60082. clip?: number;
  60083. arc?: number;
  60084. closed?: boolean;
  60085. updatable?: boolean;
  60086. sideOrientation?: number;
  60087. frontUVs?: Vector4;
  60088. backUVs?: Vector4;
  60089. cap?: number;
  60090. invertUV?: boolean;
  60091. }, scene?: Nullable<Scene>): Mesh;
  60092. /**
  60093. * Creates a tiled plane mesh
  60094. * * You can set a limited pattern arrangement with the tiles
  60095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60098. * @param name defines the name of the mesh
  60099. * @param options defines the options used to create the mesh
  60100. * @param scene defines the hosting scene
  60101. * @returns the plane mesh
  60102. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60103. */
  60104. static CreateTiledPlane(name: string, options: {
  60105. pattern?: number;
  60106. tileSize?: number;
  60107. tileWidth?: number;
  60108. tileHeight?: number;
  60109. size?: number;
  60110. width?: number;
  60111. height?: number;
  60112. alignHorizontal?: number;
  60113. alignVertical?: number;
  60114. sideOrientation?: number;
  60115. frontUVs?: Vector4;
  60116. backUVs?: Vector4;
  60117. updatable?: boolean;
  60118. }, scene?: Nullable<Scene>): Mesh;
  60119. /**
  60120. * Creates a plane mesh
  60121. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60122. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60123. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60127. * @param name defines the name of the mesh
  60128. * @param options defines the options used to create the mesh
  60129. * @param scene defines the hosting scene
  60130. * @returns the plane mesh
  60131. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60132. */
  60133. static CreatePlane(name: string, options: {
  60134. size?: number;
  60135. width?: number;
  60136. height?: number;
  60137. sideOrientation?: number;
  60138. frontUVs?: Vector4;
  60139. backUVs?: Vector4;
  60140. updatable?: boolean;
  60141. sourcePlane?: Plane;
  60142. }, scene?: Nullable<Scene>): Mesh;
  60143. /**
  60144. * Creates a ground mesh
  60145. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60146. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60148. * @param name defines the name of the mesh
  60149. * @param options defines the options used to create the mesh
  60150. * @param scene defines the hosting scene
  60151. * @returns the ground mesh
  60152. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60153. */
  60154. static CreateGround(name: string, options: {
  60155. width?: number;
  60156. height?: number;
  60157. subdivisions?: number;
  60158. subdivisionsX?: number;
  60159. subdivisionsY?: number;
  60160. updatable?: boolean;
  60161. }, scene?: Nullable<Scene>): Mesh;
  60162. /**
  60163. * Creates a tiled ground mesh
  60164. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60165. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60166. * * 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
  60167. * * 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
  60168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60169. * @param name defines the name of the mesh
  60170. * @param options defines the options used to create the mesh
  60171. * @param scene defines the hosting scene
  60172. * @returns the tiled ground mesh
  60173. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60174. */
  60175. static CreateTiledGround(name: string, options: {
  60176. xmin: number;
  60177. zmin: number;
  60178. xmax: number;
  60179. zmax: number;
  60180. subdivisions?: {
  60181. w: number;
  60182. h: number;
  60183. };
  60184. precision?: {
  60185. w: number;
  60186. h: number;
  60187. };
  60188. updatable?: boolean;
  60189. }, scene?: Nullable<Scene>): Mesh;
  60190. /**
  60191. * Creates a ground mesh from a height map
  60192. * * The parameter `url` sets the URL of the height map image resource.
  60193. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60194. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60195. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60196. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60197. * * 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.
  60198. * * 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).
  60199. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60201. * @param name defines the name of the mesh
  60202. * @param url defines the url to the height map
  60203. * @param options defines the options used to create the mesh
  60204. * @param scene defines the hosting scene
  60205. * @returns the ground mesh
  60206. * @see https://doc.babylonjs.com/babylon101/height_map
  60207. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60208. */
  60209. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60210. width?: number;
  60211. height?: number;
  60212. subdivisions?: number;
  60213. minHeight?: number;
  60214. maxHeight?: number;
  60215. colorFilter?: Color3;
  60216. alphaFilter?: number;
  60217. updatable?: boolean;
  60218. onReady?: (mesh: GroundMesh) => void;
  60219. }, scene?: Nullable<Scene>): GroundMesh;
  60220. /**
  60221. * Creates a polygon mesh
  60222. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60223. * * 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
  60224. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60227. * * Remember you can only change the shape positions, not their number when updating a polygon
  60228. * @param name defines the name of the mesh
  60229. * @param options defines the options used to create the mesh
  60230. * @param scene defines the hosting scene
  60231. * @param earcutInjection can be used to inject your own earcut reference
  60232. * @returns the polygon mesh
  60233. */
  60234. static CreatePolygon(name: string, options: {
  60235. shape: Vector3[];
  60236. holes?: Vector3[][];
  60237. depth?: number;
  60238. faceUV?: Vector4[];
  60239. faceColors?: Color4[];
  60240. updatable?: boolean;
  60241. sideOrientation?: number;
  60242. frontUVs?: Vector4;
  60243. backUVs?: Vector4;
  60244. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60245. /**
  60246. * Creates an extruded polygon mesh, with depth in the Y direction.
  60247. * * 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)
  60248. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60249. * @param name defines the name of the mesh
  60250. * @param options defines the options used to create the mesh
  60251. * @param scene defines the hosting scene
  60252. * @param earcutInjection can be used to inject your own earcut reference
  60253. * @returns the polygon mesh
  60254. */
  60255. static ExtrudePolygon(name: string, options: {
  60256. shape: Vector3[];
  60257. holes?: Vector3[][];
  60258. depth?: number;
  60259. faceUV?: Vector4[];
  60260. faceColors?: Color4[];
  60261. updatable?: boolean;
  60262. sideOrientation?: number;
  60263. frontUVs?: Vector4;
  60264. backUVs?: Vector4;
  60265. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60266. /**
  60267. * Creates a tube mesh.
  60268. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60269. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60270. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60271. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60272. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60273. * * 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)
  60274. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60275. * * 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
  60276. * * 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
  60277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60279. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60281. * @param name defines the name of the mesh
  60282. * @param options defines the options used to create the mesh
  60283. * @param scene defines the hosting scene
  60284. * @returns the tube mesh
  60285. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60286. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60287. */
  60288. static CreateTube(name: string, options: {
  60289. path: Vector3[];
  60290. radius?: number;
  60291. tessellation?: number;
  60292. radiusFunction?: {
  60293. (i: number, distance: number): number;
  60294. };
  60295. cap?: number;
  60296. arc?: number;
  60297. updatable?: boolean;
  60298. sideOrientation?: number;
  60299. frontUVs?: Vector4;
  60300. backUVs?: Vector4;
  60301. instance?: Mesh;
  60302. invertUV?: boolean;
  60303. }, scene?: Nullable<Scene>): Mesh;
  60304. /**
  60305. * Creates a polyhedron mesh
  60306. * * 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
  60307. * * The parameter `size` (positive float, default 1) sets the polygon size
  60308. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  60309. * * 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`
  60310. * * 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
  60311. * * 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)`)
  60312. * * 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
  60313. * * 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
  60314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60317. * @param name defines the name of the mesh
  60318. * @param options defines the options used to create the mesh
  60319. * @param scene defines the hosting scene
  60320. * @returns the polyhedron mesh
  60321. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  60322. */
  60323. static CreatePolyhedron(name: string, options: {
  60324. type?: number;
  60325. size?: number;
  60326. sizeX?: number;
  60327. sizeY?: number;
  60328. sizeZ?: number;
  60329. custom?: any;
  60330. faceUV?: Vector4[];
  60331. faceColors?: Color4[];
  60332. flat?: boolean;
  60333. updatable?: boolean;
  60334. sideOrientation?: number;
  60335. frontUVs?: Vector4;
  60336. backUVs?: Vector4;
  60337. }, scene?: Nullable<Scene>): Mesh;
  60338. /**
  60339. * Creates a decal mesh.
  60340. * 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
  60341. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60342. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60343. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60344. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60345. * @param name defines the name of the mesh
  60346. * @param sourceMesh defines the mesh where the decal must be applied
  60347. * @param options defines the options used to create the mesh
  60348. * @param scene defines the hosting scene
  60349. * @returns the decal mesh
  60350. * @see https://doc.babylonjs.com/how_to/decals
  60351. */
  60352. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60353. position?: Vector3;
  60354. normal?: Vector3;
  60355. size?: Vector3;
  60356. angle?: number;
  60357. }): Mesh;
  60358. }
  60359. }
  60360. declare module "babylonjs/Meshes/meshSimplification" {
  60361. import { Mesh } from "babylonjs/Meshes/mesh";
  60362. /**
  60363. * A simplifier interface for future simplification implementations
  60364. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60365. */
  60366. export interface ISimplifier {
  60367. /**
  60368. * Simplification of a given mesh according to the given settings.
  60369. * Since this requires computation, it is assumed that the function runs async.
  60370. * @param settings The settings of the simplification, including quality and distance
  60371. * @param successCallback A callback that will be called after the mesh was simplified.
  60372. * @param errorCallback in case of an error, this callback will be called. optional.
  60373. */
  60374. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60375. }
  60376. /**
  60377. * Expected simplification settings.
  60378. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60379. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60380. */
  60381. export interface ISimplificationSettings {
  60382. /**
  60383. * Gets or sets the expected quality
  60384. */
  60385. quality: number;
  60386. /**
  60387. * Gets or sets the distance when this optimized version should be used
  60388. */
  60389. distance: number;
  60390. /**
  60391. * Gets an already optimized mesh
  60392. */
  60393. optimizeMesh?: boolean;
  60394. }
  60395. /**
  60396. * Class used to specify simplification options
  60397. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60398. */
  60399. export class SimplificationSettings implements ISimplificationSettings {
  60400. /** expected quality */
  60401. quality: number;
  60402. /** distance when this optimized version should be used */
  60403. distance: number;
  60404. /** already optimized mesh */
  60405. optimizeMesh?: boolean | undefined;
  60406. /**
  60407. * Creates a SimplificationSettings
  60408. * @param quality expected quality
  60409. * @param distance distance when this optimized version should be used
  60410. * @param optimizeMesh already optimized mesh
  60411. */
  60412. constructor(
  60413. /** expected quality */
  60414. quality: number,
  60415. /** distance when this optimized version should be used */
  60416. distance: number,
  60417. /** already optimized mesh */
  60418. optimizeMesh?: boolean | undefined);
  60419. }
  60420. /**
  60421. * Interface used to define a simplification task
  60422. */
  60423. export interface ISimplificationTask {
  60424. /**
  60425. * Array of settings
  60426. */
  60427. settings: Array<ISimplificationSettings>;
  60428. /**
  60429. * Simplification type
  60430. */
  60431. simplificationType: SimplificationType;
  60432. /**
  60433. * Mesh to simplify
  60434. */
  60435. mesh: Mesh;
  60436. /**
  60437. * Callback called on success
  60438. */
  60439. successCallback?: () => void;
  60440. /**
  60441. * Defines if parallel processing can be used
  60442. */
  60443. parallelProcessing: boolean;
  60444. }
  60445. /**
  60446. * Queue used to order the simplification tasks
  60447. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60448. */
  60449. export class SimplificationQueue {
  60450. private _simplificationArray;
  60451. /**
  60452. * Gets a boolean indicating that the process is still running
  60453. */
  60454. running: boolean;
  60455. /**
  60456. * Creates a new queue
  60457. */
  60458. constructor();
  60459. /**
  60460. * Adds a new simplification task
  60461. * @param task defines a task to add
  60462. */
  60463. addTask(task: ISimplificationTask): void;
  60464. /**
  60465. * Execute next task
  60466. */
  60467. executeNext(): void;
  60468. /**
  60469. * Execute a simplification task
  60470. * @param task defines the task to run
  60471. */
  60472. runSimplification(task: ISimplificationTask): void;
  60473. private getSimplifier;
  60474. }
  60475. /**
  60476. * The implemented types of simplification
  60477. * At the moment only Quadratic Error Decimation is implemented
  60478. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60479. */
  60480. export enum SimplificationType {
  60481. /** Quadratic error decimation */
  60482. QUADRATIC = 0
  60483. }
  60484. }
  60485. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60486. import { Scene } from "babylonjs/scene";
  60487. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60488. import { ISceneComponent } from "babylonjs/sceneComponent";
  60489. module "babylonjs/scene" {
  60490. interface Scene {
  60491. /** @hidden (Backing field) */
  60492. _simplificationQueue: SimplificationQueue;
  60493. /**
  60494. * Gets or sets the simplification queue attached to the scene
  60495. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60496. */
  60497. simplificationQueue: SimplificationQueue;
  60498. }
  60499. }
  60500. module "babylonjs/Meshes/mesh" {
  60501. interface Mesh {
  60502. /**
  60503. * Simplify the mesh according to the given array of settings.
  60504. * Function will return immediately and will simplify async
  60505. * @param settings a collection of simplification settings
  60506. * @param parallelProcessing should all levels calculate parallel or one after the other
  60507. * @param simplificationType the type of simplification to run
  60508. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60509. * @returns the current mesh
  60510. */
  60511. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60512. }
  60513. }
  60514. /**
  60515. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60516. * created in a scene
  60517. */
  60518. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60519. /**
  60520. * The component name helpfull to identify the component in the list of scene components.
  60521. */
  60522. readonly name: string;
  60523. /**
  60524. * The scene the component belongs to.
  60525. */
  60526. scene: Scene;
  60527. /**
  60528. * Creates a new instance of the component for the given scene
  60529. * @param scene Defines the scene to register the component in
  60530. */
  60531. constructor(scene: Scene);
  60532. /**
  60533. * Registers the component in a given scene
  60534. */
  60535. register(): void;
  60536. /**
  60537. * Rebuilds the elements related to this component in case of
  60538. * context lost for instance.
  60539. */
  60540. rebuild(): void;
  60541. /**
  60542. * Disposes the component and the associated ressources
  60543. */
  60544. dispose(): void;
  60545. private _beforeCameraUpdate;
  60546. }
  60547. }
  60548. declare module "babylonjs/Meshes/Builders/index" {
  60549. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60550. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60551. export * from "babylonjs/Meshes/Builders/discBuilder";
  60552. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60553. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60554. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60555. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60556. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60557. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60558. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60559. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60560. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60561. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60562. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60563. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60564. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60565. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60566. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60567. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60568. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60569. }
  60570. declare module "babylonjs/Meshes/index" {
  60571. export * from "babylonjs/Meshes/abstractMesh";
  60572. export * from "babylonjs/Meshes/buffer";
  60573. export * from "babylonjs/Meshes/Compression/index";
  60574. export * from "babylonjs/Meshes/csg";
  60575. export * from "babylonjs/Meshes/geometry";
  60576. export * from "babylonjs/Meshes/groundMesh";
  60577. export * from "babylonjs/Meshes/trailMesh";
  60578. export * from "babylonjs/Meshes/instancedMesh";
  60579. export * from "babylonjs/Meshes/linesMesh";
  60580. export * from "babylonjs/Meshes/mesh";
  60581. export * from "babylonjs/Meshes/mesh.vertexData";
  60582. export * from "babylonjs/Meshes/meshBuilder";
  60583. export * from "babylonjs/Meshes/meshSimplification";
  60584. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60585. export * from "babylonjs/Meshes/polygonMesh";
  60586. export * from "babylonjs/Meshes/subMesh";
  60587. export * from "babylonjs/Meshes/meshLODLevel";
  60588. export * from "babylonjs/Meshes/transformNode";
  60589. export * from "babylonjs/Meshes/Builders/index";
  60590. export * from "babylonjs/Meshes/dataBuffer";
  60591. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60592. }
  60593. declare module "babylonjs/Morph/index" {
  60594. export * from "babylonjs/Morph/morphTarget";
  60595. export * from "babylonjs/Morph/morphTargetManager";
  60596. }
  60597. declare module "babylonjs/Navigation/INavigationEngine" {
  60598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60599. import { Vector3 } from "babylonjs/Maths/math";
  60600. import { Mesh } from "babylonjs/Meshes/mesh";
  60601. import { Scene } from "babylonjs/scene";
  60602. /**
  60603. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60604. */
  60605. export interface INavigationEnginePlugin {
  60606. /**
  60607. * plugin name
  60608. */
  60609. name: string;
  60610. /**
  60611. * Creates a navigation mesh
  60612. * @param meshes array of all the geometry used to compute the navigatio mesh
  60613. * @param parameters bunch of parameters used to filter geometry
  60614. */
  60615. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60616. /**
  60617. * Create a navigation mesh debug mesh
  60618. * @param scene is where the mesh will be added
  60619. * @returns debug display mesh
  60620. */
  60621. createDebugNavMesh(scene: Scene): Mesh;
  60622. /**
  60623. * Get a navigation mesh constrained position, closest to the parameter position
  60624. * @param position world position
  60625. * @returns the closest point to position constrained by the navigation mesh
  60626. */
  60627. getClosestPoint(position: Vector3): Vector3;
  60628. /**
  60629. * Get a navigation mesh constrained position, within a particular radius
  60630. * @param position world position
  60631. * @param maxRadius the maximum distance to the constrained world position
  60632. * @returns the closest point to position constrained by the navigation mesh
  60633. */
  60634. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60635. /**
  60636. * Compute the final position from a segment made of destination-position
  60637. * @param position world position
  60638. * @param destination world position
  60639. * @returns the resulting point along the navmesh
  60640. */
  60641. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60642. /**
  60643. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60644. * @param start world position
  60645. * @param end world position
  60646. * @returns array containing world position composing the path
  60647. */
  60648. computePath(start: Vector3, end: Vector3): Vector3[];
  60649. /**
  60650. * If this plugin is supported
  60651. * @returns true if plugin is supported
  60652. */
  60653. isSupported(): boolean;
  60654. /**
  60655. * Create a new Crowd so you can add agents
  60656. * @param maxAgents the maximum agent count in the crowd
  60657. * @param maxAgentRadius the maximum radius an agent can have
  60658. * @param scene to attach the crowd to
  60659. * @returns the crowd you can add agents to
  60660. */
  60661. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60662. /**
  60663. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60664. * The queries will try to find a solution within those bounds
  60665. * default is (1,1,1)
  60666. * @param extent x,y,z value that define the extent around the queries point of reference
  60667. */
  60668. setDefaultQueryExtent(extent: Vector3): void;
  60669. /**
  60670. * Get the Bounding box extent specified by setDefaultQueryExtent
  60671. * @returns the box extent values
  60672. */
  60673. getDefaultQueryExtent(): Vector3;
  60674. /**
  60675. * Release all resources
  60676. */
  60677. dispose(): void;
  60678. }
  60679. /**
  60680. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60681. */
  60682. export interface ICrowd {
  60683. /**
  60684. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60685. * You can attach anything to that node. The node position is updated in the scene update tick.
  60686. * @param pos world position that will be constrained by the navigation mesh
  60687. * @param parameters agent parameters
  60688. * @param transform hooked to the agent that will be update by the scene
  60689. * @returns agent index
  60690. */
  60691. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60692. /**
  60693. * Returns the agent position in world space
  60694. * @param index agent index returned by addAgent
  60695. * @returns world space position
  60696. */
  60697. getAgentPosition(index: number): Vector3;
  60698. /**
  60699. * Gets the agent velocity in world space
  60700. * @param index agent index returned by addAgent
  60701. * @returns world space velocity
  60702. */
  60703. getAgentVelocity(index: number): Vector3;
  60704. /**
  60705. * remove a particular agent previously created
  60706. * @param index agent index returned by addAgent
  60707. */
  60708. removeAgent(index: number): void;
  60709. /**
  60710. * get the list of all agents attached to this crowd
  60711. * @returns list of agent indices
  60712. */
  60713. getAgents(): number[];
  60714. /**
  60715. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60716. * @param deltaTime in seconds
  60717. */
  60718. update(deltaTime: number): void;
  60719. /**
  60720. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60721. * @param index agent index returned by addAgent
  60722. * @param destination targeted world position
  60723. */
  60724. agentGoto(index: number, destination: Vector3): void;
  60725. /**
  60726. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60727. * The queries will try to find a solution within those bounds
  60728. * default is (1,1,1)
  60729. * @param extent x,y,z value that define the extent around the queries point of reference
  60730. */
  60731. setDefaultQueryExtent(extent: Vector3): void;
  60732. /**
  60733. * Get the Bounding box extent specified by setDefaultQueryExtent
  60734. * @returns the box extent values
  60735. */
  60736. getDefaultQueryExtent(): Vector3;
  60737. /**
  60738. * Release all resources
  60739. */
  60740. dispose(): void;
  60741. }
  60742. /**
  60743. * Configures an agent
  60744. */
  60745. export interface IAgentParameters {
  60746. /**
  60747. * Agent radius. [Limit: >= 0]
  60748. */
  60749. radius: number;
  60750. /**
  60751. * Agent height. [Limit: > 0]
  60752. */
  60753. height: number;
  60754. /**
  60755. * Maximum allowed acceleration. [Limit: >= 0]
  60756. */
  60757. maxAcceleration: number;
  60758. /**
  60759. * Maximum allowed speed. [Limit: >= 0]
  60760. */
  60761. maxSpeed: number;
  60762. /**
  60763. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60764. */
  60765. collisionQueryRange: number;
  60766. /**
  60767. * The path visibility optimization range. [Limit: > 0]
  60768. */
  60769. pathOptimizationRange: number;
  60770. /**
  60771. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60772. */
  60773. separationWeight: number;
  60774. }
  60775. /**
  60776. * Configures the navigation mesh creation
  60777. */
  60778. export interface INavMeshParameters {
  60779. /**
  60780. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60781. */
  60782. cs: number;
  60783. /**
  60784. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60785. */
  60786. ch: number;
  60787. /**
  60788. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60789. */
  60790. walkableSlopeAngle: number;
  60791. /**
  60792. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60793. * be considered walkable. [Limit: >= 3] [Units: vx]
  60794. */
  60795. walkableHeight: number;
  60796. /**
  60797. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60798. */
  60799. walkableClimb: number;
  60800. /**
  60801. * The distance to erode/shrink the walkable area of the heightfield away from
  60802. * obstructions. [Limit: >=0] [Units: vx]
  60803. */
  60804. walkableRadius: number;
  60805. /**
  60806. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60807. */
  60808. maxEdgeLen: number;
  60809. /**
  60810. * The maximum distance a simplfied contour's border edges should deviate
  60811. * the original raw contour. [Limit: >=0] [Units: vx]
  60812. */
  60813. maxSimplificationError: number;
  60814. /**
  60815. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60816. */
  60817. minRegionArea: number;
  60818. /**
  60819. * Any regions with a span count smaller than this value will, if possible,
  60820. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60821. */
  60822. mergeRegionArea: number;
  60823. /**
  60824. * The maximum number of vertices allowed for polygons generated during the
  60825. * contour to polygon conversion process. [Limit: >= 3]
  60826. */
  60827. maxVertsPerPoly: number;
  60828. /**
  60829. * Sets the sampling distance to use when generating the detail mesh.
  60830. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60831. */
  60832. detailSampleDist: number;
  60833. /**
  60834. * The maximum distance the detail mesh surface should deviate from heightfield
  60835. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60836. */
  60837. detailSampleMaxError: number;
  60838. }
  60839. }
  60840. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60841. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60842. import { Mesh } from "babylonjs/Meshes/mesh";
  60843. import { Scene } from "babylonjs/scene";
  60844. import { Vector3 } from "babylonjs/Maths/math";
  60845. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60846. /**
  60847. * RecastJS navigation plugin
  60848. */
  60849. export class RecastJSPlugin implements INavigationEnginePlugin {
  60850. /**
  60851. * Reference to the Recast library
  60852. */
  60853. bjsRECAST: any;
  60854. /**
  60855. * plugin name
  60856. */
  60857. name: string;
  60858. /**
  60859. * the first navmesh created. We might extend this to support multiple navmeshes
  60860. */
  60861. navMesh: any;
  60862. /**
  60863. * Initializes the recastJS plugin
  60864. * @param recastInjection can be used to inject your own recast reference
  60865. */
  60866. constructor(recastInjection?: any);
  60867. /**
  60868. * Creates a navigation mesh
  60869. * @param meshes array of all the geometry used to compute the navigatio mesh
  60870. * @param parameters bunch of parameters used to filter geometry
  60871. */
  60872. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60873. /**
  60874. * Create a navigation mesh debug mesh
  60875. * @param scene is where the mesh will be added
  60876. * @returns debug display mesh
  60877. */
  60878. createDebugNavMesh(scene: Scene): Mesh;
  60879. /**
  60880. * Get a navigation mesh constrained position, closest to the parameter position
  60881. * @param position world position
  60882. * @returns the closest point to position constrained by the navigation mesh
  60883. */
  60884. getClosestPoint(position: Vector3): Vector3;
  60885. /**
  60886. * Get a navigation mesh constrained position, within a particular radius
  60887. * @param position world position
  60888. * @param maxRadius the maximum distance to the constrained world position
  60889. * @returns the closest point to position constrained by the navigation mesh
  60890. */
  60891. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60892. /**
  60893. * Compute the final position from a segment made of destination-position
  60894. * @param position world position
  60895. * @param destination world position
  60896. * @returns the resulting point along the navmesh
  60897. */
  60898. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60899. /**
  60900. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60901. * @param start world position
  60902. * @param end world position
  60903. * @returns array containing world position composing the path
  60904. */
  60905. computePath(start: Vector3, end: Vector3): Vector3[];
  60906. /**
  60907. * Create a new Crowd so you can add agents
  60908. * @param maxAgents the maximum agent count in the crowd
  60909. * @param maxAgentRadius the maximum radius an agent can have
  60910. * @param scene to attach the crowd to
  60911. * @returns the crowd you can add agents to
  60912. */
  60913. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60914. /**
  60915. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60916. * The queries will try to find a solution within those bounds
  60917. * default is (1,1,1)
  60918. * @param extent x,y,z value that define the extent around the queries point of reference
  60919. */
  60920. setDefaultQueryExtent(extent: Vector3): void;
  60921. /**
  60922. * Get the Bounding box extent specified by setDefaultQueryExtent
  60923. * @returns the box extent values
  60924. */
  60925. getDefaultQueryExtent(): Vector3;
  60926. /**
  60927. * Disposes
  60928. */
  60929. dispose(): void;
  60930. /**
  60931. * If this plugin is supported
  60932. * @returns true if plugin is supported
  60933. */
  60934. isSupported(): boolean;
  60935. }
  60936. /**
  60937. * Recast detour crowd implementation
  60938. */
  60939. export class RecastJSCrowd implements ICrowd {
  60940. /**
  60941. * Recast/detour plugin
  60942. */
  60943. bjsRECASTPlugin: RecastJSPlugin;
  60944. /**
  60945. * Link to the detour crowd
  60946. */
  60947. recastCrowd: any;
  60948. /**
  60949. * One transform per agent
  60950. */
  60951. transforms: TransformNode[];
  60952. /**
  60953. * All agents created
  60954. */
  60955. agents: number[];
  60956. /**
  60957. * Link to the scene is kept to unregister the crowd from the scene
  60958. */
  60959. private _scene;
  60960. /**
  60961. * Observer for crowd updates
  60962. */
  60963. private _onBeforeAnimationsObserver;
  60964. /**
  60965. * Constructor
  60966. * @param plugin recastJS plugin
  60967. * @param maxAgents the maximum agent count in the crowd
  60968. * @param maxAgentRadius the maximum radius an agent can have
  60969. * @param scene to attach the crowd to
  60970. * @returns the crowd you can add agents to
  60971. */
  60972. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60973. /**
  60974. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60975. * You can attach anything to that node. The node position is updated in the scene update tick.
  60976. * @param pos world position that will be constrained by the navigation mesh
  60977. * @param parameters agent parameters
  60978. * @param transform hooked to the agent that will be update by the scene
  60979. * @returns agent index
  60980. */
  60981. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60982. /**
  60983. * Returns the agent position in world space
  60984. * @param index agent index returned by addAgent
  60985. * @returns world space position
  60986. */
  60987. getAgentPosition(index: number): Vector3;
  60988. /**
  60989. * Returns the agent velocity in world space
  60990. * @param index agent index returned by addAgent
  60991. * @returns world space velocity
  60992. */
  60993. getAgentVelocity(index: number): Vector3;
  60994. /**
  60995. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60996. * @param index agent index returned by addAgent
  60997. * @param destination targeted world position
  60998. */
  60999. agentGoto(index: number, destination: Vector3): void;
  61000. /**
  61001. * remove a particular agent previously created
  61002. * @param index agent index returned by addAgent
  61003. */
  61004. removeAgent(index: number): void;
  61005. /**
  61006. * get the list of all agents attached to this crowd
  61007. * @returns list of agent indices
  61008. */
  61009. getAgents(): number[];
  61010. /**
  61011. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61012. * @param deltaTime in seconds
  61013. */
  61014. update(deltaTime: number): void;
  61015. /**
  61016. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61017. * The queries will try to find a solution within those bounds
  61018. * default is (1,1,1)
  61019. * @param extent x,y,z value that define the extent around the queries point of reference
  61020. */
  61021. setDefaultQueryExtent(extent: Vector3): void;
  61022. /**
  61023. * Get the Bounding box extent specified by setDefaultQueryExtent
  61024. * @returns the box extent values
  61025. */
  61026. getDefaultQueryExtent(): Vector3;
  61027. /**
  61028. * Release all resources
  61029. */
  61030. dispose(): void;
  61031. }
  61032. }
  61033. declare module "babylonjs/Navigation/Plugins/index" {
  61034. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61035. }
  61036. declare module "babylonjs/Navigation/index" {
  61037. export * from "babylonjs/Navigation/INavigationEngine";
  61038. export * from "babylonjs/Navigation/Plugins/index";
  61039. }
  61040. declare module "babylonjs/Offline/database" {
  61041. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61042. /**
  61043. * Class used to enable access to IndexedDB
  61044. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61045. */
  61046. export class Database implements IOfflineProvider {
  61047. private _callbackManifestChecked;
  61048. private _currentSceneUrl;
  61049. private _db;
  61050. private _enableSceneOffline;
  61051. private _enableTexturesOffline;
  61052. private _manifestVersionFound;
  61053. private _mustUpdateRessources;
  61054. private _hasReachedQuota;
  61055. private _isSupported;
  61056. private _idbFactory;
  61057. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61058. private static IsUASupportingBlobStorage;
  61059. /**
  61060. * Gets a boolean indicating if Database storate is enabled (off by default)
  61061. */
  61062. static IDBStorageEnabled: boolean;
  61063. /**
  61064. * Gets a boolean indicating if scene must be saved in the database
  61065. */
  61066. readonly enableSceneOffline: boolean;
  61067. /**
  61068. * Gets a boolean indicating if textures must be saved in the database
  61069. */
  61070. readonly enableTexturesOffline: boolean;
  61071. /**
  61072. * Creates a new Database
  61073. * @param urlToScene defines the url to load the scene
  61074. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61075. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61076. */
  61077. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61078. private static _ParseURL;
  61079. private static _ReturnFullUrlLocation;
  61080. private _checkManifestFile;
  61081. /**
  61082. * Open the database and make it available
  61083. * @param successCallback defines the callback to call on success
  61084. * @param errorCallback defines the callback to call on error
  61085. */
  61086. open(successCallback: () => void, errorCallback: () => void): void;
  61087. /**
  61088. * Loads an image from the database
  61089. * @param url defines the url to load from
  61090. * @param image defines the target DOM image
  61091. */
  61092. loadImage(url: string, image: HTMLImageElement): void;
  61093. private _loadImageFromDBAsync;
  61094. private _saveImageIntoDBAsync;
  61095. private _checkVersionFromDB;
  61096. private _loadVersionFromDBAsync;
  61097. private _saveVersionIntoDBAsync;
  61098. /**
  61099. * Loads a file from database
  61100. * @param url defines the URL to load from
  61101. * @param sceneLoaded defines a callback to call on success
  61102. * @param progressCallBack defines a callback to call when progress changed
  61103. * @param errorCallback defines a callback to call on error
  61104. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61105. */
  61106. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61107. private _loadFileAsync;
  61108. private _saveFileAsync;
  61109. /**
  61110. * Validates if xhr data is correct
  61111. * @param xhr defines the request to validate
  61112. * @param dataType defines the expected data type
  61113. * @returns true if data is correct
  61114. */
  61115. private static _ValidateXHRData;
  61116. }
  61117. }
  61118. declare module "babylonjs/Offline/index" {
  61119. export * from "babylonjs/Offline/database";
  61120. export * from "babylonjs/Offline/IOfflineProvider";
  61121. }
  61122. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61123. /** @hidden */
  61124. export var gpuUpdateParticlesPixelShader: {
  61125. name: string;
  61126. shader: string;
  61127. };
  61128. }
  61129. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61130. /** @hidden */
  61131. export var gpuUpdateParticlesVertexShader: {
  61132. name: string;
  61133. shader: string;
  61134. };
  61135. }
  61136. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61137. /** @hidden */
  61138. export var clipPlaneFragmentDeclaration2: {
  61139. name: string;
  61140. shader: string;
  61141. };
  61142. }
  61143. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61144. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61145. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61146. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61147. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61148. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61149. /** @hidden */
  61150. export var gpuRenderParticlesPixelShader: {
  61151. name: string;
  61152. shader: string;
  61153. };
  61154. }
  61155. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61156. /** @hidden */
  61157. export var clipPlaneVertexDeclaration2: {
  61158. name: string;
  61159. shader: string;
  61160. };
  61161. }
  61162. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61163. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61164. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61165. /** @hidden */
  61166. export var gpuRenderParticlesVertexShader: {
  61167. name: string;
  61168. shader: string;
  61169. };
  61170. }
  61171. declare module "babylonjs/Particles/gpuParticleSystem" {
  61172. import { Nullable } from "babylonjs/types";
  61173. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61174. import { Observable } from "babylonjs/Misc/observable";
  61175. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61176. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61177. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61178. import { Scene, IDisposable } from "babylonjs/scene";
  61179. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61180. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61181. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61182. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61183. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61184. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61185. /**
  61186. * This represents a GPU particle system in Babylon
  61187. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61188. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61189. */
  61190. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61191. /**
  61192. * The layer mask we are rendering the particles through.
  61193. */
  61194. layerMask: number;
  61195. private _capacity;
  61196. private _activeCount;
  61197. private _currentActiveCount;
  61198. private _accumulatedCount;
  61199. private _renderEffect;
  61200. private _updateEffect;
  61201. private _buffer0;
  61202. private _buffer1;
  61203. private _spriteBuffer;
  61204. private _updateVAO;
  61205. private _renderVAO;
  61206. private _targetIndex;
  61207. private _sourceBuffer;
  61208. private _targetBuffer;
  61209. private _engine;
  61210. private _currentRenderId;
  61211. private _started;
  61212. private _stopped;
  61213. private _timeDelta;
  61214. private _randomTexture;
  61215. private _randomTexture2;
  61216. private _attributesStrideSize;
  61217. private _updateEffectOptions;
  61218. private _randomTextureSize;
  61219. private _actualFrame;
  61220. private readonly _rawTextureWidth;
  61221. /**
  61222. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61223. */
  61224. static readonly IsSupported: boolean;
  61225. /**
  61226. * An event triggered when the system is disposed.
  61227. */
  61228. onDisposeObservable: Observable<GPUParticleSystem>;
  61229. /**
  61230. * Gets the maximum number of particles active at the same time.
  61231. * @returns The max number of active particles.
  61232. */
  61233. getCapacity(): number;
  61234. /**
  61235. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61236. * to override the particles.
  61237. */
  61238. forceDepthWrite: boolean;
  61239. /**
  61240. * Gets or set the number of active particles
  61241. */
  61242. activeParticleCount: number;
  61243. private _preWarmDone;
  61244. /**
  61245. * Is this system ready to be used/rendered
  61246. * @return true if the system is ready
  61247. */
  61248. isReady(): boolean;
  61249. /**
  61250. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61251. * @returns True if it has been started, otherwise false.
  61252. */
  61253. isStarted(): boolean;
  61254. /**
  61255. * Starts the particle system and begins to emit
  61256. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61257. */
  61258. start(delay?: number): void;
  61259. /**
  61260. * Stops the particle system.
  61261. */
  61262. stop(): void;
  61263. /**
  61264. * Remove all active particles
  61265. */
  61266. reset(): void;
  61267. /**
  61268. * Returns the string "GPUParticleSystem"
  61269. * @returns a string containing the class name
  61270. */
  61271. getClassName(): string;
  61272. private _colorGradientsTexture;
  61273. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61274. /**
  61275. * Adds a new color gradient
  61276. * @param gradient defines the gradient to use (between 0 and 1)
  61277. * @param color1 defines the color to affect to the specified gradient
  61278. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61279. * @returns the current particle system
  61280. */
  61281. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  61282. /**
  61283. * Remove a specific color gradient
  61284. * @param gradient defines the gradient to remove
  61285. * @returns the current particle system
  61286. */
  61287. removeColorGradient(gradient: number): GPUParticleSystem;
  61288. private _angularSpeedGradientsTexture;
  61289. private _sizeGradientsTexture;
  61290. private _velocityGradientsTexture;
  61291. private _limitVelocityGradientsTexture;
  61292. private _dragGradientsTexture;
  61293. private _addFactorGradient;
  61294. /**
  61295. * Adds a new size gradient
  61296. * @param gradient defines the gradient to use (between 0 and 1)
  61297. * @param factor defines the size factor to affect to the specified gradient
  61298. * @returns the current particle system
  61299. */
  61300. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  61301. /**
  61302. * Remove a specific size gradient
  61303. * @param gradient defines the gradient to remove
  61304. * @returns the current particle system
  61305. */
  61306. removeSizeGradient(gradient: number): GPUParticleSystem;
  61307. /**
  61308. * Adds a new angular speed gradient
  61309. * @param gradient defines the gradient to use (between 0 and 1)
  61310. * @param factor defines the angular speed to affect to the specified gradient
  61311. * @returns the current particle system
  61312. */
  61313. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  61314. /**
  61315. * Remove a specific angular speed gradient
  61316. * @param gradient defines the gradient to remove
  61317. * @returns the current particle system
  61318. */
  61319. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  61320. /**
  61321. * Adds a new velocity gradient
  61322. * @param gradient defines the gradient to use (between 0 and 1)
  61323. * @param factor defines the velocity to affect to the specified gradient
  61324. * @returns the current particle system
  61325. */
  61326. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61327. /**
  61328. * Remove a specific velocity gradient
  61329. * @param gradient defines the gradient to remove
  61330. * @returns the current particle system
  61331. */
  61332. removeVelocityGradient(gradient: number): GPUParticleSystem;
  61333. /**
  61334. * Adds a new limit velocity gradient
  61335. * @param gradient defines the gradient to use (between 0 and 1)
  61336. * @param factor defines the limit velocity value to affect to the specified gradient
  61337. * @returns the current particle system
  61338. */
  61339. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  61340. /**
  61341. * Remove a specific limit velocity gradient
  61342. * @param gradient defines the gradient to remove
  61343. * @returns the current particle system
  61344. */
  61345. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  61346. /**
  61347. * Adds a new drag gradient
  61348. * @param gradient defines the gradient to use (between 0 and 1)
  61349. * @param factor defines the drag value to affect to the specified gradient
  61350. * @returns the current particle system
  61351. */
  61352. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61353. /**
  61354. * Remove a specific drag gradient
  61355. * @param gradient defines the gradient to remove
  61356. * @returns the current particle system
  61357. */
  61358. removeDragGradient(gradient: number): GPUParticleSystem;
  61359. /**
  61360. * Not supported by GPUParticleSystem
  61361. * @param gradient defines the gradient to use (between 0 and 1)
  61362. * @param factor defines the emit rate value to affect to the specified gradient
  61363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61364. * @returns the current particle system
  61365. */
  61366. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61367. /**
  61368. * Not supported by GPUParticleSystem
  61369. * @param gradient defines the gradient to remove
  61370. * @returns the current particle system
  61371. */
  61372. removeEmitRateGradient(gradient: number): IParticleSystem;
  61373. /**
  61374. * Not supported by GPUParticleSystem
  61375. * @param gradient defines the gradient to use (between 0 and 1)
  61376. * @param factor defines the start size value to affect to the specified gradient
  61377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61378. * @returns the current particle system
  61379. */
  61380. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61381. /**
  61382. * Not supported by GPUParticleSystem
  61383. * @param gradient defines the gradient to remove
  61384. * @returns the current particle system
  61385. */
  61386. removeStartSizeGradient(gradient: number): IParticleSystem;
  61387. /**
  61388. * Not supported by GPUParticleSystem
  61389. * @param gradient defines the gradient to use (between 0 and 1)
  61390. * @param min defines the color remap minimal range
  61391. * @param max defines the color remap maximal range
  61392. * @returns the current particle system
  61393. */
  61394. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61395. /**
  61396. * Not supported by GPUParticleSystem
  61397. * @param gradient defines the gradient to remove
  61398. * @returns the current particle system
  61399. */
  61400. removeColorRemapGradient(): IParticleSystem;
  61401. /**
  61402. * Not supported by GPUParticleSystem
  61403. * @param gradient defines the gradient to use (between 0 and 1)
  61404. * @param min defines the alpha remap minimal range
  61405. * @param max defines the alpha remap maximal range
  61406. * @returns the current particle system
  61407. */
  61408. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61409. /**
  61410. * Not supported by GPUParticleSystem
  61411. * @param gradient defines the gradient to remove
  61412. * @returns the current particle system
  61413. */
  61414. removeAlphaRemapGradient(): IParticleSystem;
  61415. /**
  61416. * Not supported by GPUParticleSystem
  61417. * @param gradient defines the gradient to use (between 0 and 1)
  61418. * @param color defines the color to affect to the specified gradient
  61419. * @returns the current particle system
  61420. */
  61421. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61422. /**
  61423. * Not supported by GPUParticleSystem
  61424. * @param gradient defines the gradient to remove
  61425. * @returns the current particle system
  61426. */
  61427. removeRampGradient(): IParticleSystem;
  61428. /**
  61429. * Not supported by GPUParticleSystem
  61430. * @returns the list of ramp gradients
  61431. */
  61432. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61433. /**
  61434. * Not supported by GPUParticleSystem
  61435. * Gets or sets a boolean indicating that ramp gradients must be used
  61436. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61437. */
  61438. useRampGradients: boolean;
  61439. /**
  61440. * Not supported by GPUParticleSystem
  61441. * @param gradient defines the gradient to use (between 0 and 1)
  61442. * @param factor defines the life time factor to affect to the specified gradient
  61443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61444. * @returns the current particle system
  61445. */
  61446. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61447. /**
  61448. * Not supported by GPUParticleSystem
  61449. * @param gradient defines the gradient to remove
  61450. * @returns the current particle system
  61451. */
  61452. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61453. /**
  61454. * Instantiates a GPU particle system.
  61455. * 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.
  61456. * @param name The name of the particle system
  61457. * @param options The options used to create the system
  61458. * @param scene The scene the particle system belongs to
  61459. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61460. */
  61461. constructor(name: string, options: Partial<{
  61462. capacity: number;
  61463. randomTextureSize: number;
  61464. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61465. protected _reset(): void;
  61466. private _createUpdateVAO;
  61467. private _createRenderVAO;
  61468. private _initialize;
  61469. /** @hidden */
  61470. _recreateUpdateEffect(): void;
  61471. /** @hidden */
  61472. _recreateRenderEffect(): void;
  61473. /**
  61474. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61475. * @param preWarm defines if we are in the pre-warmimg phase
  61476. */
  61477. animate(preWarm?: boolean): void;
  61478. private _createFactorGradientTexture;
  61479. private _createSizeGradientTexture;
  61480. private _createAngularSpeedGradientTexture;
  61481. private _createVelocityGradientTexture;
  61482. private _createLimitVelocityGradientTexture;
  61483. private _createDragGradientTexture;
  61484. private _createColorGradientTexture;
  61485. /**
  61486. * Renders the particle system in its current state
  61487. * @param preWarm defines if the system should only update the particles but not render them
  61488. * @returns the current number of particles
  61489. */
  61490. render(preWarm?: boolean): number;
  61491. /**
  61492. * Rebuilds the particle system
  61493. */
  61494. rebuild(): void;
  61495. private _releaseBuffers;
  61496. private _releaseVAOs;
  61497. /**
  61498. * Disposes the particle system and free the associated resources
  61499. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61500. */
  61501. dispose(disposeTexture?: boolean): void;
  61502. /**
  61503. * Clones the particle system.
  61504. * @param name The name of the cloned object
  61505. * @param newEmitter The new emitter to use
  61506. * @returns the cloned particle system
  61507. */
  61508. clone(name: string, newEmitter: any): GPUParticleSystem;
  61509. /**
  61510. * Serializes the particle system to a JSON object.
  61511. * @returns the JSON object
  61512. */
  61513. serialize(): any;
  61514. /**
  61515. * Parses a JSON object to create a GPU particle system.
  61516. * @param parsedParticleSystem The JSON object to parse
  61517. * @param scene The scene to create the particle system in
  61518. * @param rootUrl The root url to use to load external dependencies like texture
  61519. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61520. * @returns the parsed GPU particle system
  61521. */
  61522. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61523. }
  61524. }
  61525. declare module "babylonjs/Particles/particleSystemSet" {
  61526. import { Nullable } from "babylonjs/types";
  61527. import { Color3 } from "babylonjs/Maths/math.color";
  61528. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61530. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61531. import { Scene, IDisposable } from "babylonjs/scene";
  61532. /**
  61533. * Represents a set of particle systems working together to create a specific effect
  61534. */
  61535. export class ParticleSystemSet implements IDisposable {
  61536. /**
  61537. * Gets or sets base Assets URL
  61538. */
  61539. static BaseAssetsUrl: string;
  61540. private _emitterCreationOptions;
  61541. private _emitterNode;
  61542. /**
  61543. * Gets the particle system list
  61544. */
  61545. systems: IParticleSystem[];
  61546. /**
  61547. * Gets the emitter node used with this set
  61548. */
  61549. readonly emitterNode: Nullable<TransformNode>;
  61550. /**
  61551. * Creates a new emitter mesh as a sphere
  61552. * @param options defines the options used to create the sphere
  61553. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61554. * @param scene defines the hosting scene
  61555. */
  61556. setEmitterAsSphere(options: {
  61557. diameter: number;
  61558. segments: number;
  61559. color: Color3;
  61560. }, renderingGroupId: number, scene: Scene): void;
  61561. /**
  61562. * Starts all particle systems of the set
  61563. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61564. */
  61565. start(emitter?: AbstractMesh): void;
  61566. /**
  61567. * Release all associated resources
  61568. */
  61569. dispose(): void;
  61570. /**
  61571. * Serialize the set into a JSON compatible object
  61572. * @returns a JSON compatible representation of the set
  61573. */
  61574. serialize(): any;
  61575. /**
  61576. * Parse a new ParticleSystemSet from a serialized source
  61577. * @param data defines a JSON compatible representation of the set
  61578. * @param scene defines the hosting scene
  61579. * @param gpu defines if we want GPU particles or CPU particles
  61580. * @returns a new ParticleSystemSet
  61581. */
  61582. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61583. }
  61584. }
  61585. declare module "babylonjs/Particles/particleHelper" {
  61586. import { Nullable } from "babylonjs/types";
  61587. import { Scene } from "babylonjs/scene";
  61588. import { Vector3 } from "babylonjs/Maths/math.vector";
  61589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61590. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61591. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61592. /**
  61593. * This class is made for on one-liner static method to help creating particle system set.
  61594. */
  61595. export class ParticleHelper {
  61596. /**
  61597. * Gets or sets base Assets URL
  61598. */
  61599. static BaseAssetsUrl: string;
  61600. /**
  61601. * Create a default particle system that you can tweak
  61602. * @param emitter defines the emitter to use
  61603. * @param capacity defines the system capacity (default is 500 particles)
  61604. * @param scene defines the hosting scene
  61605. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61606. * @returns the new Particle system
  61607. */
  61608. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61609. /**
  61610. * This is the main static method (one-liner) of this helper to create different particle systems
  61611. * @param type This string represents the type to the particle system to create
  61612. * @param scene The scene where the particle system should live
  61613. * @param gpu If the system will use gpu
  61614. * @returns the ParticleSystemSet created
  61615. */
  61616. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61617. /**
  61618. * Static function used to export a particle system to a ParticleSystemSet variable.
  61619. * Please note that the emitter shape is not exported
  61620. * @param systems defines the particle systems to export
  61621. * @returns the created particle system set
  61622. */
  61623. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61624. }
  61625. }
  61626. declare module "babylonjs/Particles/particleSystemComponent" {
  61627. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61628. import { Effect } from "babylonjs/Materials/effect";
  61629. import "babylonjs/Shaders/particles.vertex";
  61630. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61631. module "babylonjs/Engines/engine" {
  61632. interface Engine {
  61633. /**
  61634. * Create an effect to use with particle systems.
  61635. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61636. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61637. * @param uniformsNames defines a list of attribute names
  61638. * @param samplers defines an array of string used to represent textures
  61639. * @param defines defines the string containing the defines to use to compile the shaders
  61640. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61641. * @param onCompiled defines a function to call when the effect creation is successful
  61642. * @param onError defines a function to call when the effect creation has failed
  61643. * @returns the new Effect
  61644. */
  61645. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61646. }
  61647. }
  61648. module "babylonjs/Meshes/mesh" {
  61649. interface Mesh {
  61650. /**
  61651. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61652. * @returns an array of IParticleSystem
  61653. */
  61654. getEmittedParticleSystems(): IParticleSystem[];
  61655. /**
  61656. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61657. * @returns an array of IParticleSystem
  61658. */
  61659. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61660. }
  61661. }
  61662. /**
  61663. * @hidden
  61664. */
  61665. export var _IDoNeedToBeInTheBuild: number;
  61666. }
  61667. declare module "babylonjs/Particles/pointsCloudSystem" {
  61668. import { Color4 } from "babylonjs/Maths/math";
  61669. import { Mesh } from "babylonjs/Meshes/mesh";
  61670. import { Scene, IDisposable } from "babylonjs/scene";
  61671. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  61672. /** Defines the 4 color options */
  61673. export enum PointColor {
  61674. /** color value */
  61675. Color = 2,
  61676. /** uv value */
  61677. UV = 1,
  61678. /** random value */
  61679. Random = 0,
  61680. /** stated value */
  61681. Stated = 3
  61682. }
  61683. /**
  61684. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  61685. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  61686. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  61687. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  61688. *
  61689. * Full documentation here : TO BE ENTERED
  61690. */
  61691. export class PointsCloudSystem implements IDisposable {
  61692. /**
  61693. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  61694. * Example : var p = SPS.particles[i];
  61695. */
  61696. particles: CloudPoint[];
  61697. /**
  61698. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  61699. */
  61700. nbParticles: number;
  61701. /**
  61702. * This a counter for your own usage. It's not set by any SPS functions.
  61703. */
  61704. counter: number;
  61705. /**
  61706. * The PCS name. This name is also given to the underlying mesh.
  61707. */
  61708. name: string;
  61709. /**
  61710. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  61711. */
  61712. mesh: Mesh;
  61713. /**
  61714. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  61715. * Please read :
  61716. */
  61717. vars: any;
  61718. /**
  61719. * @hidden
  61720. */
  61721. _size: number;
  61722. private _scene;
  61723. private _promises;
  61724. private _positions;
  61725. private _indices;
  61726. private _normals;
  61727. private _colors;
  61728. private _uvs;
  61729. private _indices32;
  61730. private _positions32;
  61731. private _colors32;
  61732. private _uvs32;
  61733. private _updatable;
  61734. private _isVisibilityBoxLocked;
  61735. private _alwaysVisible;
  61736. private _groups;
  61737. private _groupCounter;
  61738. private _computeParticleColor;
  61739. private _computeParticleTexture;
  61740. private _computeParticleRotation;
  61741. private _computeBoundingBox;
  61742. private _isReady;
  61743. /**
  61744. * Creates a PCS (Points Cloud System) object
  61745. * @param name (String) is the PCS name, this will be the underlying mesh name
  61746. * @param pointSize (number) is the size for each point
  61747. * @param scene (Scene) is the scene in which the PCS is added
  61748. * @param options defines the options of the PCS e.g.
  61749. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  61750. */
  61751. constructor(name: string, pointSize: number, scene: Scene, options?: {
  61752. updatable?: boolean;
  61753. });
  61754. /**
  61755. * Builds the PCS underlying mesh. Returns a standard Mesh.
  61756. * If no points were added to the PCS, the returned mesh is just a single point.
  61757. * @returns a promise for the created mesh
  61758. */
  61759. buildMeshAsync(): Promise<Mesh>;
  61760. /**
  61761. * @hidden
  61762. */
  61763. private _buildMesh;
  61764. private _addParticle;
  61765. private _randomUnitVector;
  61766. private _getColorIndicesForCoord;
  61767. private _setPointsColorOrUV;
  61768. private _colorFromTexture;
  61769. private _calculateDensity;
  61770. /**
  61771. * Adds points to the PCS in random positions within a unit sphere
  61772. * @param nb (positive integer) the number of particles to be created from this model
  61773. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  61774. * @returns the number of groups in the system
  61775. */
  61776. addPoints(nb: number, pointFunction?: any): number;
  61777. /**
  61778. * Adds points to the PCS from the surface of the model shape
  61779. * @param mesh is any Mesh object that will be used as a surface model for the points
  61780. * @param nb (positive integer) the number of particles to be created from this model
  61781. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  61782. * @param color (color3) to be used when colorWith is stated
  61783. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61784. * @returns the number of groups in the system
  61785. */
  61786. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61787. /**
  61788. * Adds points to the PCS inside the model shape
  61789. * @param mesh is any Mesh object that will be used as a surface model for the points
  61790. * @param nb (positive integer) the number of particles to be created from this model
  61791. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  61792. * @param color (color4) to be used when colorWith is stated
  61793. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  61794. * @returns the number of groups in the system
  61795. */
  61796. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  61797. /**
  61798. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  61799. * This method calls `updateParticle()` for each particle of the SPS.
  61800. * For an animated SPS, it is usually called within the render loop.
  61801. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  61802. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  61803. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  61804. * @returns the PCS.
  61805. */
  61806. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  61807. /**
  61808. * Disposes the PCS.
  61809. */
  61810. dispose(): void;
  61811. /**
  61812. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  61813. * doc :
  61814. * @returns the PCS.
  61815. */
  61816. refreshVisibleSize(): PointsCloudSystem;
  61817. /**
  61818. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  61819. * @param size the size (float) of the visibility box
  61820. * note : this doesn't lock the PCS mesh bounding box.
  61821. * doc :
  61822. */
  61823. setVisibilityBox(size: number): void;
  61824. /**
  61825. * Gets whether the PCS is always visible or not
  61826. * doc :
  61827. */
  61828. /**
  61829. * Sets the PCS as always visible or not
  61830. * doc :
  61831. */
  61832. isAlwaysVisible: boolean;
  61833. /**
  61834. * Tells to `setParticles()` to compute the particle rotations or not
  61835. * Default value : false. The PCS is faster when it's set to false
  61836. * Note : particle rotations are only applied to parent particles
  61837. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  61838. */
  61839. computeParticleRotation: boolean;
  61840. /**
  61841. * Tells to `setParticles()` to compute the particle colors or not.
  61842. * Default value : true. The PCS is faster when it's set to false.
  61843. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61844. */
  61845. /**
  61846. * Gets if `setParticles()` computes the particle colors or not.
  61847. * Default value : false. The PCS is faster when it's set to false.
  61848. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  61849. */
  61850. computeParticleColor: boolean;
  61851. /**
  61852. * Gets if `setParticles()` computes the particle textures or not.
  61853. * Default value : false. The PCS is faster when it's set to false.
  61854. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  61855. */
  61856. computeParticleTexture: boolean;
  61857. /**
  61858. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  61859. */
  61860. /**
  61861. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  61862. */
  61863. computeBoundingBox: boolean;
  61864. /**
  61865. * This function does nothing. It may be overwritten to set all the particle first values.
  61866. * The PCS doesn't call this function, you may have to call it by your own.
  61867. * doc :
  61868. */
  61869. initParticles(): void;
  61870. /**
  61871. * This function does nothing. It may be overwritten to recycle a particle
  61872. * The PCS doesn't call this function, you can to call it
  61873. * doc :
  61874. * @param particle The particle to recycle
  61875. * @returns the recycled particle
  61876. */
  61877. recycleParticle(particle: CloudPoint): CloudPoint;
  61878. /**
  61879. * Updates a particle : this function should be overwritten by the user.
  61880. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  61881. * doc :
  61882. * @example : just set a particle position or velocity and recycle conditions
  61883. * @param particle The particle to update
  61884. * @returns the updated particle
  61885. */
  61886. updateParticle(particle: CloudPoint): CloudPoint;
  61887. /**
  61888. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  61889. * This does nothing and may be overwritten by the user.
  61890. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61891. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61892. * @param update the boolean update value actually passed to setParticles()
  61893. */
  61894. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61895. /**
  61896. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  61897. * This will be passed three parameters.
  61898. * This does nothing and may be overwritten by the user.
  61899. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  61900. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  61901. * @param update the boolean update value actually passed to setParticles()
  61902. */
  61903. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  61904. }
  61905. }
  61906. declare module "babylonjs/Particles/cloudPoint" {
  61907. import { Nullable } from "babylonjs/types";
  61908. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  61909. import { Mesh } from "babylonjs/Meshes/mesh";
  61910. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61911. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  61912. /**
  61913. * Represents one particle of a points cloud system.
  61914. */
  61915. export class CloudPoint {
  61916. /**
  61917. * particle global index
  61918. */
  61919. idx: number;
  61920. /**
  61921. * The color of the particle
  61922. */
  61923. color: Nullable<Color4>;
  61924. /**
  61925. * The world space position of the particle.
  61926. */
  61927. position: Vector3;
  61928. /**
  61929. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  61930. */
  61931. rotation: Vector3;
  61932. /**
  61933. * The world space rotation quaternion of the particle.
  61934. */
  61935. rotationQuaternion: Nullable<Quaternion>;
  61936. /**
  61937. * The uv of the particle.
  61938. */
  61939. uv: Nullable<Vector2>;
  61940. /**
  61941. * The current speed of the particle.
  61942. */
  61943. velocity: Vector3;
  61944. /**
  61945. * The pivot point in the particle local space.
  61946. */
  61947. pivot: Vector3;
  61948. /**
  61949. * Must the particle be translated from its pivot point in its local space ?
  61950. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  61951. * Default : false
  61952. */
  61953. translateFromPivot: boolean;
  61954. /**
  61955. * Index of this particle in the global "positions" array (Internal use)
  61956. * @hidden
  61957. */
  61958. _pos: number;
  61959. /**
  61960. * @hidden Index of this particle in the global "indices" array (Internal use)
  61961. */
  61962. _ind: number;
  61963. /**
  61964. * Group this particle belongs to
  61965. */
  61966. _group: PointsGroup;
  61967. /**
  61968. * Group id of this particle
  61969. */
  61970. groupId: number;
  61971. /**
  61972. * Index of the particle in its group id (Internal use)
  61973. */
  61974. idxInGroup: number;
  61975. /**
  61976. * @hidden Particle BoundingInfo object (Internal use)
  61977. */
  61978. _boundingInfo: BoundingInfo;
  61979. /**
  61980. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  61981. */
  61982. _pcs: PointsCloudSystem;
  61983. /**
  61984. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  61985. */
  61986. _stillInvisible: boolean;
  61987. /**
  61988. * @hidden Last computed particle rotation matrix
  61989. */
  61990. _rotationMatrix: number[];
  61991. /**
  61992. * Parent particle Id, if any.
  61993. * Default null.
  61994. */
  61995. parentId: Nullable<number>;
  61996. /**
  61997. * @hidden Internal global position in the PCS.
  61998. */
  61999. _globalPosition: Vector3;
  62000. /**
  62001. * Creates a Point Cloud object.
  62002. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62003. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62004. * @param group (PointsGroup) is the group the particle belongs to
  62005. * @param groupId (integer) is the group identifier in the PCS.
  62006. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62007. * @param pcs defines the PCS it is associated to
  62008. */
  62009. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62010. /**
  62011. * get point size
  62012. */
  62013. /**
  62014. * Set point size
  62015. */
  62016. size: Vector3;
  62017. /**
  62018. * Legacy support, changed quaternion to rotationQuaternion
  62019. */
  62020. /**
  62021. * Legacy support, changed quaternion to rotationQuaternion
  62022. */
  62023. quaternion: Nullable<Quaternion>;
  62024. /**
  62025. * Returns a boolean. True if the particle intersects a mesh, else false
  62026. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62027. * @param target is the object (point or mesh) what the intersection is computed against
  62028. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62029. * @returns true if it intersects
  62030. */
  62031. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62032. /**
  62033. * get the rotation matrix of the particle
  62034. * @hidden
  62035. */
  62036. getRotationMatrix(m: Matrix): void;
  62037. }
  62038. /**
  62039. * Represents a group of points in a points cloud system
  62040. * * PCS internal tool, don't use it manually.
  62041. */
  62042. export class PointsGroup {
  62043. /**
  62044. * The group id
  62045. * @hidden
  62046. */
  62047. groupID: number;
  62048. /**
  62049. * image data for group (internal use)
  62050. * @hidden
  62051. */
  62052. _groupImageData: Nullable<ArrayBufferView>;
  62053. /**
  62054. * Image Width (internal use)
  62055. * @hidden
  62056. */
  62057. _groupImgWidth: number;
  62058. /**
  62059. * Image Height (internal use)
  62060. * @hidden
  62061. */
  62062. _groupImgHeight: number;
  62063. /**
  62064. * Custom position function (internal use)
  62065. * @hidden
  62066. */
  62067. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62068. /**
  62069. * density per facet for surface points
  62070. * @hidden
  62071. */
  62072. _groupDensity: number[];
  62073. /**
  62074. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62075. * PCS internal tool, don't use it manually.
  62076. * @hidden
  62077. */
  62078. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62079. }
  62080. }
  62081. declare module "babylonjs/Particles/index" {
  62082. export * from "babylonjs/Particles/baseParticleSystem";
  62083. export * from "babylonjs/Particles/EmitterTypes/index";
  62084. export * from "babylonjs/Particles/gpuParticleSystem";
  62085. export * from "babylonjs/Particles/IParticleSystem";
  62086. export * from "babylonjs/Particles/particle";
  62087. export * from "babylonjs/Particles/particleHelper";
  62088. export * from "babylonjs/Particles/particleSystem";
  62089. export * from "babylonjs/Particles/particleSystemComponent";
  62090. export * from "babylonjs/Particles/particleSystemSet";
  62091. export * from "babylonjs/Particles/solidParticle";
  62092. export * from "babylonjs/Particles/solidParticleSystem";
  62093. export * from "babylonjs/Particles/cloudPoint";
  62094. export * from "babylonjs/Particles/pointsCloudSystem";
  62095. export * from "babylonjs/Particles/subEmitter";
  62096. }
  62097. declare module "babylonjs/Physics/physicsEngineComponent" {
  62098. import { Nullable } from "babylonjs/types";
  62099. import { Observable, Observer } from "babylonjs/Misc/observable";
  62100. import { Vector3 } from "babylonjs/Maths/math.vector";
  62101. import { Mesh } from "babylonjs/Meshes/mesh";
  62102. import { ISceneComponent } from "babylonjs/sceneComponent";
  62103. import { Scene } from "babylonjs/scene";
  62104. import { Node } from "babylonjs/node";
  62105. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62106. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62107. module "babylonjs/scene" {
  62108. interface Scene {
  62109. /** @hidden (Backing field) */
  62110. _physicsEngine: Nullable<IPhysicsEngine>;
  62111. /**
  62112. * Gets the current physics engine
  62113. * @returns a IPhysicsEngine or null if none attached
  62114. */
  62115. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62116. /**
  62117. * Enables physics to the current scene
  62118. * @param gravity defines the scene's gravity for the physics engine
  62119. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62120. * @return a boolean indicating if the physics engine was initialized
  62121. */
  62122. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62123. /**
  62124. * Disables and disposes the physics engine associated with the scene
  62125. */
  62126. disablePhysicsEngine(): void;
  62127. /**
  62128. * Gets a boolean indicating if there is an active physics engine
  62129. * @returns a boolean indicating if there is an active physics engine
  62130. */
  62131. isPhysicsEnabled(): boolean;
  62132. /**
  62133. * Deletes a physics compound impostor
  62134. * @param compound defines the compound to delete
  62135. */
  62136. deleteCompoundImpostor(compound: any): void;
  62137. /**
  62138. * An event triggered when physic simulation is about to be run
  62139. */
  62140. onBeforePhysicsObservable: Observable<Scene>;
  62141. /**
  62142. * An event triggered when physic simulation has been done
  62143. */
  62144. onAfterPhysicsObservable: Observable<Scene>;
  62145. }
  62146. }
  62147. module "babylonjs/Meshes/abstractMesh" {
  62148. interface AbstractMesh {
  62149. /** @hidden */
  62150. _physicsImpostor: Nullable<PhysicsImpostor>;
  62151. /**
  62152. * Gets or sets impostor used for physic simulation
  62153. * @see http://doc.babylonjs.com/features/physics_engine
  62154. */
  62155. physicsImpostor: Nullable<PhysicsImpostor>;
  62156. /**
  62157. * Gets the current physics impostor
  62158. * @see http://doc.babylonjs.com/features/physics_engine
  62159. * @returns a physics impostor or null
  62160. */
  62161. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62162. /** Apply a physic impulse to the mesh
  62163. * @param force defines the force to apply
  62164. * @param contactPoint defines where to apply the force
  62165. * @returns the current mesh
  62166. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62167. */
  62168. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62169. /**
  62170. * Creates a physic joint between two meshes
  62171. * @param otherMesh defines the other mesh to use
  62172. * @param pivot1 defines the pivot to use on this mesh
  62173. * @param pivot2 defines the pivot to use on the other mesh
  62174. * @param options defines additional options (can be plugin dependent)
  62175. * @returns the current mesh
  62176. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62177. */
  62178. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62179. /** @hidden */
  62180. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62181. }
  62182. }
  62183. /**
  62184. * Defines the physics engine scene component responsible to manage a physics engine
  62185. */
  62186. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62187. /**
  62188. * The component name helpful to identify the component in the list of scene components.
  62189. */
  62190. readonly name: string;
  62191. /**
  62192. * The scene the component belongs to.
  62193. */
  62194. scene: Scene;
  62195. /**
  62196. * Creates a new instance of the component for the given scene
  62197. * @param scene Defines the scene to register the component in
  62198. */
  62199. constructor(scene: Scene);
  62200. /**
  62201. * Registers the component in a given scene
  62202. */
  62203. register(): void;
  62204. /**
  62205. * Rebuilds the elements related to this component in case of
  62206. * context lost for instance.
  62207. */
  62208. rebuild(): void;
  62209. /**
  62210. * Disposes the component and the associated ressources
  62211. */
  62212. dispose(): void;
  62213. }
  62214. }
  62215. declare module "babylonjs/Physics/physicsHelper" {
  62216. import { Nullable } from "babylonjs/types";
  62217. import { Vector3 } from "babylonjs/Maths/math.vector";
  62218. import { Mesh } from "babylonjs/Meshes/mesh";
  62219. import { Scene } from "babylonjs/scene";
  62220. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62221. /**
  62222. * A helper for physics simulations
  62223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62224. */
  62225. export class PhysicsHelper {
  62226. private _scene;
  62227. private _physicsEngine;
  62228. /**
  62229. * Initializes the Physics helper
  62230. * @param scene Babylon.js scene
  62231. */
  62232. constructor(scene: Scene);
  62233. /**
  62234. * Applies a radial explosion impulse
  62235. * @param origin the origin of the explosion
  62236. * @param radiusOrEventOptions the radius or the options of radial explosion
  62237. * @param strength the explosion strength
  62238. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62239. * @returns A physics radial explosion event, or null
  62240. */
  62241. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62242. /**
  62243. * Applies a radial explosion force
  62244. * @param origin the origin of the explosion
  62245. * @param radiusOrEventOptions the radius or the options of radial explosion
  62246. * @param strength the explosion strength
  62247. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62248. * @returns A physics radial explosion event, or null
  62249. */
  62250. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62251. /**
  62252. * Creates a gravitational field
  62253. * @param origin the origin of the explosion
  62254. * @param radiusOrEventOptions the radius or the options of radial explosion
  62255. * @param strength the explosion strength
  62256. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62257. * @returns A physics gravitational field event, or null
  62258. */
  62259. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62260. /**
  62261. * Creates a physics updraft event
  62262. * @param origin the origin of the updraft
  62263. * @param radiusOrEventOptions the radius or the options of the updraft
  62264. * @param strength the strength of the updraft
  62265. * @param height the height of the updraft
  62266. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62267. * @returns A physics updraft event, or null
  62268. */
  62269. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62270. /**
  62271. * Creates a physics vortex event
  62272. * @param origin the of the vortex
  62273. * @param radiusOrEventOptions the radius or the options of the vortex
  62274. * @param strength the strength of the vortex
  62275. * @param height the height of the vortex
  62276. * @returns a Physics vortex event, or null
  62277. * A physics vortex event or null
  62278. */
  62279. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  62280. }
  62281. /**
  62282. * Represents a physics radial explosion event
  62283. */
  62284. class PhysicsRadialExplosionEvent {
  62285. private _scene;
  62286. private _options;
  62287. private _sphere;
  62288. private _dataFetched;
  62289. /**
  62290. * Initializes a radial explosioin event
  62291. * @param _scene BabylonJS scene
  62292. * @param _options The options for the vortex event
  62293. */
  62294. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  62295. /**
  62296. * Returns the data related to the radial explosion event (sphere).
  62297. * @returns The radial explosion event data
  62298. */
  62299. getData(): PhysicsRadialExplosionEventData;
  62300. /**
  62301. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  62302. * @param impostor A physics imposter
  62303. * @param origin the origin of the explosion
  62304. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  62305. */
  62306. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  62307. /**
  62308. * Triggers affecterd impostors callbacks
  62309. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  62310. */
  62311. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  62312. /**
  62313. * Disposes the sphere.
  62314. * @param force Specifies if the sphere should be disposed by force
  62315. */
  62316. dispose(force?: boolean): void;
  62317. /*** Helpers ***/
  62318. private _prepareSphere;
  62319. private _intersectsWithSphere;
  62320. }
  62321. /**
  62322. * Represents a gravitational field event
  62323. */
  62324. class PhysicsGravitationalFieldEvent {
  62325. private _physicsHelper;
  62326. private _scene;
  62327. private _origin;
  62328. private _options;
  62329. private _tickCallback;
  62330. private _sphere;
  62331. private _dataFetched;
  62332. /**
  62333. * Initializes the physics gravitational field event
  62334. * @param _physicsHelper A physics helper
  62335. * @param _scene BabylonJS scene
  62336. * @param _origin The origin position of the gravitational field event
  62337. * @param _options The options for the vortex event
  62338. */
  62339. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  62340. /**
  62341. * Returns the data related to the gravitational field event (sphere).
  62342. * @returns A gravitational field event
  62343. */
  62344. getData(): PhysicsGravitationalFieldEventData;
  62345. /**
  62346. * Enables the gravitational field.
  62347. */
  62348. enable(): void;
  62349. /**
  62350. * Disables the gravitational field.
  62351. */
  62352. disable(): void;
  62353. /**
  62354. * Disposes the sphere.
  62355. * @param force The force to dispose from the gravitational field event
  62356. */
  62357. dispose(force?: boolean): void;
  62358. private _tick;
  62359. }
  62360. /**
  62361. * Represents a physics updraft event
  62362. */
  62363. class PhysicsUpdraftEvent {
  62364. private _scene;
  62365. private _origin;
  62366. private _options;
  62367. private _physicsEngine;
  62368. private _originTop;
  62369. private _originDirection;
  62370. private _tickCallback;
  62371. private _cylinder;
  62372. private _cylinderPosition;
  62373. private _dataFetched;
  62374. /**
  62375. * Initializes the physics updraft event
  62376. * @param _scene BabylonJS scene
  62377. * @param _origin The origin position of the updraft
  62378. * @param _options The options for the updraft event
  62379. */
  62380. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  62381. /**
  62382. * Returns the data related to the updraft event (cylinder).
  62383. * @returns A physics updraft event
  62384. */
  62385. getData(): PhysicsUpdraftEventData;
  62386. /**
  62387. * Enables the updraft.
  62388. */
  62389. enable(): void;
  62390. /**
  62391. * Disables the updraft.
  62392. */
  62393. disable(): void;
  62394. /**
  62395. * Disposes the cylinder.
  62396. * @param force Specifies if the updraft should be disposed by force
  62397. */
  62398. dispose(force?: boolean): void;
  62399. private getImpostorHitData;
  62400. private _tick;
  62401. /*** Helpers ***/
  62402. private _prepareCylinder;
  62403. private _intersectsWithCylinder;
  62404. }
  62405. /**
  62406. * Represents a physics vortex event
  62407. */
  62408. class PhysicsVortexEvent {
  62409. private _scene;
  62410. private _origin;
  62411. private _options;
  62412. private _physicsEngine;
  62413. private _originTop;
  62414. private _tickCallback;
  62415. private _cylinder;
  62416. private _cylinderPosition;
  62417. private _dataFetched;
  62418. /**
  62419. * Initializes the physics vortex event
  62420. * @param _scene The BabylonJS scene
  62421. * @param _origin The origin position of the vortex
  62422. * @param _options The options for the vortex event
  62423. */
  62424. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  62425. /**
  62426. * Returns the data related to the vortex event (cylinder).
  62427. * @returns The physics vortex event data
  62428. */
  62429. getData(): PhysicsVortexEventData;
  62430. /**
  62431. * Enables the vortex.
  62432. */
  62433. enable(): void;
  62434. /**
  62435. * Disables the cortex.
  62436. */
  62437. disable(): void;
  62438. /**
  62439. * Disposes the sphere.
  62440. * @param force
  62441. */
  62442. dispose(force?: boolean): void;
  62443. private getImpostorHitData;
  62444. private _tick;
  62445. /*** Helpers ***/
  62446. private _prepareCylinder;
  62447. private _intersectsWithCylinder;
  62448. }
  62449. /**
  62450. * Options fot the radial explosion event
  62451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62452. */
  62453. export class PhysicsRadialExplosionEventOptions {
  62454. /**
  62455. * The radius of the sphere for the radial explosion.
  62456. */
  62457. radius: number;
  62458. /**
  62459. * The strenth of the explosion.
  62460. */
  62461. strength: number;
  62462. /**
  62463. * The strenght of the force in correspondence to the distance of the affected object
  62464. */
  62465. falloff: PhysicsRadialImpulseFalloff;
  62466. /**
  62467. * Sphere options for the radial explosion.
  62468. */
  62469. sphere: {
  62470. segments: number;
  62471. diameter: number;
  62472. };
  62473. /**
  62474. * Sphere options for the radial explosion.
  62475. */
  62476. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  62477. }
  62478. /**
  62479. * Options fot the updraft event
  62480. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62481. */
  62482. export class PhysicsUpdraftEventOptions {
  62483. /**
  62484. * The radius of the cylinder for the vortex
  62485. */
  62486. radius: number;
  62487. /**
  62488. * The strenth of the updraft.
  62489. */
  62490. strength: number;
  62491. /**
  62492. * The height of the cylinder for the updraft.
  62493. */
  62494. height: number;
  62495. /**
  62496. * The mode for the the updraft.
  62497. */
  62498. updraftMode: PhysicsUpdraftMode;
  62499. }
  62500. /**
  62501. * Options fot the vortex event
  62502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62503. */
  62504. export class PhysicsVortexEventOptions {
  62505. /**
  62506. * The radius of the cylinder for the vortex
  62507. */
  62508. radius: number;
  62509. /**
  62510. * The strenth of the vortex.
  62511. */
  62512. strength: number;
  62513. /**
  62514. * The height of the cylinder for the vortex.
  62515. */
  62516. height: number;
  62517. /**
  62518. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  62519. */
  62520. centripetalForceThreshold: number;
  62521. /**
  62522. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  62523. */
  62524. centripetalForceMultiplier: number;
  62525. /**
  62526. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  62527. */
  62528. centrifugalForceMultiplier: number;
  62529. /**
  62530. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  62531. */
  62532. updraftForceMultiplier: number;
  62533. }
  62534. /**
  62535. * The strenght of the force in correspondence to the distance of the affected object
  62536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62537. */
  62538. export enum PhysicsRadialImpulseFalloff {
  62539. /** Defines that impulse is constant in strength across it's whole radius */
  62540. Constant = 0,
  62541. /** Defines that impulse gets weaker if it's further from the origin */
  62542. Linear = 1
  62543. }
  62544. /**
  62545. * The strength of the force in correspondence to the distance of the affected object
  62546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62547. */
  62548. export enum PhysicsUpdraftMode {
  62549. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  62550. Center = 0,
  62551. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  62552. Perpendicular = 1
  62553. }
  62554. /**
  62555. * Interface for a physics hit data
  62556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62557. */
  62558. export interface PhysicsHitData {
  62559. /**
  62560. * The force applied at the contact point
  62561. */
  62562. force: Vector3;
  62563. /**
  62564. * The contact point
  62565. */
  62566. contactPoint: Vector3;
  62567. /**
  62568. * The distance from the origin to the contact point
  62569. */
  62570. distanceFromOrigin: number;
  62571. }
  62572. /**
  62573. * Interface for radial explosion event data
  62574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62575. */
  62576. export interface PhysicsRadialExplosionEventData {
  62577. /**
  62578. * A sphere used for the radial explosion event
  62579. */
  62580. sphere: Mesh;
  62581. }
  62582. /**
  62583. * Interface for gravitational field event data
  62584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62585. */
  62586. export interface PhysicsGravitationalFieldEventData {
  62587. /**
  62588. * A sphere mesh used for the gravitational field event
  62589. */
  62590. sphere: Mesh;
  62591. }
  62592. /**
  62593. * Interface for updraft event data
  62594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62595. */
  62596. export interface PhysicsUpdraftEventData {
  62597. /**
  62598. * A cylinder used for the updraft event
  62599. */
  62600. cylinder: Mesh;
  62601. }
  62602. /**
  62603. * Interface for vortex event data
  62604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62605. */
  62606. export interface PhysicsVortexEventData {
  62607. /**
  62608. * A cylinder used for the vortex event
  62609. */
  62610. cylinder: Mesh;
  62611. }
  62612. /**
  62613. * Interface for an affected physics impostor
  62614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62615. */
  62616. export interface PhysicsAffectedImpostorWithData {
  62617. /**
  62618. * The impostor affected by the effect
  62619. */
  62620. impostor: PhysicsImpostor;
  62621. /**
  62622. * The data about the hit/horce from the explosion
  62623. */
  62624. hitData: PhysicsHitData;
  62625. }
  62626. }
  62627. declare module "babylonjs/Physics/Plugins/index" {
  62628. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  62629. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  62630. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  62631. }
  62632. declare module "babylonjs/Physics/index" {
  62633. export * from "babylonjs/Physics/IPhysicsEngine";
  62634. export * from "babylonjs/Physics/physicsEngine";
  62635. export * from "babylonjs/Physics/physicsEngineComponent";
  62636. export * from "babylonjs/Physics/physicsHelper";
  62637. export * from "babylonjs/Physics/physicsImpostor";
  62638. export * from "babylonjs/Physics/physicsJoint";
  62639. export * from "babylonjs/Physics/Plugins/index";
  62640. }
  62641. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  62642. /** @hidden */
  62643. export var blackAndWhitePixelShader: {
  62644. name: string;
  62645. shader: string;
  62646. };
  62647. }
  62648. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  62649. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62650. import { Camera } from "babylonjs/Cameras/camera";
  62651. import { Engine } from "babylonjs/Engines/engine";
  62652. import "babylonjs/Shaders/blackAndWhite.fragment";
  62653. /**
  62654. * Post process used to render in black and white
  62655. */
  62656. export class BlackAndWhitePostProcess extends PostProcess {
  62657. /**
  62658. * Linear about to convert he result to black and white (default: 1)
  62659. */
  62660. degree: number;
  62661. /**
  62662. * Creates a black and white post process
  62663. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  62664. * @param name The name of the effect.
  62665. * @param options The required width/height ratio to downsize to before computing the render pass.
  62666. * @param camera The camera to apply the render pass to.
  62667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62668. * @param engine The engine which the post process will be applied. (default: current engine)
  62669. * @param reusable If the post process can be reused on the same frame. (default: false)
  62670. */
  62671. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62672. }
  62673. }
  62674. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  62675. import { Nullable } from "babylonjs/types";
  62676. import { Camera } from "babylonjs/Cameras/camera";
  62677. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62678. import { Engine } from "babylonjs/Engines/engine";
  62679. /**
  62680. * This represents a set of one or more post processes in Babylon.
  62681. * A post process can be used to apply a shader to a texture after it is rendered.
  62682. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62683. */
  62684. export class PostProcessRenderEffect {
  62685. private _postProcesses;
  62686. private _getPostProcesses;
  62687. private _singleInstance;
  62688. private _cameras;
  62689. private _indicesForCamera;
  62690. /**
  62691. * Name of the effect
  62692. * @hidden
  62693. */
  62694. _name: string;
  62695. /**
  62696. * Instantiates a post process render effect.
  62697. * A post process can be used to apply a shader to a texture after it is rendered.
  62698. * @param engine The engine the effect is tied to
  62699. * @param name The name of the effect
  62700. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  62701. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  62702. */
  62703. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  62704. /**
  62705. * Checks if all the post processes in the effect are supported.
  62706. */
  62707. readonly isSupported: boolean;
  62708. /**
  62709. * Updates the current state of the effect
  62710. * @hidden
  62711. */
  62712. _update(): void;
  62713. /**
  62714. * Attaches the effect on cameras
  62715. * @param cameras The camera to attach to.
  62716. * @hidden
  62717. */
  62718. _attachCameras(cameras: Camera): void;
  62719. /**
  62720. * Attaches the effect on cameras
  62721. * @param cameras The camera to attach to.
  62722. * @hidden
  62723. */
  62724. _attachCameras(cameras: Camera[]): void;
  62725. /**
  62726. * Detaches the effect on cameras
  62727. * @param cameras The camera to detatch from.
  62728. * @hidden
  62729. */
  62730. _detachCameras(cameras: Camera): void;
  62731. /**
  62732. * Detatches the effect on cameras
  62733. * @param cameras The camera to detatch from.
  62734. * @hidden
  62735. */
  62736. _detachCameras(cameras: Camera[]): void;
  62737. /**
  62738. * Enables the effect on given cameras
  62739. * @param cameras The camera to enable.
  62740. * @hidden
  62741. */
  62742. _enable(cameras: Camera): void;
  62743. /**
  62744. * Enables the effect on given cameras
  62745. * @param cameras The camera to enable.
  62746. * @hidden
  62747. */
  62748. _enable(cameras: Nullable<Camera[]>): void;
  62749. /**
  62750. * Disables the effect on the given cameras
  62751. * @param cameras The camera to disable.
  62752. * @hidden
  62753. */
  62754. _disable(cameras: Camera): void;
  62755. /**
  62756. * Disables the effect on the given cameras
  62757. * @param cameras The camera to disable.
  62758. * @hidden
  62759. */
  62760. _disable(cameras: Nullable<Camera[]>): void;
  62761. /**
  62762. * Gets a list of the post processes contained in the effect.
  62763. * @param camera The camera to get the post processes on.
  62764. * @returns The list of the post processes in the effect.
  62765. */
  62766. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  62767. }
  62768. }
  62769. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62770. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62771. /** @hidden */
  62772. export var extractHighlightsPixelShader: {
  62773. name: string;
  62774. shader: string;
  62775. };
  62776. }
  62777. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62778. import { Nullable } from "babylonjs/types";
  62779. import { Camera } from "babylonjs/Cameras/camera";
  62780. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62781. import { Engine } from "babylonjs/Engines/engine";
  62782. import "babylonjs/Shaders/extractHighlights.fragment";
  62783. /**
  62784. * 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.
  62785. */
  62786. export class ExtractHighlightsPostProcess extends PostProcess {
  62787. /**
  62788. * The luminance threshold, pixels below this value will be set to black.
  62789. */
  62790. threshold: number;
  62791. /** @hidden */
  62792. _exposure: number;
  62793. /**
  62794. * Post process which has the input texture to be used when performing highlight extraction
  62795. * @hidden
  62796. */
  62797. _inputPostProcess: Nullable<PostProcess>;
  62798. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62799. }
  62800. }
  62801. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62802. /** @hidden */
  62803. export var bloomMergePixelShader: {
  62804. name: string;
  62805. shader: string;
  62806. };
  62807. }
  62808. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62809. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62810. import { Nullable } from "babylonjs/types";
  62811. import { Engine } from "babylonjs/Engines/engine";
  62812. import { Camera } from "babylonjs/Cameras/camera";
  62813. import "babylonjs/Shaders/bloomMerge.fragment";
  62814. /**
  62815. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62816. */
  62817. export class BloomMergePostProcess extends PostProcess {
  62818. /** Weight of the bloom to be added to the original input. */
  62819. weight: number;
  62820. /**
  62821. * Creates a new instance of @see BloomMergePostProcess
  62822. * @param name The name of the effect.
  62823. * @param originalFromInput Post process which's input will be used for the merge.
  62824. * @param blurred Blurred highlights post process which's output will be used.
  62825. * @param weight Weight of the bloom to be added to the original input.
  62826. * @param options The required width/height ratio to downsize to before computing the render pass.
  62827. * @param camera The camera to apply the render pass to.
  62828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62829. * @param engine The engine which the post process will be applied. (default: current engine)
  62830. * @param reusable If the post process can be reused on the same frame. (default: false)
  62831. * @param textureType Type of textures used when performing the post process. (default: 0)
  62832. * @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)
  62833. */
  62834. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62835. /** Weight of the bloom to be added to the original input. */
  62836. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62837. }
  62838. }
  62839. declare module "babylonjs/PostProcesses/bloomEffect" {
  62840. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62842. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62843. import { Camera } from "babylonjs/Cameras/camera";
  62844. import { Scene } from "babylonjs/scene";
  62845. /**
  62846. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62847. */
  62848. export class BloomEffect extends PostProcessRenderEffect {
  62849. private bloomScale;
  62850. /**
  62851. * @hidden Internal
  62852. */
  62853. _effects: Array<PostProcess>;
  62854. /**
  62855. * @hidden Internal
  62856. */
  62857. _downscale: ExtractHighlightsPostProcess;
  62858. private _blurX;
  62859. private _blurY;
  62860. private _merge;
  62861. /**
  62862. * The luminance threshold to find bright areas of the image to bloom.
  62863. */
  62864. threshold: number;
  62865. /**
  62866. * The strength of the bloom.
  62867. */
  62868. weight: number;
  62869. /**
  62870. * Specifies the size of the bloom blur kernel, relative to the final output size
  62871. */
  62872. kernel: number;
  62873. /**
  62874. * Creates a new instance of @see BloomEffect
  62875. * @param scene The scene the effect belongs to.
  62876. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62877. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62878. * @param bloomWeight The the strength of bloom.
  62879. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62880. * @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)
  62881. */
  62882. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62883. /**
  62884. * Disposes each of the internal effects for a given camera.
  62885. * @param camera The camera to dispose the effect on.
  62886. */
  62887. disposeEffects(camera: Camera): void;
  62888. /**
  62889. * @hidden Internal
  62890. */
  62891. _updateEffects(): void;
  62892. /**
  62893. * Internal
  62894. * @returns if all the contained post processes are ready.
  62895. * @hidden
  62896. */
  62897. _isReady(): boolean;
  62898. }
  62899. }
  62900. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62901. /** @hidden */
  62902. export var chromaticAberrationPixelShader: {
  62903. name: string;
  62904. shader: string;
  62905. };
  62906. }
  62907. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62908. import { Vector2 } from "babylonjs/Maths/math.vector";
  62909. import { Nullable } from "babylonjs/types";
  62910. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62911. import { Camera } from "babylonjs/Cameras/camera";
  62912. import { Engine } from "babylonjs/Engines/engine";
  62913. import "babylonjs/Shaders/chromaticAberration.fragment";
  62914. /**
  62915. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62916. */
  62917. export class ChromaticAberrationPostProcess extends PostProcess {
  62918. /**
  62919. * The amount of seperation of rgb channels (default: 30)
  62920. */
  62921. aberrationAmount: number;
  62922. /**
  62923. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62924. */
  62925. radialIntensity: number;
  62926. /**
  62927. * 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))
  62928. */
  62929. direction: Vector2;
  62930. /**
  62931. * 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))
  62932. */
  62933. centerPosition: Vector2;
  62934. /**
  62935. * Creates a new instance ChromaticAberrationPostProcess
  62936. * @param name The name of the effect.
  62937. * @param screenWidth The width of the screen to apply the effect on.
  62938. * @param screenHeight The height of the screen to apply the effect on.
  62939. * @param options The required width/height ratio to downsize to before computing the render pass.
  62940. * @param camera The camera to apply the render pass to.
  62941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62942. * @param engine The engine which the post process will be applied. (default: current engine)
  62943. * @param reusable If the post process can be reused on the same frame. (default: false)
  62944. * @param textureType Type of textures used when performing the post process. (default: 0)
  62945. * @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)
  62946. */
  62947. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62948. }
  62949. }
  62950. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62951. /** @hidden */
  62952. export var circleOfConfusionPixelShader: {
  62953. name: string;
  62954. shader: string;
  62955. };
  62956. }
  62957. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62958. import { Nullable } from "babylonjs/types";
  62959. import { Engine } from "babylonjs/Engines/engine";
  62960. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62961. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62962. import { Camera } from "babylonjs/Cameras/camera";
  62963. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62964. /**
  62965. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62966. */
  62967. export class CircleOfConfusionPostProcess extends PostProcess {
  62968. /**
  62969. * 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.
  62970. */
  62971. lensSize: number;
  62972. /**
  62973. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62974. */
  62975. fStop: number;
  62976. /**
  62977. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62978. */
  62979. focusDistance: number;
  62980. /**
  62981. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62982. */
  62983. focalLength: number;
  62984. private _depthTexture;
  62985. /**
  62986. * Creates a new instance CircleOfConfusionPostProcess
  62987. * @param name The name of the effect.
  62988. * @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.
  62989. * @param options The required width/height ratio to downsize to before computing the render pass.
  62990. * @param camera The camera to apply the render pass to.
  62991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62992. * @param engine The engine which the post process will be applied. (default: current engine)
  62993. * @param reusable If the post process can be reused on the same frame. (default: false)
  62994. * @param textureType Type of textures used when performing the post process. (default: 0)
  62995. * @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)
  62996. */
  62997. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62998. /**
  62999. * 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.
  63000. */
  63001. depthTexture: RenderTargetTexture;
  63002. }
  63003. }
  63004. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63005. /** @hidden */
  63006. export var colorCorrectionPixelShader: {
  63007. name: string;
  63008. shader: string;
  63009. };
  63010. }
  63011. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63012. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63013. import { Engine } from "babylonjs/Engines/engine";
  63014. import { Camera } from "babylonjs/Cameras/camera";
  63015. import "babylonjs/Shaders/colorCorrection.fragment";
  63016. /**
  63017. *
  63018. * This post-process allows the modification of rendered colors by using
  63019. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63020. *
  63021. * The object needs to be provided an url to a texture containing the color
  63022. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63023. * Use an image editing software to tweak the LUT to match your needs.
  63024. *
  63025. * For an example of a color LUT, see here:
  63026. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63027. * For explanations on color grading, see here:
  63028. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63029. *
  63030. */
  63031. export class ColorCorrectionPostProcess extends PostProcess {
  63032. private _colorTableTexture;
  63033. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63034. }
  63035. }
  63036. declare module "babylonjs/Shaders/convolution.fragment" {
  63037. /** @hidden */
  63038. export var convolutionPixelShader: {
  63039. name: string;
  63040. shader: string;
  63041. };
  63042. }
  63043. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63045. import { Nullable } from "babylonjs/types";
  63046. import { Camera } from "babylonjs/Cameras/camera";
  63047. import { Engine } from "babylonjs/Engines/engine";
  63048. import "babylonjs/Shaders/convolution.fragment";
  63049. /**
  63050. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63051. * input texture to perform effects such as edge detection or sharpening
  63052. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63053. */
  63054. export class ConvolutionPostProcess extends PostProcess {
  63055. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63056. kernel: number[];
  63057. /**
  63058. * Creates a new instance ConvolutionPostProcess
  63059. * @param name The name of the effect.
  63060. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63061. * @param options The required width/height ratio to downsize to before computing the render pass.
  63062. * @param camera The camera to apply the render pass to.
  63063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63064. * @param engine The engine which the post process will be applied. (default: current engine)
  63065. * @param reusable If the post process can be reused on the same frame. (default: false)
  63066. * @param textureType Type of textures used when performing the post process. (default: 0)
  63067. */
  63068. constructor(name: string,
  63069. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63070. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63071. /**
  63072. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63073. */
  63074. static EdgeDetect0Kernel: number[];
  63075. /**
  63076. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63077. */
  63078. static EdgeDetect1Kernel: number[];
  63079. /**
  63080. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63081. */
  63082. static EdgeDetect2Kernel: number[];
  63083. /**
  63084. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63085. */
  63086. static SharpenKernel: number[];
  63087. /**
  63088. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63089. */
  63090. static EmbossKernel: number[];
  63091. /**
  63092. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63093. */
  63094. static GaussianKernel: number[];
  63095. }
  63096. }
  63097. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63098. import { Nullable } from "babylonjs/types";
  63099. import { Vector2 } from "babylonjs/Maths/math.vector";
  63100. import { Camera } from "babylonjs/Cameras/camera";
  63101. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63102. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63103. import { Engine } from "babylonjs/Engines/engine";
  63104. import { Scene } from "babylonjs/scene";
  63105. /**
  63106. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63107. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63108. * based on samples that have a large difference in distance than the center pixel.
  63109. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63110. */
  63111. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63112. direction: Vector2;
  63113. /**
  63114. * Creates a new instance CircleOfConfusionPostProcess
  63115. * @param name The name of the effect.
  63116. * @param scene The scene the effect belongs to.
  63117. * @param direction The direction the blur should be applied.
  63118. * @param kernel The size of the kernel used to blur.
  63119. * @param options The required width/height ratio to downsize to before computing the render pass.
  63120. * @param camera The camera to apply the render pass to.
  63121. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63122. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63124. * @param engine The engine which the post process will be applied. (default: current engine)
  63125. * @param reusable If the post process can be reused on the same frame. (default: false)
  63126. * @param textureType Type of textures used when performing the post process. (default: 0)
  63127. * @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)
  63128. */
  63129. 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);
  63130. }
  63131. }
  63132. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63133. /** @hidden */
  63134. export var depthOfFieldMergePixelShader: {
  63135. name: string;
  63136. shader: string;
  63137. };
  63138. }
  63139. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63140. import { Nullable } from "babylonjs/types";
  63141. import { Camera } from "babylonjs/Cameras/camera";
  63142. import { Effect } from "babylonjs/Materials/effect";
  63143. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63144. import { Engine } from "babylonjs/Engines/engine";
  63145. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63146. /**
  63147. * Options to be set when merging outputs from the default pipeline.
  63148. */
  63149. export class DepthOfFieldMergePostProcessOptions {
  63150. /**
  63151. * The original image to merge on top of
  63152. */
  63153. originalFromInput: PostProcess;
  63154. /**
  63155. * Parameters to perform the merge of the depth of field effect
  63156. */
  63157. depthOfField?: {
  63158. circleOfConfusion: PostProcess;
  63159. blurSteps: Array<PostProcess>;
  63160. };
  63161. /**
  63162. * Parameters to perform the merge of bloom effect
  63163. */
  63164. bloom?: {
  63165. blurred: PostProcess;
  63166. weight: number;
  63167. };
  63168. }
  63169. /**
  63170. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63171. */
  63172. export class DepthOfFieldMergePostProcess extends PostProcess {
  63173. private blurSteps;
  63174. /**
  63175. * Creates a new instance of DepthOfFieldMergePostProcess
  63176. * @param name The name of the effect.
  63177. * @param originalFromInput Post process which's input will be used for the merge.
  63178. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63179. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63180. * @param options The required width/height ratio to downsize to before computing the render pass.
  63181. * @param camera The camera to apply the render pass to.
  63182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63183. * @param engine The engine which the post process will be applied. (default: current engine)
  63184. * @param reusable If the post process can be reused on the same frame. (default: false)
  63185. * @param textureType Type of textures used when performing the post process. (default: 0)
  63186. * @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)
  63187. */
  63188. 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);
  63189. /**
  63190. * Updates the effect with the current post process compile time values and recompiles the shader.
  63191. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63192. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63193. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63194. * @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
  63195. * @param onCompiled Called when the shader has been compiled.
  63196. * @param onError Called if there is an error when compiling a shader.
  63197. */
  63198. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63199. }
  63200. }
  63201. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63202. import { Nullable } from "babylonjs/types";
  63203. import { Camera } from "babylonjs/Cameras/camera";
  63204. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63205. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63206. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63207. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63208. import { Scene } from "babylonjs/scene";
  63209. /**
  63210. * Specifies the level of max blur that should be applied when using the depth of field effect
  63211. */
  63212. export enum DepthOfFieldEffectBlurLevel {
  63213. /**
  63214. * Subtle blur
  63215. */
  63216. Low = 0,
  63217. /**
  63218. * Medium blur
  63219. */
  63220. Medium = 1,
  63221. /**
  63222. * Large blur
  63223. */
  63224. High = 2
  63225. }
  63226. /**
  63227. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63228. */
  63229. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63230. private _circleOfConfusion;
  63231. /**
  63232. * @hidden Internal, blurs from high to low
  63233. */
  63234. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63235. private _depthOfFieldBlurY;
  63236. private _dofMerge;
  63237. /**
  63238. * @hidden Internal post processes in depth of field effect
  63239. */
  63240. _effects: Array<PostProcess>;
  63241. /**
  63242. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63243. */
  63244. focalLength: number;
  63245. /**
  63246. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63247. */
  63248. fStop: number;
  63249. /**
  63250. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63251. */
  63252. focusDistance: number;
  63253. /**
  63254. * 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.
  63255. */
  63256. lensSize: number;
  63257. /**
  63258. * Creates a new instance DepthOfFieldEffect
  63259. * @param scene The scene the effect belongs to.
  63260. * @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.
  63261. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63262. * @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)
  63263. */
  63264. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63265. /**
  63266. * Get the current class name of the current effet
  63267. * @returns "DepthOfFieldEffect"
  63268. */
  63269. getClassName(): string;
  63270. /**
  63271. * 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.
  63272. */
  63273. depthTexture: RenderTargetTexture;
  63274. /**
  63275. * Disposes each of the internal effects for a given camera.
  63276. * @param camera The camera to dispose the effect on.
  63277. */
  63278. disposeEffects(camera: Camera): void;
  63279. /**
  63280. * @hidden Internal
  63281. */
  63282. _updateEffects(): void;
  63283. /**
  63284. * Internal
  63285. * @returns if all the contained post processes are ready.
  63286. * @hidden
  63287. */
  63288. _isReady(): boolean;
  63289. }
  63290. }
  63291. declare module "babylonjs/Shaders/displayPass.fragment" {
  63292. /** @hidden */
  63293. export var displayPassPixelShader: {
  63294. name: string;
  63295. shader: string;
  63296. };
  63297. }
  63298. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  63299. import { Nullable } from "babylonjs/types";
  63300. import { Camera } from "babylonjs/Cameras/camera";
  63301. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63302. import { Engine } from "babylonjs/Engines/engine";
  63303. import "babylonjs/Shaders/displayPass.fragment";
  63304. /**
  63305. * DisplayPassPostProcess which produces an output the same as it's input
  63306. */
  63307. export class DisplayPassPostProcess extends PostProcess {
  63308. /**
  63309. * Creates the DisplayPassPostProcess
  63310. * @param name The name of the effect.
  63311. * @param options The required width/height ratio to downsize to before computing the render pass.
  63312. * @param camera The camera to apply the render pass to.
  63313. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63314. * @param engine The engine which the post process will be applied. (default: current engine)
  63315. * @param reusable If the post process can be reused on the same frame. (default: false)
  63316. */
  63317. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63318. }
  63319. }
  63320. declare module "babylonjs/Shaders/filter.fragment" {
  63321. /** @hidden */
  63322. export var filterPixelShader: {
  63323. name: string;
  63324. shader: string;
  63325. };
  63326. }
  63327. declare module "babylonjs/PostProcesses/filterPostProcess" {
  63328. import { Nullable } from "babylonjs/types";
  63329. import { Matrix } from "babylonjs/Maths/math.vector";
  63330. import { Camera } from "babylonjs/Cameras/camera";
  63331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63332. import { Engine } from "babylonjs/Engines/engine";
  63333. import "babylonjs/Shaders/filter.fragment";
  63334. /**
  63335. * Applies a kernel filter to the image
  63336. */
  63337. export class FilterPostProcess extends PostProcess {
  63338. /** The matrix to be applied to the image */
  63339. kernelMatrix: Matrix;
  63340. /**
  63341. *
  63342. * @param name The name of the effect.
  63343. * @param kernelMatrix The matrix to be applied to the image
  63344. * @param options The required width/height ratio to downsize to before computing the render pass.
  63345. * @param camera The camera to apply the render pass to.
  63346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63347. * @param engine The engine which the post process will be applied. (default: current engine)
  63348. * @param reusable If the post process can be reused on the same frame. (default: false)
  63349. */
  63350. constructor(name: string,
  63351. /** The matrix to be applied to the image */
  63352. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63353. }
  63354. }
  63355. declare module "babylonjs/Shaders/fxaa.fragment" {
  63356. /** @hidden */
  63357. export var fxaaPixelShader: {
  63358. name: string;
  63359. shader: string;
  63360. };
  63361. }
  63362. declare module "babylonjs/Shaders/fxaa.vertex" {
  63363. /** @hidden */
  63364. export var fxaaVertexShader: {
  63365. name: string;
  63366. shader: string;
  63367. };
  63368. }
  63369. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  63370. import { Nullable } from "babylonjs/types";
  63371. import { Camera } from "babylonjs/Cameras/camera";
  63372. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63373. import { Engine } from "babylonjs/Engines/engine";
  63374. import "babylonjs/Shaders/fxaa.fragment";
  63375. import "babylonjs/Shaders/fxaa.vertex";
  63376. /**
  63377. * Fxaa post process
  63378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  63379. */
  63380. export class FxaaPostProcess extends PostProcess {
  63381. /** @hidden */
  63382. texelWidth: number;
  63383. /** @hidden */
  63384. texelHeight: number;
  63385. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63386. private _getDefines;
  63387. }
  63388. }
  63389. declare module "babylonjs/Shaders/grain.fragment" {
  63390. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63391. /** @hidden */
  63392. export var grainPixelShader: {
  63393. name: string;
  63394. shader: string;
  63395. };
  63396. }
  63397. declare module "babylonjs/PostProcesses/grainPostProcess" {
  63398. import { Nullable } from "babylonjs/types";
  63399. import { Camera } from "babylonjs/Cameras/camera";
  63400. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63401. import { Engine } from "babylonjs/Engines/engine";
  63402. import "babylonjs/Shaders/grain.fragment";
  63403. /**
  63404. * The GrainPostProcess adds noise to the image at mid luminance levels
  63405. */
  63406. export class GrainPostProcess extends PostProcess {
  63407. /**
  63408. * The intensity of the grain added (default: 30)
  63409. */
  63410. intensity: number;
  63411. /**
  63412. * If the grain should be randomized on every frame
  63413. */
  63414. animated: boolean;
  63415. /**
  63416. * Creates a new instance of @see GrainPostProcess
  63417. * @param name The name of the effect.
  63418. * @param options The required width/height ratio to downsize to before computing the render pass.
  63419. * @param camera The camera to apply the render pass to.
  63420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63421. * @param engine The engine which the post process will be applied. (default: current engine)
  63422. * @param reusable If the post process can be reused on the same frame. (default: false)
  63423. * @param textureType Type of textures used when performing the post process. (default: 0)
  63424. * @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)
  63425. */
  63426. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63427. }
  63428. }
  63429. declare module "babylonjs/Shaders/highlights.fragment" {
  63430. /** @hidden */
  63431. export var highlightsPixelShader: {
  63432. name: string;
  63433. shader: string;
  63434. };
  63435. }
  63436. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  63437. import { Nullable } from "babylonjs/types";
  63438. import { Camera } from "babylonjs/Cameras/camera";
  63439. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63440. import { Engine } from "babylonjs/Engines/engine";
  63441. import "babylonjs/Shaders/highlights.fragment";
  63442. /**
  63443. * Extracts highlights from the image
  63444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63445. */
  63446. export class HighlightsPostProcess extends PostProcess {
  63447. /**
  63448. * Extracts highlights from the image
  63449. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  63450. * @param name The name of the effect.
  63451. * @param options The required width/height ratio to downsize to before computing the render pass.
  63452. * @param camera The camera to apply the render pass to.
  63453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63454. * @param engine The engine which the post process will be applied. (default: current engine)
  63455. * @param reusable If the post process can be reused on the same frame. (default: false)
  63456. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  63457. */
  63458. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63459. }
  63460. }
  63461. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  63462. /** @hidden */
  63463. export var mrtFragmentDeclaration: {
  63464. name: string;
  63465. shader: string;
  63466. };
  63467. }
  63468. declare module "babylonjs/Shaders/geometry.fragment" {
  63469. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  63470. /** @hidden */
  63471. export var geometryPixelShader: {
  63472. name: string;
  63473. shader: string;
  63474. };
  63475. }
  63476. declare module "babylonjs/Shaders/geometry.vertex" {
  63477. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63478. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63479. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63480. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63481. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63482. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63483. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63484. /** @hidden */
  63485. export var geometryVertexShader: {
  63486. name: string;
  63487. shader: string;
  63488. };
  63489. }
  63490. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  63491. import { Matrix } from "babylonjs/Maths/math.vector";
  63492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63493. import { Mesh } from "babylonjs/Meshes/mesh";
  63494. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  63495. import { Effect } from "babylonjs/Materials/effect";
  63496. import { Scene } from "babylonjs/scene";
  63497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63498. import "babylonjs/Shaders/geometry.fragment";
  63499. import "babylonjs/Shaders/geometry.vertex";
  63500. /** @hidden */
  63501. interface ISavedTransformationMatrix {
  63502. world: Matrix;
  63503. viewProjection: Matrix;
  63504. }
  63505. /**
  63506. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  63507. */
  63508. export class GeometryBufferRenderer {
  63509. /**
  63510. * Constant used to retrieve the position texture index in the G-Buffer textures array
  63511. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  63512. */
  63513. static readonly POSITION_TEXTURE_TYPE: number;
  63514. /**
  63515. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  63516. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  63517. */
  63518. static readonly VELOCITY_TEXTURE_TYPE: number;
  63519. /**
  63520. * Dictionary used to store the previous transformation matrices of each rendered mesh
  63521. * in order to compute objects velocities when enableVelocity is set to "true"
  63522. * @hidden
  63523. */
  63524. _previousTransformationMatrices: {
  63525. [index: number]: ISavedTransformationMatrix;
  63526. };
  63527. /**
  63528. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  63529. * in order to compute objects velocities when enableVelocity is set to "true"
  63530. * @hidden
  63531. */
  63532. _previousBonesTransformationMatrices: {
  63533. [index: number]: Float32Array;
  63534. };
  63535. /**
  63536. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  63537. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  63538. */
  63539. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  63540. private _scene;
  63541. private _multiRenderTarget;
  63542. private _ratio;
  63543. private _enablePosition;
  63544. private _enableVelocity;
  63545. private _positionIndex;
  63546. private _velocityIndex;
  63547. protected _effect: Effect;
  63548. protected _cachedDefines: string;
  63549. /**
  63550. * Set the render list (meshes to be rendered) used in the G buffer.
  63551. */
  63552. renderList: Mesh[];
  63553. /**
  63554. * Gets wether or not G buffer are supported by the running hardware.
  63555. * This requires draw buffer supports
  63556. */
  63557. readonly isSupported: boolean;
  63558. /**
  63559. * Returns the index of the given texture type in the G-Buffer textures array
  63560. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  63561. * @returns the index of the given texture type in the G-Buffer textures array
  63562. */
  63563. getTextureIndex(textureType: number): number;
  63564. /**
  63565. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  63566. */
  63567. /**
  63568. * Sets whether or not objects positions are enabled for the G buffer.
  63569. */
  63570. enablePosition: boolean;
  63571. /**
  63572. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  63573. */
  63574. /**
  63575. * Sets wether or not objects velocities are enabled for the G buffer.
  63576. */
  63577. enableVelocity: boolean;
  63578. /**
  63579. * Gets the scene associated with the buffer.
  63580. */
  63581. readonly scene: Scene;
  63582. /**
  63583. * Gets the ratio used by the buffer during its creation.
  63584. * How big is the buffer related to the main canvas.
  63585. */
  63586. readonly ratio: number;
  63587. /** @hidden */
  63588. static _SceneComponentInitialization: (scene: Scene) => void;
  63589. /**
  63590. * Creates a new G Buffer for the scene
  63591. * @param scene The scene the buffer belongs to
  63592. * @param ratio How big is the buffer related to the main canvas.
  63593. */
  63594. constructor(scene: Scene, ratio?: number);
  63595. /**
  63596. * Checks wether everything is ready to render a submesh to the G buffer.
  63597. * @param subMesh the submesh to check readiness for
  63598. * @param useInstances is the mesh drawn using instance or not
  63599. * @returns true if ready otherwise false
  63600. */
  63601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63602. /**
  63603. * Gets the current underlying G Buffer.
  63604. * @returns the buffer
  63605. */
  63606. getGBuffer(): MultiRenderTarget;
  63607. /**
  63608. * Gets the number of samples used to render the buffer (anti aliasing).
  63609. */
  63610. /**
  63611. * Sets the number of samples used to render the buffer (anti aliasing).
  63612. */
  63613. samples: number;
  63614. /**
  63615. * Disposes the renderer and frees up associated resources.
  63616. */
  63617. dispose(): void;
  63618. protected _createRenderTargets(): void;
  63619. private _copyBonesTransformationMatrices;
  63620. }
  63621. }
  63622. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  63623. import { Nullable } from "babylonjs/types";
  63624. import { Scene } from "babylonjs/scene";
  63625. import { ISceneComponent } from "babylonjs/sceneComponent";
  63626. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  63627. module "babylonjs/scene" {
  63628. interface Scene {
  63629. /** @hidden (Backing field) */
  63630. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63631. /**
  63632. * Gets or Sets the current geometry buffer associated to the scene.
  63633. */
  63634. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  63635. /**
  63636. * Enables a GeometryBufferRender and associates it with the scene
  63637. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  63638. * @returns the GeometryBufferRenderer
  63639. */
  63640. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  63641. /**
  63642. * Disables the GeometryBufferRender associated with the scene
  63643. */
  63644. disableGeometryBufferRenderer(): void;
  63645. }
  63646. }
  63647. /**
  63648. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  63649. * in several rendering techniques.
  63650. */
  63651. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  63652. /**
  63653. * The component name helpful to identify the component in the list of scene components.
  63654. */
  63655. readonly name: string;
  63656. /**
  63657. * The scene the component belongs to.
  63658. */
  63659. scene: Scene;
  63660. /**
  63661. * Creates a new instance of the component for the given scene
  63662. * @param scene Defines the scene to register the component in
  63663. */
  63664. constructor(scene: Scene);
  63665. /**
  63666. * Registers the component in a given scene
  63667. */
  63668. register(): void;
  63669. /**
  63670. * Rebuilds the elements related to this component in case of
  63671. * context lost for instance.
  63672. */
  63673. rebuild(): void;
  63674. /**
  63675. * Disposes the component and the associated ressources
  63676. */
  63677. dispose(): void;
  63678. private _gatherRenderTargets;
  63679. }
  63680. }
  63681. declare module "babylonjs/Shaders/motionBlur.fragment" {
  63682. /** @hidden */
  63683. export var motionBlurPixelShader: {
  63684. name: string;
  63685. shader: string;
  63686. };
  63687. }
  63688. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  63689. import { Nullable } from "babylonjs/types";
  63690. import { Camera } from "babylonjs/Cameras/camera";
  63691. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63692. import { Scene } from "babylonjs/scene";
  63693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63694. import "babylonjs/Animations/animatable";
  63695. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63696. import "babylonjs/Shaders/motionBlur.fragment";
  63697. import { Engine } from "babylonjs/Engines/engine";
  63698. /**
  63699. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  63700. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  63701. * As an example, all you have to do is to create the post-process:
  63702. * var mb = new BABYLON.MotionBlurPostProcess(
  63703. * 'mb', // The name of the effect.
  63704. * scene, // The scene containing the objects to blur according to their velocity.
  63705. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  63706. * camera // The camera to apply the render pass to.
  63707. * );
  63708. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  63709. */
  63710. export class MotionBlurPostProcess extends PostProcess {
  63711. /**
  63712. * Defines how much the image is blurred by the movement. Default value is equal to 1
  63713. */
  63714. motionStrength: number;
  63715. /**
  63716. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  63717. */
  63718. /**
  63719. * Sets the number of iterations to be used for motion blur quality
  63720. */
  63721. motionBlurSamples: number;
  63722. private _motionBlurSamples;
  63723. private _geometryBufferRenderer;
  63724. /**
  63725. * Creates a new instance MotionBlurPostProcess
  63726. * @param name The name of the effect.
  63727. * @param scene The scene containing the objects to blur according to their velocity.
  63728. * @param options The required width/height ratio to downsize to before computing the render pass.
  63729. * @param camera The camera to apply the render pass to.
  63730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63731. * @param engine The engine which the post process will be applied. (default: current engine)
  63732. * @param reusable If the post process can be reused on the same frame. (default: false)
  63733. * @param textureType Type of textures used when performing the post process. (default: 0)
  63734. * @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)
  63735. */
  63736. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63737. /**
  63738. * Excludes the given skinned mesh from computing bones velocities.
  63739. * 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.
  63740. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  63741. */
  63742. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63743. /**
  63744. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  63745. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  63746. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  63747. */
  63748. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  63749. /**
  63750. * Disposes the post process.
  63751. * @param camera The camera to dispose the post process on.
  63752. */
  63753. dispose(camera?: Camera): void;
  63754. }
  63755. }
  63756. declare module "babylonjs/Shaders/refraction.fragment" {
  63757. /** @hidden */
  63758. export var refractionPixelShader: {
  63759. name: string;
  63760. shader: string;
  63761. };
  63762. }
  63763. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  63764. import { Color3 } from "babylonjs/Maths/math.color";
  63765. import { Camera } from "babylonjs/Cameras/camera";
  63766. import { Texture } from "babylonjs/Materials/Textures/texture";
  63767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63768. import { Engine } from "babylonjs/Engines/engine";
  63769. import "babylonjs/Shaders/refraction.fragment";
  63770. /**
  63771. * Post process which applies a refractin texture
  63772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63773. */
  63774. export class RefractionPostProcess extends PostProcess {
  63775. /** the base color of the refraction (used to taint the rendering) */
  63776. color: Color3;
  63777. /** simulated refraction depth */
  63778. depth: number;
  63779. /** the coefficient of the base color (0 to remove base color tainting) */
  63780. colorLevel: number;
  63781. private _refTexture;
  63782. private _ownRefractionTexture;
  63783. /**
  63784. * Gets or sets the refraction texture
  63785. * Please note that you are responsible for disposing the texture if you set it manually
  63786. */
  63787. refractionTexture: Texture;
  63788. /**
  63789. * Initializes the RefractionPostProcess
  63790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63791. * @param name The name of the effect.
  63792. * @param refractionTextureUrl Url of the refraction texture to use
  63793. * @param color the base color of the refraction (used to taint the rendering)
  63794. * @param depth simulated refraction depth
  63795. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63796. * @param camera The camera to apply the render pass to.
  63797. * @param options The required width/height ratio to downsize to before computing the render pass.
  63798. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63799. * @param engine The engine which the post process will be applied. (default: current engine)
  63800. * @param reusable If the post process can be reused on the same frame. (default: false)
  63801. */
  63802. constructor(name: string, refractionTextureUrl: string,
  63803. /** the base color of the refraction (used to taint the rendering) */
  63804. color: Color3,
  63805. /** simulated refraction depth */
  63806. depth: number,
  63807. /** the coefficient of the base color (0 to remove base color tainting) */
  63808. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63809. /**
  63810. * Disposes of the post process
  63811. * @param camera Camera to dispose post process on
  63812. */
  63813. dispose(camera: Camera): void;
  63814. }
  63815. }
  63816. declare module "babylonjs/Shaders/sharpen.fragment" {
  63817. /** @hidden */
  63818. export var sharpenPixelShader: {
  63819. name: string;
  63820. shader: string;
  63821. };
  63822. }
  63823. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63824. import { Nullable } from "babylonjs/types";
  63825. import { Camera } from "babylonjs/Cameras/camera";
  63826. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63827. import "babylonjs/Shaders/sharpen.fragment";
  63828. import { Engine } from "babylonjs/Engines/engine";
  63829. /**
  63830. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63831. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63832. */
  63833. export class SharpenPostProcess extends PostProcess {
  63834. /**
  63835. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63836. */
  63837. colorAmount: number;
  63838. /**
  63839. * How much sharpness should be applied (default: 0.3)
  63840. */
  63841. edgeAmount: number;
  63842. /**
  63843. * Creates a new instance ConvolutionPostProcess
  63844. * @param name The name of the effect.
  63845. * @param options The required width/height ratio to downsize to before computing the render pass.
  63846. * @param camera The camera to apply the render pass to.
  63847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63848. * @param engine The engine which the post process will be applied. (default: current engine)
  63849. * @param reusable If the post process can be reused on the same frame. (default: false)
  63850. * @param textureType Type of textures used when performing the post process. (default: 0)
  63851. * @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)
  63852. */
  63853. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63854. }
  63855. }
  63856. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63857. import { Nullable } from "babylonjs/types";
  63858. import { Camera } from "babylonjs/Cameras/camera";
  63859. import { Engine } from "babylonjs/Engines/engine";
  63860. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63861. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63862. /**
  63863. * PostProcessRenderPipeline
  63864. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63865. */
  63866. export class PostProcessRenderPipeline {
  63867. private engine;
  63868. private _renderEffects;
  63869. private _renderEffectsForIsolatedPass;
  63870. /**
  63871. * List of inspectable custom properties (used by the Inspector)
  63872. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63873. */
  63874. inspectableCustomProperties: IInspectable[];
  63875. /**
  63876. * @hidden
  63877. */
  63878. protected _cameras: Camera[];
  63879. /** @hidden */
  63880. _name: string;
  63881. /**
  63882. * Gets pipeline name
  63883. */
  63884. readonly name: string;
  63885. /**
  63886. * Initializes a PostProcessRenderPipeline
  63887. * @param engine engine to add the pipeline to
  63888. * @param name name of the pipeline
  63889. */
  63890. constructor(engine: Engine, name: string);
  63891. /**
  63892. * Gets the class name
  63893. * @returns "PostProcessRenderPipeline"
  63894. */
  63895. getClassName(): string;
  63896. /**
  63897. * If all the render effects in the pipeline are supported
  63898. */
  63899. readonly isSupported: boolean;
  63900. /**
  63901. * Adds an effect to the pipeline
  63902. * @param renderEffect the effect to add
  63903. */
  63904. addEffect(renderEffect: PostProcessRenderEffect): void;
  63905. /** @hidden */
  63906. _rebuild(): void;
  63907. /** @hidden */
  63908. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63909. /** @hidden */
  63910. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63911. /** @hidden */
  63912. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63913. /** @hidden */
  63914. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63915. /** @hidden */
  63916. _attachCameras(cameras: Camera, unique: boolean): void;
  63917. /** @hidden */
  63918. _attachCameras(cameras: Camera[], unique: boolean): void;
  63919. /** @hidden */
  63920. _detachCameras(cameras: Camera): void;
  63921. /** @hidden */
  63922. _detachCameras(cameras: Nullable<Camera[]>): void;
  63923. /** @hidden */
  63924. _update(): void;
  63925. /** @hidden */
  63926. _reset(): void;
  63927. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63928. /**
  63929. * Disposes of the pipeline
  63930. */
  63931. dispose(): void;
  63932. }
  63933. }
  63934. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63935. import { Camera } from "babylonjs/Cameras/camera";
  63936. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63937. /**
  63938. * PostProcessRenderPipelineManager class
  63939. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63940. */
  63941. export class PostProcessRenderPipelineManager {
  63942. private _renderPipelines;
  63943. /**
  63944. * Initializes a PostProcessRenderPipelineManager
  63945. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63946. */
  63947. constructor();
  63948. /**
  63949. * Gets the list of supported render pipelines
  63950. */
  63951. readonly supportedPipelines: PostProcessRenderPipeline[];
  63952. /**
  63953. * Adds a pipeline to the manager
  63954. * @param renderPipeline The pipeline to add
  63955. */
  63956. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63957. /**
  63958. * Attaches a camera to the pipeline
  63959. * @param renderPipelineName The name of the pipeline to attach to
  63960. * @param cameras the camera to attach
  63961. * @param unique if the camera can be attached multiple times to the pipeline
  63962. */
  63963. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63964. /**
  63965. * Detaches a camera from the pipeline
  63966. * @param renderPipelineName The name of the pipeline to detach from
  63967. * @param cameras the camera to detach
  63968. */
  63969. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63970. /**
  63971. * Enables an effect by name on a pipeline
  63972. * @param renderPipelineName the name of the pipeline to enable the effect in
  63973. * @param renderEffectName the name of the effect to enable
  63974. * @param cameras the cameras that the effect should be enabled on
  63975. */
  63976. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63977. /**
  63978. * Disables an effect by name on a pipeline
  63979. * @param renderPipelineName the name of the pipeline to disable the effect in
  63980. * @param renderEffectName the name of the effect to disable
  63981. * @param cameras the cameras that the effect should be disabled on
  63982. */
  63983. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63984. /**
  63985. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63986. */
  63987. update(): void;
  63988. /** @hidden */
  63989. _rebuild(): void;
  63990. /**
  63991. * Disposes of the manager and pipelines
  63992. */
  63993. dispose(): void;
  63994. }
  63995. }
  63996. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63997. import { ISceneComponent } from "babylonjs/sceneComponent";
  63998. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63999. import { Scene } from "babylonjs/scene";
  64000. module "babylonjs/scene" {
  64001. interface Scene {
  64002. /** @hidden (Backing field) */
  64003. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64004. /**
  64005. * Gets the postprocess render pipeline manager
  64006. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64007. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64008. */
  64009. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64010. }
  64011. }
  64012. /**
  64013. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64014. */
  64015. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64016. /**
  64017. * The component name helpfull to identify the component in the list of scene components.
  64018. */
  64019. readonly name: string;
  64020. /**
  64021. * The scene the component belongs to.
  64022. */
  64023. scene: Scene;
  64024. /**
  64025. * Creates a new instance of the component for the given scene
  64026. * @param scene Defines the scene to register the component in
  64027. */
  64028. constructor(scene: Scene);
  64029. /**
  64030. * Registers the component in a given scene
  64031. */
  64032. register(): void;
  64033. /**
  64034. * Rebuilds the elements related to this component in case of
  64035. * context lost for instance.
  64036. */
  64037. rebuild(): void;
  64038. /**
  64039. * Disposes the component and the associated ressources
  64040. */
  64041. dispose(): void;
  64042. private _gatherRenderTargets;
  64043. }
  64044. }
  64045. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64046. import { Nullable } from "babylonjs/types";
  64047. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64048. import { Camera } from "babylonjs/Cameras/camera";
  64049. import { IDisposable } from "babylonjs/scene";
  64050. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64051. import { Scene } from "babylonjs/scene";
  64052. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64053. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64054. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64055. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64056. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64057. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64058. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64059. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64060. import { Animation } from "babylonjs/Animations/animation";
  64061. /**
  64062. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64063. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64064. */
  64065. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64066. private _scene;
  64067. private _camerasToBeAttached;
  64068. /**
  64069. * ID of the sharpen post process,
  64070. */
  64071. private readonly SharpenPostProcessId;
  64072. /**
  64073. * @ignore
  64074. * ID of the image processing post process;
  64075. */
  64076. readonly ImageProcessingPostProcessId: string;
  64077. /**
  64078. * @ignore
  64079. * ID of the Fast Approximate Anti-Aliasing post process;
  64080. */
  64081. readonly FxaaPostProcessId: string;
  64082. /**
  64083. * ID of the chromatic aberration post process,
  64084. */
  64085. private readonly ChromaticAberrationPostProcessId;
  64086. /**
  64087. * ID of the grain post process
  64088. */
  64089. private readonly GrainPostProcessId;
  64090. /**
  64091. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64092. */
  64093. sharpen: SharpenPostProcess;
  64094. private _sharpenEffect;
  64095. private bloom;
  64096. /**
  64097. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64098. */
  64099. depthOfField: DepthOfFieldEffect;
  64100. /**
  64101. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64102. */
  64103. fxaa: FxaaPostProcess;
  64104. /**
  64105. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64106. */
  64107. imageProcessing: ImageProcessingPostProcess;
  64108. /**
  64109. * Chromatic aberration post process which will shift rgb colors in the image
  64110. */
  64111. chromaticAberration: ChromaticAberrationPostProcess;
  64112. private _chromaticAberrationEffect;
  64113. /**
  64114. * Grain post process which add noise to the image
  64115. */
  64116. grain: GrainPostProcess;
  64117. private _grainEffect;
  64118. /**
  64119. * Glow post process which adds a glow to emissive areas of the image
  64120. */
  64121. private _glowLayer;
  64122. /**
  64123. * Animations which can be used to tweak settings over a period of time
  64124. */
  64125. animations: Animation[];
  64126. private _imageProcessingConfigurationObserver;
  64127. private _sharpenEnabled;
  64128. private _bloomEnabled;
  64129. private _depthOfFieldEnabled;
  64130. private _depthOfFieldBlurLevel;
  64131. private _fxaaEnabled;
  64132. private _imageProcessingEnabled;
  64133. private _defaultPipelineTextureType;
  64134. private _bloomScale;
  64135. private _chromaticAberrationEnabled;
  64136. private _grainEnabled;
  64137. private _buildAllowed;
  64138. /**
  64139. * Gets active scene
  64140. */
  64141. readonly scene: Scene;
  64142. /**
  64143. * Enable or disable the sharpen process from the pipeline
  64144. */
  64145. sharpenEnabled: boolean;
  64146. private _resizeObserver;
  64147. private _hardwareScaleLevel;
  64148. private _bloomKernel;
  64149. /**
  64150. * Specifies the size of the bloom blur kernel, relative to the final output size
  64151. */
  64152. bloomKernel: number;
  64153. /**
  64154. * Specifies the weight of the bloom in the final rendering
  64155. */
  64156. private _bloomWeight;
  64157. /**
  64158. * Specifies the luma threshold for the area that will be blurred by the bloom
  64159. */
  64160. private _bloomThreshold;
  64161. private _hdr;
  64162. /**
  64163. * The strength of the bloom.
  64164. */
  64165. bloomWeight: number;
  64166. /**
  64167. * The strength of the bloom.
  64168. */
  64169. bloomThreshold: number;
  64170. /**
  64171. * The scale of the bloom, lower value will provide better performance.
  64172. */
  64173. bloomScale: number;
  64174. /**
  64175. * Enable or disable the bloom from the pipeline
  64176. */
  64177. bloomEnabled: boolean;
  64178. private _rebuildBloom;
  64179. /**
  64180. * If the depth of field is enabled.
  64181. */
  64182. depthOfFieldEnabled: boolean;
  64183. /**
  64184. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64185. */
  64186. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64187. /**
  64188. * If the anti aliasing is enabled.
  64189. */
  64190. fxaaEnabled: boolean;
  64191. private _samples;
  64192. /**
  64193. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64194. */
  64195. samples: number;
  64196. /**
  64197. * If image processing is enabled.
  64198. */
  64199. imageProcessingEnabled: boolean;
  64200. /**
  64201. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64202. */
  64203. glowLayerEnabled: boolean;
  64204. /**
  64205. * Gets the glow layer (or null if not defined)
  64206. */
  64207. readonly glowLayer: Nullable<GlowLayer>;
  64208. /**
  64209. * Enable or disable the chromaticAberration process from the pipeline
  64210. */
  64211. chromaticAberrationEnabled: boolean;
  64212. /**
  64213. * Enable or disable the grain process from the pipeline
  64214. */
  64215. grainEnabled: boolean;
  64216. /**
  64217. * @constructor
  64218. * @param name - The rendering pipeline name (default: "")
  64219. * @param hdr - If high dynamic range textures should be used (default: true)
  64220. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64221. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64222. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64223. */
  64224. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64225. /**
  64226. * Get the class name
  64227. * @returns "DefaultRenderingPipeline"
  64228. */
  64229. getClassName(): string;
  64230. /**
  64231. * Force the compilation of the entire pipeline.
  64232. */
  64233. prepare(): void;
  64234. private _hasCleared;
  64235. private _prevPostProcess;
  64236. private _prevPrevPostProcess;
  64237. private _setAutoClearAndTextureSharing;
  64238. private _depthOfFieldSceneObserver;
  64239. private _buildPipeline;
  64240. private _disposePostProcesses;
  64241. /**
  64242. * Adds a camera to the pipeline
  64243. * @param camera the camera to be added
  64244. */
  64245. addCamera(camera: Camera): void;
  64246. /**
  64247. * Removes a camera from the pipeline
  64248. * @param camera the camera to remove
  64249. */
  64250. removeCamera(camera: Camera): void;
  64251. /**
  64252. * Dispose of the pipeline and stop all post processes
  64253. */
  64254. dispose(): void;
  64255. /**
  64256. * Serialize the rendering pipeline (Used when exporting)
  64257. * @returns the serialized object
  64258. */
  64259. serialize(): any;
  64260. /**
  64261. * Parse the serialized pipeline
  64262. * @param source Source pipeline.
  64263. * @param scene The scene to load the pipeline to.
  64264. * @param rootUrl The URL of the serialized pipeline.
  64265. * @returns An instantiated pipeline from the serialized object.
  64266. */
  64267. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64268. }
  64269. }
  64270. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64271. /** @hidden */
  64272. export var lensHighlightsPixelShader: {
  64273. name: string;
  64274. shader: string;
  64275. };
  64276. }
  64277. declare module "babylonjs/Shaders/depthOfField.fragment" {
  64278. /** @hidden */
  64279. export var depthOfFieldPixelShader: {
  64280. name: string;
  64281. shader: string;
  64282. };
  64283. }
  64284. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  64285. import { Camera } from "babylonjs/Cameras/camera";
  64286. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64287. import { Scene } from "babylonjs/scene";
  64288. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64289. import "babylonjs/Shaders/chromaticAberration.fragment";
  64290. import "babylonjs/Shaders/lensHighlights.fragment";
  64291. import "babylonjs/Shaders/depthOfField.fragment";
  64292. /**
  64293. * BABYLON.JS Chromatic Aberration GLSL Shader
  64294. * Author: Olivier Guyot
  64295. * Separates very slightly R, G and B colors on the edges of the screen
  64296. * Inspired by Francois Tarlier & Martins Upitis
  64297. */
  64298. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  64299. /**
  64300. * @ignore
  64301. * The chromatic aberration PostProcess id in the pipeline
  64302. */
  64303. LensChromaticAberrationEffect: string;
  64304. /**
  64305. * @ignore
  64306. * The highlights enhancing PostProcess id in the pipeline
  64307. */
  64308. HighlightsEnhancingEffect: string;
  64309. /**
  64310. * @ignore
  64311. * The depth-of-field PostProcess id in the pipeline
  64312. */
  64313. LensDepthOfFieldEffect: string;
  64314. private _scene;
  64315. private _depthTexture;
  64316. private _grainTexture;
  64317. private _chromaticAberrationPostProcess;
  64318. private _highlightsPostProcess;
  64319. private _depthOfFieldPostProcess;
  64320. private _edgeBlur;
  64321. private _grainAmount;
  64322. private _chromaticAberration;
  64323. private _distortion;
  64324. private _highlightsGain;
  64325. private _highlightsThreshold;
  64326. private _dofDistance;
  64327. private _dofAperture;
  64328. private _dofDarken;
  64329. private _dofPentagon;
  64330. private _blurNoise;
  64331. /**
  64332. * @constructor
  64333. *
  64334. * Effect parameters are as follow:
  64335. * {
  64336. * chromatic_aberration: number; // from 0 to x (1 for realism)
  64337. * edge_blur: number; // from 0 to x (1 for realism)
  64338. * distortion: number; // from 0 to x (1 for realism)
  64339. * grain_amount: number; // from 0 to 1
  64340. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  64341. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  64342. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  64343. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  64344. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  64345. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  64346. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  64347. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  64348. * }
  64349. * Note: if an effect parameter is unset, effect is disabled
  64350. *
  64351. * @param name The rendering pipeline name
  64352. * @param parameters - An object containing all parameters (see above)
  64353. * @param scene The scene linked to this pipeline
  64354. * @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)
  64355. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64356. */
  64357. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  64358. /**
  64359. * Get the class name
  64360. * @returns "LensRenderingPipeline"
  64361. */
  64362. getClassName(): string;
  64363. /**
  64364. * Gets associated scene
  64365. */
  64366. readonly scene: Scene;
  64367. /**
  64368. * Gets or sets the edge blur
  64369. */
  64370. edgeBlur: number;
  64371. /**
  64372. * Gets or sets the grain amount
  64373. */
  64374. grainAmount: number;
  64375. /**
  64376. * Gets or sets the chromatic aberration amount
  64377. */
  64378. chromaticAberration: number;
  64379. /**
  64380. * Gets or sets the depth of field aperture
  64381. */
  64382. dofAperture: number;
  64383. /**
  64384. * Gets or sets the edge distortion
  64385. */
  64386. edgeDistortion: number;
  64387. /**
  64388. * Gets or sets the depth of field distortion
  64389. */
  64390. dofDistortion: number;
  64391. /**
  64392. * Gets or sets the darken out of focus amount
  64393. */
  64394. darkenOutOfFocus: number;
  64395. /**
  64396. * Gets or sets a boolean indicating if blur noise is enabled
  64397. */
  64398. blurNoise: boolean;
  64399. /**
  64400. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  64401. */
  64402. pentagonBokeh: boolean;
  64403. /**
  64404. * Gets or sets the highlight grain amount
  64405. */
  64406. highlightsGain: number;
  64407. /**
  64408. * Gets or sets the highlight threshold
  64409. */
  64410. highlightsThreshold: number;
  64411. /**
  64412. * Sets the amount of blur at the edges
  64413. * @param amount blur amount
  64414. */
  64415. setEdgeBlur(amount: number): void;
  64416. /**
  64417. * Sets edge blur to 0
  64418. */
  64419. disableEdgeBlur(): void;
  64420. /**
  64421. * Sets the amout of grain
  64422. * @param amount Amount of grain
  64423. */
  64424. setGrainAmount(amount: number): void;
  64425. /**
  64426. * Set grain amount to 0
  64427. */
  64428. disableGrain(): void;
  64429. /**
  64430. * Sets the chromatic aberration amount
  64431. * @param amount amount of chromatic aberration
  64432. */
  64433. setChromaticAberration(amount: number): void;
  64434. /**
  64435. * Sets chromatic aberration amount to 0
  64436. */
  64437. disableChromaticAberration(): void;
  64438. /**
  64439. * Sets the EdgeDistortion amount
  64440. * @param amount amount of EdgeDistortion
  64441. */
  64442. setEdgeDistortion(amount: number): void;
  64443. /**
  64444. * Sets edge distortion to 0
  64445. */
  64446. disableEdgeDistortion(): void;
  64447. /**
  64448. * Sets the FocusDistance amount
  64449. * @param amount amount of FocusDistance
  64450. */
  64451. setFocusDistance(amount: number): void;
  64452. /**
  64453. * Disables depth of field
  64454. */
  64455. disableDepthOfField(): void;
  64456. /**
  64457. * Sets the Aperture amount
  64458. * @param amount amount of Aperture
  64459. */
  64460. setAperture(amount: number): void;
  64461. /**
  64462. * Sets the DarkenOutOfFocus amount
  64463. * @param amount amount of DarkenOutOfFocus
  64464. */
  64465. setDarkenOutOfFocus(amount: number): void;
  64466. private _pentagonBokehIsEnabled;
  64467. /**
  64468. * Creates a pentagon bokeh effect
  64469. */
  64470. enablePentagonBokeh(): void;
  64471. /**
  64472. * Disables the pentagon bokeh effect
  64473. */
  64474. disablePentagonBokeh(): void;
  64475. /**
  64476. * Enables noise blur
  64477. */
  64478. enableNoiseBlur(): void;
  64479. /**
  64480. * Disables noise blur
  64481. */
  64482. disableNoiseBlur(): void;
  64483. /**
  64484. * Sets the HighlightsGain amount
  64485. * @param amount amount of HighlightsGain
  64486. */
  64487. setHighlightsGain(amount: number): void;
  64488. /**
  64489. * Sets the HighlightsThreshold amount
  64490. * @param amount amount of HighlightsThreshold
  64491. */
  64492. setHighlightsThreshold(amount: number): void;
  64493. /**
  64494. * Disables highlights
  64495. */
  64496. disableHighlights(): void;
  64497. /**
  64498. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  64499. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  64500. */
  64501. dispose(disableDepthRender?: boolean): void;
  64502. private _createChromaticAberrationPostProcess;
  64503. private _createHighlightsPostProcess;
  64504. private _createDepthOfFieldPostProcess;
  64505. private _createGrainTexture;
  64506. }
  64507. }
  64508. declare module "babylonjs/Shaders/ssao2.fragment" {
  64509. /** @hidden */
  64510. export var ssao2PixelShader: {
  64511. name: string;
  64512. shader: string;
  64513. };
  64514. }
  64515. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  64516. /** @hidden */
  64517. export var ssaoCombinePixelShader: {
  64518. name: string;
  64519. shader: string;
  64520. };
  64521. }
  64522. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  64523. import { Camera } from "babylonjs/Cameras/camera";
  64524. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64525. import { Scene } from "babylonjs/scene";
  64526. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64527. import "babylonjs/Shaders/ssao2.fragment";
  64528. import "babylonjs/Shaders/ssaoCombine.fragment";
  64529. /**
  64530. * Render pipeline to produce ssao effect
  64531. */
  64532. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  64533. /**
  64534. * @ignore
  64535. * The PassPostProcess id in the pipeline that contains the original scene color
  64536. */
  64537. SSAOOriginalSceneColorEffect: string;
  64538. /**
  64539. * @ignore
  64540. * The SSAO PostProcess id in the pipeline
  64541. */
  64542. SSAORenderEffect: string;
  64543. /**
  64544. * @ignore
  64545. * The horizontal blur PostProcess id in the pipeline
  64546. */
  64547. SSAOBlurHRenderEffect: string;
  64548. /**
  64549. * @ignore
  64550. * The vertical blur PostProcess id in the pipeline
  64551. */
  64552. SSAOBlurVRenderEffect: string;
  64553. /**
  64554. * @ignore
  64555. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64556. */
  64557. SSAOCombineRenderEffect: string;
  64558. /**
  64559. * The output strength of the SSAO post-process. Default value is 1.0.
  64560. */
  64561. totalStrength: number;
  64562. /**
  64563. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  64564. */
  64565. maxZ: number;
  64566. /**
  64567. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  64568. */
  64569. minZAspect: number;
  64570. private _samples;
  64571. /**
  64572. * Number of samples used for the SSAO calculations. Default value is 8
  64573. */
  64574. samples: number;
  64575. private _textureSamples;
  64576. /**
  64577. * Number of samples to use for antialiasing
  64578. */
  64579. textureSamples: number;
  64580. /**
  64581. * Ratio object used for SSAO ratio and blur ratio
  64582. */
  64583. private _ratio;
  64584. /**
  64585. * Dynamically generated sphere sampler.
  64586. */
  64587. private _sampleSphere;
  64588. /**
  64589. * Blur filter offsets
  64590. */
  64591. private _samplerOffsets;
  64592. private _expensiveBlur;
  64593. /**
  64594. * If bilateral blur should be used
  64595. */
  64596. expensiveBlur: boolean;
  64597. /**
  64598. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  64599. */
  64600. radius: number;
  64601. /**
  64602. * The base color of the SSAO post-process
  64603. * The final result is "base + ssao" between [0, 1]
  64604. */
  64605. base: number;
  64606. /**
  64607. * Support test.
  64608. */
  64609. static readonly IsSupported: boolean;
  64610. private _scene;
  64611. private _depthTexture;
  64612. private _normalTexture;
  64613. private _randomTexture;
  64614. private _originalColorPostProcess;
  64615. private _ssaoPostProcess;
  64616. private _blurHPostProcess;
  64617. private _blurVPostProcess;
  64618. private _ssaoCombinePostProcess;
  64619. private _firstUpdate;
  64620. /**
  64621. * Gets active scene
  64622. */
  64623. readonly scene: Scene;
  64624. /**
  64625. * @constructor
  64626. * @param name The rendering pipeline name
  64627. * @param scene The scene linked to this pipeline
  64628. * @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 }
  64629. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64630. */
  64631. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64632. /**
  64633. * Get the class name
  64634. * @returns "SSAO2RenderingPipeline"
  64635. */
  64636. getClassName(): string;
  64637. /**
  64638. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64639. */
  64640. dispose(disableGeometryBufferRenderer?: boolean): void;
  64641. private _createBlurPostProcess;
  64642. /** @hidden */
  64643. _rebuild(): void;
  64644. private _bits;
  64645. private _radicalInverse_VdC;
  64646. private _hammersley;
  64647. private _hemisphereSample_uniform;
  64648. private _generateHemisphere;
  64649. private _createSSAOPostProcess;
  64650. private _createSSAOCombinePostProcess;
  64651. private _createRandomTexture;
  64652. /**
  64653. * Serialize the rendering pipeline (Used when exporting)
  64654. * @returns the serialized object
  64655. */
  64656. serialize(): any;
  64657. /**
  64658. * Parse the serialized pipeline
  64659. * @param source Source pipeline.
  64660. * @param scene The scene to load the pipeline to.
  64661. * @param rootUrl The URL of the serialized pipeline.
  64662. * @returns An instantiated pipeline from the serialized object.
  64663. */
  64664. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  64665. }
  64666. }
  64667. declare module "babylonjs/Shaders/ssao.fragment" {
  64668. /** @hidden */
  64669. export var ssaoPixelShader: {
  64670. name: string;
  64671. shader: string;
  64672. };
  64673. }
  64674. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  64675. import { Camera } from "babylonjs/Cameras/camera";
  64676. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64677. import { Scene } from "babylonjs/scene";
  64678. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64679. import "babylonjs/Shaders/ssao.fragment";
  64680. import "babylonjs/Shaders/ssaoCombine.fragment";
  64681. /**
  64682. * Render pipeline to produce ssao effect
  64683. */
  64684. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  64685. /**
  64686. * @ignore
  64687. * The PassPostProcess id in the pipeline that contains the original scene color
  64688. */
  64689. SSAOOriginalSceneColorEffect: string;
  64690. /**
  64691. * @ignore
  64692. * The SSAO PostProcess id in the pipeline
  64693. */
  64694. SSAORenderEffect: string;
  64695. /**
  64696. * @ignore
  64697. * The horizontal blur PostProcess id in the pipeline
  64698. */
  64699. SSAOBlurHRenderEffect: string;
  64700. /**
  64701. * @ignore
  64702. * The vertical blur PostProcess id in the pipeline
  64703. */
  64704. SSAOBlurVRenderEffect: string;
  64705. /**
  64706. * @ignore
  64707. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  64708. */
  64709. SSAOCombineRenderEffect: string;
  64710. /**
  64711. * The output strength of the SSAO post-process. Default value is 1.0.
  64712. */
  64713. totalStrength: number;
  64714. /**
  64715. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  64716. */
  64717. radius: number;
  64718. /**
  64719. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  64720. * Must not be equal to fallOff and superior to fallOff.
  64721. * Default value is 0.0075
  64722. */
  64723. area: number;
  64724. /**
  64725. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  64726. * Must not be equal to area and inferior to area.
  64727. * Default value is 0.000001
  64728. */
  64729. fallOff: number;
  64730. /**
  64731. * The base color of the SSAO post-process
  64732. * The final result is "base + ssao" between [0, 1]
  64733. */
  64734. base: number;
  64735. private _scene;
  64736. private _depthTexture;
  64737. private _randomTexture;
  64738. private _originalColorPostProcess;
  64739. private _ssaoPostProcess;
  64740. private _blurHPostProcess;
  64741. private _blurVPostProcess;
  64742. private _ssaoCombinePostProcess;
  64743. private _firstUpdate;
  64744. /**
  64745. * Gets active scene
  64746. */
  64747. readonly scene: Scene;
  64748. /**
  64749. * @constructor
  64750. * @param name - The rendering pipeline name
  64751. * @param scene - The scene linked to this pipeline
  64752. * @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 }
  64753. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  64754. */
  64755. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  64756. /**
  64757. * Get the class name
  64758. * @returns "SSAORenderingPipeline"
  64759. */
  64760. getClassName(): string;
  64761. /**
  64762. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  64763. */
  64764. dispose(disableDepthRender?: boolean): void;
  64765. private _createBlurPostProcess;
  64766. /** @hidden */
  64767. _rebuild(): void;
  64768. private _createSSAOPostProcess;
  64769. private _createSSAOCombinePostProcess;
  64770. private _createRandomTexture;
  64771. }
  64772. }
  64773. declare module "babylonjs/Shaders/standard.fragment" {
  64774. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64775. /** @hidden */
  64776. export var standardPixelShader: {
  64777. name: string;
  64778. shader: string;
  64779. };
  64780. }
  64781. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64782. import { Nullable } from "babylonjs/types";
  64783. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64784. import { Camera } from "babylonjs/Cameras/camera";
  64785. import { Texture } from "babylonjs/Materials/Textures/texture";
  64786. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64787. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64788. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64789. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64790. import { IDisposable } from "babylonjs/scene";
  64791. import { SpotLight } from "babylonjs/Lights/spotLight";
  64792. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64793. import { Scene } from "babylonjs/scene";
  64794. import { Animation } from "babylonjs/Animations/animation";
  64795. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64796. import "babylonjs/Shaders/standard.fragment";
  64797. /**
  64798. * Standard rendering pipeline
  64799. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64800. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64801. */
  64802. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64803. /**
  64804. * Public members
  64805. */
  64806. /**
  64807. * Post-process which contains the original scene color before the pipeline applies all the effects
  64808. */
  64809. originalPostProcess: Nullable<PostProcess>;
  64810. /**
  64811. * Post-process used to down scale an image x4
  64812. */
  64813. downSampleX4PostProcess: Nullable<PostProcess>;
  64814. /**
  64815. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64816. */
  64817. brightPassPostProcess: Nullable<PostProcess>;
  64818. /**
  64819. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64820. */
  64821. blurHPostProcesses: PostProcess[];
  64822. /**
  64823. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64824. */
  64825. blurVPostProcesses: PostProcess[];
  64826. /**
  64827. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64828. */
  64829. textureAdderPostProcess: Nullable<PostProcess>;
  64830. /**
  64831. * Post-process used to create volumetric lighting effect
  64832. */
  64833. volumetricLightPostProcess: Nullable<PostProcess>;
  64834. /**
  64835. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64836. */
  64837. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64838. /**
  64839. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64840. */
  64841. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64842. /**
  64843. * Post-process used to merge the volumetric light effect and the real scene color
  64844. */
  64845. volumetricLightMergePostProces: Nullable<PostProcess>;
  64846. /**
  64847. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64848. */
  64849. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64850. /**
  64851. * Base post-process used to calculate the average luminance of the final image for HDR
  64852. */
  64853. luminancePostProcess: Nullable<PostProcess>;
  64854. /**
  64855. * Post-processes used to create down sample post-processes in order to get
  64856. * the average luminance of the final image for HDR
  64857. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64858. */
  64859. luminanceDownSamplePostProcesses: PostProcess[];
  64860. /**
  64861. * Post-process used to create a HDR effect (light adaptation)
  64862. */
  64863. hdrPostProcess: Nullable<PostProcess>;
  64864. /**
  64865. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64866. */
  64867. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64868. /**
  64869. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64870. */
  64871. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64872. /**
  64873. * Post-process used to merge the final HDR post-process and the real scene color
  64874. */
  64875. hdrFinalPostProcess: Nullable<PostProcess>;
  64876. /**
  64877. * Post-process used to create a lens flare effect
  64878. */
  64879. lensFlarePostProcess: Nullable<PostProcess>;
  64880. /**
  64881. * Post-process that merges the result of the lens flare post-process and the real scene color
  64882. */
  64883. lensFlareComposePostProcess: Nullable<PostProcess>;
  64884. /**
  64885. * Post-process used to create a motion blur effect
  64886. */
  64887. motionBlurPostProcess: Nullable<PostProcess>;
  64888. /**
  64889. * Post-process used to create a depth of field effect
  64890. */
  64891. depthOfFieldPostProcess: Nullable<PostProcess>;
  64892. /**
  64893. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64894. */
  64895. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64896. /**
  64897. * Represents the brightness threshold in order to configure the illuminated surfaces
  64898. */
  64899. brightThreshold: number;
  64900. /**
  64901. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64902. */
  64903. blurWidth: number;
  64904. /**
  64905. * Sets if the blur for highlighted surfaces must be only horizontal
  64906. */
  64907. horizontalBlur: boolean;
  64908. /**
  64909. * Gets the overall exposure used by the pipeline
  64910. */
  64911. /**
  64912. * Sets the overall exposure used by the pipeline
  64913. */
  64914. exposure: number;
  64915. /**
  64916. * Texture used typically to simulate "dirty" on camera lens
  64917. */
  64918. lensTexture: Nullable<Texture>;
  64919. /**
  64920. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64921. */
  64922. volumetricLightCoefficient: number;
  64923. /**
  64924. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64925. */
  64926. volumetricLightPower: number;
  64927. /**
  64928. * Used the set the blur intensity to smooth the volumetric lights
  64929. */
  64930. volumetricLightBlurScale: number;
  64931. /**
  64932. * Light (spot or directional) used to generate the volumetric lights rays
  64933. * The source light must have a shadow generate so the pipeline can get its
  64934. * depth map
  64935. */
  64936. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64937. /**
  64938. * For eye adaptation, represents the minimum luminance the eye can see
  64939. */
  64940. hdrMinimumLuminance: number;
  64941. /**
  64942. * For eye adaptation, represents the decrease luminance speed
  64943. */
  64944. hdrDecreaseRate: number;
  64945. /**
  64946. * For eye adaptation, represents the increase luminance speed
  64947. */
  64948. hdrIncreaseRate: number;
  64949. /**
  64950. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64951. */
  64952. /**
  64953. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64954. */
  64955. hdrAutoExposure: boolean;
  64956. /**
  64957. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64958. */
  64959. lensColorTexture: Nullable<Texture>;
  64960. /**
  64961. * The overall strengh for the lens flare effect
  64962. */
  64963. lensFlareStrength: number;
  64964. /**
  64965. * Dispersion coefficient for lens flare ghosts
  64966. */
  64967. lensFlareGhostDispersal: number;
  64968. /**
  64969. * Main lens flare halo width
  64970. */
  64971. lensFlareHaloWidth: number;
  64972. /**
  64973. * Based on the lens distortion effect, defines how much the lens flare result
  64974. * is distorted
  64975. */
  64976. lensFlareDistortionStrength: number;
  64977. /**
  64978. * Configures the blur intensity used for for lens flare (halo)
  64979. */
  64980. lensFlareBlurWidth: number;
  64981. /**
  64982. * Lens star texture must be used to simulate rays on the flares and is available
  64983. * in the documentation
  64984. */
  64985. lensStarTexture: Nullable<Texture>;
  64986. /**
  64987. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64988. * flare effect by taking account of the dirt texture
  64989. */
  64990. lensFlareDirtTexture: Nullable<Texture>;
  64991. /**
  64992. * Represents the focal length for the depth of field effect
  64993. */
  64994. depthOfFieldDistance: number;
  64995. /**
  64996. * Represents the blur intensity for the blurred part of the depth of field effect
  64997. */
  64998. depthOfFieldBlurWidth: number;
  64999. /**
  65000. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65001. */
  65002. /**
  65003. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65004. */
  65005. motionStrength: number;
  65006. /**
  65007. * Gets wether or not the motion blur post-process is object based or screen based.
  65008. */
  65009. /**
  65010. * Sets wether or not the motion blur post-process should be object based or screen based
  65011. */
  65012. objectBasedMotionBlur: boolean;
  65013. /**
  65014. * List of animations for the pipeline (IAnimatable implementation)
  65015. */
  65016. animations: Animation[];
  65017. /**
  65018. * Private members
  65019. */
  65020. private _scene;
  65021. private _currentDepthOfFieldSource;
  65022. private _basePostProcess;
  65023. private _fixedExposure;
  65024. private _currentExposure;
  65025. private _hdrAutoExposure;
  65026. private _hdrCurrentLuminance;
  65027. private _motionStrength;
  65028. private _isObjectBasedMotionBlur;
  65029. private _floatTextureType;
  65030. private _camerasToBeAttached;
  65031. private _ratio;
  65032. private _bloomEnabled;
  65033. private _depthOfFieldEnabled;
  65034. private _vlsEnabled;
  65035. private _lensFlareEnabled;
  65036. private _hdrEnabled;
  65037. private _motionBlurEnabled;
  65038. private _fxaaEnabled;
  65039. private _motionBlurSamples;
  65040. private _volumetricLightStepsCount;
  65041. private _samples;
  65042. /**
  65043. * @ignore
  65044. * Specifies if the bloom pipeline is enabled
  65045. */
  65046. BloomEnabled: boolean;
  65047. /**
  65048. * @ignore
  65049. * Specifies if the depth of field pipeline is enabed
  65050. */
  65051. DepthOfFieldEnabled: boolean;
  65052. /**
  65053. * @ignore
  65054. * Specifies if the lens flare pipeline is enabed
  65055. */
  65056. LensFlareEnabled: boolean;
  65057. /**
  65058. * @ignore
  65059. * Specifies if the HDR pipeline is enabled
  65060. */
  65061. HDREnabled: boolean;
  65062. /**
  65063. * @ignore
  65064. * Specifies if the volumetric lights scattering effect is enabled
  65065. */
  65066. VLSEnabled: boolean;
  65067. /**
  65068. * @ignore
  65069. * Specifies if the motion blur effect is enabled
  65070. */
  65071. MotionBlurEnabled: boolean;
  65072. /**
  65073. * Specifies if anti-aliasing is enabled
  65074. */
  65075. fxaaEnabled: boolean;
  65076. /**
  65077. * Specifies the number of steps used to calculate the volumetric lights
  65078. * Typically in interval [50, 200]
  65079. */
  65080. volumetricLightStepsCount: number;
  65081. /**
  65082. * Specifies the number of samples used for the motion blur effect
  65083. * Typically in interval [16, 64]
  65084. */
  65085. motionBlurSamples: number;
  65086. /**
  65087. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65088. */
  65089. samples: number;
  65090. /**
  65091. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65092. * @constructor
  65093. * @param name The rendering pipeline name
  65094. * @param scene The scene linked to this pipeline
  65095. * @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)
  65096. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65097. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65098. */
  65099. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65100. private _buildPipeline;
  65101. private _createDownSampleX4PostProcess;
  65102. private _createBrightPassPostProcess;
  65103. private _createBlurPostProcesses;
  65104. private _createTextureAdderPostProcess;
  65105. private _createVolumetricLightPostProcess;
  65106. private _createLuminancePostProcesses;
  65107. private _createHdrPostProcess;
  65108. private _createLensFlarePostProcess;
  65109. private _createDepthOfFieldPostProcess;
  65110. private _createMotionBlurPostProcess;
  65111. private _getDepthTexture;
  65112. private _disposePostProcesses;
  65113. /**
  65114. * Dispose of the pipeline and stop all post processes
  65115. */
  65116. dispose(): void;
  65117. /**
  65118. * Serialize the rendering pipeline (Used when exporting)
  65119. * @returns the serialized object
  65120. */
  65121. serialize(): any;
  65122. /**
  65123. * Parse the serialized pipeline
  65124. * @param source Source pipeline.
  65125. * @param scene The scene to load the pipeline to.
  65126. * @param rootUrl The URL of the serialized pipeline.
  65127. * @returns An instantiated pipeline from the serialized object.
  65128. */
  65129. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65130. /**
  65131. * Luminance steps
  65132. */
  65133. static LuminanceSteps: number;
  65134. }
  65135. }
  65136. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65137. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65138. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65139. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65140. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65141. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65142. }
  65143. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65144. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65145. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65146. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65147. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65148. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65149. }
  65150. declare module "babylonjs/Shaders/tonemap.fragment" {
  65151. /** @hidden */
  65152. export var tonemapPixelShader: {
  65153. name: string;
  65154. shader: string;
  65155. };
  65156. }
  65157. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65158. import { Camera } from "babylonjs/Cameras/camera";
  65159. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65160. import "babylonjs/Shaders/tonemap.fragment";
  65161. import { Engine } from "babylonjs/Engines/engine";
  65162. /** Defines operator used for tonemapping */
  65163. export enum TonemappingOperator {
  65164. /** Hable */
  65165. Hable = 0,
  65166. /** Reinhard */
  65167. Reinhard = 1,
  65168. /** HejiDawson */
  65169. HejiDawson = 2,
  65170. /** Photographic */
  65171. Photographic = 3
  65172. }
  65173. /**
  65174. * Defines a post process to apply tone mapping
  65175. */
  65176. export class TonemapPostProcess extends PostProcess {
  65177. private _operator;
  65178. /** Defines the required exposure adjustement */
  65179. exposureAdjustment: number;
  65180. /**
  65181. * Creates a new TonemapPostProcess
  65182. * @param name defines the name of the postprocess
  65183. * @param _operator defines the operator to use
  65184. * @param exposureAdjustment defines the required exposure adjustement
  65185. * @param camera defines the camera to use (can be null)
  65186. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65187. * @param engine defines the hosting engine (can be ignore if camera is set)
  65188. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65189. */
  65190. constructor(name: string, _operator: TonemappingOperator,
  65191. /** Defines the required exposure adjustement */
  65192. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65193. }
  65194. }
  65195. declare module "babylonjs/Shaders/depth.vertex" {
  65196. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65198. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65199. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65200. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65201. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65202. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65203. /** @hidden */
  65204. export var depthVertexShader: {
  65205. name: string;
  65206. shader: string;
  65207. };
  65208. }
  65209. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65210. /** @hidden */
  65211. export var volumetricLightScatteringPixelShader: {
  65212. name: string;
  65213. shader: string;
  65214. };
  65215. }
  65216. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65217. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65218. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65220. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65221. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65222. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65223. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65224. /** @hidden */
  65225. export var volumetricLightScatteringPassVertexShader: {
  65226. name: string;
  65227. shader: string;
  65228. };
  65229. }
  65230. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65231. /** @hidden */
  65232. export var volumetricLightScatteringPassPixelShader: {
  65233. name: string;
  65234. shader: string;
  65235. };
  65236. }
  65237. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65238. import { Vector3 } from "babylonjs/Maths/math.vector";
  65239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65240. import { Mesh } from "babylonjs/Meshes/mesh";
  65241. import { Camera } from "babylonjs/Cameras/camera";
  65242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65243. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65244. import { Scene } from "babylonjs/scene";
  65245. import "babylonjs/Meshes/Builders/planeBuilder";
  65246. import "babylonjs/Shaders/depth.vertex";
  65247. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65248. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65249. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65250. import { Engine } from "babylonjs/Engines/engine";
  65251. /**
  65252. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65253. */
  65254. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65255. private _volumetricLightScatteringPass;
  65256. private _volumetricLightScatteringRTT;
  65257. private _viewPort;
  65258. private _screenCoordinates;
  65259. private _cachedDefines;
  65260. /**
  65261. * If not undefined, the mesh position is computed from the attached node position
  65262. */
  65263. attachedNode: {
  65264. position: Vector3;
  65265. };
  65266. /**
  65267. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65268. */
  65269. customMeshPosition: Vector3;
  65270. /**
  65271. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65272. */
  65273. useCustomMeshPosition: boolean;
  65274. /**
  65275. * If the post-process should inverse the light scattering direction
  65276. */
  65277. invert: boolean;
  65278. /**
  65279. * The internal mesh used by the post-process
  65280. */
  65281. mesh: Mesh;
  65282. /**
  65283. * @hidden
  65284. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  65285. */
  65286. useDiffuseColor: boolean;
  65287. /**
  65288. * Array containing the excluded meshes not rendered in the internal pass
  65289. */
  65290. excludedMeshes: AbstractMesh[];
  65291. /**
  65292. * Controls the overall intensity of the post-process
  65293. */
  65294. exposure: number;
  65295. /**
  65296. * Dissipates each sample's contribution in range [0, 1]
  65297. */
  65298. decay: number;
  65299. /**
  65300. * Controls the overall intensity of each sample
  65301. */
  65302. weight: number;
  65303. /**
  65304. * Controls the density of each sample
  65305. */
  65306. density: number;
  65307. /**
  65308. * @constructor
  65309. * @param name The post-process name
  65310. * @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)
  65311. * @param camera The camera that the post-process will be attached to
  65312. * @param mesh The mesh used to create the light scattering
  65313. * @param samples The post-process quality, default 100
  65314. * @param samplingModeThe post-process filtering mode
  65315. * @param engine The babylon engine
  65316. * @param reusable If the post-process is reusable
  65317. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  65318. */
  65319. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  65320. /**
  65321. * Returns the string "VolumetricLightScatteringPostProcess"
  65322. * @returns "VolumetricLightScatteringPostProcess"
  65323. */
  65324. getClassName(): string;
  65325. private _isReady;
  65326. /**
  65327. * Sets the new light position for light scattering effect
  65328. * @param position The new custom light position
  65329. */
  65330. setCustomMeshPosition(position: Vector3): void;
  65331. /**
  65332. * Returns the light position for light scattering effect
  65333. * @return Vector3 The custom light position
  65334. */
  65335. getCustomMeshPosition(): Vector3;
  65336. /**
  65337. * Disposes the internal assets and detaches the post-process from the camera
  65338. */
  65339. dispose(camera: Camera): void;
  65340. /**
  65341. * Returns the render target texture used by the post-process
  65342. * @return the render target texture used by the post-process
  65343. */
  65344. getPass(): RenderTargetTexture;
  65345. private _meshExcluded;
  65346. private _createPass;
  65347. private _updateMeshScreenCoordinates;
  65348. /**
  65349. * Creates a default mesh for the Volumeric Light Scattering post-process
  65350. * @param name The mesh name
  65351. * @param scene The scene where to create the mesh
  65352. * @return the default mesh
  65353. */
  65354. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  65355. }
  65356. }
  65357. declare module "babylonjs/PostProcesses/index" {
  65358. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  65359. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  65360. export * from "babylonjs/PostProcesses/bloomEffect";
  65361. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  65362. export * from "babylonjs/PostProcesses/blurPostProcess";
  65363. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65364. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  65365. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  65366. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  65367. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65368. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  65369. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  65370. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  65371. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65372. export * from "babylonjs/PostProcesses/filterPostProcess";
  65373. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  65374. export * from "babylonjs/PostProcesses/grainPostProcess";
  65375. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  65376. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65377. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  65378. export * from "babylonjs/PostProcesses/passPostProcess";
  65379. export * from "babylonjs/PostProcesses/postProcess";
  65380. export * from "babylonjs/PostProcesses/postProcessManager";
  65381. export * from "babylonjs/PostProcesses/refractionPostProcess";
  65382. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  65383. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  65384. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  65385. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  65386. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  65387. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  65388. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  65389. }
  65390. declare module "babylonjs/Probes/index" {
  65391. export * from "babylonjs/Probes/reflectionProbe";
  65392. }
  65393. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  65394. import { Scene } from "babylonjs/scene";
  65395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65396. import { SmartArray } from "babylonjs/Misc/smartArray";
  65397. import { ISceneComponent } from "babylonjs/sceneComponent";
  65398. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  65399. import "babylonjs/Meshes/Builders/boxBuilder";
  65400. import "babylonjs/Shaders/color.fragment";
  65401. import "babylonjs/Shaders/color.vertex";
  65402. import { Color3 } from "babylonjs/Maths/math.color";
  65403. module "babylonjs/scene" {
  65404. interface Scene {
  65405. /** @hidden (Backing field) */
  65406. _boundingBoxRenderer: BoundingBoxRenderer;
  65407. /** @hidden (Backing field) */
  65408. _forceShowBoundingBoxes: boolean;
  65409. /**
  65410. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  65411. */
  65412. forceShowBoundingBoxes: boolean;
  65413. /**
  65414. * Gets the bounding box renderer associated with the scene
  65415. * @returns a BoundingBoxRenderer
  65416. */
  65417. getBoundingBoxRenderer(): BoundingBoxRenderer;
  65418. }
  65419. }
  65420. module "babylonjs/Meshes/abstractMesh" {
  65421. interface AbstractMesh {
  65422. /** @hidden (Backing field) */
  65423. _showBoundingBox: boolean;
  65424. /**
  65425. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  65426. */
  65427. showBoundingBox: boolean;
  65428. }
  65429. }
  65430. /**
  65431. * Component responsible of rendering the bounding box of the meshes in a scene.
  65432. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  65433. */
  65434. export class BoundingBoxRenderer implements ISceneComponent {
  65435. /**
  65436. * The component name helpfull to identify the component in the list of scene components.
  65437. */
  65438. readonly name: string;
  65439. /**
  65440. * The scene the component belongs to.
  65441. */
  65442. scene: Scene;
  65443. /**
  65444. * Color of the bounding box lines placed in front of an object
  65445. */
  65446. frontColor: Color3;
  65447. /**
  65448. * Color of the bounding box lines placed behind an object
  65449. */
  65450. backColor: Color3;
  65451. /**
  65452. * Defines if the renderer should show the back lines or not
  65453. */
  65454. showBackLines: boolean;
  65455. /**
  65456. * @hidden
  65457. */
  65458. renderList: SmartArray<BoundingBox>;
  65459. private _colorShader;
  65460. private _vertexBuffers;
  65461. private _indexBuffer;
  65462. private _fillIndexBuffer;
  65463. private _fillIndexData;
  65464. /**
  65465. * Instantiates a new bounding box renderer in a scene.
  65466. * @param scene the scene the renderer renders in
  65467. */
  65468. constructor(scene: Scene);
  65469. /**
  65470. * Registers the component in a given scene
  65471. */
  65472. register(): void;
  65473. private _evaluateSubMesh;
  65474. private _activeMesh;
  65475. private _prepareRessources;
  65476. private _createIndexBuffer;
  65477. /**
  65478. * Rebuilds the elements related to this component in case of
  65479. * context lost for instance.
  65480. */
  65481. rebuild(): void;
  65482. /**
  65483. * @hidden
  65484. */
  65485. reset(): void;
  65486. /**
  65487. * Render the bounding boxes of a specific rendering group
  65488. * @param renderingGroupId defines the rendering group to render
  65489. */
  65490. render(renderingGroupId: number): void;
  65491. /**
  65492. * In case of occlusion queries, we can render the occlusion bounding box through this method
  65493. * @param mesh Define the mesh to render the occlusion bounding box for
  65494. */
  65495. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  65496. /**
  65497. * Dispose and release the resources attached to this renderer.
  65498. */
  65499. dispose(): void;
  65500. }
  65501. }
  65502. declare module "babylonjs/Shaders/depth.fragment" {
  65503. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65504. /** @hidden */
  65505. export var depthPixelShader: {
  65506. name: string;
  65507. shader: string;
  65508. };
  65509. }
  65510. declare module "babylonjs/Rendering/depthRenderer" {
  65511. import { Nullable } from "babylonjs/types";
  65512. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65513. import { Scene } from "babylonjs/scene";
  65514. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65515. import { Camera } from "babylonjs/Cameras/camera";
  65516. import "babylonjs/Shaders/depth.fragment";
  65517. import "babylonjs/Shaders/depth.vertex";
  65518. /**
  65519. * This represents a depth renderer in Babylon.
  65520. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  65521. */
  65522. export class DepthRenderer {
  65523. private _scene;
  65524. private _depthMap;
  65525. private _effect;
  65526. private readonly _storeNonLinearDepth;
  65527. private readonly _clearColor;
  65528. /** Get if the depth renderer is using packed depth or not */
  65529. readonly isPacked: boolean;
  65530. private _cachedDefines;
  65531. private _camera;
  65532. /**
  65533. * Specifiess that the depth renderer will only be used within
  65534. * the camera it is created for.
  65535. * This can help forcing its rendering during the camera processing.
  65536. */
  65537. useOnlyInActiveCamera: boolean;
  65538. /** @hidden */
  65539. static _SceneComponentInitialization: (scene: Scene) => void;
  65540. /**
  65541. * Instantiates a depth renderer
  65542. * @param scene The scene the renderer belongs to
  65543. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  65544. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  65545. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65546. */
  65547. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  65548. /**
  65549. * Creates the depth rendering effect and checks if the effect is ready.
  65550. * @param subMesh The submesh to be used to render the depth map of
  65551. * @param useInstances If multiple world instances should be used
  65552. * @returns if the depth renderer is ready to render the depth map
  65553. */
  65554. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65555. /**
  65556. * Gets the texture which the depth map will be written to.
  65557. * @returns The depth map texture
  65558. */
  65559. getDepthMap(): RenderTargetTexture;
  65560. /**
  65561. * Disposes of the depth renderer.
  65562. */
  65563. dispose(): void;
  65564. }
  65565. }
  65566. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  65567. import { Nullable } from "babylonjs/types";
  65568. import { Scene } from "babylonjs/scene";
  65569. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  65570. import { Camera } from "babylonjs/Cameras/camera";
  65571. import { ISceneComponent } from "babylonjs/sceneComponent";
  65572. module "babylonjs/scene" {
  65573. interface Scene {
  65574. /** @hidden (Backing field) */
  65575. _depthRenderer: {
  65576. [id: string]: DepthRenderer;
  65577. };
  65578. /**
  65579. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  65580. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  65581. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  65582. * @returns the created depth renderer
  65583. */
  65584. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  65585. /**
  65586. * Disables a depth renderer for a given camera
  65587. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  65588. */
  65589. disableDepthRenderer(camera?: Nullable<Camera>): void;
  65590. }
  65591. }
  65592. /**
  65593. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  65594. * in several rendering techniques.
  65595. */
  65596. export class DepthRendererSceneComponent implements ISceneComponent {
  65597. /**
  65598. * The component name helpfull to identify the component in the list of scene components.
  65599. */
  65600. readonly name: string;
  65601. /**
  65602. * The scene the component belongs to.
  65603. */
  65604. scene: Scene;
  65605. /**
  65606. * Creates a new instance of the component for the given scene
  65607. * @param scene Defines the scene to register the component in
  65608. */
  65609. constructor(scene: Scene);
  65610. /**
  65611. * Registers the component in a given scene
  65612. */
  65613. register(): void;
  65614. /**
  65615. * Rebuilds the elements related to this component in case of
  65616. * context lost for instance.
  65617. */
  65618. rebuild(): void;
  65619. /**
  65620. * Disposes the component and the associated ressources
  65621. */
  65622. dispose(): void;
  65623. private _gatherRenderTargets;
  65624. private _gatherActiveCameraRenderTargets;
  65625. }
  65626. }
  65627. declare module "babylonjs/Shaders/outline.fragment" {
  65628. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65629. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  65630. /** @hidden */
  65631. export var outlinePixelShader: {
  65632. name: string;
  65633. shader: string;
  65634. };
  65635. }
  65636. declare module "babylonjs/Shaders/outline.vertex" {
  65637. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65639. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65640. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65641. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  65642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65643. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65644. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65645. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  65646. /** @hidden */
  65647. export var outlineVertexShader: {
  65648. name: string;
  65649. shader: string;
  65650. };
  65651. }
  65652. declare module "babylonjs/Rendering/outlineRenderer" {
  65653. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65654. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  65655. import { Scene } from "babylonjs/scene";
  65656. import { ISceneComponent } from "babylonjs/sceneComponent";
  65657. import "babylonjs/Shaders/outline.fragment";
  65658. import "babylonjs/Shaders/outline.vertex";
  65659. module "babylonjs/scene" {
  65660. interface Scene {
  65661. /** @hidden */
  65662. _outlineRenderer: OutlineRenderer;
  65663. /**
  65664. * Gets the outline renderer associated with the scene
  65665. * @returns a OutlineRenderer
  65666. */
  65667. getOutlineRenderer(): OutlineRenderer;
  65668. }
  65669. }
  65670. module "babylonjs/Meshes/abstractMesh" {
  65671. interface AbstractMesh {
  65672. /** @hidden (Backing field) */
  65673. _renderOutline: boolean;
  65674. /**
  65675. * Gets or sets a boolean indicating if the outline must be rendered as well
  65676. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  65677. */
  65678. renderOutline: boolean;
  65679. /** @hidden (Backing field) */
  65680. _renderOverlay: boolean;
  65681. /**
  65682. * Gets or sets a boolean indicating if the overlay must be rendered as well
  65683. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  65684. */
  65685. renderOverlay: boolean;
  65686. }
  65687. }
  65688. /**
  65689. * This class is responsible to draw bothe outline/overlay of meshes.
  65690. * It should not be used directly but through the available method on mesh.
  65691. */
  65692. export class OutlineRenderer implements ISceneComponent {
  65693. /**
  65694. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  65695. */
  65696. private static _StencilReference;
  65697. /**
  65698. * The name of the component. Each component must have a unique name.
  65699. */
  65700. name: string;
  65701. /**
  65702. * The scene the component belongs to.
  65703. */
  65704. scene: Scene;
  65705. /**
  65706. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  65707. */
  65708. zOffset: number;
  65709. private _engine;
  65710. private _effect;
  65711. private _cachedDefines;
  65712. private _savedDepthWrite;
  65713. /**
  65714. * Instantiates a new outline renderer. (There could be only one per scene).
  65715. * @param scene Defines the scene it belongs to
  65716. */
  65717. constructor(scene: Scene);
  65718. /**
  65719. * Register the component to one instance of a scene.
  65720. */
  65721. register(): void;
  65722. /**
  65723. * Rebuilds the elements related to this component in case of
  65724. * context lost for instance.
  65725. */
  65726. rebuild(): void;
  65727. /**
  65728. * Disposes the component and the associated ressources.
  65729. */
  65730. dispose(): void;
  65731. /**
  65732. * Renders the outline in the canvas.
  65733. * @param subMesh Defines the sumesh to render
  65734. * @param batch Defines the batch of meshes in case of instances
  65735. * @param useOverlay Defines if the rendering is for the overlay or the outline
  65736. */
  65737. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  65738. /**
  65739. * Returns whether or not the outline renderer is ready for a given submesh.
  65740. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  65741. * @param subMesh Defines the submesh to check readyness for
  65742. * @param useInstances Defines wheter wee are trying to render instances or not
  65743. * @returns true if ready otherwise false
  65744. */
  65745. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65746. private _beforeRenderingMesh;
  65747. private _afterRenderingMesh;
  65748. }
  65749. }
  65750. declare module "babylonjs/Rendering/index" {
  65751. export * from "babylonjs/Rendering/boundingBoxRenderer";
  65752. export * from "babylonjs/Rendering/depthRenderer";
  65753. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  65754. export * from "babylonjs/Rendering/edgesRenderer";
  65755. export * from "babylonjs/Rendering/geometryBufferRenderer";
  65756. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65757. export * from "babylonjs/Rendering/outlineRenderer";
  65758. export * from "babylonjs/Rendering/renderingGroup";
  65759. export * from "babylonjs/Rendering/renderingManager";
  65760. export * from "babylonjs/Rendering/utilityLayerRenderer";
  65761. }
  65762. declare module "babylonjs/Sprites/spritePackedManager" {
  65763. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  65764. import { Scene } from "babylonjs/scene";
  65765. /**
  65766. * Class used to manage multiple sprites of different sizes on the same spritesheet
  65767. * @see http://doc.babylonjs.com/babylon101/sprites
  65768. */
  65769. export class SpritePackedManager extends SpriteManager {
  65770. /** defines the packed manager's name */
  65771. name: string;
  65772. /**
  65773. * Creates a new sprite manager from a packed sprite sheet
  65774. * @param name defines the manager's name
  65775. * @param imgUrl defines the sprite sheet url
  65776. * @param capacity defines the maximum allowed number of sprites
  65777. * @param scene defines the hosting scene
  65778. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65779. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65780. * @param samplingMode defines the smapling mode to use with spritesheet
  65781. * @param fromPacked set to true; do not alter
  65782. */
  65783. constructor(
  65784. /** defines the packed manager's name */
  65785. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65786. }
  65787. }
  65788. declare module "babylonjs/Sprites/index" {
  65789. export * from "babylonjs/Sprites/sprite";
  65790. export * from "babylonjs/Sprites/spriteManager";
  65791. export * from "babylonjs/Sprites/spritePackedManager";
  65792. export * from "babylonjs/Sprites/spriteSceneComponent";
  65793. }
  65794. declare module "babylonjs/States/index" {
  65795. export * from "babylonjs/States/alphaCullingState";
  65796. export * from "babylonjs/States/depthCullingState";
  65797. export * from "babylonjs/States/stencilState";
  65798. }
  65799. declare module "babylonjs/Misc/assetsManager" {
  65800. import { Scene } from "babylonjs/scene";
  65801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65802. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65803. import { Skeleton } from "babylonjs/Bones/skeleton";
  65804. import { Observable } from "babylonjs/Misc/observable";
  65805. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65806. import { Texture } from "babylonjs/Materials/Textures/texture";
  65807. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65808. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65809. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65810. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65811. /**
  65812. * Defines the list of states available for a task inside a AssetsManager
  65813. */
  65814. export enum AssetTaskState {
  65815. /**
  65816. * Initialization
  65817. */
  65818. INIT = 0,
  65819. /**
  65820. * Running
  65821. */
  65822. RUNNING = 1,
  65823. /**
  65824. * Done
  65825. */
  65826. DONE = 2,
  65827. /**
  65828. * Error
  65829. */
  65830. ERROR = 3
  65831. }
  65832. /**
  65833. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65834. */
  65835. export abstract class AbstractAssetTask {
  65836. /**
  65837. * Task name
  65838. */ name: string;
  65839. /**
  65840. * Callback called when the task is successful
  65841. */
  65842. onSuccess: (task: any) => void;
  65843. /**
  65844. * Callback called when the task is not successful
  65845. */
  65846. onError: (task: any, message?: string, exception?: any) => void;
  65847. /**
  65848. * Creates a new AssetsManager
  65849. * @param name defines the name of the task
  65850. */
  65851. constructor(
  65852. /**
  65853. * Task name
  65854. */ name: string);
  65855. private _isCompleted;
  65856. private _taskState;
  65857. private _errorObject;
  65858. /**
  65859. * Get if the task is completed
  65860. */
  65861. readonly isCompleted: boolean;
  65862. /**
  65863. * Gets the current state of the task
  65864. */
  65865. readonly taskState: AssetTaskState;
  65866. /**
  65867. * Gets the current error object (if task is in error)
  65868. */
  65869. readonly errorObject: {
  65870. message?: string;
  65871. exception?: any;
  65872. };
  65873. /**
  65874. * Internal only
  65875. * @hidden
  65876. */
  65877. _setErrorObject(message?: string, exception?: any): void;
  65878. /**
  65879. * Execute the current task
  65880. * @param scene defines the scene where you want your assets to be loaded
  65881. * @param onSuccess is a callback called when the task is successfully executed
  65882. * @param onError is a callback called if an error occurs
  65883. */
  65884. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65885. /**
  65886. * Execute the current task
  65887. * @param scene defines the scene where you want your assets to be loaded
  65888. * @param onSuccess is a callback called when the task is successfully executed
  65889. * @param onError is a callback called if an error occurs
  65890. */
  65891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65892. /**
  65893. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65894. * This can be used with failed tasks that have the reason for failure fixed.
  65895. */
  65896. reset(): void;
  65897. private onErrorCallback;
  65898. private onDoneCallback;
  65899. }
  65900. /**
  65901. * Define the interface used by progress events raised during assets loading
  65902. */
  65903. export interface IAssetsProgressEvent {
  65904. /**
  65905. * Defines the number of remaining tasks to process
  65906. */
  65907. remainingCount: number;
  65908. /**
  65909. * Defines the total number of tasks
  65910. */
  65911. totalCount: number;
  65912. /**
  65913. * Defines the task that was just processed
  65914. */
  65915. task: AbstractAssetTask;
  65916. }
  65917. /**
  65918. * Class used to share progress information about assets loading
  65919. */
  65920. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65921. /**
  65922. * Defines the number of remaining tasks to process
  65923. */
  65924. remainingCount: number;
  65925. /**
  65926. * Defines the total number of tasks
  65927. */
  65928. totalCount: number;
  65929. /**
  65930. * Defines the task that was just processed
  65931. */
  65932. task: AbstractAssetTask;
  65933. /**
  65934. * Creates a AssetsProgressEvent
  65935. * @param remainingCount defines the number of remaining tasks to process
  65936. * @param totalCount defines the total number of tasks
  65937. * @param task defines the task that was just processed
  65938. */
  65939. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65940. }
  65941. /**
  65942. * Define a task used by AssetsManager to load meshes
  65943. */
  65944. export class MeshAssetTask extends AbstractAssetTask {
  65945. /**
  65946. * Defines the name of the task
  65947. */
  65948. name: string;
  65949. /**
  65950. * Defines the list of mesh's names you want to load
  65951. */
  65952. meshesNames: any;
  65953. /**
  65954. * Defines the root url to use as a base to load your meshes and associated resources
  65955. */
  65956. rootUrl: string;
  65957. /**
  65958. * Defines the filename of the scene to load from
  65959. */
  65960. sceneFilename: string;
  65961. /**
  65962. * Gets the list of loaded meshes
  65963. */
  65964. loadedMeshes: Array<AbstractMesh>;
  65965. /**
  65966. * Gets the list of loaded particle systems
  65967. */
  65968. loadedParticleSystems: Array<IParticleSystem>;
  65969. /**
  65970. * Gets the list of loaded skeletons
  65971. */
  65972. loadedSkeletons: Array<Skeleton>;
  65973. /**
  65974. * Gets the list of loaded animation groups
  65975. */
  65976. loadedAnimationGroups: Array<AnimationGroup>;
  65977. /**
  65978. * Callback called when the task is successful
  65979. */
  65980. onSuccess: (task: MeshAssetTask) => void;
  65981. /**
  65982. * Callback called when the task is successful
  65983. */
  65984. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65985. /**
  65986. * Creates a new MeshAssetTask
  65987. * @param name defines the name of the task
  65988. * @param meshesNames defines the list of mesh's names you want to load
  65989. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65990. * @param sceneFilename defines the filename of the scene to load from
  65991. */
  65992. constructor(
  65993. /**
  65994. * Defines the name of the task
  65995. */
  65996. name: string,
  65997. /**
  65998. * Defines the list of mesh's names you want to load
  65999. */
  66000. meshesNames: any,
  66001. /**
  66002. * Defines the root url to use as a base to load your meshes and associated resources
  66003. */
  66004. rootUrl: string,
  66005. /**
  66006. * Defines the filename of the scene to load from
  66007. */
  66008. sceneFilename: string);
  66009. /**
  66010. * Execute the current task
  66011. * @param scene defines the scene where you want your assets to be loaded
  66012. * @param onSuccess is a callback called when the task is successfully executed
  66013. * @param onError is a callback called if an error occurs
  66014. */
  66015. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66016. }
  66017. /**
  66018. * Define a task used by AssetsManager to load text content
  66019. */
  66020. export class TextFileAssetTask extends AbstractAssetTask {
  66021. /**
  66022. * Defines the name of the task
  66023. */
  66024. name: string;
  66025. /**
  66026. * Defines the location of the file to load
  66027. */
  66028. url: string;
  66029. /**
  66030. * Gets the loaded text string
  66031. */
  66032. text: string;
  66033. /**
  66034. * Callback called when the task is successful
  66035. */
  66036. onSuccess: (task: TextFileAssetTask) => void;
  66037. /**
  66038. * Callback called when the task is successful
  66039. */
  66040. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66041. /**
  66042. * Creates a new TextFileAssetTask object
  66043. * @param name defines the name of the task
  66044. * @param url defines the location of the file to load
  66045. */
  66046. constructor(
  66047. /**
  66048. * Defines the name of the task
  66049. */
  66050. name: string,
  66051. /**
  66052. * Defines the location of the file to load
  66053. */
  66054. url: string);
  66055. /**
  66056. * Execute the current task
  66057. * @param scene defines the scene where you want your assets to be loaded
  66058. * @param onSuccess is a callback called when the task is successfully executed
  66059. * @param onError is a callback called if an error occurs
  66060. */
  66061. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66062. }
  66063. /**
  66064. * Define a task used by AssetsManager to load binary data
  66065. */
  66066. export class BinaryFileAssetTask extends AbstractAssetTask {
  66067. /**
  66068. * Defines the name of the task
  66069. */
  66070. name: string;
  66071. /**
  66072. * Defines the location of the file to load
  66073. */
  66074. url: string;
  66075. /**
  66076. * Gets the lodaded data (as an array buffer)
  66077. */
  66078. data: ArrayBuffer;
  66079. /**
  66080. * Callback called when the task is successful
  66081. */
  66082. onSuccess: (task: BinaryFileAssetTask) => void;
  66083. /**
  66084. * Callback called when the task is successful
  66085. */
  66086. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66087. /**
  66088. * Creates a new BinaryFileAssetTask object
  66089. * @param name defines the name of the new task
  66090. * @param url defines the location of the file to load
  66091. */
  66092. constructor(
  66093. /**
  66094. * Defines the name of the task
  66095. */
  66096. name: string,
  66097. /**
  66098. * Defines the location of the file to load
  66099. */
  66100. url: string);
  66101. /**
  66102. * Execute the current task
  66103. * @param scene defines the scene where you want your assets to be loaded
  66104. * @param onSuccess is a callback called when the task is successfully executed
  66105. * @param onError is a callback called if an error occurs
  66106. */
  66107. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66108. }
  66109. /**
  66110. * Define a task used by AssetsManager to load images
  66111. */
  66112. export class ImageAssetTask extends AbstractAssetTask {
  66113. /**
  66114. * Defines the name of the task
  66115. */
  66116. name: string;
  66117. /**
  66118. * Defines the location of the image to load
  66119. */
  66120. url: string;
  66121. /**
  66122. * Gets the loaded images
  66123. */
  66124. image: HTMLImageElement;
  66125. /**
  66126. * Callback called when the task is successful
  66127. */
  66128. onSuccess: (task: ImageAssetTask) => void;
  66129. /**
  66130. * Callback called when the task is successful
  66131. */
  66132. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66133. /**
  66134. * Creates a new ImageAssetTask
  66135. * @param name defines the name of the task
  66136. * @param url defines the location of the image to load
  66137. */
  66138. constructor(
  66139. /**
  66140. * Defines the name of the task
  66141. */
  66142. name: string,
  66143. /**
  66144. * Defines the location of the image to load
  66145. */
  66146. url: string);
  66147. /**
  66148. * Execute the current task
  66149. * @param scene defines the scene where you want your assets to be loaded
  66150. * @param onSuccess is a callback called when the task is successfully executed
  66151. * @param onError is a callback called if an error occurs
  66152. */
  66153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66154. }
  66155. /**
  66156. * Defines the interface used by texture loading tasks
  66157. */
  66158. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66159. /**
  66160. * Gets the loaded texture
  66161. */
  66162. texture: TEX;
  66163. }
  66164. /**
  66165. * Define a task used by AssetsManager to load 2D textures
  66166. */
  66167. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66168. /**
  66169. * Defines the name of the task
  66170. */
  66171. name: string;
  66172. /**
  66173. * Defines the location of the file to load
  66174. */
  66175. url: string;
  66176. /**
  66177. * Defines if mipmap should not be generated (default is false)
  66178. */
  66179. noMipmap?: boolean | undefined;
  66180. /**
  66181. * Defines if texture must be inverted on Y axis (default is false)
  66182. */
  66183. invertY?: boolean | undefined;
  66184. /**
  66185. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66186. */
  66187. samplingMode: number;
  66188. /**
  66189. * Gets the loaded texture
  66190. */
  66191. texture: Texture;
  66192. /**
  66193. * Callback called when the task is successful
  66194. */
  66195. onSuccess: (task: TextureAssetTask) => void;
  66196. /**
  66197. * Callback called when the task is successful
  66198. */
  66199. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66200. /**
  66201. * Creates a new TextureAssetTask object
  66202. * @param name defines the name of the task
  66203. * @param url defines the location of the file to load
  66204. * @param noMipmap defines if mipmap should not be generated (default is false)
  66205. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66206. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66207. */
  66208. constructor(
  66209. /**
  66210. * Defines the name of the task
  66211. */
  66212. name: string,
  66213. /**
  66214. * Defines the location of the file to load
  66215. */
  66216. url: string,
  66217. /**
  66218. * Defines if mipmap should not be generated (default is false)
  66219. */
  66220. noMipmap?: boolean | undefined,
  66221. /**
  66222. * Defines if texture must be inverted on Y axis (default is false)
  66223. */
  66224. invertY?: boolean | undefined,
  66225. /**
  66226. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66227. */
  66228. samplingMode?: number);
  66229. /**
  66230. * Execute the current task
  66231. * @param scene defines the scene where you want your assets to be loaded
  66232. * @param onSuccess is a callback called when the task is successfully executed
  66233. * @param onError is a callback called if an error occurs
  66234. */
  66235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66236. }
  66237. /**
  66238. * Define a task used by AssetsManager to load cube textures
  66239. */
  66240. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66241. /**
  66242. * Defines the name of the task
  66243. */
  66244. name: string;
  66245. /**
  66246. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66247. */
  66248. url: string;
  66249. /**
  66250. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66251. */
  66252. extensions?: string[] | undefined;
  66253. /**
  66254. * Defines if mipmaps should not be generated (default is false)
  66255. */
  66256. noMipmap?: boolean | undefined;
  66257. /**
  66258. * Defines the explicit list of files (undefined by default)
  66259. */
  66260. files?: string[] | undefined;
  66261. /**
  66262. * Gets the loaded texture
  66263. */
  66264. texture: CubeTexture;
  66265. /**
  66266. * Callback called when the task is successful
  66267. */
  66268. onSuccess: (task: CubeTextureAssetTask) => void;
  66269. /**
  66270. * Callback called when the task is successful
  66271. */
  66272. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66273. /**
  66274. * Creates a new CubeTextureAssetTask
  66275. * @param name defines the name of the task
  66276. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66277. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66278. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66279. * @param files defines the explicit list of files (undefined by default)
  66280. */
  66281. constructor(
  66282. /**
  66283. * Defines the name of the task
  66284. */
  66285. name: string,
  66286. /**
  66287. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66288. */
  66289. url: string,
  66290. /**
  66291. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66292. */
  66293. extensions?: string[] | undefined,
  66294. /**
  66295. * Defines if mipmaps should not be generated (default is false)
  66296. */
  66297. noMipmap?: boolean | undefined,
  66298. /**
  66299. * Defines the explicit list of files (undefined by default)
  66300. */
  66301. files?: string[] | undefined);
  66302. /**
  66303. * Execute the current task
  66304. * @param scene defines the scene where you want your assets to be loaded
  66305. * @param onSuccess is a callback called when the task is successfully executed
  66306. * @param onError is a callback called if an error occurs
  66307. */
  66308. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66309. }
  66310. /**
  66311. * Define a task used by AssetsManager to load HDR cube textures
  66312. */
  66313. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  66314. /**
  66315. * Defines the name of the task
  66316. */
  66317. name: string;
  66318. /**
  66319. * Defines the location of the file to load
  66320. */
  66321. url: string;
  66322. /**
  66323. * Defines the desired size (the more it increases the longer the generation will be)
  66324. */
  66325. size: number;
  66326. /**
  66327. * Defines if mipmaps should not be generated (default is false)
  66328. */
  66329. noMipmap: boolean;
  66330. /**
  66331. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66332. */
  66333. generateHarmonics: boolean;
  66334. /**
  66335. * 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)
  66336. */
  66337. gammaSpace: boolean;
  66338. /**
  66339. * Internal Use Only
  66340. */
  66341. reserved: boolean;
  66342. /**
  66343. * Gets the loaded texture
  66344. */
  66345. texture: HDRCubeTexture;
  66346. /**
  66347. * Callback called when the task is successful
  66348. */
  66349. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  66350. /**
  66351. * Callback called when the task is successful
  66352. */
  66353. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  66354. /**
  66355. * Creates a new HDRCubeTextureAssetTask object
  66356. * @param name defines the name of the task
  66357. * @param url defines the location of the file to load
  66358. * @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.
  66359. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66360. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66361. * @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)
  66362. * @param reserved Internal use only
  66363. */
  66364. constructor(
  66365. /**
  66366. * Defines the name of the task
  66367. */
  66368. name: string,
  66369. /**
  66370. * Defines the location of the file to load
  66371. */
  66372. url: string,
  66373. /**
  66374. * Defines the desired size (the more it increases the longer the generation will be)
  66375. */
  66376. size: number,
  66377. /**
  66378. * Defines if mipmaps should not be generated (default is false)
  66379. */
  66380. noMipmap?: boolean,
  66381. /**
  66382. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  66383. */
  66384. generateHarmonics?: boolean,
  66385. /**
  66386. * 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)
  66387. */
  66388. gammaSpace?: boolean,
  66389. /**
  66390. * Internal Use Only
  66391. */
  66392. reserved?: boolean);
  66393. /**
  66394. * Execute the current task
  66395. * @param scene defines the scene where you want your assets to be loaded
  66396. * @param onSuccess is a callback called when the task is successfully executed
  66397. * @param onError is a callback called if an error occurs
  66398. */
  66399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66400. }
  66401. /**
  66402. * Define a task used by AssetsManager to load Equirectangular cube textures
  66403. */
  66404. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  66405. /**
  66406. * Defines the name of the task
  66407. */
  66408. name: string;
  66409. /**
  66410. * Defines the location of the file to load
  66411. */
  66412. url: string;
  66413. /**
  66414. * Defines the desired size (the more it increases the longer the generation will be)
  66415. */
  66416. size: number;
  66417. /**
  66418. * Defines if mipmaps should not be generated (default is false)
  66419. */
  66420. noMipmap: boolean;
  66421. /**
  66422. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66423. * but the standard material would require them in Gamma space) (default is true)
  66424. */
  66425. gammaSpace: boolean;
  66426. /**
  66427. * Gets the loaded texture
  66428. */
  66429. texture: EquiRectangularCubeTexture;
  66430. /**
  66431. * Callback called when the task is successful
  66432. */
  66433. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  66434. /**
  66435. * Callback called when the task is successful
  66436. */
  66437. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  66438. /**
  66439. * Creates a new EquiRectangularCubeTextureAssetTask object
  66440. * @param name defines the name of the task
  66441. * @param url defines the location of the file to load
  66442. * @param size defines the desired size (the more it increases the longer the generation will be)
  66443. * If the size is omitted this implies you are using a preprocessed cubemap.
  66444. * @param noMipmap defines if mipmaps should not be generated (default is false)
  66445. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  66446. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  66447. * (default is true)
  66448. */
  66449. constructor(
  66450. /**
  66451. * Defines the name of the task
  66452. */
  66453. name: string,
  66454. /**
  66455. * Defines the location of the file to load
  66456. */
  66457. url: string,
  66458. /**
  66459. * Defines the desired size (the more it increases the longer the generation will be)
  66460. */
  66461. size: number,
  66462. /**
  66463. * Defines if mipmaps should not be generated (default is false)
  66464. */
  66465. noMipmap?: boolean,
  66466. /**
  66467. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  66468. * but the standard material would require them in Gamma space) (default is true)
  66469. */
  66470. gammaSpace?: boolean);
  66471. /**
  66472. * Execute the current task
  66473. * @param scene defines the scene where you want your assets to be loaded
  66474. * @param onSuccess is a callback called when the task is successfully executed
  66475. * @param onError is a callback called if an error occurs
  66476. */
  66477. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66478. }
  66479. /**
  66480. * This class can be used to easily import assets into a scene
  66481. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  66482. */
  66483. export class AssetsManager {
  66484. private _scene;
  66485. private _isLoading;
  66486. protected _tasks: AbstractAssetTask[];
  66487. protected _waitingTasksCount: number;
  66488. protected _totalTasksCount: number;
  66489. /**
  66490. * Callback called when all tasks are processed
  66491. */
  66492. onFinish: (tasks: AbstractAssetTask[]) => void;
  66493. /**
  66494. * Callback called when a task is successful
  66495. */
  66496. onTaskSuccess: (task: AbstractAssetTask) => void;
  66497. /**
  66498. * Callback called when a task had an error
  66499. */
  66500. onTaskError: (task: AbstractAssetTask) => void;
  66501. /**
  66502. * Callback called when a task is done (whatever the result is)
  66503. */
  66504. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  66505. /**
  66506. * Observable called when all tasks are processed
  66507. */
  66508. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  66509. /**
  66510. * Observable called when a task had an error
  66511. */
  66512. onTaskErrorObservable: Observable<AbstractAssetTask>;
  66513. /**
  66514. * Observable called when all tasks were executed
  66515. */
  66516. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  66517. /**
  66518. * Observable called when a task is done (whatever the result is)
  66519. */
  66520. onProgressObservable: Observable<IAssetsProgressEvent>;
  66521. /**
  66522. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  66523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  66524. */
  66525. useDefaultLoadingScreen: boolean;
  66526. /**
  66527. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  66528. * when all assets have been downloaded.
  66529. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  66530. */
  66531. autoHideLoadingUI: boolean;
  66532. /**
  66533. * Creates a new AssetsManager
  66534. * @param scene defines the scene to work on
  66535. */
  66536. constructor(scene: Scene);
  66537. /**
  66538. * Add a MeshAssetTask to the list of active tasks
  66539. * @param taskName defines the name of the new task
  66540. * @param meshesNames defines the name of meshes to load
  66541. * @param rootUrl defines the root url to use to locate files
  66542. * @param sceneFilename defines the filename of the scene file
  66543. * @returns a new MeshAssetTask object
  66544. */
  66545. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  66546. /**
  66547. * Add a TextFileAssetTask to the list of active tasks
  66548. * @param taskName defines the name of the new task
  66549. * @param url defines the url of the file to load
  66550. * @returns a new TextFileAssetTask object
  66551. */
  66552. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  66553. /**
  66554. * Add a BinaryFileAssetTask to the list of active tasks
  66555. * @param taskName defines the name of the new task
  66556. * @param url defines the url of the file to load
  66557. * @returns a new BinaryFileAssetTask object
  66558. */
  66559. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  66560. /**
  66561. * Add a ImageAssetTask to the list of active tasks
  66562. * @param taskName defines the name of the new task
  66563. * @param url defines the url of the file to load
  66564. * @returns a new ImageAssetTask object
  66565. */
  66566. addImageTask(taskName: string, url: string): ImageAssetTask;
  66567. /**
  66568. * Add a TextureAssetTask to the list of active tasks
  66569. * @param taskName defines the name of the new task
  66570. * @param url defines the url of the file to load
  66571. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66572. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  66573. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66574. * @returns a new TextureAssetTask object
  66575. */
  66576. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  66577. /**
  66578. * Add a CubeTextureAssetTask to the list of active tasks
  66579. * @param taskName defines the name of the new task
  66580. * @param url defines the url of the file to load
  66581. * @param extensions defines the extension to use to load the cube map (can be null)
  66582. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66583. * @param files defines the list of files to load (can be null)
  66584. * @returns a new CubeTextureAssetTask object
  66585. */
  66586. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  66587. /**
  66588. *
  66589. * Add a HDRCubeTextureAssetTask to the list of active tasks
  66590. * @param taskName defines the name of the new task
  66591. * @param url defines the url of the file to load
  66592. * @param size defines the size you want for the cubemap (can be null)
  66593. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66594. * @param generateHarmonics defines if you want to automatically generate (true by default)
  66595. * @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)
  66596. * @param reserved Internal use only
  66597. * @returns a new HDRCubeTextureAssetTask object
  66598. */
  66599. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  66600. /**
  66601. *
  66602. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  66603. * @param taskName defines the name of the new task
  66604. * @param url defines the url of the file to load
  66605. * @param size defines the size you want for the cubemap (can be null)
  66606. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  66607. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66608. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66609. * @returns a new EquiRectangularCubeTextureAssetTask object
  66610. */
  66611. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  66612. /**
  66613. * Remove a task from the assets manager.
  66614. * @param task the task to remove
  66615. */
  66616. removeTask(task: AbstractAssetTask): void;
  66617. private _decreaseWaitingTasksCount;
  66618. private _runTask;
  66619. /**
  66620. * Reset the AssetsManager and remove all tasks
  66621. * @return the current instance of the AssetsManager
  66622. */
  66623. reset(): AssetsManager;
  66624. /**
  66625. * Start the loading process
  66626. * @return the current instance of the AssetsManager
  66627. */
  66628. load(): AssetsManager;
  66629. /**
  66630. * Start the loading process as an async operation
  66631. * @return a promise returning the list of failed tasks
  66632. */
  66633. loadAsync(): Promise<void>;
  66634. }
  66635. }
  66636. declare module "babylonjs/Misc/deferred" {
  66637. /**
  66638. * Wrapper class for promise with external resolve and reject.
  66639. */
  66640. export class Deferred<T> {
  66641. /**
  66642. * The promise associated with this deferred object.
  66643. */
  66644. readonly promise: Promise<T>;
  66645. private _resolve;
  66646. private _reject;
  66647. /**
  66648. * The resolve method of the promise associated with this deferred object.
  66649. */
  66650. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  66651. /**
  66652. * The reject method of the promise associated with this deferred object.
  66653. */
  66654. readonly reject: (reason?: any) => void;
  66655. /**
  66656. * Constructor for this deferred object.
  66657. */
  66658. constructor();
  66659. }
  66660. }
  66661. declare module "babylonjs/Misc/meshExploder" {
  66662. import { Mesh } from "babylonjs/Meshes/mesh";
  66663. /**
  66664. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  66665. */
  66666. export class MeshExploder {
  66667. private _centerMesh;
  66668. private _meshes;
  66669. private _meshesOrigins;
  66670. private _toCenterVectors;
  66671. private _scaledDirection;
  66672. private _newPosition;
  66673. private _centerPosition;
  66674. /**
  66675. * Explodes meshes from a center mesh.
  66676. * @param meshes The meshes to explode.
  66677. * @param centerMesh The mesh to be center of explosion.
  66678. */
  66679. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  66680. private _setCenterMesh;
  66681. /**
  66682. * Get class name
  66683. * @returns "MeshExploder"
  66684. */
  66685. getClassName(): string;
  66686. /**
  66687. * "Exploded meshes"
  66688. * @returns Array of meshes with the centerMesh at index 0.
  66689. */
  66690. getMeshes(): Array<Mesh>;
  66691. /**
  66692. * Explodes meshes giving a specific direction
  66693. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  66694. */
  66695. explode(direction?: number): void;
  66696. }
  66697. }
  66698. declare module "babylonjs/Misc/filesInput" {
  66699. import { Engine } from "babylonjs/Engines/engine";
  66700. import { Scene } from "babylonjs/scene";
  66701. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  66702. /**
  66703. * Class used to help managing file picking and drag'n'drop
  66704. */
  66705. export class FilesInput {
  66706. /**
  66707. * List of files ready to be loaded
  66708. */
  66709. static readonly FilesToLoad: {
  66710. [key: string]: File;
  66711. };
  66712. /**
  66713. * Callback called when a file is processed
  66714. */
  66715. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  66716. private _engine;
  66717. private _currentScene;
  66718. private _sceneLoadedCallback;
  66719. private _progressCallback;
  66720. private _additionalRenderLoopLogicCallback;
  66721. private _textureLoadingCallback;
  66722. private _startingProcessingFilesCallback;
  66723. private _onReloadCallback;
  66724. private _errorCallback;
  66725. private _elementToMonitor;
  66726. private _sceneFileToLoad;
  66727. private _filesToLoad;
  66728. /**
  66729. * Creates a new FilesInput
  66730. * @param engine defines the rendering engine
  66731. * @param scene defines the hosting scene
  66732. * @param sceneLoadedCallback callback called when scene is loaded
  66733. * @param progressCallback callback called to track progress
  66734. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  66735. * @param textureLoadingCallback callback called when a texture is loading
  66736. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  66737. * @param onReloadCallback callback called when a reload is requested
  66738. * @param errorCallback callback call if an error occurs
  66739. */
  66740. 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);
  66741. private _dragEnterHandler;
  66742. private _dragOverHandler;
  66743. private _dropHandler;
  66744. /**
  66745. * Calls this function to listen to drag'n'drop events on a specific DOM element
  66746. * @param elementToMonitor defines the DOM element to track
  66747. */
  66748. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  66749. /**
  66750. * Release all associated resources
  66751. */
  66752. dispose(): void;
  66753. private renderFunction;
  66754. private drag;
  66755. private drop;
  66756. private _traverseFolder;
  66757. private _processFiles;
  66758. /**
  66759. * Load files from a drop event
  66760. * @param event defines the drop event to use as source
  66761. */
  66762. loadFiles(event: any): void;
  66763. private _processReload;
  66764. /**
  66765. * Reload the current scene from the loaded files
  66766. */
  66767. reload(): void;
  66768. }
  66769. }
  66770. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66771. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66772. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66773. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66774. }
  66775. declare module "babylonjs/Misc/sceneOptimizer" {
  66776. import { Scene, IDisposable } from "babylonjs/scene";
  66777. import { Observable } from "babylonjs/Misc/observable";
  66778. /**
  66779. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66781. */
  66782. export class SceneOptimization {
  66783. /**
  66784. * Defines the priority of this optimization (0 by default which means first in the list)
  66785. */
  66786. priority: number;
  66787. /**
  66788. * Gets a string describing the action executed by the current optimization
  66789. * @returns description string
  66790. */
  66791. getDescription(): string;
  66792. /**
  66793. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66794. * @param scene defines the current scene where to apply this optimization
  66795. * @param optimizer defines the current optimizer
  66796. * @returns true if everything that can be done was applied
  66797. */
  66798. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66799. /**
  66800. * Creates the SceneOptimization object
  66801. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66802. * @param desc defines the description associated with the optimization
  66803. */
  66804. constructor(
  66805. /**
  66806. * Defines the priority of this optimization (0 by default which means first in the list)
  66807. */
  66808. priority?: number);
  66809. }
  66810. /**
  66811. * Defines an optimization used to reduce the size of render target textures
  66812. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66813. */
  66814. export class TextureOptimization extends SceneOptimization {
  66815. /**
  66816. * Defines the priority of this optimization (0 by default which means first in the list)
  66817. */
  66818. priority: number;
  66819. /**
  66820. * 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
  66821. */
  66822. maximumSize: number;
  66823. /**
  66824. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66825. */
  66826. step: number;
  66827. /**
  66828. * Gets a string describing the action executed by the current optimization
  66829. * @returns description string
  66830. */
  66831. getDescription(): string;
  66832. /**
  66833. * Creates the TextureOptimization object
  66834. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66835. * @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
  66836. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66837. */
  66838. constructor(
  66839. /**
  66840. * Defines the priority of this optimization (0 by default which means first in the list)
  66841. */
  66842. priority?: number,
  66843. /**
  66844. * 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
  66845. */
  66846. maximumSize?: number,
  66847. /**
  66848. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66849. */
  66850. step?: number);
  66851. /**
  66852. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66853. * @param scene defines the current scene where to apply this optimization
  66854. * @param optimizer defines the current optimizer
  66855. * @returns true if everything that can be done was applied
  66856. */
  66857. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66858. }
  66859. /**
  66860. * Defines an optimization used to increase or decrease the rendering resolution
  66861. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66862. */
  66863. export class HardwareScalingOptimization extends SceneOptimization {
  66864. /**
  66865. * Defines the priority of this optimization (0 by default which means first in the list)
  66866. */
  66867. priority: number;
  66868. /**
  66869. * Defines the maximum scale to use (2 by default)
  66870. */
  66871. maximumScale: number;
  66872. /**
  66873. * Defines the step to use between two passes (0.5 by default)
  66874. */
  66875. step: number;
  66876. private _currentScale;
  66877. private _directionOffset;
  66878. /**
  66879. * Gets a string describing the action executed by the current optimization
  66880. * @return description string
  66881. */
  66882. getDescription(): string;
  66883. /**
  66884. * Creates the HardwareScalingOptimization object
  66885. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66886. * @param maximumScale defines the maximum scale to use (2 by default)
  66887. * @param step defines the step to use between two passes (0.5 by default)
  66888. */
  66889. constructor(
  66890. /**
  66891. * Defines the priority of this optimization (0 by default which means first in the list)
  66892. */
  66893. priority?: number,
  66894. /**
  66895. * Defines the maximum scale to use (2 by default)
  66896. */
  66897. maximumScale?: number,
  66898. /**
  66899. * Defines the step to use between two passes (0.5 by default)
  66900. */
  66901. step?: number);
  66902. /**
  66903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66904. * @param scene defines the current scene where to apply this optimization
  66905. * @param optimizer defines the current optimizer
  66906. * @returns true if everything that can be done was applied
  66907. */
  66908. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66909. }
  66910. /**
  66911. * Defines an optimization used to remove shadows
  66912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66913. */
  66914. export class ShadowsOptimization extends SceneOptimization {
  66915. /**
  66916. * Gets a string describing the action executed by the current optimization
  66917. * @return description string
  66918. */
  66919. getDescription(): string;
  66920. /**
  66921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66922. * @param scene defines the current scene where to apply this optimization
  66923. * @param optimizer defines the current optimizer
  66924. * @returns true if everything that can be done was applied
  66925. */
  66926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66927. }
  66928. /**
  66929. * Defines an optimization used to turn post-processes off
  66930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66931. */
  66932. export class PostProcessesOptimization extends SceneOptimization {
  66933. /**
  66934. * Gets a string describing the action executed by the current optimization
  66935. * @return description string
  66936. */
  66937. getDescription(): string;
  66938. /**
  66939. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66940. * @param scene defines the current scene where to apply this optimization
  66941. * @param optimizer defines the current optimizer
  66942. * @returns true if everything that can be done was applied
  66943. */
  66944. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66945. }
  66946. /**
  66947. * Defines an optimization used to turn lens flares off
  66948. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66949. */
  66950. export class LensFlaresOptimization extends SceneOptimization {
  66951. /**
  66952. * Gets a string describing the action executed by the current optimization
  66953. * @return description string
  66954. */
  66955. getDescription(): string;
  66956. /**
  66957. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66958. * @param scene defines the current scene where to apply this optimization
  66959. * @param optimizer defines the current optimizer
  66960. * @returns true if everything that can be done was applied
  66961. */
  66962. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66963. }
  66964. /**
  66965. * Defines an optimization based on user defined callback.
  66966. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66967. */
  66968. export class CustomOptimization extends SceneOptimization {
  66969. /**
  66970. * Callback called to apply the custom optimization.
  66971. */
  66972. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66973. /**
  66974. * Callback called to get custom description
  66975. */
  66976. onGetDescription: () => string;
  66977. /**
  66978. * Gets a string describing the action executed by the current optimization
  66979. * @returns description string
  66980. */
  66981. getDescription(): string;
  66982. /**
  66983. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66984. * @param scene defines the current scene where to apply this optimization
  66985. * @param optimizer defines the current optimizer
  66986. * @returns true if everything that can be done was applied
  66987. */
  66988. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66989. }
  66990. /**
  66991. * Defines an optimization used to turn particles off
  66992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66993. */
  66994. export class ParticlesOptimization extends SceneOptimization {
  66995. /**
  66996. * Gets a string describing the action executed by the current optimization
  66997. * @return description string
  66998. */
  66999. getDescription(): string;
  67000. /**
  67001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67002. * @param scene defines the current scene where to apply this optimization
  67003. * @param optimizer defines the current optimizer
  67004. * @returns true if everything that can be done was applied
  67005. */
  67006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67007. }
  67008. /**
  67009. * Defines an optimization used to turn render targets off
  67010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67011. */
  67012. export class RenderTargetsOptimization extends SceneOptimization {
  67013. /**
  67014. * Gets a string describing the action executed by the current optimization
  67015. * @return description string
  67016. */
  67017. getDescription(): string;
  67018. /**
  67019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67020. * @param scene defines the current scene where to apply this optimization
  67021. * @param optimizer defines the current optimizer
  67022. * @returns true if everything that can be done was applied
  67023. */
  67024. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67025. }
  67026. /**
  67027. * Defines an optimization used to merge meshes with compatible materials
  67028. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67029. */
  67030. export class MergeMeshesOptimization extends SceneOptimization {
  67031. private static _UpdateSelectionTree;
  67032. /**
  67033. * Gets or sets a boolean which defines if optimization octree has to be updated
  67034. */
  67035. /**
  67036. * Gets or sets a boolean which defines if optimization octree has to be updated
  67037. */
  67038. static UpdateSelectionTree: boolean;
  67039. /**
  67040. * Gets a string describing the action executed by the current optimization
  67041. * @return description string
  67042. */
  67043. getDescription(): string;
  67044. private _canBeMerged;
  67045. /**
  67046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67047. * @param scene defines the current scene where to apply this optimization
  67048. * @param optimizer defines the current optimizer
  67049. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67050. * @returns true if everything that can be done was applied
  67051. */
  67052. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67053. }
  67054. /**
  67055. * Defines a list of options used by SceneOptimizer
  67056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67057. */
  67058. export class SceneOptimizerOptions {
  67059. /**
  67060. * Defines the target frame rate to reach (60 by default)
  67061. */
  67062. targetFrameRate: number;
  67063. /**
  67064. * Defines the interval between two checkes (2000ms by default)
  67065. */
  67066. trackerDuration: number;
  67067. /**
  67068. * Gets the list of optimizations to apply
  67069. */
  67070. optimizations: SceneOptimization[];
  67071. /**
  67072. * Creates a new list of options used by SceneOptimizer
  67073. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67074. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67075. */
  67076. constructor(
  67077. /**
  67078. * Defines the target frame rate to reach (60 by default)
  67079. */
  67080. targetFrameRate?: number,
  67081. /**
  67082. * Defines the interval between two checkes (2000ms by default)
  67083. */
  67084. trackerDuration?: number);
  67085. /**
  67086. * Add a new optimization
  67087. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67088. * @returns the current SceneOptimizerOptions
  67089. */
  67090. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67091. /**
  67092. * Add a new custom optimization
  67093. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67094. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67095. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67096. * @returns the current SceneOptimizerOptions
  67097. */
  67098. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67099. /**
  67100. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67101. * @param targetFrameRate defines the target frame rate (60 by default)
  67102. * @returns a SceneOptimizerOptions object
  67103. */
  67104. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67105. /**
  67106. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67107. * @param targetFrameRate defines the target frame rate (60 by default)
  67108. * @returns a SceneOptimizerOptions object
  67109. */
  67110. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67111. /**
  67112. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67113. * @param targetFrameRate defines the target frame rate (60 by default)
  67114. * @returns a SceneOptimizerOptions object
  67115. */
  67116. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67117. }
  67118. /**
  67119. * Class used to run optimizations in order to reach a target frame rate
  67120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67121. */
  67122. export class SceneOptimizer implements IDisposable {
  67123. private _isRunning;
  67124. private _options;
  67125. private _scene;
  67126. private _currentPriorityLevel;
  67127. private _targetFrameRate;
  67128. private _trackerDuration;
  67129. private _currentFrameRate;
  67130. private _sceneDisposeObserver;
  67131. private _improvementMode;
  67132. /**
  67133. * Defines an observable called when the optimizer reaches the target frame rate
  67134. */
  67135. onSuccessObservable: Observable<SceneOptimizer>;
  67136. /**
  67137. * Defines an observable called when the optimizer enables an optimization
  67138. */
  67139. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67140. /**
  67141. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67142. */
  67143. onFailureObservable: Observable<SceneOptimizer>;
  67144. /**
  67145. * Gets a boolean indicating if the optimizer is in improvement mode
  67146. */
  67147. readonly isInImprovementMode: boolean;
  67148. /**
  67149. * Gets the current priority level (0 at start)
  67150. */
  67151. readonly currentPriorityLevel: number;
  67152. /**
  67153. * Gets the current frame rate checked by the SceneOptimizer
  67154. */
  67155. readonly currentFrameRate: number;
  67156. /**
  67157. * Gets or sets the current target frame rate (60 by default)
  67158. */
  67159. /**
  67160. * Gets or sets the current target frame rate (60 by default)
  67161. */
  67162. targetFrameRate: number;
  67163. /**
  67164. * Gets or sets the current interval between two checks (every 2000ms by default)
  67165. */
  67166. /**
  67167. * Gets or sets the current interval between two checks (every 2000ms by default)
  67168. */
  67169. trackerDuration: number;
  67170. /**
  67171. * Gets the list of active optimizations
  67172. */
  67173. readonly optimizations: SceneOptimization[];
  67174. /**
  67175. * Creates a new SceneOptimizer
  67176. * @param scene defines the scene to work on
  67177. * @param options defines the options to use with the SceneOptimizer
  67178. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67179. * @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)
  67180. */
  67181. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67182. /**
  67183. * Stops the current optimizer
  67184. */
  67185. stop(): void;
  67186. /**
  67187. * Reset the optimizer to initial step (current priority level = 0)
  67188. */
  67189. reset(): void;
  67190. /**
  67191. * Start the optimizer. By default it will try to reach a specific framerate
  67192. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67193. */
  67194. start(): void;
  67195. private _checkCurrentState;
  67196. /**
  67197. * Release all resources
  67198. */
  67199. dispose(): void;
  67200. /**
  67201. * Helper function to create a SceneOptimizer with one single line of code
  67202. * @param scene defines the scene to work on
  67203. * @param options defines the options to use with the SceneOptimizer
  67204. * @param onSuccess defines a callback to call on success
  67205. * @param onFailure defines a callback to call on failure
  67206. * @returns the new SceneOptimizer object
  67207. */
  67208. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67209. }
  67210. }
  67211. declare module "babylonjs/Misc/sceneSerializer" {
  67212. import { Scene } from "babylonjs/scene";
  67213. /**
  67214. * Class used to serialize a scene into a string
  67215. */
  67216. export class SceneSerializer {
  67217. /**
  67218. * Clear cache used by a previous serialization
  67219. */
  67220. static ClearCache(): void;
  67221. /**
  67222. * Serialize a scene into a JSON compatible object
  67223. * @param scene defines the scene to serialize
  67224. * @returns a JSON compatible object
  67225. */
  67226. static Serialize(scene: Scene): any;
  67227. /**
  67228. * Serialize a mesh into a JSON compatible object
  67229. * @param toSerialize defines the mesh to serialize
  67230. * @param withParents defines if parents must be serialized as well
  67231. * @param withChildren defines if children must be serialized as well
  67232. * @returns a JSON compatible object
  67233. */
  67234. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67235. }
  67236. }
  67237. declare module "babylonjs/Misc/textureTools" {
  67238. import { Texture } from "babylonjs/Materials/Textures/texture";
  67239. /**
  67240. * Class used to host texture specific utilities
  67241. */
  67242. export class TextureTools {
  67243. /**
  67244. * Uses the GPU to create a copy texture rescaled at a given size
  67245. * @param texture Texture to copy from
  67246. * @param width defines the desired width
  67247. * @param height defines the desired height
  67248. * @param useBilinearMode defines if bilinear mode has to be used
  67249. * @return the generated texture
  67250. */
  67251. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67252. }
  67253. }
  67254. declare module "babylonjs/Misc/videoRecorder" {
  67255. import { Nullable } from "babylonjs/types";
  67256. import { Engine } from "babylonjs/Engines/engine";
  67257. /**
  67258. * This represents the different options available for the video capture.
  67259. */
  67260. export interface VideoRecorderOptions {
  67261. /** Defines the mime type of the video. */
  67262. mimeType: string;
  67263. /** Defines the FPS the video should be recorded at. */
  67264. fps: number;
  67265. /** Defines the chunk size for the recording data. */
  67266. recordChunckSize: number;
  67267. /** The audio tracks to attach to the recording. */
  67268. audioTracks?: MediaStreamTrack[];
  67269. }
  67270. /**
  67271. * This can help with recording videos from BabylonJS.
  67272. * This is based on the available WebRTC functionalities of the browser.
  67273. *
  67274. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67275. */
  67276. export class VideoRecorder {
  67277. private static readonly _defaultOptions;
  67278. /**
  67279. * Returns whether or not the VideoRecorder is available in your browser.
  67280. * @param engine Defines the Babylon Engine.
  67281. * @returns true if supported otherwise false.
  67282. */
  67283. static IsSupported(engine: Engine): boolean;
  67284. private readonly _options;
  67285. private _canvas;
  67286. private _mediaRecorder;
  67287. private _recordedChunks;
  67288. private _fileName;
  67289. private _resolve;
  67290. private _reject;
  67291. /**
  67292. * True when a recording is already in progress.
  67293. */
  67294. readonly isRecording: boolean;
  67295. /**
  67296. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  67297. * @param engine Defines the BabylonJS Engine you wish to record.
  67298. * @param options Defines options that can be used to customize the capture.
  67299. */
  67300. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  67301. /**
  67302. * Stops the current recording before the default capture timeout passed in the startRecording function.
  67303. */
  67304. stopRecording(): void;
  67305. /**
  67306. * Starts recording the canvas for a max duration specified in parameters.
  67307. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  67308. * If null no automatic download will start and you can rely on the promise to get the data back.
  67309. * @param maxDuration Defines the maximum recording time in seconds.
  67310. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  67311. * @return A promise callback at the end of the recording with the video data in Blob.
  67312. */
  67313. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  67314. /**
  67315. * Releases internal resources used during the recording.
  67316. */
  67317. dispose(): void;
  67318. private _handleDataAvailable;
  67319. private _handleError;
  67320. private _handleStop;
  67321. }
  67322. }
  67323. declare module "babylonjs/Misc/screenshotTools" {
  67324. import { Camera } from "babylonjs/Cameras/camera";
  67325. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  67326. import { Engine } from "babylonjs/Engines/engine";
  67327. /**
  67328. * Class containing a set of static utilities functions for screenshots
  67329. */
  67330. export class ScreenshotTools {
  67331. /**
  67332. * Captures a screenshot of the current rendering
  67333. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67334. * @param engine defines the rendering engine
  67335. * @param camera defines the source camera
  67336. * @param size This parameter can be set to a single number or to an object with the
  67337. * following (optional) properties: precision, width, height. If a single number is passed,
  67338. * it will be used for both width and height. If an object is passed, the screenshot size
  67339. * will be derived from the parameters. The precision property is a multiplier allowing
  67340. * rendering at a higher or lower resolution
  67341. * @param successCallback defines the callback receives a single parameter which contains the
  67342. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67343. * src parameter of an <img> to display it
  67344. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67345. * Check your browser for supported MIME types
  67346. */
  67347. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  67348. /**
  67349. * Captures a screenshot of the current rendering
  67350. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67351. * @param engine defines the rendering engine
  67352. * @param camera defines the source camera
  67353. * @param size This parameter can be set to a single number or to an object with the
  67354. * following (optional) properties: precision, width, height. If a single number is passed,
  67355. * it will be used for both width and height. If an object is passed, the screenshot size
  67356. * will be derived from the parameters. The precision property is a multiplier allowing
  67357. * rendering at a higher or lower resolution
  67358. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  67359. * Check your browser for supported MIME types
  67360. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67361. * to the src parameter of an <img> to display it
  67362. */
  67363. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  67364. /**
  67365. * Generates an image screenshot from the specified camera.
  67366. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67367. * @param engine The engine to use for rendering
  67368. * @param camera The camera to use for rendering
  67369. * @param size This parameter can be set to a single number or to an object with the
  67370. * following (optional) properties: precision, width, height. If a single number is passed,
  67371. * it will be used for both width and height. If an object is passed, the screenshot size
  67372. * will be derived from the parameters. The precision property is a multiplier allowing
  67373. * rendering at a higher or lower resolution
  67374. * @param successCallback The callback receives a single parameter which contains the
  67375. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  67376. * src parameter of an <img> to display it
  67377. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67378. * Check your browser for supported MIME types
  67379. * @param samples Texture samples (default: 1)
  67380. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67381. * @param fileName A name for for the downloaded file.
  67382. */
  67383. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  67384. /**
  67385. * Generates an image screenshot from the specified camera.
  67386. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  67387. * @param engine The engine to use for rendering
  67388. * @param camera The camera to use for rendering
  67389. * @param size This parameter can be set to a single number or to an object with the
  67390. * following (optional) properties: precision, width, height. If a single number is passed,
  67391. * it will be used for both width and height. If an object is passed, the screenshot size
  67392. * will be derived from the parameters. The precision property is a multiplier allowing
  67393. * rendering at a higher or lower resolution
  67394. * @param mimeType The MIME type of the screenshot image (default: image/png).
  67395. * Check your browser for supported MIME types
  67396. * @param samples Texture samples (default: 1)
  67397. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  67398. * @param fileName A name for for the downloaded file.
  67399. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  67400. * to the src parameter of an <img> to display it
  67401. */
  67402. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  67403. /**
  67404. * Gets height and width for screenshot size
  67405. * @private
  67406. */
  67407. private static _getScreenshotSize;
  67408. }
  67409. }
  67410. declare module "babylonjs/Misc/dataReader" {
  67411. /**
  67412. * Interface for a data buffer
  67413. */
  67414. export interface IDataBuffer {
  67415. /**
  67416. * Reads bytes from the data buffer.
  67417. * @param byteOffset The byte offset to read
  67418. * @param byteLength The byte length to read
  67419. * @returns A promise that resolves when the bytes are read
  67420. */
  67421. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  67422. /**
  67423. * The byte length of the buffer.
  67424. */
  67425. readonly byteLength: number;
  67426. }
  67427. /**
  67428. * Utility class for reading from a data buffer
  67429. */
  67430. export class DataReader {
  67431. /**
  67432. * The data buffer associated with this data reader.
  67433. */
  67434. readonly buffer: IDataBuffer;
  67435. /**
  67436. * The current byte offset from the beginning of the data buffer.
  67437. */
  67438. byteOffset: number;
  67439. private _dataView;
  67440. private _dataByteOffset;
  67441. /**
  67442. * Constructor
  67443. * @param buffer The buffer to read
  67444. */
  67445. constructor(buffer: IDataBuffer);
  67446. /**
  67447. * Loads the given byte length.
  67448. * @param byteLength The byte length to load
  67449. * @returns A promise that resolves when the load is complete
  67450. */
  67451. loadAsync(byteLength: number): Promise<void>;
  67452. /**
  67453. * Read a unsigned 32-bit integer from the currently loaded data range.
  67454. * @returns The 32-bit integer read
  67455. */
  67456. readUint32(): number;
  67457. /**
  67458. * Read a byte array from the currently loaded data range.
  67459. * @param byteLength The byte length to read
  67460. * @returns The byte array read
  67461. */
  67462. readUint8Array(byteLength: number): Uint8Array;
  67463. /**
  67464. * Read a string from the currently loaded data range.
  67465. * @param byteLength The byte length to read
  67466. * @returns The string read
  67467. */
  67468. readString(byteLength: number): string;
  67469. /**
  67470. * Skips the given byte length the currently loaded data range.
  67471. * @param byteLength The byte length to skip
  67472. */
  67473. skipBytes(byteLength: number): void;
  67474. }
  67475. }
  67476. declare module "babylonjs/Misc/index" {
  67477. export * from "babylonjs/Misc/andOrNotEvaluator";
  67478. export * from "babylonjs/Misc/assetsManager";
  67479. export * from "babylonjs/Misc/dds";
  67480. export * from "babylonjs/Misc/decorators";
  67481. export * from "babylonjs/Misc/deferred";
  67482. export * from "babylonjs/Misc/environmentTextureTools";
  67483. export * from "babylonjs/Misc/meshExploder";
  67484. export * from "babylonjs/Misc/filesInput";
  67485. export * from "babylonjs/Misc/HighDynamicRange/index";
  67486. export * from "babylonjs/Misc/khronosTextureContainer";
  67487. export * from "babylonjs/Misc/observable";
  67488. export * from "babylonjs/Misc/performanceMonitor";
  67489. export * from "babylonjs/Misc/promise";
  67490. export * from "babylonjs/Misc/sceneOptimizer";
  67491. export * from "babylonjs/Misc/sceneSerializer";
  67492. export * from "babylonjs/Misc/smartArray";
  67493. export * from "babylonjs/Misc/stringDictionary";
  67494. export * from "babylonjs/Misc/tags";
  67495. export * from "babylonjs/Misc/textureTools";
  67496. export * from "babylonjs/Misc/tga";
  67497. export * from "babylonjs/Misc/tools";
  67498. export * from "babylonjs/Misc/videoRecorder";
  67499. export * from "babylonjs/Misc/virtualJoystick";
  67500. export * from "babylonjs/Misc/workerPool";
  67501. export * from "babylonjs/Misc/logger";
  67502. export * from "babylonjs/Misc/typeStore";
  67503. export * from "babylonjs/Misc/filesInputStore";
  67504. export * from "babylonjs/Misc/deepCopier";
  67505. export * from "babylonjs/Misc/pivotTools";
  67506. export * from "babylonjs/Misc/precisionDate";
  67507. export * from "babylonjs/Misc/screenshotTools";
  67508. export * from "babylonjs/Misc/typeStore";
  67509. export * from "babylonjs/Misc/webRequest";
  67510. export * from "babylonjs/Misc/iInspectable";
  67511. export * from "babylonjs/Misc/brdfTextureTools";
  67512. export * from "babylonjs/Misc/rgbdTextureTools";
  67513. export * from "babylonjs/Misc/gradients";
  67514. export * from "babylonjs/Misc/perfCounter";
  67515. export * from "babylonjs/Misc/fileRequest";
  67516. export * from "babylonjs/Misc/customAnimationFrameRequester";
  67517. export * from "babylonjs/Misc/retryStrategy";
  67518. export * from "babylonjs/Misc/interfaces/screenshotSize";
  67519. export * from "babylonjs/Misc/canvasGenerator";
  67520. export * from "babylonjs/Misc/fileTools";
  67521. export * from "babylonjs/Misc/stringTools";
  67522. export * from "babylonjs/Misc/dataReader";
  67523. }
  67524. declare module "babylonjs/index" {
  67525. export * from "babylonjs/abstractScene";
  67526. export * from "babylonjs/Actions/index";
  67527. export * from "babylonjs/Animations/index";
  67528. export * from "babylonjs/assetContainer";
  67529. export * from "babylonjs/Audio/index";
  67530. export * from "babylonjs/Behaviors/index";
  67531. export * from "babylonjs/Bones/index";
  67532. export * from "babylonjs/Cameras/index";
  67533. export * from "babylonjs/Collisions/index";
  67534. export * from "babylonjs/Culling/index";
  67535. export * from "babylonjs/Debug/index";
  67536. export * from "babylonjs/Engines/index";
  67537. export * from "babylonjs/Events/index";
  67538. export * from "babylonjs/Gamepads/index";
  67539. export * from "babylonjs/Gizmos/index";
  67540. export * from "babylonjs/Helpers/index";
  67541. export * from "babylonjs/Instrumentation/index";
  67542. export * from "babylonjs/Layers/index";
  67543. export * from "babylonjs/LensFlares/index";
  67544. export * from "babylonjs/Lights/index";
  67545. export * from "babylonjs/Loading/index";
  67546. export * from "babylonjs/Materials/index";
  67547. export * from "babylonjs/Maths/index";
  67548. export * from "babylonjs/Meshes/index";
  67549. export * from "babylonjs/Morph/index";
  67550. export * from "babylonjs/Navigation/index";
  67551. export * from "babylonjs/node";
  67552. export * from "babylonjs/Offline/index";
  67553. export * from "babylonjs/Particles/index";
  67554. export * from "babylonjs/Physics/index";
  67555. export * from "babylonjs/PostProcesses/index";
  67556. export * from "babylonjs/Probes/index";
  67557. export * from "babylonjs/Rendering/index";
  67558. export * from "babylonjs/scene";
  67559. export * from "babylonjs/sceneComponent";
  67560. export * from "babylonjs/Sprites/index";
  67561. export * from "babylonjs/States/index";
  67562. export * from "babylonjs/Misc/index";
  67563. export * from "babylonjs/types";
  67564. }
  67565. declare module "babylonjs/Animations/pathCursor" {
  67566. import { Vector3 } from "babylonjs/Maths/math.vector";
  67567. import { Path2 } from "babylonjs/Maths/math.path";
  67568. /**
  67569. * A cursor which tracks a point on a path
  67570. */
  67571. export class PathCursor {
  67572. private path;
  67573. /**
  67574. * Stores path cursor callbacks for when an onchange event is triggered
  67575. */
  67576. private _onchange;
  67577. /**
  67578. * The value of the path cursor
  67579. */
  67580. value: number;
  67581. /**
  67582. * The animation array of the path cursor
  67583. */
  67584. animations: Animation[];
  67585. /**
  67586. * Initializes the path cursor
  67587. * @param path The path to track
  67588. */
  67589. constructor(path: Path2);
  67590. /**
  67591. * Gets the cursor point on the path
  67592. * @returns A point on the path cursor at the cursor location
  67593. */
  67594. getPoint(): Vector3;
  67595. /**
  67596. * Moves the cursor ahead by the step amount
  67597. * @param step The amount to move the cursor forward
  67598. * @returns This path cursor
  67599. */
  67600. moveAhead(step?: number): PathCursor;
  67601. /**
  67602. * Moves the cursor behind by the step amount
  67603. * @param step The amount to move the cursor back
  67604. * @returns This path cursor
  67605. */
  67606. moveBack(step?: number): PathCursor;
  67607. /**
  67608. * Moves the cursor by the step amount
  67609. * If the step amount is greater than one, an exception is thrown
  67610. * @param step The amount to move the cursor
  67611. * @returns This path cursor
  67612. */
  67613. move(step: number): PathCursor;
  67614. /**
  67615. * Ensures that the value is limited between zero and one
  67616. * @returns This path cursor
  67617. */
  67618. private ensureLimits;
  67619. /**
  67620. * Runs onchange callbacks on change (used by the animation engine)
  67621. * @returns This path cursor
  67622. */
  67623. private raiseOnChange;
  67624. /**
  67625. * Executes a function on change
  67626. * @param f A path cursor onchange callback
  67627. * @returns This path cursor
  67628. */
  67629. onchange(f: (cursor: PathCursor) => void): PathCursor;
  67630. }
  67631. }
  67632. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  67633. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  67634. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  67635. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  67636. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  67637. }
  67638. declare module "babylonjs/Engines/Processors/Expressions/index" {
  67639. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  67640. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  67641. }
  67642. declare module "babylonjs/Engines/Processors/index" {
  67643. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  67644. export * from "babylonjs/Engines/Processors/Expressions/index";
  67645. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  67646. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  67647. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  67648. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  67649. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  67650. export * from "babylonjs/Engines/Processors/shaderProcessor";
  67651. }
  67652. declare module "babylonjs/Legacy/legacy" {
  67653. import * as Babylon from "babylonjs/index";
  67654. export * from "babylonjs/index";
  67655. }
  67656. declare module "babylonjs/Shaders/blur.fragment" {
  67657. /** @hidden */
  67658. export var blurPixelShader: {
  67659. name: string;
  67660. shader: string;
  67661. };
  67662. }
  67663. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  67664. /** @hidden */
  67665. export var pointCloudVertexDeclaration: {
  67666. name: string;
  67667. shader: string;
  67668. };
  67669. }
  67670. declare module "babylonjs" {
  67671. export * from "babylonjs/Legacy/legacy";
  67672. }
  67673. declare module BABYLON {
  67674. /** Alias type for value that can be null */
  67675. export type Nullable<T> = T | null;
  67676. /**
  67677. * Alias type for number that are floats
  67678. * @ignorenaming
  67679. */
  67680. export type float = number;
  67681. /**
  67682. * Alias type for number that are doubles.
  67683. * @ignorenaming
  67684. */
  67685. export type double = number;
  67686. /**
  67687. * Alias type for number that are integer
  67688. * @ignorenaming
  67689. */
  67690. export type int = number;
  67691. /** Alias type for number array or Float32Array */
  67692. export type FloatArray = number[] | Float32Array;
  67693. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  67694. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  67695. /**
  67696. * Alias for types that can be used by a Buffer or VertexBuffer.
  67697. */
  67698. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  67699. /**
  67700. * Alias type for primitive types
  67701. * @ignorenaming
  67702. */
  67703. type Primitive = undefined | null | boolean | string | number | Function;
  67704. /**
  67705. * Type modifier to make all the properties of an object Readonly
  67706. */
  67707. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  67708. /**
  67709. * Type modifier to make all the properties of an object Readonly recursively
  67710. */
  67711. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  67712. /**
  67713. * Type modifier to make object properties readonly.
  67714. */
  67715. export type DeepImmutableObject<T> = {
  67716. readonly [K in keyof T]: DeepImmutable<T[K]>;
  67717. };
  67718. /** @hidden */
  67719. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  67720. }
  67721. }
  67722. declare module BABYLON {
  67723. /**
  67724. * A class serves as a medium between the observable and its observers
  67725. */
  67726. export class EventState {
  67727. /**
  67728. * Create a new EventState
  67729. * @param mask defines the mask associated with this state
  67730. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67731. * @param target defines the original target of the state
  67732. * @param currentTarget defines the current target of the state
  67733. */
  67734. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  67735. /**
  67736. * Initialize the current event state
  67737. * @param mask defines the mask associated with this state
  67738. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67739. * @param target defines the original target of the state
  67740. * @param currentTarget defines the current target of the state
  67741. * @returns the current event state
  67742. */
  67743. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  67744. /**
  67745. * An Observer can set this property to true to prevent subsequent observers of being notified
  67746. */
  67747. skipNextObservers: boolean;
  67748. /**
  67749. * Get the mask value that were used to trigger the event corresponding to this EventState object
  67750. */
  67751. mask: number;
  67752. /**
  67753. * The object that originally notified the event
  67754. */
  67755. target?: any;
  67756. /**
  67757. * The current object in the bubbling phase
  67758. */
  67759. currentTarget?: any;
  67760. /**
  67761. * This will be populated with the return value of the last function that was executed.
  67762. * If it is the first function in the callback chain it will be the event data.
  67763. */
  67764. lastReturnValue?: any;
  67765. }
  67766. /**
  67767. * Represent an Observer registered to a given Observable object.
  67768. */
  67769. export class Observer<T> {
  67770. /**
  67771. * Defines the callback to call when the observer is notified
  67772. */
  67773. callback: (eventData: T, eventState: EventState) => void;
  67774. /**
  67775. * Defines the mask of the observer (used to filter notifications)
  67776. */
  67777. mask: number;
  67778. /**
  67779. * Defines the current scope used to restore the JS context
  67780. */
  67781. scope: any;
  67782. /** @hidden */
  67783. _willBeUnregistered: boolean;
  67784. /**
  67785. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  67786. */
  67787. unregisterOnNextCall: boolean;
  67788. /**
  67789. * Creates a new observer
  67790. * @param callback defines the callback to call when the observer is notified
  67791. * @param mask defines the mask of the observer (used to filter notifications)
  67792. * @param scope defines the current scope used to restore the JS context
  67793. */
  67794. constructor(
  67795. /**
  67796. * Defines the callback to call when the observer is notified
  67797. */
  67798. callback: (eventData: T, eventState: EventState) => void,
  67799. /**
  67800. * Defines the mask of the observer (used to filter notifications)
  67801. */
  67802. mask: number,
  67803. /**
  67804. * Defines the current scope used to restore the JS context
  67805. */
  67806. scope?: any);
  67807. }
  67808. /**
  67809. * Represent a list of observers registered to multiple Observables object.
  67810. */
  67811. export class MultiObserver<T> {
  67812. private _observers;
  67813. private _observables;
  67814. /**
  67815. * Release associated resources
  67816. */
  67817. dispose(): void;
  67818. /**
  67819. * Raise a callback when one of the observable will notify
  67820. * @param observables defines a list of observables to watch
  67821. * @param callback defines the callback to call on notification
  67822. * @param mask defines the mask used to filter notifications
  67823. * @param scope defines the current scope used to restore the JS context
  67824. * @returns the new MultiObserver
  67825. */
  67826. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  67827. }
  67828. /**
  67829. * The Observable class is a simple implementation of the Observable pattern.
  67830. *
  67831. * 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.
  67832. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  67833. * 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).
  67834. * 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.
  67835. */
  67836. export class Observable<T> {
  67837. private _observers;
  67838. private _eventState;
  67839. private _onObserverAdded;
  67840. /**
  67841. * Gets the list of observers
  67842. */
  67843. readonly observers: Array<Observer<T>>;
  67844. /**
  67845. * Creates a new observable
  67846. * @param onObserverAdded defines a callback to call when a new observer is added
  67847. */
  67848. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67849. /**
  67850. * Create a new Observer with the specified callback
  67851. * @param callback the callback that will be executed for that Observer
  67852. * @param mask the mask used to filter observers
  67853. * @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.
  67854. * @param scope optional scope for the callback to be called from
  67855. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67856. * @returns the new observer created for the callback
  67857. */
  67858. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67859. /**
  67860. * Create a new Observer with the specified callback and unregisters after the next notification
  67861. * @param callback the callback that will be executed for that Observer
  67862. * @returns the new observer created for the callback
  67863. */
  67864. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67865. /**
  67866. * Remove an Observer from the Observable object
  67867. * @param observer the instance of the Observer to remove
  67868. * @returns false if it doesn't belong to this Observable
  67869. */
  67870. remove(observer: Nullable<Observer<T>>): boolean;
  67871. /**
  67872. * Remove a callback from the Observable object
  67873. * @param callback the callback to remove
  67874. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67875. * @returns false if it doesn't belong to this Observable
  67876. */
  67877. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67878. private _deferUnregister;
  67879. private _remove;
  67880. /**
  67881. * Moves the observable to the top of the observer list making it get called first when notified
  67882. * @param observer the observer to move
  67883. */
  67884. makeObserverTopPriority(observer: Observer<T>): void;
  67885. /**
  67886. * Moves the observable to the bottom of the observer list making it get called last when notified
  67887. * @param observer the observer to move
  67888. */
  67889. makeObserverBottomPriority(observer: Observer<T>): void;
  67890. /**
  67891. * Notify all Observers by calling their respective callback with the given data
  67892. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67893. * @param eventData defines the data to send to all observers
  67894. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67895. * @param target defines the original target of the state
  67896. * @param currentTarget defines the current target of the state
  67897. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67898. */
  67899. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67900. /**
  67901. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67902. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67903. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67904. * and it is crucial that all callbacks will be executed.
  67905. * The order of the callbacks is kept, callbacks are not executed parallel.
  67906. *
  67907. * @param eventData The data to be sent to each callback
  67908. * @param mask is used to filter observers defaults to -1
  67909. * @param target defines the callback target (see EventState)
  67910. * @param currentTarget defines he current object in the bubbling phase
  67911. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67912. */
  67913. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67914. /**
  67915. * Notify a specific observer
  67916. * @param observer defines the observer to notify
  67917. * @param eventData defines the data to be sent to each callback
  67918. * @param mask is used to filter observers defaults to -1
  67919. */
  67920. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67921. /**
  67922. * Gets a boolean indicating if the observable has at least one observer
  67923. * @returns true is the Observable has at least one Observer registered
  67924. */
  67925. hasObservers(): boolean;
  67926. /**
  67927. * Clear the list of observers
  67928. */
  67929. clear(): void;
  67930. /**
  67931. * Clone the current observable
  67932. * @returns a new observable
  67933. */
  67934. clone(): Observable<T>;
  67935. /**
  67936. * Does this observable handles observer registered with a given mask
  67937. * @param mask defines the mask to be tested
  67938. * @return whether or not one observer registered with the given mask is handeled
  67939. **/
  67940. hasSpecificMask(mask?: number): boolean;
  67941. }
  67942. }
  67943. declare module BABYLON {
  67944. /**
  67945. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67946. * Babylon.js
  67947. */
  67948. export class DomManagement {
  67949. /**
  67950. * Checks if the window object exists
  67951. * @returns true if the window object exists
  67952. */
  67953. static IsWindowObjectExist(): boolean;
  67954. /**
  67955. * Checks if the navigator object exists
  67956. * @returns true if the navigator object exists
  67957. */
  67958. static IsNavigatorAvailable(): boolean;
  67959. /**
  67960. * Extracts text content from a DOM element hierarchy
  67961. * @param element defines the root element
  67962. * @returns a string
  67963. */
  67964. static GetDOMTextContent(element: HTMLElement): string;
  67965. }
  67966. }
  67967. declare module BABYLON {
  67968. /**
  67969. * Logger used througouht the application to allow configuration of
  67970. * the log level required for the messages.
  67971. */
  67972. export class Logger {
  67973. /**
  67974. * No log
  67975. */
  67976. static readonly NoneLogLevel: number;
  67977. /**
  67978. * Only message logs
  67979. */
  67980. static readonly MessageLogLevel: number;
  67981. /**
  67982. * Only warning logs
  67983. */
  67984. static readonly WarningLogLevel: number;
  67985. /**
  67986. * Only error logs
  67987. */
  67988. static readonly ErrorLogLevel: number;
  67989. /**
  67990. * All logs
  67991. */
  67992. static readonly AllLogLevel: number;
  67993. private static _LogCache;
  67994. /**
  67995. * Gets a value indicating the number of loading errors
  67996. * @ignorenaming
  67997. */
  67998. static errorsCount: number;
  67999. /**
  68000. * Callback called when a new log is added
  68001. */
  68002. static OnNewCacheEntry: (entry: string) => void;
  68003. private static _AddLogEntry;
  68004. private static _FormatMessage;
  68005. private static _LogDisabled;
  68006. private static _LogEnabled;
  68007. private static _WarnDisabled;
  68008. private static _WarnEnabled;
  68009. private static _ErrorDisabled;
  68010. private static _ErrorEnabled;
  68011. /**
  68012. * Log a message to the console
  68013. */
  68014. static Log: (message: string) => void;
  68015. /**
  68016. * Write a warning message to the console
  68017. */
  68018. static Warn: (message: string) => void;
  68019. /**
  68020. * Write an error message to the console
  68021. */
  68022. static Error: (message: string) => void;
  68023. /**
  68024. * Gets current log cache (list of logs)
  68025. */
  68026. static readonly LogCache: string;
  68027. /**
  68028. * Clears the log cache
  68029. */
  68030. static ClearLogCache(): void;
  68031. /**
  68032. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68033. */
  68034. static LogLevels: number;
  68035. }
  68036. }
  68037. declare module BABYLON {
  68038. /** @hidden */
  68039. export class _TypeStore {
  68040. /** @hidden */
  68041. static RegisteredTypes: {
  68042. [key: string]: Object;
  68043. };
  68044. /** @hidden */
  68045. static GetClass(fqdn: string): any;
  68046. }
  68047. }
  68048. declare module BABYLON {
  68049. /**
  68050. * Helper to manipulate strings
  68051. */
  68052. export class StringTools {
  68053. /**
  68054. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68055. * @param str Source string
  68056. * @param suffix Suffix to search for in the source string
  68057. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68058. */
  68059. static EndsWith(str: string, suffix: string): boolean;
  68060. /**
  68061. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68062. * @param str Source string
  68063. * @param suffix Suffix to search for in the source string
  68064. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68065. */
  68066. static StartsWith(str: string, suffix: string): boolean;
  68067. /**
  68068. * Decodes a buffer into a string
  68069. * @param buffer The buffer to decode
  68070. * @returns The decoded string
  68071. */
  68072. static Decode(buffer: Uint8Array | Uint16Array): string;
  68073. /**
  68074. * Encode a buffer to a base64 string
  68075. * @param buffer defines the buffer to encode
  68076. * @returns the encoded string
  68077. */
  68078. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68079. }
  68080. }
  68081. declare module BABYLON {
  68082. /**
  68083. * Class containing a set of static utilities functions for deep copy.
  68084. */
  68085. export class DeepCopier {
  68086. /**
  68087. * Tries to copy an object by duplicating every property
  68088. * @param source defines the source object
  68089. * @param destination defines the target object
  68090. * @param doNotCopyList defines a list of properties to avoid
  68091. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68092. */
  68093. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68094. }
  68095. }
  68096. declare module BABYLON {
  68097. /**
  68098. * Class containing a set of static utilities functions for precision date
  68099. */
  68100. export class PrecisionDate {
  68101. /**
  68102. * Gets either window.performance.now() if supported or Date.now() else
  68103. */
  68104. static readonly Now: number;
  68105. }
  68106. }
  68107. declare module BABYLON {
  68108. /** @hidden */
  68109. export class _DevTools {
  68110. static WarnImport(name: string): string;
  68111. }
  68112. }
  68113. declare module BABYLON {
  68114. /**
  68115. * Interface used to define the mechanism to get data from the network
  68116. */
  68117. export interface IWebRequest {
  68118. /**
  68119. * Returns client's response url
  68120. */
  68121. responseURL: string;
  68122. /**
  68123. * Returns client's status
  68124. */
  68125. status: number;
  68126. /**
  68127. * Returns client's status as a text
  68128. */
  68129. statusText: string;
  68130. }
  68131. }
  68132. declare module BABYLON {
  68133. /**
  68134. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68135. */
  68136. export class WebRequest implements IWebRequest {
  68137. private _xhr;
  68138. /**
  68139. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68140. * i.e. when loading files, where the server/service expects an Authorization header
  68141. */
  68142. static CustomRequestHeaders: {
  68143. [key: string]: string;
  68144. };
  68145. /**
  68146. * Add callback functions in this array to update all the requests before they get sent to the network
  68147. */
  68148. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68149. private _injectCustomRequestHeaders;
  68150. /**
  68151. * Gets or sets a function to be called when loading progress changes
  68152. */
  68153. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68154. /**
  68155. * Returns client's state
  68156. */
  68157. readonly readyState: number;
  68158. /**
  68159. * Returns client's status
  68160. */
  68161. readonly status: number;
  68162. /**
  68163. * Returns client's status as a text
  68164. */
  68165. readonly statusText: string;
  68166. /**
  68167. * Returns client's response
  68168. */
  68169. readonly response: any;
  68170. /**
  68171. * Returns client's response url
  68172. */
  68173. readonly responseURL: string;
  68174. /**
  68175. * Returns client's response as text
  68176. */
  68177. readonly responseText: string;
  68178. /**
  68179. * Gets or sets the expected response type
  68180. */
  68181. responseType: XMLHttpRequestResponseType;
  68182. /** @hidden */
  68183. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68184. /** @hidden */
  68185. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68186. /**
  68187. * Cancels any network activity
  68188. */
  68189. abort(): void;
  68190. /**
  68191. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68192. * @param body defines an optional request body
  68193. */
  68194. send(body?: Document | BodyInit | null): void;
  68195. /**
  68196. * Sets the request method, request URL
  68197. * @param method defines the method to use (GET, POST, etc..)
  68198. * @param url defines the url to connect with
  68199. */
  68200. open(method: string, url: string): void;
  68201. /**
  68202. * Sets the value of a request header.
  68203. * @param name The name of the header whose value is to be set
  68204. * @param value The value to set as the body of the header
  68205. */
  68206. setRequestHeader(name: string, value: string): void;
  68207. /**
  68208. * Get the string containing the text of a particular header's value.
  68209. * @param name The name of the header
  68210. * @returns The string containing the text of the given header name
  68211. */
  68212. getResponseHeader(name: string): Nullable<string>;
  68213. }
  68214. }
  68215. declare module BABYLON {
  68216. /**
  68217. * File request interface
  68218. */
  68219. export interface IFileRequest {
  68220. /**
  68221. * Raised when the request is complete (success or error).
  68222. */
  68223. onCompleteObservable: Observable<IFileRequest>;
  68224. /**
  68225. * Aborts the request for a file.
  68226. */
  68227. abort: () => void;
  68228. }
  68229. }
  68230. declare module BABYLON {
  68231. /**
  68232. * Define options used to create a render target texture
  68233. */
  68234. export class RenderTargetCreationOptions {
  68235. /**
  68236. * Specifies is mipmaps must be generated
  68237. */
  68238. generateMipMaps?: boolean;
  68239. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68240. generateDepthBuffer?: boolean;
  68241. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68242. generateStencilBuffer?: boolean;
  68243. /** Defines texture type (int by default) */
  68244. type?: number;
  68245. /** Defines sampling mode (trilinear by default) */
  68246. samplingMode?: number;
  68247. /** Defines format (RGBA by default) */
  68248. format?: number;
  68249. }
  68250. }
  68251. declare module BABYLON {
  68252. /**
  68253. * @hidden
  68254. **/
  68255. export class _TimeToken {
  68256. _startTimeQuery: Nullable<WebGLQuery>;
  68257. _endTimeQuery: Nullable<WebGLQuery>;
  68258. _timeElapsedQuery: Nullable<WebGLQuery>;
  68259. _timeElapsedQueryEnded: boolean;
  68260. }
  68261. }
  68262. declare module BABYLON {
  68263. /** Defines the cross module used constants to avoid circular dependncies */
  68264. export class Constants {
  68265. /** Defines that alpha blending is disabled */
  68266. static readonly ALPHA_DISABLE: number;
  68267. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68268. static readonly ALPHA_ADD: number;
  68269. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68270. static readonly ALPHA_COMBINE: number;
  68271. /** Defines that alpha blending to DEST - SRC * DEST */
  68272. static readonly ALPHA_SUBTRACT: number;
  68273. /** Defines that alpha blending to SRC * DEST */
  68274. static readonly ALPHA_MULTIPLY: number;
  68275. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68276. static readonly ALPHA_MAXIMIZED: number;
  68277. /** Defines that alpha blending to SRC + DEST */
  68278. static readonly ALPHA_ONEONE: number;
  68279. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68280. static readonly ALPHA_PREMULTIPLIED: number;
  68281. /**
  68282. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68283. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68284. */
  68285. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68286. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68287. static readonly ALPHA_INTERPOLATE: number;
  68288. /**
  68289. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68290. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68291. */
  68292. static readonly ALPHA_SCREENMODE: number;
  68293. /**
  68294. * Defines that alpha blending to SRC + DST
  68295. * Alpha will be set to SRC ALPHA + DST ALPHA
  68296. */
  68297. static readonly ALPHA_ONEONE_ONEONE: number;
  68298. /**
  68299. * Defines that alpha blending to SRC * DST ALPHA + DST
  68300. * Alpha will be set to 0
  68301. */
  68302. static readonly ALPHA_ALPHATOCOLOR: number;
  68303. /**
  68304. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  68305. */
  68306. static readonly ALPHA_REVERSEONEMINUS: number;
  68307. /**
  68308. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  68309. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  68310. */
  68311. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  68312. /**
  68313. * Defines that alpha blending to SRC + DST
  68314. * Alpha will be set to SRC ALPHA
  68315. */
  68316. static readonly ALPHA_ONEONE_ONEZERO: number;
  68317. /** Defines that alpha blending equation a SUM */
  68318. static readonly ALPHA_EQUATION_ADD: number;
  68319. /** Defines that alpha blending equation a SUBSTRACTION */
  68320. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  68321. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  68322. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  68323. /** Defines that alpha blending equation a MAX operation */
  68324. static readonly ALPHA_EQUATION_MAX: number;
  68325. /** Defines that alpha blending equation a MIN operation */
  68326. static readonly ALPHA_EQUATION_MIN: number;
  68327. /**
  68328. * Defines that alpha blending equation a DARKEN operation:
  68329. * It takes the min of the src and sums the alpha channels.
  68330. */
  68331. static readonly ALPHA_EQUATION_DARKEN: number;
  68332. /** Defines that the ressource is not delayed*/
  68333. static readonly DELAYLOADSTATE_NONE: number;
  68334. /** Defines that the ressource was successfully delay loaded */
  68335. static readonly DELAYLOADSTATE_LOADED: number;
  68336. /** Defines that the ressource is currently delay loading */
  68337. static readonly DELAYLOADSTATE_LOADING: number;
  68338. /** Defines that the ressource is delayed and has not started loading */
  68339. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68340. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68341. static readonly NEVER: number;
  68342. /** 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 */
  68343. static readonly ALWAYS: number;
  68344. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68345. static readonly LESS: number;
  68346. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68347. static readonly EQUAL: number;
  68348. /** 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 */
  68349. static readonly LEQUAL: number;
  68350. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68351. static readonly GREATER: number;
  68352. /** 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 */
  68353. static readonly GEQUAL: number;
  68354. /** 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 */
  68355. static readonly NOTEQUAL: number;
  68356. /** Passed to stencilOperation to specify that stencil value must be kept */
  68357. static readonly KEEP: number;
  68358. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68359. static readonly REPLACE: number;
  68360. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68361. static readonly INCR: number;
  68362. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68363. static readonly DECR: number;
  68364. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68365. static readonly INVERT: number;
  68366. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68367. static readonly INCR_WRAP: number;
  68368. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68369. static readonly DECR_WRAP: number;
  68370. /** Texture is not repeating outside of 0..1 UVs */
  68371. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68372. /** Texture is repeating outside of 0..1 UVs */
  68373. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68374. /** Texture is repeating and mirrored */
  68375. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68376. /** ALPHA */
  68377. static readonly TEXTUREFORMAT_ALPHA: number;
  68378. /** LUMINANCE */
  68379. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68380. /** LUMINANCE_ALPHA */
  68381. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68382. /** RGB */
  68383. static readonly TEXTUREFORMAT_RGB: number;
  68384. /** RGBA */
  68385. static readonly TEXTUREFORMAT_RGBA: number;
  68386. /** RED */
  68387. static readonly TEXTUREFORMAT_RED: number;
  68388. /** RED (2nd reference) */
  68389. static readonly TEXTUREFORMAT_R: number;
  68390. /** RG */
  68391. static readonly TEXTUREFORMAT_RG: number;
  68392. /** RED_INTEGER */
  68393. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68394. /** RED_INTEGER (2nd reference) */
  68395. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68396. /** RG_INTEGER */
  68397. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68398. /** RGB_INTEGER */
  68399. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68400. /** RGBA_INTEGER */
  68401. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68402. /** UNSIGNED_BYTE */
  68403. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68404. /** UNSIGNED_BYTE (2nd reference) */
  68405. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68406. /** FLOAT */
  68407. static readonly TEXTURETYPE_FLOAT: number;
  68408. /** HALF_FLOAT */
  68409. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68410. /** BYTE */
  68411. static readonly TEXTURETYPE_BYTE: number;
  68412. /** SHORT */
  68413. static readonly TEXTURETYPE_SHORT: number;
  68414. /** UNSIGNED_SHORT */
  68415. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68416. /** INT */
  68417. static readonly TEXTURETYPE_INT: number;
  68418. /** UNSIGNED_INT */
  68419. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68420. /** UNSIGNED_SHORT_4_4_4_4 */
  68421. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68422. /** UNSIGNED_SHORT_5_5_5_1 */
  68423. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68424. /** UNSIGNED_SHORT_5_6_5 */
  68425. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68426. /** UNSIGNED_INT_2_10_10_10_REV */
  68427. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68428. /** UNSIGNED_INT_24_8 */
  68429. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68430. /** UNSIGNED_INT_10F_11F_11F_REV */
  68431. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68432. /** UNSIGNED_INT_5_9_9_9_REV */
  68433. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68434. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68435. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68436. /** nearest is mag = nearest and min = nearest and mip = linear */
  68437. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68438. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68439. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68440. /** Trilinear is mag = linear and min = linear and mip = linear */
  68441. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68442. /** nearest is mag = nearest and min = nearest and mip = linear */
  68443. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68444. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68445. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68446. /** Trilinear is mag = linear and min = linear and mip = linear */
  68447. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68448. /** mag = nearest and min = nearest and mip = nearest */
  68449. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68450. /** mag = nearest and min = linear and mip = nearest */
  68451. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68452. /** mag = nearest and min = linear and mip = linear */
  68453. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68454. /** mag = nearest and min = linear and mip = none */
  68455. static readonly TEXTURE_NEAREST_LINEAR: number;
  68456. /** mag = nearest and min = nearest and mip = none */
  68457. static readonly TEXTURE_NEAREST_NEAREST: number;
  68458. /** mag = linear and min = nearest and mip = nearest */
  68459. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68460. /** mag = linear and min = nearest and mip = linear */
  68461. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68462. /** mag = linear and min = linear and mip = none */
  68463. static readonly TEXTURE_LINEAR_LINEAR: number;
  68464. /** mag = linear and min = nearest and mip = none */
  68465. static readonly TEXTURE_LINEAR_NEAREST: number;
  68466. /** Explicit coordinates mode */
  68467. static readonly TEXTURE_EXPLICIT_MODE: number;
  68468. /** Spherical coordinates mode */
  68469. static readonly TEXTURE_SPHERICAL_MODE: number;
  68470. /** Planar coordinates mode */
  68471. static readonly TEXTURE_PLANAR_MODE: number;
  68472. /** Cubic coordinates mode */
  68473. static readonly TEXTURE_CUBIC_MODE: number;
  68474. /** Projection coordinates mode */
  68475. static readonly TEXTURE_PROJECTION_MODE: number;
  68476. /** Skybox coordinates mode */
  68477. static readonly TEXTURE_SKYBOX_MODE: number;
  68478. /** Inverse Cubic coordinates mode */
  68479. static readonly TEXTURE_INVCUBIC_MODE: number;
  68480. /** Equirectangular coordinates mode */
  68481. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68482. /** Equirectangular Fixed coordinates mode */
  68483. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68484. /** Equirectangular Fixed Mirrored coordinates mode */
  68485. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68486. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68487. static readonly SCALEMODE_FLOOR: number;
  68488. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68489. static readonly SCALEMODE_NEAREST: number;
  68490. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68491. static readonly SCALEMODE_CEILING: number;
  68492. /**
  68493. * The dirty texture flag value
  68494. */
  68495. static readonly MATERIAL_TextureDirtyFlag: number;
  68496. /**
  68497. * The dirty light flag value
  68498. */
  68499. static readonly MATERIAL_LightDirtyFlag: number;
  68500. /**
  68501. * The dirty fresnel flag value
  68502. */
  68503. static readonly MATERIAL_FresnelDirtyFlag: number;
  68504. /**
  68505. * The dirty attribute flag value
  68506. */
  68507. static readonly MATERIAL_AttributesDirtyFlag: number;
  68508. /**
  68509. * The dirty misc flag value
  68510. */
  68511. static readonly MATERIAL_MiscDirtyFlag: number;
  68512. /**
  68513. * The all dirty flag value
  68514. */
  68515. static readonly MATERIAL_AllDirtyFlag: number;
  68516. /**
  68517. * Returns the triangle fill mode
  68518. */
  68519. static readonly MATERIAL_TriangleFillMode: number;
  68520. /**
  68521. * Returns the wireframe mode
  68522. */
  68523. static readonly MATERIAL_WireFrameFillMode: number;
  68524. /**
  68525. * Returns the point fill mode
  68526. */
  68527. static readonly MATERIAL_PointFillMode: number;
  68528. /**
  68529. * Returns the point list draw mode
  68530. */
  68531. static readonly MATERIAL_PointListDrawMode: number;
  68532. /**
  68533. * Returns the line list draw mode
  68534. */
  68535. static readonly MATERIAL_LineListDrawMode: number;
  68536. /**
  68537. * Returns the line loop draw mode
  68538. */
  68539. static readonly MATERIAL_LineLoopDrawMode: number;
  68540. /**
  68541. * Returns the line strip draw mode
  68542. */
  68543. static readonly MATERIAL_LineStripDrawMode: number;
  68544. /**
  68545. * Returns the triangle strip draw mode
  68546. */
  68547. static readonly MATERIAL_TriangleStripDrawMode: number;
  68548. /**
  68549. * Returns the triangle fan draw mode
  68550. */
  68551. static readonly MATERIAL_TriangleFanDrawMode: number;
  68552. /**
  68553. * Stores the clock-wise side orientation
  68554. */
  68555. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68556. /**
  68557. * Stores the counter clock-wise side orientation
  68558. */
  68559. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68560. /**
  68561. * Nothing
  68562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68563. */
  68564. static readonly ACTION_NothingTrigger: number;
  68565. /**
  68566. * On pick
  68567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68568. */
  68569. static readonly ACTION_OnPickTrigger: number;
  68570. /**
  68571. * On left pick
  68572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68573. */
  68574. static readonly ACTION_OnLeftPickTrigger: number;
  68575. /**
  68576. * On right pick
  68577. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68578. */
  68579. static readonly ACTION_OnRightPickTrigger: number;
  68580. /**
  68581. * On center pick
  68582. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68583. */
  68584. static readonly ACTION_OnCenterPickTrigger: number;
  68585. /**
  68586. * On pick down
  68587. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68588. */
  68589. static readonly ACTION_OnPickDownTrigger: number;
  68590. /**
  68591. * On double pick
  68592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68593. */
  68594. static readonly ACTION_OnDoublePickTrigger: number;
  68595. /**
  68596. * On pick up
  68597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68598. */
  68599. static readonly ACTION_OnPickUpTrigger: number;
  68600. /**
  68601. * On pick out.
  68602. * This trigger will only be raised if you also declared a OnPickDown
  68603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68604. */
  68605. static readonly ACTION_OnPickOutTrigger: number;
  68606. /**
  68607. * On long press
  68608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68609. */
  68610. static readonly ACTION_OnLongPressTrigger: number;
  68611. /**
  68612. * On pointer over
  68613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68614. */
  68615. static readonly ACTION_OnPointerOverTrigger: number;
  68616. /**
  68617. * On pointer out
  68618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68619. */
  68620. static readonly ACTION_OnPointerOutTrigger: number;
  68621. /**
  68622. * On every frame
  68623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68624. */
  68625. static readonly ACTION_OnEveryFrameTrigger: number;
  68626. /**
  68627. * On intersection enter
  68628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68629. */
  68630. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68631. /**
  68632. * On intersection exit
  68633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68634. */
  68635. static readonly ACTION_OnIntersectionExitTrigger: number;
  68636. /**
  68637. * On key down
  68638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68639. */
  68640. static readonly ACTION_OnKeyDownTrigger: number;
  68641. /**
  68642. * On key up
  68643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68644. */
  68645. static readonly ACTION_OnKeyUpTrigger: number;
  68646. /**
  68647. * Billboard mode will only apply to Y axis
  68648. */
  68649. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68650. /**
  68651. * Billboard mode will apply to all axes
  68652. */
  68653. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68654. /**
  68655. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68656. */
  68657. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68658. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68659. * Test order :
  68660. * Is the bounding sphere outside the frustum ?
  68661. * If not, are the bounding box vertices outside the frustum ?
  68662. * It not, then the cullable object is in the frustum.
  68663. */
  68664. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68665. /** Culling strategy : Bounding Sphere Only.
  68666. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68667. * It's also less accurate than the standard because some not visible objects can still be selected.
  68668. * Test : is the bounding sphere outside the frustum ?
  68669. * If not, then the cullable object is in the frustum.
  68670. */
  68671. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68672. /** Culling strategy : Optimistic Inclusion.
  68673. * This in an inclusion test first, then the standard exclusion test.
  68674. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68675. * 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.
  68676. * Anyway, it's as accurate as the standard strategy.
  68677. * Test :
  68678. * Is the cullable object bounding sphere center in the frustum ?
  68679. * If not, apply the default culling strategy.
  68680. */
  68681. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68682. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68683. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68684. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68685. * 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.
  68686. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68687. * Test :
  68688. * Is the cullable object bounding sphere center in the frustum ?
  68689. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68690. */
  68691. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68692. /**
  68693. * No logging while loading
  68694. */
  68695. static readonly SCENELOADER_NO_LOGGING: number;
  68696. /**
  68697. * Minimal logging while loading
  68698. */
  68699. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68700. /**
  68701. * Summary logging while loading
  68702. */
  68703. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68704. /**
  68705. * Detailled logging while loading
  68706. */
  68707. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68708. }
  68709. }
  68710. declare module BABYLON {
  68711. /**
  68712. * This represents the required contract to create a new type of texture loader.
  68713. */
  68714. export interface IInternalTextureLoader {
  68715. /**
  68716. * Defines wether the loader supports cascade loading the different faces.
  68717. */
  68718. supportCascades: boolean;
  68719. /**
  68720. * This returns if the loader support the current file information.
  68721. * @param extension defines the file extension of the file being loaded
  68722. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68723. * @param fallback defines the fallback internal texture if any
  68724. * @param isBase64 defines whether the texture is encoded as a base64
  68725. * @param isBuffer defines whether the texture data are stored as a buffer
  68726. * @returns true if the loader can load the specified file
  68727. */
  68728. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  68729. /**
  68730. * Transform the url before loading if required.
  68731. * @param rootUrl the url of the texture
  68732. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68733. * @returns the transformed texture
  68734. */
  68735. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  68736. /**
  68737. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  68738. * @param rootUrl the url of the texture
  68739. * @param textureFormatInUse defines the current compressed format in use iun the engine
  68740. * @returns the fallback texture
  68741. */
  68742. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  68743. /**
  68744. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  68745. * @param data contains the texture data
  68746. * @param texture defines the BabylonJS internal texture
  68747. * @param createPolynomials will be true if polynomials have been requested
  68748. * @param onLoad defines the callback to trigger once the texture is ready
  68749. * @param onError defines the callback to trigger in case of error
  68750. */
  68751. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  68752. /**
  68753. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  68754. * @param data contains the texture data
  68755. * @param texture defines the BabylonJS internal texture
  68756. * @param callback defines the method to call once ready to upload
  68757. */
  68758. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  68759. }
  68760. }
  68761. declare module BABYLON {
  68762. /**
  68763. * Class used to store and describe the pipeline context associated with an effect
  68764. */
  68765. export interface IPipelineContext {
  68766. /**
  68767. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68768. */
  68769. isAsync: boolean;
  68770. /**
  68771. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68772. */
  68773. isReady: boolean;
  68774. /** @hidden */
  68775. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68776. }
  68777. }
  68778. declare module BABYLON {
  68779. /**
  68780. * Class used to store gfx data (like WebGLBuffer)
  68781. */
  68782. export class DataBuffer {
  68783. /**
  68784. * Gets or sets the number of objects referencing this buffer
  68785. */
  68786. references: number;
  68787. /** Gets or sets the size of the underlying buffer */
  68788. capacity: number;
  68789. /**
  68790. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  68791. */
  68792. is32Bits: boolean;
  68793. /**
  68794. * Gets the underlying buffer
  68795. */
  68796. readonly underlyingResource: any;
  68797. }
  68798. }
  68799. declare module BABYLON {
  68800. /** @hidden */
  68801. export interface IShaderProcessor {
  68802. attributeProcessor?: (attribute: string) => string;
  68803. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68804. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68805. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68806. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68807. lineProcessor?: (line: string, isFragment: boolean) => string;
  68808. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68809. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68810. }
  68811. }
  68812. declare module BABYLON {
  68813. /** @hidden */
  68814. export interface ProcessingOptions {
  68815. defines: string[];
  68816. indexParameters: any;
  68817. isFragment: boolean;
  68818. shouldUseHighPrecisionShader: boolean;
  68819. supportsUniformBuffers: boolean;
  68820. shadersRepository: string;
  68821. includesShadersStore: {
  68822. [key: string]: string;
  68823. };
  68824. processor?: IShaderProcessor;
  68825. version: string;
  68826. platformName: string;
  68827. lookForClosingBracketForUniformBuffer?: boolean;
  68828. }
  68829. }
  68830. declare module BABYLON {
  68831. /** @hidden */
  68832. export class ShaderCodeNode {
  68833. line: string;
  68834. children: ShaderCodeNode[];
  68835. additionalDefineKey?: string;
  68836. additionalDefineValue?: string;
  68837. isValid(preprocessors: {
  68838. [key: string]: string;
  68839. }): boolean;
  68840. process(preprocessors: {
  68841. [key: string]: string;
  68842. }, options: ProcessingOptions): string;
  68843. }
  68844. }
  68845. declare module BABYLON {
  68846. /** @hidden */
  68847. export class ShaderCodeCursor {
  68848. private _lines;
  68849. lineIndex: number;
  68850. readonly currentLine: string;
  68851. readonly canRead: boolean;
  68852. lines: string[];
  68853. }
  68854. }
  68855. declare module BABYLON {
  68856. /** @hidden */
  68857. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68858. process(preprocessors: {
  68859. [key: string]: string;
  68860. }, options: ProcessingOptions): string;
  68861. }
  68862. }
  68863. declare module BABYLON {
  68864. /** @hidden */
  68865. export class ShaderDefineExpression {
  68866. isTrue(preprocessors: {
  68867. [key: string]: string;
  68868. }): boolean;
  68869. }
  68870. }
  68871. declare module BABYLON {
  68872. /** @hidden */
  68873. export class ShaderCodeTestNode extends ShaderCodeNode {
  68874. testExpression: ShaderDefineExpression;
  68875. isValid(preprocessors: {
  68876. [key: string]: string;
  68877. }): boolean;
  68878. }
  68879. }
  68880. declare module BABYLON {
  68881. /** @hidden */
  68882. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68883. define: string;
  68884. not: boolean;
  68885. constructor(define: string, not?: boolean);
  68886. isTrue(preprocessors: {
  68887. [key: string]: string;
  68888. }): boolean;
  68889. }
  68890. }
  68891. declare module BABYLON {
  68892. /** @hidden */
  68893. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68894. leftOperand: ShaderDefineExpression;
  68895. rightOperand: ShaderDefineExpression;
  68896. isTrue(preprocessors: {
  68897. [key: string]: string;
  68898. }): boolean;
  68899. }
  68900. }
  68901. declare module BABYLON {
  68902. /** @hidden */
  68903. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68904. leftOperand: ShaderDefineExpression;
  68905. rightOperand: ShaderDefineExpression;
  68906. isTrue(preprocessors: {
  68907. [key: string]: string;
  68908. }): boolean;
  68909. }
  68910. }
  68911. declare module BABYLON {
  68912. /** @hidden */
  68913. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68914. define: string;
  68915. operand: string;
  68916. testValue: string;
  68917. constructor(define: string, operand: string, testValue: string);
  68918. isTrue(preprocessors: {
  68919. [key: string]: string;
  68920. }): boolean;
  68921. }
  68922. }
  68923. declare module BABYLON {
  68924. /**
  68925. * Class used to enable access to offline support
  68926. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68927. */
  68928. export interface IOfflineProvider {
  68929. /**
  68930. * Gets a boolean indicating if scene must be saved in the database
  68931. */
  68932. enableSceneOffline: boolean;
  68933. /**
  68934. * Gets a boolean indicating if textures must be saved in the database
  68935. */
  68936. enableTexturesOffline: boolean;
  68937. /**
  68938. * Open the offline support and make it available
  68939. * @param successCallback defines the callback to call on success
  68940. * @param errorCallback defines the callback to call on error
  68941. */
  68942. open(successCallback: () => void, errorCallback: () => void): void;
  68943. /**
  68944. * Loads an image from the offline support
  68945. * @param url defines the url to load from
  68946. * @param image defines the target DOM image
  68947. */
  68948. loadImage(url: string, image: HTMLImageElement): void;
  68949. /**
  68950. * Loads a file from offline support
  68951. * @param url defines the URL to load from
  68952. * @param sceneLoaded defines a callback to call on success
  68953. * @param progressCallBack defines a callback to call when progress changed
  68954. * @param errorCallback defines a callback to call on error
  68955. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68956. */
  68957. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68958. }
  68959. }
  68960. declare module BABYLON {
  68961. /**
  68962. * Class used to help managing file picking and drag'n'drop
  68963. * File Storage
  68964. */
  68965. export class FilesInputStore {
  68966. /**
  68967. * List of files ready to be loaded
  68968. */
  68969. static FilesToLoad: {
  68970. [key: string]: File;
  68971. };
  68972. }
  68973. }
  68974. declare module BABYLON {
  68975. /**
  68976. * Class used to define a retry strategy when error happens while loading assets
  68977. */
  68978. export class RetryStrategy {
  68979. /**
  68980. * Function used to defines an exponential back off strategy
  68981. * @param maxRetries defines the maximum number of retries (3 by default)
  68982. * @param baseInterval defines the interval between retries
  68983. * @returns the strategy function to use
  68984. */
  68985. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68986. }
  68987. }
  68988. declare module BABYLON {
  68989. /**
  68990. * @ignore
  68991. * Application error to support additional information when loading a file
  68992. */
  68993. export abstract class BaseError extends Error {
  68994. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  68995. }
  68996. }
  68997. declare module BABYLON {
  68998. /** @ignore */
  68999. export class LoadFileError extends BaseError {
  69000. request?: WebRequest;
  69001. file?: File;
  69002. /**
  69003. * Creates a new LoadFileError
  69004. * @param message defines the message of the error
  69005. * @param request defines the optional web request
  69006. * @param file defines the optional file
  69007. */
  69008. constructor(message: string, object?: WebRequest | File);
  69009. }
  69010. /** @ignore */
  69011. export class RequestFileError extends BaseError {
  69012. request: WebRequest;
  69013. /**
  69014. * Creates a new LoadFileError
  69015. * @param message defines the message of the error
  69016. * @param request defines the optional web request
  69017. */
  69018. constructor(message: string, request: WebRequest);
  69019. }
  69020. /** @ignore */
  69021. export class ReadFileError extends BaseError {
  69022. file: File;
  69023. /**
  69024. * Creates a new ReadFileError
  69025. * @param message defines the message of the error
  69026. * @param file defines the optional file
  69027. */
  69028. constructor(message: string, file: File);
  69029. }
  69030. /**
  69031. * @hidden
  69032. */
  69033. export class FileTools {
  69034. /**
  69035. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69036. */
  69037. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69038. /**
  69039. * Gets or sets the base URL to use to load assets
  69040. */
  69041. static BaseUrl: string;
  69042. /**
  69043. * Default behaviour for cors in the application.
  69044. * It can be a string if the expected behavior is identical in the entire app.
  69045. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69046. */
  69047. static CorsBehavior: string | ((url: string | string[]) => string);
  69048. /**
  69049. * Gets or sets a function used to pre-process url before using them to load assets
  69050. */
  69051. static PreprocessUrl: (url: string) => string;
  69052. /**
  69053. * Removes unwanted characters from an url
  69054. * @param url defines the url to clean
  69055. * @returns the cleaned url
  69056. */
  69057. private static _CleanUrl;
  69058. /**
  69059. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69060. * @param url define the url we are trying
  69061. * @param element define the dom element where to configure the cors policy
  69062. */
  69063. static SetCorsBehavior(url: string | string[], element: {
  69064. crossOrigin: string | null;
  69065. }): void;
  69066. /**
  69067. * Loads an image as an HTMLImageElement.
  69068. * @param input url string, ArrayBuffer, or Blob to load
  69069. * @param onLoad callback called when the image successfully loads
  69070. * @param onError callback called when the image fails to load
  69071. * @param offlineProvider offline provider for caching
  69072. * @param mimeType optional mime type
  69073. * @returns the HTMLImageElement of the loaded image
  69074. */
  69075. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  69076. /**
  69077. * Reads a file from a File object
  69078. * @param file defines the file to load
  69079. * @param onSuccess defines the callback to call when data is loaded
  69080. * @param onProgress defines the callback to call during loading process
  69081. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69082. * @param onError defines the callback to call when an error occurs
  69083. * @returns a file request object
  69084. */
  69085. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69086. /**
  69087. * Loads a file from a url
  69088. * @param url url to load
  69089. * @param onSuccess callback called when the file successfully loads
  69090. * @param onProgress callback called while file is loading (if the server supports this mode)
  69091. * @param offlineProvider defines the offline provider for caching
  69092. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69093. * @param onError callback called when the file fails to load
  69094. * @returns a file request object
  69095. */
  69096. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  69097. /**
  69098. * Loads a file
  69099. * @param url url to load
  69100. * @param onSuccess callback called when the file successfully loads
  69101. * @param onProgress callback called while file is loading (if the server supports this mode)
  69102. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69103. * @param onError callback called when the file fails to load
  69104. * @param onOpened callback called when the web request is opened
  69105. * @returns a file request object
  69106. */
  69107. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  69108. /**
  69109. * Checks if the loaded document was accessed via `file:`-Protocol.
  69110. * @returns boolean
  69111. */
  69112. static IsFileURL(): boolean;
  69113. }
  69114. }
  69115. declare module BABYLON {
  69116. /** @hidden */
  69117. export class ShaderProcessor {
  69118. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69119. private static _ProcessPrecision;
  69120. private static _ExtractOperation;
  69121. private static _BuildSubExpression;
  69122. private static _BuildExpression;
  69123. private static _MoveCursorWithinIf;
  69124. private static _MoveCursor;
  69125. private static _EvaluatePreProcessors;
  69126. private static _PreparePreProcessors;
  69127. private static _ProcessShaderConversion;
  69128. private static _ProcessIncludes;
  69129. }
  69130. }
  69131. declare module BABYLON {
  69132. /**
  69133. * @hidden
  69134. */
  69135. export interface IColor4Like {
  69136. r: float;
  69137. g: float;
  69138. b: float;
  69139. a: float;
  69140. }
  69141. /**
  69142. * @hidden
  69143. */
  69144. export interface IColor3Like {
  69145. r: float;
  69146. g: float;
  69147. b: float;
  69148. }
  69149. /**
  69150. * @hidden
  69151. */
  69152. export interface IVector4Like {
  69153. x: float;
  69154. y: float;
  69155. z: float;
  69156. w: float;
  69157. }
  69158. /**
  69159. * @hidden
  69160. */
  69161. export interface IVector3Like {
  69162. x: float;
  69163. y: float;
  69164. z: float;
  69165. }
  69166. /**
  69167. * @hidden
  69168. */
  69169. export interface IVector2Like {
  69170. x: float;
  69171. y: float;
  69172. }
  69173. /**
  69174. * @hidden
  69175. */
  69176. export interface IMatrixLike {
  69177. toArray(): DeepImmutable<Float32Array>;
  69178. updateFlag: int;
  69179. }
  69180. /**
  69181. * @hidden
  69182. */
  69183. export interface IViewportLike {
  69184. x: float;
  69185. y: float;
  69186. width: float;
  69187. height: float;
  69188. }
  69189. /**
  69190. * @hidden
  69191. */
  69192. export interface IPlaneLike {
  69193. normal: IVector3Like;
  69194. d: float;
  69195. normalize(): void;
  69196. }
  69197. }
  69198. declare module BABYLON {
  69199. /**
  69200. * Interface used to define common properties for effect fallbacks
  69201. */
  69202. export interface IEffectFallbacks {
  69203. /**
  69204. * Removes the defines that should be removed when falling back.
  69205. * @param currentDefines defines the current define statements for the shader.
  69206. * @param effect defines the current effect we try to compile
  69207. * @returns The resulting defines with defines of the current rank removed.
  69208. */
  69209. reduce(currentDefines: string, effect: Effect): string;
  69210. /**
  69211. * Removes the fallback from the bound mesh.
  69212. */
  69213. unBindMesh(): void;
  69214. /**
  69215. * Checks to see if more fallbacks are still availible.
  69216. */
  69217. hasMoreFallbacks: boolean;
  69218. }
  69219. }
  69220. declare module BABYLON {
  69221. /**
  69222. * Class used to evalaute queries containing `and` and `or` operators
  69223. */
  69224. export class AndOrNotEvaluator {
  69225. /**
  69226. * Evaluate a query
  69227. * @param query defines the query to evaluate
  69228. * @param evaluateCallback defines the callback used to filter result
  69229. * @returns true if the query matches
  69230. */
  69231. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69232. private static _HandleParenthesisContent;
  69233. private static _SimplifyNegation;
  69234. }
  69235. }
  69236. declare module BABYLON {
  69237. /**
  69238. * Class used to store custom tags
  69239. */
  69240. export class Tags {
  69241. /**
  69242. * Adds support for tags on the given object
  69243. * @param obj defines the object to use
  69244. */
  69245. static EnableFor(obj: any): void;
  69246. /**
  69247. * Removes tags support
  69248. * @param obj defines the object to use
  69249. */
  69250. static DisableFor(obj: any): void;
  69251. /**
  69252. * Gets a boolean indicating if the given object has tags
  69253. * @param obj defines the object to use
  69254. * @returns a boolean
  69255. */
  69256. static HasTags(obj: any): boolean;
  69257. /**
  69258. * Gets the tags available on a given object
  69259. * @param obj defines the object to use
  69260. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69261. * @returns the tags
  69262. */
  69263. static GetTags(obj: any, asString?: boolean): any;
  69264. /**
  69265. * Adds tags to an object
  69266. * @param obj defines the object to use
  69267. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69268. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69269. */
  69270. static AddTagsTo(obj: any, tagsString: string): void;
  69271. /**
  69272. * @hidden
  69273. */
  69274. static _AddTagTo(obj: any, tag: string): void;
  69275. /**
  69276. * Removes specific tags from a specific object
  69277. * @param obj defines the object to use
  69278. * @param tagsString defines the tags to remove
  69279. */
  69280. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69281. /**
  69282. * @hidden
  69283. */
  69284. static _RemoveTagFrom(obj: any, tag: string): void;
  69285. /**
  69286. * Defines if tags hosted on an object match a given query
  69287. * @param obj defines the object to use
  69288. * @param tagsQuery defines the tag query
  69289. * @returns a boolean
  69290. */
  69291. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69292. }
  69293. }
  69294. declare module BABYLON {
  69295. /**
  69296. * Scalar computation library
  69297. */
  69298. export class Scalar {
  69299. /**
  69300. * Two pi constants convenient for computation.
  69301. */
  69302. static TwoPi: number;
  69303. /**
  69304. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69305. * @param a number
  69306. * @param b number
  69307. * @param epsilon (default = 1.401298E-45)
  69308. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  69309. */
  69310. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  69311. /**
  69312. * Returns a string : the upper case translation of the number i to hexadecimal.
  69313. * @param i number
  69314. * @returns the upper case translation of the number i to hexadecimal.
  69315. */
  69316. static ToHex(i: number): string;
  69317. /**
  69318. * Returns -1 if value is negative and +1 is value is positive.
  69319. * @param value the value
  69320. * @returns the value itself if it's equal to zero.
  69321. */
  69322. static Sign(value: number): number;
  69323. /**
  69324. * Returns the value itself if it's between min and max.
  69325. * Returns min if the value is lower than min.
  69326. * Returns max if the value is greater than max.
  69327. * @param value the value to clmap
  69328. * @param min the min value to clamp to (default: 0)
  69329. * @param max the max value to clamp to (default: 1)
  69330. * @returns the clamped value
  69331. */
  69332. static Clamp(value: number, min?: number, max?: number): number;
  69333. /**
  69334. * the log2 of value.
  69335. * @param value the value to compute log2 of
  69336. * @returns the log2 of value.
  69337. */
  69338. static Log2(value: number): number;
  69339. /**
  69340. * Loops the value, so that it is never larger than length and never smaller than 0.
  69341. *
  69342. * This is similar to the modulo operator but it works with floating point numbers.
  69343. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  69344. * With t = 5 and length = 2.5, the result would be 0.0.
  69345. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  69346. * @param value the value
  69347. * @param length the length
  69348. * @returns the looped value
  69349. */
  69350. static Repeat(value: number, length: number): number;
  69351. /**
  69352. * Normalize the value between 0.0 and 1.0 using min and max values
  69353. * @param value value to normalize
  69354. * @param min max to normalize between
  69355. * @param max min to normalize between
  69356. * @returns the normalized value
  69357. */
  69358. static Normalize(value: number, min: number, max: number): number;
  69359. /**
  69360. * Denormalize the value from 0.0 and 1.0 using min and max values
  69361. * @param normalized value to denormalize
  69362. * @param min max to denormalize between
  69363. * @param max min to denormalize between
  69364. * @returns the denormalized value
  69365. */
  69366. static Denormalize(normalized: number, min: number, max: number): number;
  69367. /**
  69368. * Calculates the shortest difference between two given angles given in degrees.
  69369. * @param current current angle in degrees
  69370. * @param target target angle in degrees
  69371. * @returns the delta
  69372. */
  69373. static DeltaAngle(current: number, target: number): number;
  69374. /**
  69375. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  69376. * @param tx value
  69377. * @param length length
  69378. * @returns The returned value will move back and forth between 0 and length
  69379. */
  69380. static PingPong(tx: number, length: number): number;
  69381. /**
  69382. * Interpolates between min and max with smoothing at the limits.
  69383. *
  69384. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  69385. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  69386. * @param from from
  69387. * @param to to
  69388. * @param tx value
  69389. * @returns the smooth stepped value
  69390. */
  69391. static SmoothStep(from: number, to: number, tx: number): number;
  69392. /**
  69393. * Moves a value current towards target.
  69394. *
  69395. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  69396. * Negative values of maxDelta pushes the value away from target.
  69397. * @param current current value
  69398. * @param target target value
  69399. * @param maxDelta max distance to move
  69400. * @returns resulting value
  69401. */
  69402. static MoveTowards(current: number, target: number, maxDelta: number): number;
  69403. /**
  69404. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69405. *
  69406. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  69407. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  69408. * @param current current value
  69409. * @param target target value
  69410. * @param maxDelta max distance to move
  69411. * @returns resulting angle
  69412. */
  69413. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  69414. /**
  69415. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  69416. * @param start start value
  69417. * @param end target value
  69418. * @param amount amount to lerp between
  69419. * @returns the lerped value
  69420. */
  69421. static Lerp(start: number, end: number, amount: number): number;
  69422. /**
  69423. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  69424. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  69425. * @param start start value
  69426. * @param end target value
  69427. * @param amount amount to lerp between
  69428. * @returns the lerped value
  69429. */
  69430. static LerpAngle(start: number, end: number, amount: number): number;
  69431. /**
  69432. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  69433. * @param a start value
  69434. * @param b target value
  69435. * @param value value between a and b
  69436. * @returns the inverseLerp value
  69437. */
  69438. static InverseLerp(a: number, b: number, value: number): number;
  69439. /**
  69440. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  69441. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  69442. * @param value1 spline value
  69443. * @param tangent1 spline value
  69444. * @param value2 spline value
  69445. * @param tangent2 spline value
  69446. * @param amount input value
  69447. * @returns hermite result
  69448. */
  69449. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  69450. /**
  69451. * Returns a random float number between and min and max values
  69452. * @param min min value of random
  69453. * @param max max value of random
  69454. * @returns random value
  69455. */
  69456. static RandomRange(min: number, max: number): number;
  69457. /**
  69458. * This function returns percentage of a number in a given range.
  69459. *
  69460. * RangeToPercent(40,20,60) will return 0.5 (50%)
  69461. * RangeToPercent(34,0,100) will return 0.34 (34%)
  69462. * @param number to convert to percentage
  69463. * @param min min range
  69464. * @param max max range
  69465. * @returns the percentage
  69466. */
  69467. static RangeToPercent(number: number, min: number, max: number): number;
  69468. /**
  69469. * This function returns number that corresponds to the percentage in a given range.
  69470. *
  69471. * PercentToRange(0.34,0,100) will return 34.
  69472. * @param percent to convert to number
  69473. * @param min min range
  69474. * @param max max range
  69475. * @returns the number
  69476. */
  69477. static PercentToRange(percent: number, min: number, max: number): number;
  69478. /**
  69479. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  69480. * @param angle The angle to normalize in radian.
  69481. * @return The converted angle.
  69482. */
  69483. static NormalizeRadians(angle: number): number;
  69484. }
  69485. }
  69486. declare module BABYLON {
  69487. /**
  69488. * Constant used to convert a value to gamma space
  69489. * @ignorenaming
  69490. */
  69491. export const ToGammaSpace: number;
  69492. /**
  69493. * Constant used to convert a value to linear space
  69494. * @ignorenaming
  69495. */
  69496. export const ToLinearSpace = 2.2;
  69497. /**
  69498. * Constant used to define the minimal number value in Babylon.js
  69499. * @ignorenaming
  69500. */
  69501. let Epsilon: number;
  69502. }
  69503. declare module BABYLON {
  69504. /**
  69505. * Class used to represent a viewport on screen
  69506. */
  69507. export class Viewport {
  69508. /** viewport left coordinate */
  69509. x: number;
  69510. /** viewport top coordinate */
  69511. y: number;
  69512. /**viewport width */
  69513. width: number;
  69514. /** viewport height */
  69515. height: number;
  69516. /**
  69517. * Creates a Viewport object located at (x, y) and sized (width, height)
  69518. * @param x defines viewport left coordinate
  69519. * @param y defines viewport top coordinate
  69520. * @param width defines the viewport width
  69521. * @param height defines the viewport height
  69522. */
  69523. constructor(
  69524. /** viewport left coordinate */
  69525. x: number,
  69526. /** viewport top coordinate */
  69527. y: number,
  69528. /**viewport width */
  69529. width: number,
  69530. /** viewport height */
  69531. height: number);
  69532. /**
  69533. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  69534. * @param renderWidth defines the rendering width
  69535. * @param renderHeight defines the rendering height
  69536. * @returns a new Viewport
  69537. */
  69538. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  69539. /**
  69540. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  69541. * @param renderWidth defines the rendering width
  69542. * @param renderHeight defines the rendering height
  69543. * @param ref defines the target viewport
  69544. * @returns the current viewport
  69545. */
  69546. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  69547. /**
  69548. * Returns a new Viewport copied from the current one
  69549. * @returns a new Viewport
  69550. */
  69551. clone(): Viewport;
  69552. }
  69553. }
  69554. declare module BABYLON {
  69555. /**
  69556. * Class containing a set of static utilities functions for arrays.
  69557. */
  69558. export class ArrayTools {
  69559. /**
  69560. * Returns an array of the given size filled with element built from the given constructor and the paramters
  69561. * @param size the number of element to construct and put in the array
  69562. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  69563. * @returns a new array filled with new objects
  69564. */
  69565. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  69566. }
  69567. }
  69568. declare module BABYLON {
  69569. /**
  69570. * Class representing a vector containing 2 coordinates
  69571. */
  69572. export class Vector2 {
  69573. /** defines the first coordinate */
  69574. x: number;
  69575. /** defines the second coordinate */
  69576. y: number;
  69577. /**
  69578. * Creates a new Vector2 from the given x and y coordinates
  69579. * @param x defines the first coordinate
  69580. * @param y defines the second coordinate
  69581. */
  69582. constructor(
  69583. /** defines the first coordinate */
  69584. x?: number,
  69585. /** defines the second coordinate */
  69586. y?: number);
  69587. /**
  69588. * Gets a string with the Vector2 coordinates
  69589. * @returns a string with the Vector2 coordinates
  69590. */
  69591. toString(): string;
  69592. /**
  69593. * Gets class name
  69594. * @returns the string "Vector2"
  69595. */
  69596. getClassName(): string;
  69597. /**
  69598. * Gets current vector hash code
  69599. * @returns the Vector2 hash code as a number
  69600. */
  69601. getHashCode(): number;
  69602. /**
  69603. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69604. * @param array defines the source array
  69605. * @param index defines the offset in source array
  69606. * @returns the current Vector2
  69607. */
  69608. toArray(array: FloatArray, index?: number): Vector2;
  69609. /**
  69610. * Copy the current vector to an array
  69611. * @returns a new array with 2 elements: the Vector2 coordinates.
  69612. */
  69613. asArray(): number[];
  69614. /**
  69615. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69616. * @param source defines the source Vector2
  69617. * @returns the current updated Vector2
  69618. */
  69619. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  69620. /**
  69621. * Sets the Vector2 coordinates with the given floats
  69622. * @param x defines the first coordinate
  69623. * @param y defines the second coordinate
  69624. * @returns the current updated Vector2
  69625. */
  69626. copyFromFloats(x: number, y: number): Vector2;
  69627. /**
  69628. * Sets the Vector2 coordinates with the given floats
  69629. * @param x defines the first coordinate
  69630. * @param y defines the second coordinate
  69631. * @returns the current updated Vector2
  69632. */
  69633. set(x: number, y: number): Vector2;
  69634. /**
  69635. * Add another vector with the current one
  69636. * @param otherVector defines the other vector
  69637. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69638. */
  69639. add(otherVector: DeepImmutable<Vector2>): Vector2;
  69640. /**
  69641. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69642. * @param otherVector defines the other vector
  69643. * @param result defines the target vector
  69644. * @returns the unmodified current Vector2
  69645. */
  69646. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69647. /**
  69648. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69649. * @param otherVector defines the other vector
  69650. * @returns the current updated Vector2
  69651. */
  69652. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69653. /**
  69654. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69655. * @param otherVector defines the other vector
  69656. * @returns a new Vector2
  69657. */
  69658. addVector3(otherVector: Vector3): Vector2;
  69659. /**
  69660. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69661. * @param otherVector defines the other vector
  69662. * @returns a new Vector2
  69663. */
  69664. subtract(otherVector: Vector2): Vector2;
  69665. /**
  69666. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69667. * @param otherVector defines the other vector
  69668. * @param result defines the target vector
  69669. * @returns the unmodified current Vector2
  69670. */
  69671. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69672. /**
  69673. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69674. * @param otherVector defines the other vector
  69675. * @returns the current updated Vector2
  69676. */
  69677. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69678. /**
  69679. * Multiplies in place the current Vector2 coordinates by the given ones
  69680. * @param otherVector defines the other vector
  69681. * @returns the current updated Vector2
  69682. */
  69683. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69684. /**
  69685. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69686. * @param otherVector defines the other vector
  69687. * @returns a new Vector2
  69688. */
  69689. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  69690. /**
  69691. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69692. * @param otherVector defines the other vector
  69693. * @param result defines the target vector
  69694. * @returns the unmodified current Vector2
  69695. */
  69696. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69697. /**
  69698. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69699. * @param x defines the first coordinate
  69700. * @param y defines the second coordinate
  69701. * @returns a new Vector2
  69702. */
  69703. multiplyByFloats(x: number, y: number): Vector2;
  69704. /**
  69705. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69706. * @param otherVector defines the other vector
  69707. * @returns a new Vector2
  69708. */
  69709. divide(otherVector: Vector2): Vector2;
  69710. /**
  69711. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69712. * @param otherVector defines the other vector
  69713. * @param result defines the target vector
  69714. * @returns the unmodified current Vector2
  69715. */
  69716. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  69717. /**
  69718. * Divides the current Vector2 coordinates by the given ones
  69719. * @param otherVector defines the other vector
  69720. * @returns the current updated Vector2
  69721. */
  69722. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  69723. /**
  69724. * Gets a new Vector2 with current Vector2 negated coordinates
  69725. * @returns a new Vector2
  69726. */
  69727. negate(): Vector2;
  69728. /**
  69729. * Multiply the Vector2 coordinates by scale
  69730. * @param scale defines the scaling factor
  69731. * @returns the current updated Vector2
  69732. */
  69733. scaleInPlace(scale: number): Vector2;
  69734. /**
  69735. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69736. * @param scale defines the scaling factor
  69737. * @returns a new Vector2
  69738. */
  69739. scale(scale: number): Vector2;
  69740. /**
  69741. * Scale the current Vector2 values by a factor to a given Vector2
  69742. * @param scale defines the scale factor
  69743. * @param result defines the Vector2 object where to store the result
  69744. * @returns the unmodified current Vector2
  69745. */
  69746. scaleToRef(scale: number, result: Vector2): Vector2;
  69747. /**
  69748. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69749. * @param scale defines the scale factor
  69750. * @param result defines the Vector2 object where to store the result
  69751. * @returns the unmodified current Vector2
  69752. */
  69753. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  69754. /**
  69755. * Gets a boolean if two vectors are equals
  69756. * @param otherVector defines the other vector
  69757. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69758. */
  69759. equals(otherVector: DeepImmutable<Vector2>): boolean;
  69760. /**
  69761. * Gets a boolean if two vectors are equals (using an epsilon value)
  69762. * @param otherVector defines the other vector
  69763. * @param epsilon defines the minimal distance to consider equality
  69764. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69765. */
  69766. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  69767. /**
  69768. * Gets a new Vector2 from current Vector2 floored values
  69769. * @returns a new Vector2
  69770. */
  69771. floor(): Vector2;
  69772. /**
  69773. * Gets a new Vector2 from current Vector2 floored values
  69774. * @returns a new Vector2
  69775. */
  69776. fract(): Vector2;
  69777. /**
  69778. * Gets the length of the vector
  69779. * @returns the vector length (float)
  69780. */
  69781. length(): number;
  69782. /**
  69783. * Gets the vector squared length
  69784. * @returns the vector squared length (float)
  69785. */
  69786. lengthSquared(): number;
  69787. /**
  69788. * Normalize the vector
  69789. * @returns the current updated Vector2
  69790. */
  69791. normalize(): Vector2;
  69792. /**
  69793. * Gets a new Vector2 copied from the Vector2
  69794. * @returns a new Vector2
  69795. */
  69796. clone(): Vector2;
  69797. /**
  69798. * Gets a new Vector2(0, 0)
  69799. * @returns a new Vector2
  69800. */
  69801. static Zero(): Vector2;
  69802. /**
  69803. * Gets a new Vector2(1, 1)
  69804. * @returns a new Vector2
  69805. */
  69806. static One(): Vector2;
  69807. /**
  69808. * Gets a new Vector2 set from the given index element of the given array
  69809. * @param array defines the data source
  69810. * @param offset defines the offset in the data source
  69811. * @returns a new Vector2
  69812. */
  69813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  69814. /**
  69815. * Sets "result" from the given index element of the given array
  69816. * @param array defines the data source
  69817. * @param offset defines the offset in the data source
  69818. * @param result defines the target vector
  69819. */
  69820. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  69821. /**
  69822. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69823. * @param value1 defines 1st point of control
  69824. * @param value2 defines 2nd point of control
  69825. * @param value3 defines 3rd point of control
  69826. * @param value4 defines 4th point of control
  69827. * @param amount defines the interpolation factor
  69828. * @returns a new Vector2
  69829. */
  69830. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  69831. /**
  69832. * 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".
  69833. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69834. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69835. * @param value defines the value to clamp
  69836. * @param min defines the lower limit
  69837. * @param max defines the upper limit
  69838. * @returns a new Vector2
  69839. */
  69840. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  69841. /**
  69842. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69843. * @param value1 defines the 1st control point
  69844. * @param tangent1 defines the outgoing tangent
  69845. * @param value2 defines the 2nd control point
  69846. * @param tangent2 defines the incoming tangent
  69847. * @param amount defines the interpolation factor
  69848. * @returns a new Vector2
  69849. */
  69850. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  69851. /**
  69852. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69853. * @param start defines the start vector
  69854. * @param end defines the end vector
  69855. * @param amount defines the interpolation factor
  69856. * @returns a new Vector2
  69857. */
  69858. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  69859. /**
  69860. * Gets the dot product of the vector "left" and the vector "right"
  69861. * @param left defines first vector
  69862. * @param right defines second vector
  69863. * @returns the dot product (float)
  69864. */
  69865. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  69866. /**
  69867. * Returns a new Vector2 equal to the normalized given vector
  69868. * @param vector defines the vector to normalize
  69869. * @returns a new Vector2
  69870. */
  69871. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  69872. /**
  69873. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69874. * @param left defines 1st vector
  69875. * @param right defines 2nd vector
  69876. * @returns a new Vector2
  69877. */
  69878. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69879. /**
  69880. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69881. * @param left defines 1st vector
  69882. * @param right defines 2nd vector
  69883. * @returns a new Vector2
  69884. */
  69885. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  69886. /**
  69887. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69888. * @param vector defines the vector to transform
  69889. * @param transformation defines the matrix to apply
  69890. * @returns a new Vector2
  69891. */
  69892. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69893. /**
  69894. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69895. * @param vector defines the vector to transform
  69896. * @param transformation defines the matrix to apply
  69897. * @param result defines the target vector
  69898. */
  69899. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69900. /**
  69901. * Determines if a given vector is included in a triangle
  69902. * @param p defines the vector to test
  69903. * @param p0 defines 1st triangle point
  69904. * @param p1 defines 2nd triangle point
  69905. * @param p2 defines 3rd triangle point
  69906. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69907. */
  69908. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69909. /**
  69910. * Gets the distance between the vectors "value1" and "value2"
  69911. * @param value1 defines first vector
  69912. * @param value2 defines second vector
  69913. * @returns the distance between vectors
  69914. */
  69915. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69916. /**
  69917. * Returns the squared distance between the vectors "value1" and "value2"
  69918. * @param value1 defines first vector
  69919. * @param value2 defines second vector
  69920. * @returns the squared distance between vectors
  69921. */
  69922. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69923. /**
  69924. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69925. * @param value1 defines first vector
  69926. * @param value2 defines second vector
  69927. * @returns a new Vector2
  69928. */
  69929. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69930. /**
  69931. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69932. * @param p defines the middle point
  69933. * @param segA defines one point of the segment
  69934. * @param segB defines the other point of the segment
  69935. * @returns the shortest distance
  69936. */
  69937. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69938. }
  69939. /**
  69940. * Classed used to store (x,y,z) vector representation
  69941. * A Vector3 is the main object used in 3D geometry
  69942. * It can represent etiher the coordinates of a point the space, either a direction
  69943. * Reminder: js uses a left handed forward facing system
  69944. */
  69945. export class Vector3 {
  69946. /**
  69947. * Defines the first coordinates (on X axis)
  69948. */
  69949. x: number;
  69950. /**
  69951. * Defines the second coordinates (on Y axis)
  69952. */
  69953. y: number;
  69954. /**
  69955. * Defines the third coordinates (on Z axis)
  69956. */
  69957. z: number;
  69958. private static _UpReadOnly;
  69959. private static _ZeroReadOnly;
  69960. /**
  69961. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69962. * @param x defines the first coordinates (on X axis)
  69963. * @param y defines the second coordinates (on Y axis)
  69964. * @param z defines the third coordinates (on Z axis)
  69965. */
  69966. constructor(
  69967. /**
  69968. * Defines the first coordinates (on X axis)
  69969. */
  69970. x?: number,
  69971. /**
  69972. * Defines the second coordinates (on Y axis)
  69973. */
  69974. y?: number,
  69975. /**
  69976. * Defines the third coordinates (on Z axis)
  69977. */
  69978. z?: number);
  69979. /**
  69980. * Creates a string representation of the Vector3
  69981. * @returns a string with the Vector3 coordinates.
  69982. */
  69983. toString(): string;
  69984. /**
  69985. * Gets the class name
  69986. * @returns the string "Vector3"
  69987. */
  69988. getClassName(): string;
  69989. /**
  69990. * Creates the Vector3 hash code
  69991. * @returns a number which tends to be unique between Vector3 instances
  69992. */
  69993. getHashCode(): number;
  69994. /**
  69995. * Creates an array containing three elements : the coordinates of the Vector3
  69996. * @returns a new array of numbers
  69997. */
  69998. asArray(): number[];
  69999. /**
  70000. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70001. * @param array defines the destination array
  70002. * @param index defines the offset in the destination array
  70003. * @returns the current Vector3
  70004. */
  70005. toArray(array: FloatArray, index?: number): Vector3;
  70006. /**
  70007. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70008. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70009. */
  70010. toQuaternion(): Quaternion;
  70011. /**
  70012. * Adds the given vector to the current Vector3
  70013. * @param otherVector defines the second operand
  70014. * @returns the current updated Vector3
  70015. */
  70016. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70017. /**
  70018. * Adds the given coordinates to the current Vector3
  70019. * @param x defines the x coordinate of the operand
  70020. * @param y defines the y coordinate of the operand
  70021. * @param z defines the z coordinate of the operand
  70022. * @returns the current updated Vector3
  70023. */
  70024. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70025. /**
  70026. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70027. * @param otherVector defines the second operand
  70028. * @returns the resulting Vector3
  70029. */
  70030. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70031. /**
  70032. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70033. * @param otherVector defines the second operand
  70034. * @param result defines the Vector3 object where to store the result
  70035. * @returns the current Vector3
  70036. */
  70037. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70038. /**
  70039. * Subtract the given vector from the current Vector3
  70040. * @param otherVector defines the second operand
  70041. * @returns the current updated Vector3
  70042. */
  70043. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70044. /**
  70045. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70046. * @param otherVector defines the second operand
  70047. * @returns the resulting Vector3
  70048. */
  70049. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70050. /**
  70051. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70052. * @param otherVector defines the second operand
  70053. * @param result defines the Vector3 object where to store the result
  70054. * @returns the current Vector3
  70055. */
  70056. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70057. /**
  70058. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70059. * @param x defines the x coordinate of the operand
  70060. * @param y defines the y coordinate of the operand
  70061. * @param z defines the z coordinate of the operand
  70062. * @returns the resulting Vector3
  70063. */
  70064. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70065. /**
  70066. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70067. * @param x defines the x coordinate of the operand
  70068. * @param y defines the y coordinate of the operand
  70069. * @param z defines the z coordinate of the operand
  70070. * @param result defines the Vector3 object where to store the result
  70071. * @returns the current Vector3
  70072. */
  70073. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70074. /**
  70075. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70076. * @returns a new Vector3
  70077. */
  70078. negate(): Vector3;
  70079. /**
  70080. * Multiplies the Vector3 coordinates by the float "scale"
  70081. * @param scale defines the multiplier factor
  70082. * @returns the current updated Vector3
  70083. */
  70084. scaleInPlace(scale: number): Vector3;
  70085. /**
  70086. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70087. * @param scale defines the multiplier factor
  70088. * @returns a new Vector3
  70089. */
  70090. scale(scale: number): Vector3;
  70091. /**
  70092. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70093. * @param scale defines the multiplier factor
  70094. * @param result defines the Vector3 object where to store the result
  70095. * @returns the current Vector3
  70096. */
  70097. scaleToRef(scale: number, result: Vector3): Vector3;
  70098. /**
  70099. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70100. * @param scale defines the scale factor
  70101. * @param result defines the Vector3 object where to store the result
  70102. * @returns the unmodified current Vector3
  70103. */
  70104. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70105. /**
  70106. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70107. * @param otherVector defines the second operand
  70108. * @returns true if both vectors are equals
  70109. */
  70110. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70111. /**
  70112. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70113. * @param otherVector defines the second operand
  70114. * @param epsilon defines the minimal distance to define values as equals
  70115. * @returns true if both vectors are distant less than epsilon
  70116. */
  70117. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70118. /**
  70119. * Returns true if the current Vector3 coordinates equals the given floats
  70120. * @param x defines the x coordinate of the operand
  70121. * @param y defines the y coordinate of the operand
  70122. * @param z defines the z coordinate of the operand
  70123. * @returns true if both vectors are equals
  70124. */
  70125. equalsToFloats(x: number, y: number, z: number): boolean;
  70126. /**
  70127. * Multiplies the current Vector3 coordinates by the given ones
  70128. * @param otherVector defines the second operand
  70129. * @returns the current updated Vector3
  70130. */
  70131. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70132. /**
  70133. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70134. * @param otherVector defines the second operand
  70135. * @returns the new Vector3
  70136. */
  70137. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70138. /**
  70139. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70140. * @param otherVector defines the second operand
  70141. * @param result defines the Vector3 object where to store the result
  70142. * @returns the current Vector3
  70143. */
  70144. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70145. /**
  70146. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70147. * @param x defines the x coordinate of the operand
  70148. * @param y defines the y coordinate of the operand
  70149. * @param z defines the z coordinate of the operand
  70150. * @returns the new Vector3
  70151. */
  70152. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70153. /**
  70154. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70155. * @param otherVector defines the second operand
  70156. * @returns the new Vector3
  70157. */
  70158. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70159. /**
  70160. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70161. * @param otherVector defines the second operand
  70162. * @param result defines the Vector3 object where to store the result
  70163. * @returns the current Vector3
  70164. */
  70165. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70166. /**
  70167. * Divides the current Vector3 coordinates by the given ones.
  70168. * @param otherVector defines the second operand
  70169. * @returns the current updated Vector3
  70170. */
  70171. divideInPlace(otherVector: Vector3): Vector3;
  70172. /**
  70173. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70174. * @param other defines the second operand
  70175. * @returns the current updated Vector3
  70176. */
  70177. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70178. /**
  70179. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70180. * @param other defines the second operand
  70181. * @returns the current updated Vector3
  70182. */
  70183. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70184. /**
  70185. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70186. * @param x defines the x coordinate of the operand
  70187. * @param y defines the y coordinate of the operand
  70188. * @param z defines the z coordinate of the operand
  70189. * @returns the current updated Vector3
  70190. */
  70191. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70192. /**
  70193. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70194. * @param x defines the x coordinate of the operand
  70195. * @param y defines the y coordinate of the operand
  70196. * @param z defines the z coordinate of the operand
  70197. * @returns the current updated Vector3
  70198. */
  70199. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70200. /**
  70201. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70202. * Check if is non uniform within a certain amount of decimal places to account for this
  70203. * @param epsilon the amount the values can differ
  70204. * @returns if the the vector is non uniform to a certain number of decimal places
  70205. */
  70206. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70207. /**
  70208. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70209. */
  70210. readonly isNonUniform: boolean;
  70211. /**
  70212. * Gets a new Vector3 from current Vector3 floored values
  70213. * @returns a new Vector3
  70214. */
  70215. floor(): Vector3;
  70216. /**
  70217. * Gets a new Vector3 from current Vector3 floored values
  70218. * @returns a new Vector3
  70219. */
  70220. fract(): Vector3;
  70221. /**
  70222. * Gets the length of the Vector3
  70223. * @returns the length of the Vector3
  70224. */
  70225. length(): number;
  70226. /**
  70227. * Gets the squared length of the Vector3
  70228. * @returns squared length of the Vector3
  70229. */
  70230. lengthSquared(): number;
  70231. /**
  70232. * Normalize the current Vector3.
  70233. * Please note that this is an in place operation.
  70234. * @returns the current updated Vector3
  70235. */
  70236. normalize(): Vector3;
  70237. /**
  70238. * Reorders the x y z properties of the vector in place
  70239. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70240. * @returns the current updated vector
  70241. */
  70242. reorderInPlace(order: string): this;
  70243. /**
  70244. * Rotates the vector around 0,0,0 by a quaternion
  70245. * @param quaternion the rotation quaternion
  70246. * @param result vector to store the result
  70247. * @returns the resulting vector
  70248. */
  70249. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70250. /**
  70251. * Rotates a vector around a given point
  70252. * @param quaternion the rotation quaternion
  70253. * @param point the point to rotate around
  70254. * @param result vector to store the result
  70255. * @returns the resulting vector
  70256. */
  70257. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70258. /**
  70259. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70260. * The cross product is then orthogonal to both current and "other"
  70261. * @param other defines the right operand
  70262. * @returns the cross product
  70263. */
  70264. cross(other: Vector3): Vector3;
  70265. /**
  70266. * Normalize the current Vector3 with the given input length.
  70267. * Please note that this is an in place operation.
  70268. * @param len the length of the vector
  70269. * @returns the current updated Vector3
  70270. */
  70271. normalizeFromLength(len: number): Vector3;
  70272. /**
  70273. * Normalize the current Vector3 to a new vector
  70274. * @returns the new Vector3
  70275. */
  70276. normalizeToNew(): Vector3;
  70277. /**
  70278. * Normalize the current Vector3 to the reference
  70279. * @param reference define the Vector3 to update
  70280. * @returns the updated Vector3
  70281. */
  70282. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  70283. /**
  70284. * Creates a new Vector3 copied from the current Vector3
  70285. * @returns the new Vector3
  70286. */
  70287. clone(): Vector3;
  70288. /**
  70289. * Copies the given vector coordinates to the current Vector3 ones
  70290. * @param source defines the source Vector3
  70291. * @returns the current updated Vector3
  70292. */
  70293. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  70294. /**
  70295. * Copies the given floats to the current Vector3 coordinates
  70296. * @param x defines the x coordinate of the operand
  70297. * @param y defines the y coordinate of the operand
  70298. * @param z defines the z coordinate of the operand
  70299. * @returns the current updated Vector3
  70300. */
  70301. copyFromFloats(x: number, y: number, z: number): Vector3;
  70302. /**
  70303. * Copies the given floats to the current Vector3 coordinates
  70304. * @param x defines the x coordinate of the operand
  70305. * @param y defines the y coordinate of the operand
  70306. * @param z defines the z coordinate of the operand
  70307. * @returns the current updated Vector3
  70308. */
  70309. set(x: number, y: number, z: number): Vector3;
  70310. /**
  70311. * Copies the given float to the current Vector3 coordinates
  70312. * @param v defines the x, y and z coordinates of the operand
  70313. * @returns the current updated Vector3
  70314. */
  70315. setAll(v: number): Vector3;
  70316. /**
  70317. * Get the clip factor between two vectors
  70318. * @param vector0 defines the first operand
  70319. * @param vector1 defines the second operand
  70320. * @param axis defines the axis to use
  70321. * @param size defines the size along the axis
  70322. * @returns the clip factor
  70323. */
  70324. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  70325. /**
  70326. * Get angle between two vectors
  70327. * @param vector0 angle between vector0 and vector1
  70328. * @param vector1 angle between vector0 and vector1
  70329. * @param normal direction of the normal
  70330. * @return the angle between vector0 and vector1
  70331. */
  70332. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  70333. /**
  70334. * Returns a new Vector3 set from the index "offset" of the given array
  70335. * @param array defines the source array
  70336. * @param offset defines the offset in the source array
  70337. * @returns the new Vector3
  70338. */
  70339. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  70340. /**
  70341. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70342. * This function is deprecated. Use FromArray instead
  70343. * @param array defines the source array
  70344. * @param offset defines the offset in the source array
  70345. * @returns the new Vector3
  70346. */
  70347. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  70348. /**
  70349. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70350. * @param array defines the source array
  70351. * @param offset defines the offset in the source array
  70352. * @param result defines the Vector3 where to store the result
  70353. */
  70354. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  70355. /**
  70356. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70357. * This function is deprecated. Use FromArrayToRef instead.
  70358. * @param array defines the source array
  70359. * @param offset defines the offset in the source array
  70360. * @param result defines the Vector3 where to store the result
  70361. */
  70362. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  70363. /**
  70364. * Sets the given vector "result" with the given floats.
  70365. * @param x defines the x coordinate of the source
  70366. * @param y defines the y coordinate of the source
  70367. * @param z defines the z coordinate of the source
  70368. * @param result defines the Vector3 where to store the result
  70369. */
  70370. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  70371. /**
  70372. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70373. * @returns a new empty Vector3
  70374. */
  70375. static Zero(): Vector3;
  70376. /**
  70377. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70378. * @returns a new unit Vector3
  70379. */
  70380. static One(): Vector3;
  70381. /**
  70382. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70383. * @returns a new up Vector3
  70384. */
  70385. static Up(): Vector3;
  70386. /**
  70387. * Gets a up Vector3 that must not be updated
  70388. */
  70389. static readonly UpReadOnly: DeepImmutable<Vector3>;
  70390. /**
  70391. * Gets a zero Vector3 that must not be updated
  70392. */
  70393. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  70394. /**
  70395. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70396. * @returns a new down Vector3
  70397. */
  70398. static Down(): Vector3;
  70399. /**
  70400. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70401. * @returns a new forward Vector3
  70402. */
  70403. static Forward(): Vector3;
  70404. /**
  70405. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70406. * @returns a new forward Vector3
  70407. */
  70408. static Backward(): Vector3;
  70409. /**
  70410. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70411. * @returns a new right Vector3
  70412. */
  70413. static Right(): Vector3;
  70414. /**
  70415. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70416. * @returns a new left Vector3
  70417. */
  70418. static Left(): Vector3;
  70419. /**
  70420. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70421. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70422. * @param vector defines the Vector3 to transform
  70423. * @param transformation defines the transformation matrix
  70424. * @returns the transformed Vector3
  70425. */
  70426. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70427. /**
  70428. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70429. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70430. * @param vector defines the Vector3 to transform
  70431. * @param transformation defines the transformation matrix
  70432. * @param result defines the Vector3 where to store the result
  70433. */
  70434. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70435. /**
  70436. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70437. * This method computes tranformed coordinates only, not transformed direction vectors
  70438. * @param x define the x coordinate of the source vector
  70439. * @param y define the y coordinate of the source vector
  70440. * @param z define the z coordinate of the source vector
  70441. * @param transformation defines the transformation matrix
  70442. * @param result defines the Vector3 where to store the result
  70443. */
  70444. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70445. /**
  70446. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70447. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70448. * @param vector defines the Vector3 to transform
  70449. * @param transformation defines the transformation matrix
  70450. * @returns the new Vector3
  70451. */
  70452. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  70453. /**
  70454. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70455. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70456. * @param vector defines the Vector3 to transform
  70457. * @param transformation defines the transformation matrix
  70458. * @param result defines the Vector3 where to store the result
  70459. */
  70460. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70461. /**
  70462. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70463. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70464. * @param x define the x coordinate of the source vector
  70465. * @param y define the y coordinate of the source vector
  70466. * @param z define the z coordinate of the source vector
  70467. * @param transformation defines the transformation matrix
  70468. * @param result defines the Vector3 where to store the result
  70469. */
  70470. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  70471. /**
  70472. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70473. * @param value1 defines the first control point
  70474. * @param value2 defines the second control point
  70475. * @param value3 defines the third control point
  70476. * @param value4 defines the fourth control point
  70477. * @param amount defines the amount on the spline to use
  70478. * @returns the new Vector3
  70479. */
  70480. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  70481. /**
  70482. * 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"
  70483. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70484. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70485. * @param value defines the current value
  70486. * @param min defines the lower range value
  70487. * @param max defines the upper range value
  70488. * @returns the new Vector3
  70489. */
  70490. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  70491. /**
  70492. * 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"
  70493. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70494. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70495. * @param value defines the current value
  70496. * @param min defines the lower range value
  70497. * @param max defines the upper range value
  70498. * @param result defines the Vector3 where to store the result
  70499. */
  70500. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  70501. /**
  70502. * Checks if a given vector is inside a specific range
  70503. * @param v defines the vector to test
  70504. * @param min defines the minimum range
  70505. * @param max defines the maximum range
  70506. */
  70507. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  70508. /**
  70509. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70510. * @param value1 defines the first control point
  70511. * @param tangent1 defines the first tangent vector
  70512. * @param value2 defines the second control point
  70513. * @param tangent2 defines the second tangent vector
  70514. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70515. * @returns the new Vector3
  70516. */
  70517. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  70518. /**
  70519. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70520. * @param start defines the start value
  70521. * @param end defines the end value
  70522. * @param amount max defines amount between both (between 0 and 1)
  70523. * @returns the new Vector3
  70524. */
  70525. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  70526. /**
  70527. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70528. * @param start defines the start value
  70529. * @param end defines the end value
  70530. * @param amount max defines amount between both (between 0 and 1)
  70531. * @param result defines the Vector3 where to store the result
  70532. */
  70533. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  70534. /**
  70535. * Returns the dot product (float) between the vectors "left" and "right"
  70536. * @param left defines the left operand
  70537. * @param right defines the right operand
  70538. * @returns the dot product
  70539. */
  70540. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  70541. /**
  70542. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70543. * The cross product is then orthogonal to both "left" and "right"
  70544. * @param left defines the left operand
  70545. * @param right defines the right operand
  70546. * @returns the cross product
  70547. */
  70548. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70549. /**
  70550. * Sets the given vector "result" with the cross product of "left" and "right"
  70551. * The cross product is then orthogonal to both "left" and "right"
  70552. * @param left defines the left operand
  70553. * @param right defines the right operand
  70554. * @param result defines the Vector3 where to store the result
  70555. */
  70556. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  70557. /**
  70558. * Returns a new Vector3 as the normalization of the given vector
  70559. * @param vector defines the Vector3 to normalize
  70560. * @returns the new Vector3
  70561. */
  70562. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  70563. /**
  70564. * Sets the given vector "result" with the normalization of the given first vector
  70565. * @param vector defines the Vector3 to normalize
  70566. * @param result defines the Vector3 where to store the result
  70567. */
  70568. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  70569. /**
  70570. * Project a Vector3 onto screen space
  70571. * @param vector defines the Vector3 to project
  70572. * @param world defines the world matrix to use
  70573. * @param transform defines the transform (view x projection) matrix to use
  70574. * @param viewport defines the screen viewport to use
  70575. * @returns the new Vector3
  70576. */
  70577. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  70578. /** @hidden */
  70579. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  70580. /**
  70581. * Unproject from screen space to object space
  70582. * @param source defines the screen space Vector3 to use
  70583. * @param viewportWidth defines the current width of the viewport
  70584. * @param viewportHeight defines the current height of the viewport
  70585. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70586. * @param transform defines the transform (view x projection) matrix to use
  70587. * @returns the new Vector3
  70588. */
  70589. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  70590. /**
  70591. * Unproject from screen space to object space
  70592. * @param source defines the screen space Vector3 to use
  70593. * @param viewportWidth defines the current width of the viewport
  70594. * @param viewportHeight defines the current height of the viewport
  70595. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70596. * @param view defines the view matrix to use
  70597. * @param projection defines the projection matrix to use
  70598. * @returns the new Vector3
  70599. */
  70600. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  70601. /**
  70602. * Unproject from screen space to object space
  70603. * @param source defines the screen space Vector3 to use
  70604. * @param viewportWidth defines the current width of the viewport
  70605. * @param viewportHeight defines the current height of the viewport
  70606. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70607. * @param view defines the view matrix to use
  70608. * @param projection defines the projection matrix to use
  70609. * @param result defines the Vector3 where to store the result
  70610. */
  70611. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70612. /**
  70613. * Unproject from screen space to object space
  70614. * @param sourceX defines the screen space x coordinate to use
  70615. * @param sourceY defines the screen space y coordinate to use
  70616. * @param sourceZ defines the screen space z coordinate to use
  70617. * @param viewportWidth defines the current width of the viewport
  70618. * @param viewportHeight defines the current height of the viewport
  70619. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70620. * @param view defines the view matrix to use
  70621. * @param projection defines the projection matrix to use
  70622. * @param result defines the Vector3 where to store the result
  70623. */
  70624. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  70625. /**
  70626. * Gets the minimal coordinate values between two Vector3
  70627. * @param left defines the first operand
  70628. * @param right defines the second operand
  70629. * @returns the new Vector3
  70630. */
  70631. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70632. /**
  70633. * Gets the maximal coordinate values between two Vector3
  70634. * @param left defines the first operand
  70635. * @param right defines the second operand
  70636. * @returns the new Vector3
  70637. */
  70638. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  70639. /**
  70640. * Returns the distance between the vectors "value1" and "value2"
  70641. * @param value1 defines the first operand
  70642. * @param value2 defines the second operand
  70643. * @returns the distance
  70644. */
  70645. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70646. /**
  70647. * Returns the squared distance between the vectors "value1" and "value2"
  70648. * @param value1 defines the first operand
  70649. * @param value2 defines the second operand
  70650. * @returns the squared distance
  70651. */
  70652. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  70653. /**
  70654. * Returns a new Vector3 located at the center between "value1" and "value2"
  70655. * @param value1 defines the first operand
  70656. * @param value2 defines the second operand
  70657. * @returns the new Vector3
  70658. */
  70659. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  70660. /**
  70661. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70662. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70663. * to something in order to rotate it from its local system to the given target system
  70664. * Note: axis1, axis2 and axis3 are normalized during this operation
  70665. * @param axis1 defines the first axis
  70666. * @param axis2 defines the second axis
  70667. * @param axis3 defines the third axis
  70668. * @returns a new Vector3
  70669. */
  70670. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  70671. /**
  70672. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70673. * @param axis1 defines the first axis
  70674. * @param axis2 defines the second axis
  70675. * @param axis3 defines the third axis
  70676. * @param ref defines the Vector3 where to store the result
  70677. */
  70678. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  70679. }
  70680. /**
  70681. * Vector4 class created for EulerAngle class conversion to Quaternion
  70682. */
  70683. export class Vector4 {
  70684. /** x value of the vector */
  70685. x: number;
  70686. /** y value of the vector */
  70687. y: number;
  70688. /** z value of the vector */
  70689. z: number;
  70690. /** w value of the vector */
  70691. w: number;
  70692. /**
  70693. * Creates a Vector4 object from the given floats.
  70694. * @param x x value of the vector
  70695. * @param y y value of the vector
  70696. * @param z z value of the vector
  70697. * @param w w value of the vector
  70698. */
  70699. constructor(
  70700. /** x value of the vector */
  70701. x: number,
  70702. /** y value of the vector */
  70703. y: number,
  70704. /** z value of the vector */
  70705. z: number,
  70706. /** w value of the vector */
  70707. w: number);
  70708. /**
  70709. * Returns the string with the Vector4 coordinates.
  70710. * @returns a string containing all the vector values
  70711. */
  70712. toString(): string;
  70713. /**
  70714. * Returns the string "Vector4".
  70715. * @returns "Vector4"
  70716. */
  70717. getClassName(): string;
  70718. /**
  70719. * Returns the Vector4 hash code.
  70720. * @returns a unique hash code
  70721. */
  70722. getHashCode(): number;
  70723. /**
  70724. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70725. * @returns the resulting array
  70726. */
  70727. asArray(): number[];
  70728. /**
  70729. * Populates the given array from the given index with the Vector4 coordinates.
  70730. * @param array array to populate
  70731. * @param index index of the array to start at (default: 0)
  70732. * @returns the Vector4.
  70733. */
  70734. toArray(array: FloatArray, index?: number): Vector4;
  70735. /**
  70736. * Adds the given vector to the current Vector4.
  70737. * @param otherVector the vector to add
  70738. * @returns the updated Vector4.
  70739. */
  70740. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70741. /**
  70742. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70743. * @param otherVector the vector to add
  70744. * @returns the resulting vector
  70745. */
  70746. add(otherVector: DeepImmutable<Vector4>): Vector4;
  70747. /**
  70748. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70749. * @param otherVector the vector to add
  70750. * @param result the vector to store the result
  70751. * @returns the current Vector4.
  70752. */
  70753. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70754. /**
  70755. * Subtract in place the given vector from the current Vector4.
  70756. * @param otherVector the vector to subtract
  70757. * @returns the updated Vector4.
  70758. */
  70759. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70760. /**
  70761. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70762. * @param otherVector the vector to add
  70763. * @returns the new vector with the result
  70764. */
  70765. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  70766. /**
  70767. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70768. * @param otherVector the vector to subtract
  70769. * @param result the vector to store the result
  70770. * @returns the current Vector4.
  70771. */
  70772. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70773. /**
  70774. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70775. */
  70776. /**
  70777. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70778. * @param x value to subtract
  70779. * @param y value to subtract
  70780. * @param z value to subtract
  70781. * @param w value to subtract
  70782. * @returns new vector containing the result
  70783. */
  70784. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70785. /**
  70786. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70787. * @param x value to subtract
  70788. * @param y value to subtract
  70789. * @param z value to subtract
  70790. * @param w value to subtract
  70791. * @param result the vector to store the result in
  70792. * @returns the current Vector4.
  70793. */
  70794. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  70795. /**
  70796. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70797. * @returns a new vector with the negated values
  70798. */
  70799. negate(): Vector4;
  70800. /**
  70801. * Multiplies the current Vector4 coordinates by scale (float).
  70802. * @param scale the number to scale with
  70803. * @returns the updated Vector4.
  70804. */
  70805. scaleInPlace(scale: number): Vector4;
  70806. /**
  70807. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  70808. * @param scale the number to scale with
  70809. * @returns a new vector with the result
  70810. */
  70811. scale(scale: number): Vector4;
  70812. /**
  70813. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  70814. * @param scale the number to scale with
  70815. * @param result a vector to store the result in
  70816. * @returns the current Vector4.
  70817. */
  70818. scaleToRef(scale: number, result: Vector4): Vector4;
  70819. /**
  70820. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  70821. * @param scale defines the scale factor
  70822. * @param result defines the Vector4 object where to store the result
  70823. * @returns the unmodified current Vector4
  70824. */
  70825. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  70826. /**
  70827. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  70828. * @param otherVector the vector to compare against
  70829. * @returns true if they are equal
  70830. */
  70831. equals(otherVector: DeepImmutable<Vector4>): boolean;
  70832. /**
  70833. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  70834. * @param otherVector vector to compare against
  70835. * @param epsilon (Default: very small number)
  70836. * @returns true if they are equal
  70837. */
  70838. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  70839. /**
  70840. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  70841. * @param x x value to compare against
  70842. * @param y y value to compare against
  70843. * @param z z value to compare against
  70844. * @param w w value to compare against
  70845. * @returns true if equal
  70846. */
  70847. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  70848. /**
  70849. * Multiplies in place the current Vector4 by the given one.
  70850. * @param otherVector vector to multiple with
  70851. * @returns the updated Vector4.
  70852. */
  70853. multiplyInPlace(otherVector: Vector4): Vector4;
  70854. /**
  70855. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  70856. * @param otherVector vector to multiple with
  70857. * @returns resulting new vector
  70858. */
  70859. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  70860. /**
  70861. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  70862. * @param otherVector vector to multiple with
  70863. * @param result vector to store the result
  70864. * @returns the current Vector4.
  70865. */
  70866. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70867. /**
  70868. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  70869. * @param x x value multiply with
  70870. * @param y y value multiply with
  70871. * @param z z value multiply with
  70872. * @param w w value multiply with
  70873. * @returns resulting new vector
  70874. */
  70875. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  70876. /**
  70877. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  70878. * @param otherVector vector to devide with
  70879. * @returns resulting new vector
  70880. */
  70881. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  70882. /**
  70883. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  70884. * @param otherVector vector to devide with
  70885. * @param result vector to store the result
  70886. * @returns the current Vector4.
  70887. */
  70888. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  70889. /**
  70890. * Divides the current Vector3 coordinates by the given ones.
  70891. * @param otherVector vector to devide with
  70892. * @returns the updated Vector3.
  70893. */
  70894. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70895. /**
  70896. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70897. * @param other defines the second operand
  70898. * @returns the current updated Vector4
  70899. */
  70900. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70901. /**
  70902. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70903. * @param other defines the second operand
  70904. * @returns the current updated Vector4
  70905. */
  70906. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70907. /**
  70908. * Gets a new Vector4 from current Vector4 floored values
  70909. * @returns a new Vector4
  70910. */
  70911. floor(): Vector4;
  70912. /**
  70913. * Gets a new Vector4 from current Vector3 floored values
  70914. * @returns a new Vector4
  70915. */
  70916. fract(): Vector4;
  70917. /**
  70918. * Returns the Vector4 length (float).
  70919. * @returns the length
  70920. */
  70921. length(): number;
  70922. /**
  70923. * Returns the Vector4 squared length (float).
  70924. * @returns the length squared
  70925. */
  70926. lengthSquared(): number;
  70927. /**
  70928. * Normalizes in place the Vector4.
  70929. * @returns the updated Vector4.
  70930. */
  70931. normalize(): Vector4;
  70932. /**
  70933. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70934. * @returns this converted to a new vector3
  70935. */
  70936. toVector3(): Vector3;
  70937. /**
  70938. * Returns a new Vector4 copied from the current one.
  70939. * @returns the new cloned vector
  70940. */
  70941. clone(): Vector4;
  70942. /**
  70943. * Updates the current Vector4 with the given one coordinates.
  70944. * @param source the source vector to copy from
  70945. * @returns the updated Vector4.
  70946. */
  70947. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70948. /**
  70949. * Updates the current Vector4 coordinates with the given floats.
  70950. * @param x float to copy from
  70951. * @param y float to copy from
  70952. * @param z float to copy from
  70953. * @param w float to copy from
  70954. * @returns the updated Vector4.
  70955. */
  70956. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70957. /**
  70958. * Updates the current Vector4 coordinates with the given floats.
  70959. * @param x float to set from
  70960. * @param y float to set from
  70961. * @param z float to set from
  70962. * @param w float to set from
  70963. * @returns the updated Vector4.
  70964. */
  70965. set(x: number, y: number, z: number, w: number): Vector4;
  70966. /**
  70967. * Copies the given float to the current Vector3 coordinates
  70968. * @param v defines the x, y, z and w coordinates of the operand
  70969. * @returns the current updated Vector3
  70970. */
  70971. setAll(v: number): Vector4;
  70972. /**
  70973. * Returns a new Vector4 set from the starting index of the given array.
  70974. * @param array the array to pull values from
  70975. * @param offset the offset into the array to start at
  70976. * @returns the new vector
  70977. */
  70978. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70979. /**
  70980. * Updates the given vector "result" from the starting index of the given array.
  70981. * @param array the array to pull values from
  70982. * @param offset the offset into the array to start at
  70983. * @param result the vector to store the result in
  70984. */
  70985. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70986. /**
  70987. * Updates the given vector "result" from the starting index of the given Float32Array.
  70988. * @param array the array to pull values from
  70989. * @param offset the offset into the array to start at
  70990. * @param result the vector to store the result in
  70991. */
  70992. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70993. /**
  70994. * Updates the given vector "result" coordinates from the given floats.
  70995. * @param x float to set from
  70996. * @param y float to set from
  70997. * @param z float to set from
  70998. * @param w float to set from
  70999. * @param result the vector to the floats in
  71000. */
  71001. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71002. /**
  71003. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71004. * @returns the new vector
  71005. */
  71006. static Zero(): Vector4;
  71007. /**
  71008. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71009. * @returns the new vector
  71010. */
  71011. static One(): Vector4;
  71012. /**
  71013. * Returns a new normalized Vector4 from the given one.
  71014. * @param vector the vector to normalize
  71015. * @returns the vector
  71016. */
  71017. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71018. /**
  71019. * Updates the given vector "result" from the normalization of the given one.
  71020. * @param vector the vector to normalize
  71021. * @param result the vector to store the result in
  71022. */
  71023. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71024. /**
  71025. * Returns a vector with the minimum values from the left and right vectors
  71026. * @param left left vector to minimize
  71027. * @param right right vector to minimize
  71028. * @returns a new vector with the minimum of the left and right vector values
  71029. */
  71030. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71031. /**
  71032. * Returns a vector with the maximum values from the left and right vectors
  71033. * @param left left vector to maximize
  71034. * @param right right vector to maximize
  71035. * @returns a new vector with the maximum of the left and right vector values
  71036. */
  71037. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71038. /**
  71039. * Returns the distance (float) between the vectors "value1" and "value2".
  71040. * @param value1 value to calulate the distance between
  71041. * @param value2 value to calulate the distance between
  71042. * @return the distance between the two vectors
  71043. */
  71044. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71045. /**
  71046. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71047. * @param value1 value to calulate the distance between
  71048. * @param value2 value to calulate the distance between
  71049. * @return the distance between the two vectors squared
  71050. */
  71051. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71052. /**
  71053. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71054. * @param value1 value to calulate the center between
  71055. * @param value2 value to calulate the center between
  71056. * @return the center between the two vectors
  71057. */
  71058. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71059. /**
  71060. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71061. * This methods computes transformed normalized direction vectors only.
  71062. * @param vector the vector to transform
  71063. * @param transformation the transformation matrix to apply
  71064. * @returns the new vector
  71065. */
  71066. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71067. /**
  71068. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71069. * This methods computes transformed normalized direction vectors only.
  71070. * @param vector the vector to transform
  71071. * @param transformation the transformation matrix to apply
  71072. * @param result the vector to store the result in
  71073. */
  71074. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71075. /**
  71076. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71077. * This methods computes transformed normalized direction vectors only.
  71078. * @param x value to transform
  71079. * @param y value to transform
  71080. * @param z value to transform
  71081. * @param w value to transform
  71082. * @param transformation the transformation matrix to apply
  71083. * @param result the vector to store the results in
  71084. */
  71085. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71086. /**
  71087. * Creates a new Vector4 from a Vector3
  71088. * @param source defines the source data
  71089. * @param w defines the 4th component (default is 0)
  71090. * @returns a new Vector4
  71091. */
  71092. static FromVector3(source: Vector3, w?: number): Vector4;
  71093. }
  71094. /**
  71095. * Class used to store quaternion data
  71096. * @see https://en.wikipedia.org/wiki/Quaternion
  71097. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71098. */
  71099. export class Quaternion {
  71100. /** defines the first component (0 by default) */
  71101. x: number;
  71102. /** defines the second component (0 by default) */
  71103. y: number;
  71104. /** defines the third component (0 by default) */
  71105. z: number;
  71106. /** defines the fourth component (1.0 by default) */
  71107. w: number;
  71108. /**
  71109. * Creates a new Quaternion from the given floats
  71110. * @param x defines the first component (0 by default)
  71111. * @param y defines the second component (0 by default)
  71112. * @param z defines the third component (0 by default)
  71113. * @param w defines the fourth component (1.0 by default)
  71114. */
  71115. constructor(
  71116. /** defines the first component (0 by default) */
  71117. x?: number,
  71118. /** defines the second component (0 by default) */
  71119. y?: number,
  71120. /** defines the third component (0 by default) */
  71121. z?: number,
  71122. /** defines the fourth component (1.0 by default) */
  71123. w?: number);
  71124. /**
  71125. * Gets a string representation for the current quaternion
  71126. * @returns a string with the Quaternion coordinates
  71127. */
  71128. toString(): string;
  71129. /**
  71130. * Gets the class name of the quaternion
  71131. * @returns the string "Quaternion"
  71132. */
  71133. getClassName(): string;
  71134. /**
  71135. * Gets a hash code for this quaternion
  71136. * @returns the quaternion hash code
  71137. */
  71138. getHashCode(): number;
  71139. /**
  71140. * Copy the quaternion to an array
  71141. * @returns a new array populated with 4 elements from the quaternion coordinates
  71142. */
  71143. asArray(): number[];
  71144. /**
  71145. * Check if two quaternions are equals
  71146. * @param otherQuaternion defines the second operand
  71147. * @return true if the current quaternion and the given one coordinates are strictly equals
  71148. */
  71149. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71150. /**
  71151. * Clone the current quaternion
  71152. * @returns a new quaternion copied from the current one
  71153. */
  71154. clone(): Quaternion;
  71155. /**
  71156. * Copy a quaternion to the current one
  71157. * @param other defines the other quaternion
  71158. * @returns the updated current quaternion
  71159. */
  71160. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71161. /**
  71162. * Updates the current quaternion with the given float coordinates
  71163. * @param x defines the x coordinate
  71164. * @param y defines the y coordinate
  71165. * @param z defines the z coordinate
  71166. * @param w defines the w coordinate
  71167. * @returns the updated current quaternion
  71168. */
  71169. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71170. /**
  71171. * Updates the current quaternion from the given float coordinates
  71172. * @param x defines the x coordinate
  71173. * @param y defines the y coordinate
  71174. * @param z defines the z coordinate
  71175. * @param w defines the w coordinate
  71176. * @returns the updated current quaternion
  71177. */
  71178. set(x: number, y: number, z: number, w: number): Quaternion;
  71179. /**
  71180. * Adds two quaternions
  71181. * @param other defines the second operand
  71182. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71183. */
  71184. add(other: DeepImmutable<Quaternion>): Quaternion;
  71185. /**
  71186. * Add a quaternion to the current one
  71187. * @param other defines the quaternion to add
  71188. * @returns the current quaternion
  71189. */
  71190. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71191. /**
  71192. * Subtract two quaternions
  71193. * @param other defines the second operand
  71194. * @returns a new quaternion as the subtraction result of the given one from the current one
  71195. */
  71196. subtract(other: Quaternion): Quaternion;
  71197. /**
  71198. * Multiplies the current quaternion by a scale factor
  71199. * @param value defines the scale factor
  71200. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71201. */
  71202. scale(value: number): Quaternion;
  71203. /**
  71204. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71205. * @param scale defines the scale factor
  71206. * @param result defines the Quaternion object where to store the result
  71207. * @returns the unmodified current quaternion
  71208. */
  71209. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71210. /**
  71211. * Multiplies in place the current quaternion by a scale factor
  71212. * @param value defines the scale factor
  71213. * @returns the current modified quaternion
  71214. */
  71215. scaleInPlace(value: number): Quaternion;
  71216. /**
  71217. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71218. * @param scale defines the scale factor
  71219. * @param result defines the Quaternion object where to store the result
  71220. * @returns the unmodified current quaternion
  71221. */
  71222. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71223. /**
  71224. * Multiplies two quaternions
  71225. * @param q1 defines the second operand
  71226. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71227. */
  71228. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71229. /**
  71230. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71231. * @param q1 defines the second operand
  71232. * @param result defines the target quaternion
  71233. * @returns the current quaternion
  71234. */
  71235. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71236. /**
  71237. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71238. * @param q1 defines the second operand
  71239. * @returns the currentupdated quaternion
  71240. */
  71241. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71242. /**
  71243. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71244. * @param ref defines the target quaternion
  71245. * @returns the current quaternion
  71246. */
  71247. conjugateToRef(ref: Quaternion): Quaternion;
  71248. /**
  71249. * Conjugates in place (1-q) the current quaternion
  71250. * @returns the current updated quaternion
  71251. */
  71252. conjugateInPlace(): Quaternion;
  71253. /**
  71254. * Conjugates in place (1-q) the current quaternion
  71255. * @returns a new quaternion
  71256. */
  71257. conjugate(): Quaternion;
  71258. /**
  71259. * Gets length of current quaternion
  71260. * @returns the quaternion length (float)
  71261. */
  71262. length(): number;
  71263. /**
  71264. * Normalize in place the current quaternion
  71265. * @returns the current updated quaternion
  71266. */
  71267. normalize(): Quaternion;
  71268. /**
  71269. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71270. * @param order is a reserved parameter and is ignore for now
  71271. * @returns a new Vector3 containing the Euler angles
  71272. */
  71273. toEulerAngles(order?: string): Vector3;
  71274. /**
  71275. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71276. * @param result defines the vector which will be filled with the Euler angles
  71277. * @param order is a reserved parameter and is ignore for now
  71278. * @returns the current unchanged quaternion
  71279. */
  71280. toEulerAnglesToRef(result: Vector3): Quaternion;
  71281. /**
  71282. * Updates the given rotation matrix with the current quaternion values
  71283. * @param result defines the target matrix
  71284. * @returns the current unchanged quaternion
  71285. */
  71286. toRotationMatrix(result: Matrix): Quaternion;
  71287. /**
  71288. * Updates the current quaternion from the given rotation matrix values
  71289. * @param matrix defines the source matrix
  71290. * @returns the current updated quaternion
  71291. */
  71292. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71293. /**
  71294. * Creates a new quaternion from a rotation matrix
  71295. * @param matrix defines the source matrix
  71296. * @returns a new quaternion created from the given rotation matrix values
  71297. */
  71298. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  71299. /**
  71300. * Updates the given quaternion with the given rotation matrix values
  71301. * @param matrix defines the source matrix
  71302. * @param result defines the target quaternion
  71303. */
  71304. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  71305. /**
  71306. * Returns the dot product (float) between the quaternions "left" and "right"
  71307. * @param left defines the left operand
  71308. * @param right defines the right operand
  71309. * @returns the dot product
  71310. */
  71311. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  71312. /**
  71313. * Checks if the two quaternions are close to each other
  71314. * @param quat0 defines the first quaternion to check
  71315. * @param quat1 defines the second quaternion to check
  71316. * @returns true if the two quaternions are close to each other
  71317. */
  71318. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  71319. /**
  71320. * Creates an empty quaternion
  71321. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  71322. */
  71323. static Zero(): Quaternion;
  71324. /**
  71325. * Inverse a given quaternion
  71326. * @param q defines the source quaternion
  71327. * @returns a new quaternion as the inverted current quaternion
  71328. */
  71329. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  71330. /**
  71331. * Inverse a given quaternion
  71332. * @param q defines the source quaternion
  71333. * @param result the quaternion the result will be stored in
  71334. * @returns the result quaternion
  71335. */
  71336. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  71337. /**
  71338. * Creates an identity quaternion
  71339. * @returns the identity quaternion
  71340. */
  71341. static Identity(): Quaternion;
  71342. /**
  71343. * Gets a boolean indicating if the given quaternion is identity
  71344. * @param quaternion defines the quaternion to check
  71345. * @returns true if the quaternion is identity
  71346. */
  71347. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  71348. /**
  71349. * Creates a quaternion from a rotation around an axis
  71350. * @param axis defines the axis to use
  71351. * @param angle defines the angle to use
  71352. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  71353. */
  71354. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  71355. /**
  71356. * Creates a rotation around an axis and stores it into the given quaternion
  71357. * @param axis defines the axis to use
  71358. * @param angle defines the angle to use
  71359. * @param result defines the target quaternion
  71360. * @returns the target quaternion
  71361. */
  71362. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  71363. /**
  71364. * Creates a new quaternion from data stored into an array
  71365. * @param array defines the data source
  71366. * @param offset defines the offset in the source array where the data starts
  71367. * @returns a new quaternion
  71368. */
  71369. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  71370. /**
  71371. * Create a quaternion from Euler rotation angles
  71372. * @param x Pitch
  71373. * @param y Yaw
  71374. * @param z Roll
  71375. * @returns the new Quaternion
  71376. */
  71377. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  71378. /**
  71379. * Updates a quaternion from Euler rotation angles
  71380. * @param x Pitch
  71381. * @param y Yaw
  71382. * @param z Roll
  71383. * @param result the quaternion to store the result
  71384. * @returns the updated quaternion
  71385. */
  71386. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  71387. /**
  71388. * Create a quaternion from Euler rotation vector
  71389. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71390. * @returns the new Quaternion
  71391. */
  71392. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  71393. /**
  71394. * Updates a quaternion from Euler rotation vector
  71395. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  71396. * @param result the quaternion to store the result
  71397. * @returns the updated quaternion
  71398. */
  71399. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  71400. /**
  71401. * Creates a new quaternion from the given Euler float angles (y, x, z)
  71402. * @param yaw defines the rotation around Y axis
  71403. * @param pitch defines the rotation around X axis
  71404. * @param roll defines the rotation around Z axis
  71405. * @returns the new quaternion
  71406. */
  71407. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  71408. /**
  71409. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  71410. * @param yaw defines the rotation around Y axis
  71411. * @param pitch defines the rotation around X axis
  71412. * @param roll defines the rotation around Z axis
  71413. * @param result defines the target quaternion
  71414. */
  71415. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  71416. /**
  71417. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  71418. * @param alpha defines the rotation around first axis
  71419. * @param beta defines the rotation around second axis
  71420. * @param gamma defines the rotation around third axis
  71421. * @returns the new quaternion
  71422. */
  71423. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  71424. /**
  71425. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  71426. * @param alpha defines the rotation around first axis
  71427. * @param beta defines the rotation around second axis
  71428. * @param gamma defines the rotation around third axis
  71429. * @param result defines the target quaternion
  71430. */
  71431. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  71432. /**
  71433. * 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)
  71434. * @param axis1 defines the first axis
  71435. * @param axis2 defines the second axis
  71436. * @param axis3 defines the third axis
  71437. * @returns the new quaternion
  71438. */
  71439. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  71440. /**
  71441. * 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
  71442. * @param axis1 defines the first axis
  71443. * @param axis2 defines the second axis
  71444. * @param axis3 defines the third axis
  71445. * @param ref defines the target quaternion
  71446. */
  71447. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  71448. /**
  71449. * Interpolates between two quaternions
  71450. * @param left defines first quaternion
  71451. * @param right defines second quaternion
  71452. * @param amount defines the gradient to use
  71453. * @returns the new interpolated quaternion
  71454. */
  71455. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71456. /**
  71457. * Interpolates between two quaternions and stores it into a target quaternion
  71458. * @param left defines first quaternion
  71459. * @param right defines second quaternion
  71460. * @param amount defines the gradient to use
  71461. * @param result defines the target quaternion
  71462. */
  71463. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  71464. /**
  71465. * Interpolate between two quaternions using Hermite interpolation
  71466. * @param value1 defines first quaternion
  71467. * @param tangent1 defines the incoming tangent
  71468. * @param value2 defines second quaternion
  71469. * @param tangent2 defines the outgoing tangent
  71470. * @param amount defines the target quaternion
  71471. * @returns the new interpolated quaternion
  71472. */
  71473. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  71474. }
  71475. /**
  71476. * Class used to store matrix data (4x4)
  71477. */
  71478. export class Matrix {
  71479. private static _updateFlagSeed;
  71480. private static _identityReadOnly;
  71481. private _isIdentity;
  71482. private _isIdentityDirty;
  71483. private _isIdentity3x2;
  71484. private _isIdentity3x2Dirty;
  71485. /**
  71486. * Gets the update flag of the matrix which is an unique number for the matrix.
  71487. * It will be incremented every time the matrix data change.
  71488. * You can use it to speed the comparison between two versions of the same matrix.
  71489. */
  71490. updateFlag: number;
  71491. private readonly _m;
  71492. /**
  71493. * Gets the internal data of the matrix
  71494. */
  71495. readonly m: DeepImmutable<Float32Array>;
  71496. /** @hidden */
  71497. _markAsUpdated(): void;
  71498. /** @hidden */
  71499. private _updateIdentityStatus;
  71500. /**
  71501. * Creates an empty matrix (filled with zeros)
  71502. */
  71503. constructor();
  71504. /**
  71505. * Check if the current matrix is identity
  71506. * @returns true is the matrix is the identity matrix
  71507. */
  71508. isIdentity(): boolean;
  71509. /**
  71510. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  71511. * @returns true is the matrix is the identity matrix
  71512. */
  71513. isIdentityAs3x2(): boolean;
  71514. /**
  71515. * Gets the determinant of the matrix
  71516. * @returns the matrix determinant
  71517. */
  71518. determinant(): number;
  71519. /**
  71520. * Returns the matrix as a Float32Array
  71521. * @returns the matrix underlying array
  71522. */
  71523. toArray(): DeepImmutable<Float32Array>;
  71524. /**
  71525. * Returns the matrix as a Float32Array
  71526. * @returns the matrix underlying array.
  71527. */
  71528. asArray(): DeepImmutable<Float32Array>;
  71529. /**
  71530. * Inverts the current matrix in place
  71531. * @returns the current inverted matrix
  71532. */
  71533. invert(): Matrix;
  71534. /**
  71535. * Sets all the matrix elements to zero
  71536. * @returns the current matrix
  71537. */
  71538. reset(): Matrix;
  71539. /**
  71540. * Adds the current matrix with a second one
  71541. * @param other defines the matrix to add
  71542. * @returns a new matrix as the addition of the current matrix and the given one
  71543. */
  71544. add(other: DeepImmutable<Matrix>): Matrix;
  71545. /**
  71546. * Sets the given matrix "result" to the addition of the current matrix and the given one
  71547. * @param other defines the matrix to add
  71548. * @param result defines the target matrix
  71549. * @returns the current matrix
  71550. */
  71551. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71552. /**
  71553. * Adds in place the given matrix to the current matrix
  71554. * @param other defines the second operand
  71555. * @returns the current updated matrix
  71556. */
  71557. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  71558. /**
  71559. * Sets the given matrix to the current inverted Matrix
  71560. * @param other defines the target matrix
  71561. * @returns the unmodified current matrix
  71562. */
  71563. invertToRef(other: Matrix): Matrix;
  71564. /**
  71565. * add a value at the specified position in the current Matrix
  71566. * @param index the index of the value within the matrix. between 0 and 15.
  71567. * @param value the value to be added
  71568. * @returns the current updated matrix
  71569. */
  71570. addAtIndex(index: number, value: number): Matrix;
  71571. /**
  71572. * mutiply the specified position in the current Matrix by a value
  71573. * @param index the index of the value within the matrix. between 0 and 15.
  71574. * @param value the value to be added
  71575. * @returns the current updated matrix
  71576. */
  71577. multiplyAtIndex(index: number, value: number): Matrix;
  71578. /**
  71579. * Inserts the translation vector (using 3 floats) in the current matrix
  71580. * @param x defines the 1st component of the translation
  71581. * @param y defines the 2nd component of the translation
  71582. * @param z defines the 3rd component of the translation
  71583. * @returns the current updated matrix
  71584. */
  71585. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71586. /**
  71587. * Adds the translation vector (using 3 floats) in the current matrix
  71588. * @param x defines the 1st component of the translation
  71589. * @param y defines the 2nd component of the translation
  71590. * @param z defines the 3rd component of the translation
  71591. * @returns the current updated matrix
  71592. */
  71593. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  71594. /**
  71595. * Inserts the translation vector in the current matrix
  71596. * @param vector3 defines the translation to insert
  71597. * @returns the current updated matrix
  71598. */
  71599. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  71600. /**
  71601. * Gets the translation value of the current matrix
  71602. * @returns a new Vector3 as the extracted translation from the matrix
  71603. */
  71604. getTranslation(): Vector3;
  71605. /**
  71606. * Fill a Vector3 with the extracted translation from the matrix
  71607. * @param result defines the Vector3 where to store the translation
  71608. * @returns the current matrix
  71609. */
  71610. getTranslationToRef(result: Vector3): Matrix;
  71611. /**
  71612. * Remove rotation and scaling part from the matrix
  71613. * @returns the updated matrix
  71614. */
  71615. removeRotationAndScaling(): Matrix;
  71616. /**
  71617. * Multiply two matrices
  71618. * @param other defines the second operand
  71619. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  71620. */
  71621. multiply(other: DeepImmutable<Matrix>): Matrix;
  71622. /**
  71623. * Copy the current matrix from the given one
  71624. * @param other defines the source matrix
  71625. * @returns the current updated matrix
  71626. */
  71627. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  71628. /**
  71629. * Populates the given array from the starting index with the current matrix values
  71630. * @param array defines the target array
  71631. * @param offset defines the offset in the target array where to start storing values
  71632. * @returns the current matrix
  71633. */
  71634. copyToArray(array: Float32Array, offset?: number): Matrix;
  71635. /**
  71636. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  71637. * @param other defines the second operand
  71638. * @param result defines the matrix where to store the multiplication
  71639. * @returns the current matrix
  71640. */
  71641. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  71642. /**
  71643. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  71644. * @param other defines the second operand
  71645. * @param result defines the array where to store the multiplication
  71646. * @param offset defines the offset in the target array where to start storing values
  71647. * @returns the current matrix
  71648. */
  71649. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  71650. /**
  71651. * Check equality between this matrix and a second one
  71652. * @param value defines the second matrix to compare
  71653. * @returns true is the current matrix and the given one values are strictly equal
  71654. */
  71655. equals(value: DeepImmutable<Matrix>): boolean;
  71656. /**
  71657. * Clone the current matrix
  71658. * @returns a new matrix from the current matrix
  71659. */
  71660. clone(): Matrix;
  71661. /**
  71662. * Returns the name of the current matrix class
  71663. * @returns the string "Matrix"
  71664. */
  71665. getClassName(): string;
  71666. /**
  71667. * Gets the hash code of the current matrix
  71668. * @returns the hash code
  71669. */
  71670. getHashCode(): number;
  71671. /**
  71672. * Decomposes the current Matrix into a translation, rotation and scaling components
  71673. * @param scale defines the scale vector3 given as a reference to update
  71674. * @param rotation defines the rotation quaternion given as a reference to update
  71675. * @param translation defines the translation vector3 given as a reference to update
  71676. * @returns true if operation was successful
  71677. */
  71678. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  71679. /**
  71680. * Gets specific row of the matrix
  71681. * @param index defines the number of the row to get
  71682. * @returns the index-th row of the current matrix as a new Vector4
  71683. */
  71684. getRow(index: number): Nullable<Vector4>;
  71685. /**
  71686. * Sets the index-th row of the current matrix to the vector4 values
  71687. * @param index defines the number of the row to set
  71688. * @param row defines the target vector4
  71689. * @returns the updated current matrix
  71690. */
  71691. setRow(index: number, row: Vector4): Matrix;
  71692. /**
  71693. * Compute the transpose of the matrix
  71694. * @returns the new transposed matrix
  71695. */
  71696. transpose(): Matrix;
  71697. /**
  71698. * Compute the transpose of the matrix and store it in a given matrix
  71699. * @param result defines the target matrix
  71700. * @returns the current matrix
  71701. */
  71702. transposeToRef(result: Matrix): Matrix;
  71703. /**
  71704. * Sets the index-th row of the current matrix with the given 4 x float values
  71705. * @param index defines the row index
  71706. * @param x defines the x component to set
  71707. * @param y defines the y component to set
  71708. * @param z defines the z component to set
  71709. * @param w defines the w component to set
  71710. * @returns the updated current matrix
  71711. */
  71712. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  71713. /**
  71714. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  71715. * @param scale defines the scale factor
  71716. * @returns a new matrix
  71717. */
  71718. scale(scale: number): Matrix;
  71719. /**
  71720. * Scale the current matrix values by a factor to a given result matrix
  71721. * @param scale defines the scale factor
  71722. * @param result defines the matrix to store the result
  71723. * @returns the current matrix
  71724. */
  71725. scaleToRef(scale: number, result: Matrix): Matrix;
  71726. /**
  71727. * Scale the current matrix values by a factor and add the result to a given matrix
  71728. * @param scale defines the scale factor
  71729. * @param result defines the Matrix to store the result
  71730. * @returns the current matrix
  71731. */
  71732. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  71733. /**
  71734. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  71735. * @param ref matrix to store the result
  71736. */
  71737. toNormalMatrix(ref: Matrix): void;
  71738. /**
  71739. * Gets only rotation part of the current matrix
  71740. * @returns a new matrix sets to the extracted rotation matrix from the current one
  71741. */
  71742. getRotationMatrix(): Matrix;
  71743. /**
  71744. * Extracts the rotation matrix from the current one and sets it as the given "result"
  71745. * @param result defines the target matrix to store data to
  71746. * @returns the current matrix
  71747. */
  71748. getRotationMatrixToRef(result: Matrix): Matrix;
  71749. /**
  71750. * Toggles model matrix from being right handed to left handed in place and vice versa
  71751. */
  71752. toggleModelMatrixHandInPlace(): void;
  71753. /**
  71754. * Toggles projection matrix from being right handed to left handed in place and vice versa
  71755. */
  71756. toggleProjectionMatrixHandInPlace(): void;
  71757. /**
  71758. * Creates a matrix from an array
  71759. * @param array defines the source array
  71760. * @param offset defines an offset in the source array
  71761. * @returns a new Matrix set from the starting index of the given array
  71762. */
  71763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  71764. /**
  71765. * Copy the content of an array into a given matrix
  71766. * @param array defines the source array
  71767. * @param offset defines an offset in the source array
  71768. * @param result defines the target matrix
  71769. */
  71770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  71771. /**
  71772. * Stores an array into a matrix after having multiplied each component by a given factor
  71773. * @param array defines the source array
  71774. * @param offset defines the offset in the source array
  71775. * @param scale defines the scaling factor
  71776. * @param result defines the target matrix
  71777. */
  71778. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  71779. /**
  71780. * Gets an identity matrix that must not be updated
  71781. */
  71782. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  71783. /**
  71784. * Stores a list of values (16) inside a given matrix
  71785. * @param initialM11 defines 1st value of 1st row
  71786. * @param initialM12 defines 2nd value of 1st row
  71787. * @param initialM13 defines 3rd value of 1st row
  71788. * @param initialM14 defines 4th value of 1st row
  71789. * @param initialM21 defines 1st value of 2nd row
  71790. * @param initialM22 defines 2nd value of 2nd row
  71791. * @param initialM23 defines 3rd value of 2nd row
  71792. * @param initialM24 defines 4th value of 2nd row
  71793. * @param initialM31 defines 1st value of 3rd row
  71794. * @param initialM32 defines 2nd value of 3rd row
  71795. * @param initialM33 defines 3rd value of 3rd row
  71796. * @param initialM34 defines 4th value of 3rd row
  71797. * @param initialM41 defines 1st value of 4th row
  71798. * @param initialM42 defines 2nd value of 4th row
  71799. * @param initialM43 defines 3rd value of 4th row
  71800. * @param initialM44 defines 4th value of 4th row
  71801. * @param result defines the target matrix
  71802. */
  71803. 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;
  71804. /**
  71805. * Creates new matrix from a list of values (16)
  71806. * @param initialM11 defines 1st value of 1st row
  71807. * @param initialM12 defines 2nd value of 1st row
  71808. * @param initialM13 defines 3rd value of 1st row
  71809. * @param initialM14 defines 4th value of 1st row
  71810. * @param initialM21 defines 1st value of 2nd row
  71811. * @param initialM22 defines 2nd value of 2nd row
  71812. * @param initialM23 defines 3rd value of 2nd row
  71813. * @param initialM24 defines 4th value of 2nd row
  71814. * @param initialM31 defines 1st value of 3rd row
  71815. * @param initialM32 defines 2nd value of 3rd row
  71816. * @param initialM33 defines 3rd value of 3rd row
  71817. * @param initialM34 defines 4th value of 3rd row
  71818. * @param initialM41 defines 1st value of 4th row
  71819. * @param initialM42 defines 2nd value of 4th row
  71820. * @param initialM43 defines 3rd value of 4th row
  71821. * @param initialM44 defines 4th value of 4th row
  71822. * @returns the new matrix
  71823. */
  71824. 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;
  71825. /**
  71826. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71827. * @param scale defines the scale vector3
  71828. * @param rotation defines the rotation quaternion
  71829. * @param translation defines the translation vector3
  71830. * @returns a new matrix
  71831. */
  71832. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  71833. /**
  71834. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  71835. * @param scale defines the scale vector3
  71836. * @param rotation defines the rotation quaternion
  71837. * @param translation defines the translation vector3
  71838. * @param result defines the target matrix
  71839. */
  71840. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  71841. /**
  71842. * Creates a new identity matrix
  71843. * @returns a new identity matrix
  71844. */
  71845. static Identity(): Matrix;
  71846. /**
  71847. * Creates a new identity matrix and stores the result in a given matrix
  71848. * @param result defines the target matrix
  71849. */
  71850. static IdentityToRef(result: Matrix): void;
  71851. /**
  71852. * Creates a new zero matrix
  71853. * @returns a new zero matrix
  71854. */
  71855. static Zero(): Matrix;
  71856. /**
  71857. * Creates a new rotation matrix for "angle" radians around the X axis
  71858. * @param angle defines the angle (in radians) to use
  71859. * @return the new matrix
  71860. */
  71861. static RotationX(angle: number): Matrix;
  71862. /**
  71863. * Creates a new matrix as the invert of a given matrix
  71864. * @param source defines the source matrix
  71865. * @returns the new matrix
  71866. */
  71867. static Invert(source: DeepImmutable<Matrix>): Matrix;
  71868. /**
  71869. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  71870. * @param angle defines the angle (in radians) to use
  71871. * @param result defines the target matrix
  71872. */
  71873. static RotationXToRef(angle: number, result: Matrix): void;
  71874. /**
  71875. * Creates a new rotation matrix for "angle" radians around the Y axis
  71876. * @param angle defines the angle (in radians) to use
  71877. * @return the new matrix
  71878. */
  71879. static RotationY(angle: number): Matrix;
  71880. /**
  71881. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  71882. * @param angle defines the angle (in radians) to use
  71883. * @param result defines the target matrix
  71884. */
  71885. static RotationYToRef(angle: number, result: Matrix): void;
  71886. /**
  71887. * Creates a new rotation matrix for "angle" radians around the Z axis
  71888. * @param angle defines the angle (in radians) to use
  71889. * @return the new matrix
  71890. */
  71891. static RotationZ(angle: number): Matrix;
  71892. /**
  71893. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71894. * @param angle defines the angle (in radians) to use
  71895. * @param result defines the target matrix
  71896. */
  71897. static RotationZToRef(angle: number, result: Matrix): void;
  71898. /**
  71899. * Creates a new rotation matrix for "angle" radians around the given axis
  71900. * @param axis defines the axis to use
  71901. * @param angle defines the angle (in radians) to use
  71902. * @return the new matrix
  71903. */
  71904. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71905. /**
  71906. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71907. * @param axis defines the axis to use
  71908. * @param angle defines the angle (in radians) to use
  71909. * @param result defines the target matrix
  71910. */
  71911. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71912. /**
  71913. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71914. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71915. * @param from defines the vector to align
  71916. * @param to defines the vector to align to
  71917. * @param result defines the target matrix
  71918. */
  71919. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71920. /**
  71921. * Creates a rotation matrix
  71922. * @param yaw defines the yaw angle in radians (Y axis)
  71923. * @param pitch defines the pitch angle in radians (X axis)
  71924. * @param roll defines the roll angle in radians (X axis)
  71925. * @returns the new rotation matrix
  71926. */
  71927. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71928. /**
  71929. * Creates a rotation matrix and stores it in a given matrix
  71930. * @param yaw defines the yaw angle in radians (Y axis)
  71931. * @param pitch defines the pitch angle in radians (X axis)
  71932. * @param roll defines the roll angle in radians (X axis)
  71933. * @param result defines the target matrix
  71934. */
  71935. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71936. /**
  71937. * Creates a scaling matrix
  71938. * @param x defines the scale factor on X axis
  71939. * @param y defines the scale factor on Y axis
  71940. * @param z defines the scale factor on Z axis
  71941. * @returns the new matrix
  71942. */
  71943. static Scaling(x: number, y: number, z: number): Matrix;
  71944. /**
  71945. * Creates a scaling matrix and stores it in a given matrix
  71946. * @param x defines the scale factor on X axis
  71947. * @param y defines the scale factor on Y axis
  71948. * @param z defines the scale factor on Z axis
  71949. * @param result defines the target matrix
  71950. */
  71951. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71952. /**
  71953. * Creates a translation matrix
  71954. * @param x defines the translation on X axis
  71955. * @param y defines the translation on Y axis
  71956. * @param z defines the translationon Z axis
  71957. * @returns the new matrix
  71958. */
  71959. static Translation(x: number, y: number, z: number): Matrix;
  71960. /**
  71961. * Creates a translation matrix and stores it in a given matrix
  71962. * @param x defines the translation on X axis
  71963. * @param y defines the translation on Y axis
  71964. * @param z defines the translationon Z axis
  71965. * @param result defines the target matrix
  71966. */
  71967. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71968. /**
  71969. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71970. * @param startValue defines the start value
  71971. * @param endValue defines the end value
  71972. * @param gradient defines the gradient factor
  71973. * @returns the new matrix
  71974. */
  71975. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71976. /**
  71977. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71978. * @param startValue defines the start value
  71979. * @param endValue defines the end value
  71980. * @param gradient defines the gradient factor
  71981. * @param result defines the Matrix object where to store data
  71982. */
  71983. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71984. /**
  71985. * Builds a new matrix whose values are computed by:
  71986. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71987. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71988. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71989. * @param startValue defines the first matrix
  71990. * @param endValue defines the second matrix
  71991. * @param gradient defines the gradient between the two matrices
  71992. * @returns the new matrix
  71993. */
  71994. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71995. /**
  71996. * Update a matrix to values which are computed by:
  71997. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71998. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71999. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72000. * @param startValue defines the first matrix
  72001. * @param endValue defines the second matrix
  72002. * @param gradient defines the gradient between the two matrices
  72003. * @param result defines the target matrix
  72004. */
  72005. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72006. /**
  72007. * 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"
  72008. * This function works in left handed mode
  72009. * @param eye defines the final position of the entity
  72010. * @param target defines where the entity should look at
  72011. * @param up defines the up vector for the entity
  72012. * @returns the new matrix
  72013. */
  72014. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72015. /**
  72016. * 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".
  72017. * This function works in left handed mode
  72018. * @param eye defines the final position of the entity
  72019. * @param target defines where the entity should look at
  72020. * @param up defines the up vector for the entity
  72021. * @param result defines the target matrix
  72022. */
  72023. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72024. /**
  72025. * 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"
  72026. * This function works in right handed mode
  72027. * @param eye defines the final position of the entity
  72028. * @param target defines where the entity should look at
  72029. * @param up defines the up vector for the entity
  72030. * @returns the new matrix
  72031. */
  72032. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72033. /**
  72034. * 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".
  72035. * This function works in right handed mode
  72036. * @param eye defines the final position of the entity
  72037. * @param target defines where the entity should look at
  72038. * @param up defines the up vector for the entity
  72039. * @param result defines the target matrix
  72040. */
  72041. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72042. /**
  72043. * Create a left-handed orthographic projection matrix
  72044. * @param width defines the viewport width
  72045. * @param height defines the viewport height
  72046. * @param znear defines the near clip plane
  72047. * @param zfar defines the far clip plane
  72048. * @returns a new matrix as a left-handed orthographic projection matrix
  72049. */
  72050. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72051. /**
  72052. * Store a left-handed orthographic projection to a given matrix
  72053. * @param width defines the viewport width
  72054. * @param height defines the viewport height
  72055. * @param znear defines the near clip plane
  72056. * @param zfar defines the far clip plane
  72057. * @param result defines the target matrix
  72058. */
  72059. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72060. /**
  72061. * Create a left-handed orthographic projection matrix
  72062. * @param left defines the viewport left coordinate
  72063. * @param right defines the viewport right coordinate
  72064. * @param bottom defines the viewport bottom coordinate
  72065. * @param top defines the viewport top coordinate
  72066. * @param znear defines the near clip plane
  72067. * @param zfar defines the far clip plane
  72068. * @returns a new matrix as a left-handed orthographic projection matrix
  72069. */
  72070. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72071. /**
  72072. * Stores a left-handed orthographic projection into a given matrix
  72073. * @param left defines the viewport left coordinate
  72074. * @param right defines the viewport right coordinate
  72075. * @param bottom defines the viewport bottom coordinate
  72076. * @param top defines the viewport top coordinate
  72077. * @param znear defines the near clip plane
  72078. * @param zfar defines the far clip plane
  72079. * @param result defines the target matrix
  72080. */
  72081. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72082. /**
  72083. * Creates a right-handed orthographic projection matrix
  72084. * @param left defines the viewport left coordinate
  72085. * @param right defines the viewport right coordinate
  72086. * @param bottom defines the viewport bottom coordinate
  72087. * @param top defines the viewport top coordinate
  72088. * @param znear defines the near clip plane
  72089. * @param zfar defines the far clip plane
  72090. * @returns a new matrix as a right-handed orthographic projection matrix
  72091. */
  72092. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72093. /**
  72094. * Stores a right-handed orthographic projection into a given matrix
  72095. * @param left defines the viewport left coordinate
  72096. * @param right defines the viewport right coordinate
  72097. * @param bottom defines the viewport bottom coordinate
  72098. * @param top defines the viewport top coordinate
  72099. * @param znear defines the near clip plane
  72100. * @param zfar defines the far clip plane
  72101. * @param result defines the target matrix
  72102. */
  72103. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72104. /**
  72105. * Creates a left-handed perspective projection matrix
  72106. * @param width defines the viewport width
  72107. * @param height defines the viewport height
  72108. * @param znear defines the near clip plane
  72109. * @param zfar defines the far clip plane
  72110. * @returns a new matrix as a left-handed perspective projection matrix
  72111. */
  72112. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72113. /**
  72114. * Creates a left-handed perspective projection matrix
  72115. * @param fov defines the horizontal field of view
  72116. * @param aspect defines the aspect ratio
  72117. * @param znear defines the near clip plane
  72118. * @param zfar defines the far clip plane
  72119. * @returns a new matrix as a left-handed perspective projection matrix
  72120. */
  72121. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72122. /**
  72123. * Stores a left-handed perspective projection into a given matrix
  72124. * @param fov defines the horizontal field of view
  72125. * @param aspect defines the aspect ratio
  72126. * @param znear defines the near clip plane
  72127. * @param zfar defines the far clip plane
  72128. * @param result defines the target matrix
  72129. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72130. */
  72131. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72132. /**
  72133. * Creates a right-handed perspective projection matrix
  72134. * @param fov defines the horizontal field of view
  72135. * @param aspect defines the aspect ratio
  72136. * @param znear defines the near clip plane
  72137. * @param zfar defines the far clip plane
  72138. * @returns a new matrix as a right-handed perspective projection matrix
  72139. */
  72140. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72141. /**
  72142. * Stores a right-handed perspective projection into a given matrix
  72143. * @param fov defines the horizontal field of view
  72144. * @param aspect defines the aspect ratio
  72145. * @param znear defines the near clip plane
  72146. * @param zfar defines the far clip plane
  72147. * @param result defines the target matrix
  72148. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72149. */
  72150. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72151. /**
  72152. * Stores a perspective projection for WebVR info a given matrix
  72153. * @param fov defines the field of view
  72154. * @param znear defines the near clip plane
  72155. * @param zfar defines the far clip plane
  72156. * @param result defines the target matrix
  72157. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72158. */
  72159. static PerspectiveFovWebVRToRef(fov: {
  72160. upDegrees: number;
  72161. downDegrees: number;
  72162. leftDegrees: number;
  72163. rightDegrees: number;
  72164. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72165. /**
  72166. * Computes a complete transformation matrix
  72167. * @param viewport defines the viewport to use
  72168. * @param world defines the world matrix
  72169. * @param view defines the view matrix
  72170. * @param projection defines the projection matrix
  72171. * @param zmin defines the near clip plane
  72172. * @param zmax defines the far clip plane
  72173. * @returns the transformation matrix
  72174. */
  72175. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72176. /**
  72177. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72178. * @param matrix defines the matrix to use
  72179. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72180. */
  72181. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72182. /**
  72183. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72184. * @param matrix defines the matrix to use
  72185. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72186. */
  72187. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72188. /**
  72189. * Compute the transpose of a given matrix
  72190. * @param matrix defines the matrix to transpose
  72191. * @returns the new matrix
  72192. */
  72193. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72194. /**
  72195. * Compute the transpose of a matrix and store it in a target matrix
  72196. * @param matrix defines the matrix to transpose
  72197. * @param result defines the target matrix
  72198. */
  72199. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72200. /**
  72201. * Computes a reflection matrix from a plane
  72202. * @param plane defines the reflection plane
  72203. * @returns a new matrix
  72204. */
  72205. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72206. /**
  72207. * Computes a reflection matrix from a plane
  72208. * @param plane defines the reflection plane
  72209. * @param result defines the target matrix
  72210. */
  72211. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72212. /**
  72213. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72214. * @param xaxis defines the value of the 1st axis
  72215. * @param yaxis defines the value of the 2nd axis
  72216. * @param zaxis defines the value of the 3rd axis
  72217. * @param result defines the target matrix
  72218. */
  72219. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72220. /**
  72221. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72222. * @param quat defines the quaternion to use
  72223. * @param result defines the target matrix
  72224. */
  72225. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72226. }
  72227. /**
  72228. * @hidden
  72229. */
  72230. export class TmpVectors {
  72231. static Vector2: Vector2[];
  72232. static Vector3: Vector3[];
  72233. static Vector4: Vector4[];
  72234. static Quaternion: Quaternion[];
  72235. static Matrix: Matrix[];
  72236. }
  72237. }
  72238. declare module BABYLON {
  72239. /**
  72240. * Defines potential orientation for back face culling
  72241. */
  72242. export enum Orientation {
  72243. /**
  72244. * Clockwise
  72245. */
  72246. CW = 0,
  72247. /** Counter clockwise */
  72248. CCW = 1
  72249. }
  72250. /** Class used to represent a Bezier curve */
  72251. export class BezierCurve {
  72252. /**
  72253. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72254. * @param t defines the time
  72255. * @param x1 defines the left coordinate on X axis
  72256. * @param y1 defines the left coordinate on Y axis
  72257. * @param x2 defines the right coordinate on X axis
  72258. * @param y2 defines the right coordinate on Y axis
  72259. * @returns the interpolated value
  72260. */
  72261. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72262. }
  72263. /**
  72264. * Defines angle representation
  72265. */
  72266. export class Angle {
  72267. private _radians;
  72268. /**
  72269. * Creates an Angle object of "radians" radians (float).
  72270. * @param radians the angle in radians
  72271. */
  72272. constructor(radians: number);
  72273. /**
  72274. * Get value in degrees
  72275. * @returns the Angle value in degrees (float)
  72276. */
  72277. degrees(): number;
  72278. /**
  72279. * Get value in radians
  72280. * @returns the Angle value in radians (float)
  72281. */
  72282. radians(): number;
  72283. /**
  72284. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72285. * @param a defines first vector
  72286. * @param b defines second vector
  72287. * @returns a new Angle
  72288. */
  72289. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72290. /**
  72291. * Gets a new Angle object from the given float in radians
  72292. * @param radians defines the angle value in radians
  72293. * @returns a new Angle
  72294. */
  72295. static FromRadians(radians: number): Angle;
  72296. /**
  72297. * Gets a new Angle object from the given float in degrees
  72298. * @param degrees defines the angle value in degrees
  72299. * @returns a new Angle
  72300. */
  72301. static FromDegrees(degrees: number): Angle;
  72302. }
  72303. /**
  72304. * This represents an arc in a 2d space.
  72305. */
  72306. export class Arc2 {
  72307. /** Defines the start point of the arc */
  72308. startPoint: Vector2;
  72309. /** Defines the mid point of the arc */
  72310. midPoint: Vector2;
  72311. /** Defines the end point of the arc */
  72312. endPoint: Vector2;
  72313. /**
  72314. * Defines the center point of the arc.
  72315. */
  72316. centerPoint: Vector2;
  72317. /**
  72318. * Defines the radius of the arc.
  72319. */
  72320. radius: number;
  72321. /**
  72322. * Defines the angle of the arc (from mid point to end point).
  72323. */
  72324. angle: Angle;
  72325. /**
  72326. * Defines the start angle of the arc (from start point to middle point).
  72327. */
  72328. startAngle: Angle;
  72329. /**
  72330. * Defines the orientation of the arc (clock wise/counter clock wise).
  72331. */
  72332. orientation: Orientation;
  72333. /**
  72334. * Creates an Arc object from the three given points : start, middle and end.
  72335. * @param startPoint Defines the start point of the arc
  72336. * @param midPoint Defines the midlle point of the arc
  72337. * @param endPoint Defines the end point of the arc
  72338. */
  72339. constructor(
  72340. /** Defines the start point of the arc */
  72341. startPoint: Vector2,
  72342. /** Defines the mid point of the arc */
  72343. midPoint: Vector2,
  72344. /** Defines the end point of the arc */
  72345. endPoint: Vector2);
  72346. }
  72347. /**
  72348. * Represents a 2D path made up of multiple 2D points
  72349. */
  72350. export class Path2 {
  72351. private _points;
  72352. private _length;
  72353. /**
  72354. * If the path start and end point are the same
  72355. */
  72356. closed: boolean;
  72357. /**
  72358. * Creates a Path2 object from the starting 2D coordinates x and y.
  72359. * @param x the starting points x value
  72360. * @param y the starting points y value
  72361. */
  72362. constructor(x: number, y: number);
  72363. /**
  72364. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72365. * @param x the added points x value
  72366. * @param y the added points y value
  72367. * @returns the updated Path2.
  72368. */
  72369. addLineTo(x: number, y: number): Path2;
  72370. /**
  72371. * 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.
  72372. * @param midX middle point x value
  72373. * @param midY middle point y value
  72374. * @param endX end point x value
  72375. * @param endY end point y value
  72376. * @param numberOfSegments (default: 36)
  72377. * @returns the updated Path2.
  72378. */
  72379. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72380. /**
  72381. * Closes the Path2.
  72382. * @returns the Path2.
  72383. */
  72384. close(): Path2;
  72385. /**
  72386. * Gets the sum of the distance between each sequential point in the path
  72387. * @returns the Path2 total length (float).
  72388. */
  72389. length(): number;
  72390. /**
  72391. * Gets the points which construct the path
  72392. * @returns the Path2 internal array of points.
  72393. */
  72394. getPoints(): Vector2[];
  72395. /**
  72396. * Retreives the point at the distance aways from the starting point
  72397. * @param normalizedLengthPosition the length along the path to retreive the point from
  72398. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72399. */
  72400. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72401. /**
  72402. * Creates a new path starting from an x and y position
  72403. * @param x starting x value
  72404. * @param y starting y value
  72405. * @returns a new Path2 starting at the coordinates (x, y).
  72406. */
  72407. static StartingAt(x: number, y: number): Path2;
  72408. }
  72409. /**
  72410. * Represents a 3D path made up of multiple 3D points
  72411. */
  72412. export class Path3D {
  72413. /**
  72414. * an array of Vector3, the curve axis of the Path3D
  72415. */
  72416. path: Vector3[];
  72417. private _curve;
  72418. private _distances;
  72419. private _tangents;
  72420. private _normals;
  72421. private _binormals;
  72422. private _raw;
  72423. /**
  72424. * new Path3D(path, normal, raw)
  72425. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72426. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72427. * @param path an array of Vector3, the curve axis of the Path3D
  72428. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72429. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72430. */
  72431. constructor(
  72432. /**
  72433. * an array of Vector3, the curve axis of the Path3D
  72434. */
  72435. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72436. /**
  72437. * Returns the Path3D array of successive Vector3 designing its curve.
  72438. * @returns the Path3D array of successive Vector3 designing its curve.
  72439. */
  72440. getCurve(): Vector3[];
  72441. /**
  72442. * Returns an array populated with tangent vectors on each Path3D curve point.
  72443. * @returns an array populated with tangent vectors on each Path3D curve point.
  72444. */
  72445. getTangents(): Vector3[];
  72446. /**
  72447. * Returns an array populated with normal vectors on each Path3D curve point.
  72448. * @returns an array populated with normal vectors on each Path3D curve point.
  72449. */
  72450. getNormals(): Vector3[];
  72451. /**
  72452. * Returns an array populated with binormal vectors on each Path3D curve point.
  72453. * @returns an array populated with binormal vectors on each Path3D curve point.
  72454. */
  72455. getBinormals(): Vector3[];
  72456. /**
  72457. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72458. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72459. */
  72460. getDistances(): number[];
  72461. /**
  72462. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72463. * @param path path which all values are copied into the curves points
  72464. * @param firstNormal which should be projected onto the curve
  72465. * @returns the same object updated.
  72466. */
  72467. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72468. private _compute;
  72469. private _getFirstNonNullVector;
  72470. private _getLastNonNullVector;
  72471. private _normalVector;
  72472. }
  72473. /**
  72474. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72475. * A Curve3 is designed from a series of successive Vector3.
  72476. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72477. */
  72478. export class Curve3 {
  72479. private _points;
  72480. private _length;
  72481. /**
  72482. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72483. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72484. * @param v1 (Vector3) the control point
  72485. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72486. * @param nbPoints (integer) the wanted number of points in the curve
  72487. * @returns the created Curve3
  72488. */
  72489. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72490. /**
  72491. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72492. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72493. * @param v1 (Vector3) the first control point
  72494. * @param v2 (Vector3) the second control point
  72495. * @param v3 (Vector3) the end point of the Cubic Bezier
  72496. * @param nbPoints (integer) the wanted number of points in the curve
  72497. * @returns the created Curve3
  72498. */
  72499. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72500. /**
  72501. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72502. * @param p1 (Vector3) the origin point of the Hermite Spline
  72503. * @param t1 (Vector3) the tangent vector at the origin point
  72504. * @param p2 (Vector3) the end point of the Hermite Spline
  72505. * @param t2 (Vector3) the tangent vector at the end point
  72506. * @param nbPoints (integer) the wanted number of points in the curve
  72507. * @returns the created Curve3
  72508. */
  72509. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72510. /**
  72511. * Returns a Curve3 object along a CatmullRom Spline curve :
  72512. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72513. * @param nbPoints (integer) the wanted number of points between each curve control points
  72514. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72515. * @returns the created Curve3
  72516. */
  72517. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72518. /**
  72519. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72520. * A Curve3 is designed from a series of successive Vector3.
  72521. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72522. * @param points points which make up the curve
  72523. */
  72524. constructor(points: Vector3[]);
  72525. /**
  72526. * @returns the Curve3 stored array of successive Vector3
  72527. */
  72528. getPoints(): Vector3[];
  72529. /**
  72530. * @returns the computed length (float) of the curve.
  72531. */
  72532. length(): number;
  72533. /**
  72534. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72535. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72536. * curveA and curveB keep unchanged.
  72537. * @param curve the curve to continue from this curve
  72538. * @returns the newly constructed curve
  72539. */
  72540. continue(curve: DeepImmutable<Curve3>): Curve3;
  72541. private _computeLength;
  72542. }
  72543. }
  72544. declare module BABYLON {
  72545. /**
  72546. * This represents the main contract an easing function should follow.
  72547. * Easing functions are used throughout the animation system.
  72548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72549. */
  72550. export interface IEasingFunction {
  72551. /**
  72552. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72553. * of the easing function.
  72554. * The link below provides some of the most common examples of easing functions.
  72555. * @see https://easings.net/
  72556. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72557. * @returns the corresponding value on the curve defined by the easing function
  72558. */
  72559. ease(gradient: number): number;
  72560. }
  72561. /**
  72562. * Base class used for every default easing function.
  72563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72564. */
  72565. export class EasingFunction implements IEasingFunction {
  72566. /**
  72567. * Interpolation follows the mathematical formula associated with the easing function.
  72568. */
  72569. static readonly EASINGMODE_EASEIN: number;
  72570. /**
  72571. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72572. */
  72573. static readonly EASINGMODE_EASEOUT: number;
  72574. /**
  72575. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72576. */
  72577. static readonly EASINGMODE_EASEINOUT: number;
  72578. private _easingMode;
  72579. /**
  72580. * Sets the easing mode of the current function.
  72581. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72582. */
  72583. setEasingMode(easingMode: number): void;
  72584. /**
  72585. * Gets the current easing mode.
  72586. * @returns the easing mode
  72587. */
  72588. getEasingMode(): number;
  72589. /**
  72590. * @hidden
  72591. */
  72592. easeInCore(gradient: number): number;
  72593. /**
  72594. * Given an input gradient between 0 and 1, this returns the corresponding value
  72595. * of the easing function.
  72596. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72597. * @returns the corresponding value on the curve defined by the easing function
  72598. */
  72599. ease(gradient: number): number;
  72600. }
  72601. /**
  72602. * Easing function with a circle shape (see link below).
  72603. * @see https://easings.net/#easeInCirc
  72604. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72605. */
  72606. export class CircleEase extends EasingFunction implements IEasingFunction {
  72607. /** @hidden */
  72608. easeInCore(gradient: number): number;
  72609. }
  72610. /**
  72611. * Easing function with a ease back shape (see link below).
  72612. * @see https://easings.net/#easeInBack
  72613. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72614. */
  72615. export class BackEase extends EasingFunction implements IEasingFunction {
  72616. /** Defines the amplitude of the function */
  72617. amplitude: number;
  72618. /**
  72619. * Instantiates a back ease easing
  72620. * @see https://easings.net/#easeInBack
  72621. * @param amplitude Defines the amplitude of the function
  72622. */
  72623. constructor(
  72624. /** Defines the amplitude of the function */
  72625. amplitude?: number);
  72626. /** @hidden */
  72627. easeInCore(gradient: number): number;
  72628. }
  72629. /**
  72630. * Easing function with a bouncing shape (see link below).
  72631. * @see https://easings.net/#easeInBounce
  72632. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72633. */
  72634. export class BounceEase extends EasingFunction implements IEasingFunction {
  72635. /** Defines the number of bounces */
  72636. bounces: number;
  72637. /** Defines the amplitude of the bounce */
  72638. bounciness: number;
  72639. /**
  72640. * Instantiates a bounce easing
  72641. * @see https://easings.net/#easeInBounce
  72642. * @param bounces Defines the number of bounces
  72643. * @param bounciness Defines the amplitude of the bounce
  72644. */
  72645. constructor(
  72646. /** Defines the number of bounces */
  72647. bounces?: number,
  72648. /** Defines the amplitude of the bounce */
  72649. bounciness?: number);
  72650. /** @hidden */
  72651. easeInCore(gradient: number): number;
  72652. }
  72653. /**
  72654. * Easing function with a power of 3 shape (see link below).
  72655. * @see https://easings.net/#easeInCubic
  72656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72657. */
  72658. export class CubicEase extends EasingFunction implements IEasingFunction {
  72659. /** @hidden */
  72660. easeInCore(gradient: number): number;
  72661. }
  72662. /**
  72663. * Easing function with an elastic shape (see link below).
  72664. * @see https://easings.net/#easeInElastic
  72665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72666. */
  72667. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72668. /** Defines the number of oscillations*/
  72669. oscillations: number;
  72670. /** Defines the amplitude of the oscillations*/
  72671. springiness: number;
  72672. /**
  72673. * Instantiates an elastic easing function
  72674. * @see https://easings.net/#easeInElastic
  72675. * @param oscillations Defines the number of oscillations
  72676. * @param springiness Defines the amplitude of the oscillations
  72677. */
  72678. constructor(
  72679. /** Defines the number of oscillations*/
  72680. oscillations?: number,
  72681. /** Defines the amplitude of the oscillations*/
  72682. springiness?: number);
  72683. /** @hidden */
  72684. easeInCore(gradient: number): number;
  72685. }
  72686. /**
  72687. * Easing function with an exponential shape (see link below).
  72688. * @see https://easings.net/#easeInExpo
  72689. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72690. */
  72691. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72692. /** Defines the exponent of the function */
  72693. exponent: number;
  72694. /**
  72695. * Instantiates an exponential easing function
  72696. * @see https://easings.net/#easeInExpo
  72697. * @param exponent Defines the exponent of the function
  72698. */
  72699. constructor(
  72700. /** Defines the exponent of the function */
  72701. exponent?: number);
  72702. /** @hidden */
  72703. easeInCore(gradient: number): number;
  72704. }
  72705. /**
  72706. * Easing function with a power shape (see link below).
  72707. * @see https://easings.net/#easeInQuad
  72708. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72709. */
  72710. export class PowerEase extends EasingFunction implements IEasingFunction {
  72711. /** Defines the power of the function */
  72712. power: number;
  72713. /**
  72714. * Instantiates an power base easing function
  72715. * @see https://easings.net/#easeInQuad
  72716. * @param power Defines the power of the function
  72717. */
  72718. constructor(
  72719. /** Defines the power of the function */
  72720. power?: number);
  72721. /** @hidden */
  72722. easeInCore(gradient: number): number;
  72723. }
  72724. /**
  72725. * Easing function with a power of 2 shape (see link below).
  72726. * @see https://easings.net/#easeInQuad
  72727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72728. */
  72729. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72730. /** @hidden */
  72731. easeInCore(gradient: number): number;
  72732. }
  72733. /**
  72734. * Easing function with a power of 4 shape (see link below).
  72735. * @see https://easings.net/#easeInQuart
  72736. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72737. */
  72738. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72739. /** @hidden */
  72740. easeInCore(gradient: number): number;
  72741. }
  72742. /**
  72743. * Easing function with a power of 5 shape (see link below).
  72744. * @see https://easings.net/#easeInQuint
  72745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72746. */
  72747. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72748. /** @hidden */
  72749. easeInCore(gradient: number): number;
  72750. }
  72751. /**
  72752. * Easing function with a sin shape (see link below).
  72753. * @see https://easings.net/#easeInSine
  72754. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72755. */
  72756. export class SineEase extends EasingFunction implements IEasingFunction {
  72757. /** @hidden */
  72758. easeInCore(gradient: number): number;
  72759. }
  72760. /**
  72761. * Easing function with a bezier shape (see link below).
  72762. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72764. */
  72765. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72766. /** Defines the x component of the start tangent in the bezier curve */
  72767. x1: number;
  72768. /** Defines the y component of the start tangent in the bezier curve */
  72769. y1: number;
  72770. /** Defines the x component of the end tangent in the bezier curve */
  72771. x2: number;
  72772. /** Defines the y component of the end tangent in the bezier curve */
  72773. y2: number;
  72774. /**
  72775. * Instantiates a bezier function
  72776. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72777. * @param x1 Defines the x component of the start tangent in the bezier curve
  72778. * @param y1 Defines the y component of the start tangent in the bezier curve
  72779. * @param x2 Defines the x component of the end tangent in the bezier curve
  72780. * @param y2 Defines the y component of the end tangent in the bezier curve
  72781. */
  72782. constructor(
  72783. /** Defines the x component of the start tangent in the bezier curve */
  72784. x1?: number,
  72785. /** Defines the y component of the start tangent in the bezier curve */
  72786. y1?: number,
  72787. /** Defines the x component of the end tangent in the bezier curve */
  72788. x2?: number,
  72789. /** Defines the y component of the end tangent in the bezier curve */
  72790. y2?: number);
  72791. /** @hidden */
  72792. easeInCore(gradient: number): number;
  72793. }
  72794. }
  72795. declare module BABYLON {
  72796. /**
  72797. * Class used to hold a RBG color
  72798. */
  72799. export class Color3 {
  72800. /**
  72801. * Defines the red component (between 0 and 1, default is 0)
  72802. */
  72803. r: number;
  72804. /**
  72805. * Defines the green component (between 0 and 1, default is 0)
  72806. */
  72807. g: number;
  72808. /**
  72809. * Defines the blue component (between 0 and 1, default is 0)
  72810. */
  72811. b: number;
  72812. /**
  72813. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  72814. * @param r defines the red component (between 0 and 1, default is 0)
  72815. * @param g defines the green component (between 0 and 1, default is 0)
  72816. * @param b defines the blue component (between 0 and 1, default is 0)
  72817. */
  72818. constructor(
  72819. /**
  72820. * Defines the red component (between 0 and 1, default is 0)
  72821. */
  72822. r?: number,
  72823. /**
  72824. * Defines the green component (between 0 and 1, default is 0)
  72825. */
  72826. g?: number,
  72827. /**
  72828. * Defines the blue component (between 0 and 1, default is 0)
  72829. */
  72830. b?: number);
  72831. /**
  72832. * Creates a string with the Color3 current values
  72833. * @returns the string representation of the Color3 object
  72834. */
  72835. toString(): string;
  72836. /**
  72837. * Returns the string "Color3"
  72838. * @returns "Color3"
  72839. */
  72840. getClassName(): string;
  72841. /**
  72842. * Compute the Color3 hash code
  72843. * @returns an unique number that can be used to hash Color3 objects
  72844. */
  72845. getHashCode(): number;
  72846. /**
  72847. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  72848. * @param array defines the array where to store the r,g,b components
  72849. * @param index defines an optional index in the target array to define where to start storing values
  72850. * @returns the current Color3 object
  72851. */
  72852. toArray(array: FloatArray, index?: number): Color3;
  72853. /**
  72854. * Returns a new Color4 object from the current Color3 and the given alpha
  72855. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  72856. * @returns a new Color4 object
  72857. */
  72858. toColor4(alpha?: number): Color4;
  72859. /**
  72860. * Returns a new array populated with 3 numeric elements : red, green and blue values
  72861. * @returns the new array
  72862. */
  72863. asArray(): number[];
  72864. /**
  72865. * Returns the luminance value
  72866. * @returns a float value
  72867. */
  72868. toLuminance(): number;
  72869. /**
  72870. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  72871. * @param otherColor defines the second operand
  72872. * @returns the new Color3 object
  72873. */
  72874. multiply(otherColor: DeepImmutable<Color3>): Color3;
  72875. /**
  72876. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  72877. * @param otherColor defines the second operand
  72878. * @param result defines the Color3 object where to store the result
  72879. * @returns the current Color3
  72880. */
  72881. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72882. /**
  72883. * Determines equality between Color3 objects
  72884. * @param otherColor defines the second operand
  72885. * @returns true if the rgb values are equal to the given ones
  72886. */
  72887. equals(otherColor: DeepImmutable<Color3>): boolean;
  72888. /**
  72889. * Determines equality between the current Color3 object and a set of r,b,g values
  72890. * @param r defines the red component to check
  72891. * @param g defines the green component to check
  72892. * @param b defines the blue component to check
  72893. * @returns true if the rgb values are equal to the given ones
  72894. */
  72895. equalsFloats(r: number, g: number, b: number): boolean;
  72896. /**
  72897. * Multiplies in place each rgb value by scale
  72898. * @param scale defines the scaling factor
  72899. * @returns the updated Color3
  72900. */
  72901. scale(scale: number): Color3;
  72902. /**
  72903. * Multiplies the rgb values by scale and stores the result into "result"
  72904. * @param scale defines the scaling factor
  72905. * @param result defines the Color3 object where to store the result
  72906. * @returns the unmodified current Color3
  72907. */
  72908. scaleToRef(scale: number, result: Color3): Color3;
  72909. /**
  72910. * Scale the current Color3 values by a factor and add the result to a given Color3
  72911. * @param scale defines the scale factor
  72912. * @param result defines color to store the result into
  72913. * @returns the unmodified current Color3
  72914. */
  72915. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72916. /**
  72917. * Clamps the rgb values by the min and max values and stores the result into "result"
  72918. * @param min defines minimum clamping value (default is 0)
  72919. * @param max defines maximum clamping value (default is 1)
  72920. * @param result defines color to store the result into
  72921. * @returns the original Color3
  72922. */
  72923. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72924. /**
  72925. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72926. * @param otherColor defines the second operand
  72927. * @returns the new Color3
  72928. */
  72929. add(otherColor: DeepImmutable<Color3>): Color3;
  72930. /**
  72931. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72932. * @param otherColor defines the second operand
  72933. * @param result defines Color3 object to store the result into
  72934. * @returns the unmodified current Color3
  72935. */
  72936. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72937. /**
  72938. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72939. * @param otherColor defines the second operand
  72940. * @returns the new Color3
  72941. */
  72942. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72943. /**
  72944. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72945. * @param otherColor defines the second operand
  72946. * @param result defines Color3 object to store the result into
  72947. * @returns the unmodified current Color3
  72948. */
  72949. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72950. /**
  72951. * Copy the current object
  72952. * @returns a new Color3 copied the current one
  72953. */
  72954. clone(): Color3;
  72955. /**
  72956. * Copies the rgb values from the source in the current Color3
  72957. * @param source defines the source Color3 object
  72958. * @returns the updated Color3 object
  72959. */
  72960. copyFrom(source: DeepImmutable<Color3>): Color3;
  72961. /**
  72962. * Updates the Color3 rgb values from the given floats
  72963. * @param r defines the red component to read from
  72964. * @param g defines the green component to read from
  72965. * @param b defines the blue component to read from
  72966. * @returns the current Color3 object
  72967. */
  72968. copyFromFloats(r: number, g: number, b: number): Color3;
  72969. /**
  72970. * Updates the Color3 rgb values from the given floats
  72971. * @param r defines the red component to read from
  72972. * @param g defines the green component to read from
  72973. * @param b defines the blue component to read from
  72974. * @returns the current Color3 object
  72975. */
  72976. set(r: number, g: number, b: number): Color3;
  72977. /**
  72978. * Compute the Color3 hexadecimal code as a string
  72979. * @returns a string containing the hexadecimal representation of the Color3 object
  72980. */
  72981. toHexString(): string;
  72982. /**
  72983. * Computes a new Color3 converted from the current one to linear space
  72984. * @returns a new Color3 object
  72985. */
  72986. toLinearSpace(): Color3;
  72987. /**
  72988. * Converts current color in rgb space to HSV values
  72989. * @returns a new color3 representing the HSV values
  72990. */
  72991. toHSV(): Color3;
  72992. /**
  72993. * Converts current color in rgb space to HSV values
  72994. * @param result defines the Color3 where to store the HSV values
  72995. */
  72996. toHSVToRef(result: Color3): void;
  72997. /**
  72998. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72999. * @param convertedColor defines the Color3 object where to store the linear space version
  73000. * @returns the unmodified Color3
  73001. */
  73002. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73003. /**
  73004. * Computes a new Color3 converted from the current one to gamma space
  73005. * @returns a new Color3 object
  73006. */
  73007. toGammaSpace(): Color3;
  73008. /**
  73009. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73010. * @param convertedColor defines the Color3 object where to store the gamma space version
  73011. * @returns the unmodified Color3
  73012. */
  73013. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73014. private static _BlackReadOnly;
  73015. /**
  73016. * Convert Hue, saturation and value to a Color3 (RGB)
  73017. * @param hue defines the hue
  73018. * @param saturation defines the saturation
  73019. * @param value defines the value
  73020. * @param result defines the Color3 where to store the RGB values
  73021. */
  73022. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73023. /**
  73024. * Creates a new Color3 from the string containing valid hexadecimal values
  73025. * @param hex defines a string containing valid hexadecimal values
  73026. * @returns a new Color3 object
  73027. */
  73028. static FromHexString(hex: string): Color3;
  73029. /**
  73030. * Creates a new Color3 from the starting index of the given array
  73031. * @param array defines the source array
  73032. * @param offset defines an offset in the source array
  73033. * @returns a new Color3 object
  73034. */
  73035. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73036. /**
  73037. * Creates a new Color3 from integer values (< 256)
  73038. * @param r defines the red component to read from (value between 0 and 255)
  73039. * @param g defines the green component to read from (value between 0 and 255)
  73040. * @param b defines the blue component to read from (value between 0 and 255)
  73041. * @returns a new Color3 object
  73042. */
  73043. static FromInts(r: number, g: number, b: number): Color3;
  73044. /**
  73045. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73046. * @param start defines the start Color3 value
  73047. * @param end defines the end Color3 value
  73048. * @param amount defines the gradient value between start and end
  73049. * @returns a new Color3 object
  73050. */
  73051. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73052. /**
  73053. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73054. * @param left defines the start value
  73055. * @param right defines the end value
  73056. * @param amount defines the gradient factor
  73057. * @param result defines the Color3 object where to store the result
  73058. */
  73059. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73060. /**
  73061. * Returns a Color3 value containing a red color
  73062. * @returns a new Color3 object
  73063. */
  73064. static Red(): Color3;
  73065. /**
  73066. * Returns a Color3 value containing a green color
  73067. * @returns a new Color3 object
  73068. */
  73069. static Green(): Color3;
  73070. /**
  73071. * Returns a Color3 value containing a blue color
  73072. * @returns a new Color3 object
  73073. */
  73074. static Blue(): Color3;
  73075. /**
  73076. * Returns a Color3 value containing a black color
  73077. * @returns a new Color3 object
  73078. */
  73079. static Black(): Color3;
  73080. /**
  73081. * Gets a Color3 value containing a black color that must not be updated
  73082. */
  73083. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73084. /**
  73085. * Returns a Color3 value containing a white color
  73086. * @returns a new Color3 object
  73087. */
  73088. static White(): Color3;
  73089. /**
  73090. * Returns a Color3 value containing a purple color
  73091. * @returns a new Color3 object
  73092. */
  73093. static Purple(): Color3;
  73094. /**
  73095. * Returns a Color3 value containing a magenta color
  73096. * @returns a new Color3 object
  73097. */
  73098. static Magenta(): Color3;
  73099. /**
  73100. * Returns a Color3 value containing a yellow color
  73101. * @returns a new Color3 object
  73102. */
  73103. static Yellow(): Color3;
  73104. /**
  73105. * Returns a Color3 value containing a gray color
  73106. * @returns a new Color3 object
  73107. */
  73108. static Gray(): Color3;
  73109. /**
  73110. * Returns a Color3 value containing a teal color
  73111. * @returns a new Color3 object
  73112. */
  73113. static Teal(): Color3;
  73114. /**
  73115. * Returns a Color3 value containing a random color
  73116. * @returns a new Color3 object
  73117. */
  73118. static Random(): Color3;
  73119. }
  73120. /**
  73121. * Class used to hold a RBGA color
  73122. */
  73123. export class Color4 {
  73124. /**
  73125. * Defines the red component (between 0 and 1, default is 0)
  73126. */
  73127. r: number;
  73128. /**
  73129. * Defines the green component (between 0 and 1, default is 0)
  73130. */
  73131. g: number;
  73132. /**
  73133. * Defines the blue component (between 0 and 1, default is 0)
  73134. */
  73135. b: number;
  73136. /**
  73137. * Defines the alpha component (between 0 and 1, default is 1)
  73138. */
  73139. a: number;
  73140. /**
  73141. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73142. * @param r defines the red component (between 0 and 1, default is 0)
  73143. * @param g defines the green component (between 0 and 1, default is 0)
  73144. * @param b defines the blue component (between 0 and 1, default is 0)
  73145. * @param a defines the alpha component (between 0 and 1, default is 1)
  73146. */
  73147. constructor(
  73148. /**
  73149. * Defines the red component (between 0 and 1, default is 0)
  73150. */
  73151. r?: number,
  73152. /**
  73153. * Defines the green component (between 0 and 1, default is 0)
  73154. */
  73155. g?: number,
  73156. /**
  73157. * Defines the blue component (between 0 and 1, default is 0)
  73158. */
  73159. b?: number,
  73160. /**
  73161. * Defines the alpha component (between 0 and 1, default is 1)
  73162. */
  73163. a?: number);
  73164. /**
  73165. * Adds in place the given Color4 values to the current Color4 object
  73166. * @param right defines the second operand
  73167. * @returns the current updated Color4 object
  73168. */
  73169. addInPlace(right: DeepImmutable<Color4>): Color4;
  73170. /**
  73171. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  73172. * @returns the new array
  73173. */
  73174. asArray(): number[];
  73175. /**
  73176. * Stores from the starting index in the given array the Color4 successive values
  73177. * @param array defines the array where to store the r,g,b components
  73178. * @param index defines an optional index in the target array to define where to start storing values
  73179. * @returns the current Color4 object
  73180. */
  73181. toArray(array: number[], index?: number): Color4;
  73182. /**
  73183. * Determines equality between Color4 objects
  73184. * @param otherColor defines the second operand
  73185. * @returns true if the rgba values are equal to the given ones
  73186. */
  73187. equals(otherColor: DeepImmutable<Color4>): boolean;
  73188. /**
  73189. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  73190. * @param right defines the second operand
  73191. * @returns a new Color4 object
  73192. */
  73193. add(right: DeepImmutable<Color4>): Color4;
  73194. /**
  73195. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  73196. * @param right defines the second operand
  73197. * @returns a new Color4 object
  73198. */
  73199. subtract(right: DeepImmutable<Color4>): Color4;
  73200. /**
  73201. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  73202. * @param right defines the second operand
  73203. * @param result defines the Color4 object where to store the result
  73204. * @returns the current Color4 object
  73205. */
  73206. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  73207. /**
  73208. * Creates a new Color4 with the current Color4 values multiplied by scale
  73209. * @param scale defines the scaling factor to apply
  73210. * @returns a new Color4 object
  73211. */
  73212. scale(scale: number): Color4;
  73213. /**
  73214. * Multiplies the current Color4 values by scale and stores the result in "result"
  73215. * @param scale defines the scaling factor to apply
  73216. * @param result defines the Color4 object where to store the result
  73217. * @returns the current unmodified Color4
  73218. */
  73219. scaleToRef(scale: number, result: Color4): Color4;
  73220. /**
  73221. * Scale the current Color4 values by a factor and add the result to a given Color4
  73222. * @param scale defines the scale factor
  73223. * @param result defines the Color4 object where to store the result
  73224. * @returns the unmodified current Color4
  73225. */
  73226. scaleAndAddToRef(scale: number, result: Color4): Color4;
  73227. /**
  73228. * Clamps the rgb values by the min and max values and stores the result into "result"
  73229. * @param min defines minimum clamping value (default is 0)
  73230. * @param max defines maximum clamping value (default is 1)
  73231. * @param result defines color to store the result into.
  73232. * @returns the cuurent Color4
  73233. */
  73234. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  73235. /**
  73236. * Multipy an Color4 value by another and return a new Color4 object
  73237. * @param color defines the Color4 value to multiply by
  73238. * @returns a new Color4 object
  73239. */
  73240. multiply(color: Color4): Color4;
  73241. /**
  73242. * Multipy a Color4 value by another and push the result in a reference value
  73243. * @param color defines the Color4 value to multiply by
  73244. * @param result defines the Color4 to fill the result in
  73245. * @returns the result Color4
  73246. */
  73247. multiplyToRef(color: Color4, result: Color4): Color4;
  73248. /**
  73249. * Creates a string with the Color4 current values
  73250. * @returns the string representation of the Color4 object
  73251. */
  73252. toString(): string;
  73253. /**
  73254. * Returns the string "Color4"
  73255. * @returns "Color4"
  73256. */
  73257. getClassName(): string;
  73258. /**
  73259. * Compute the Color4 hash code
  73260. * @returns an unique number that can be used to hash Color4 objects
  73261. */
  73262. getHashCode(): number;
  73263. /**
  73264. * Creates a new Color4 copied from the current one
  73265. * @returns a new Color4 object
  73266. */
  73267. clone(): Color4;
  73268. /**
  73269. * Copies the given Color4 values into the current one
  73270. * @param source defines the source Color4 object
  73271. * @returns the current updated Color4 object
  73272. */
  73273. copyFrom(source: Color4): Color4;
  73274. /**
  73275. * Copies the given float values into the current one
  73276. * @param r defines the red component to read from
  73277. * @param g defines the green component to read from
  73278. * @param b defines the blue component to read from
  73279. * @param a defines the alpha component to read from
  73280. * @returns the current updated Color4 object
  73281. */
  73282. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  73283. /**
  73284. * Copies the given float values into the current one
  73285. * @param r defines the red component to read from
  73286. * @param g defines the green component to read from
  73287. * @param b defines the blue component to read from
  73288. * @param a defines the alpha component to read from
  73289. * @returns the current updated Color4 object
  73290. */
  73291. set(r: number, g: number, b: number, a: number): Color4;
  73292. /**
  73293. * Compute the Color4 hexadecimal code as a string
  73294. * @returns a string containing the hexadecimal representation of the Color4 object
  73295. */
  73296. toHexString(): string;
  73297. /**
  73298. * Computes a new Color4 converted from the current one to linear space
  73299. * @returns a new Color4 object
  73300. */
  73301. toLinearSpace(): Color4;
  73302. /**
  73303. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  73304. * @param convertedColor defines the Color4 object where to store the linear space version
  73305. * @returns the unmodified Color4
  73306. */
  73307. toLinearSpaceToRef(convertedColor: Color4): Color4;
  73308. /**
  73309. * Computes a new Color4 converted from the current one to gamma space
  73310. * @returns a new Color4 object
  73311. */
  73312. toGammaSpace(): Color4;
  73313. /**
  73314. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  73315. * @param convertedColor defines the Color4 object where to store the gamma space version
  73316. * @returns the unmodified Color4
  73317. */
  73318. toGammaSpaceToRef(convertedColor: Color4): Color4;
  73319. /**
  73320. * Creates a new Color4 from the string containing valid hexadecimal values
  73321. * @param hex defines a string containing valid hexadecimal values
  73322. * @returns a new Color4 object
  73323. */
  73324. static FromHexString(hex: string): Color4;
  73325. /**
  73326. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73327. * @param left defines the start value
  73328. * @param right defines the end value
  73329. * @param amount defines the gradient factor
  73330. * @returns a new Color4 object
  73331. */
  73332. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  73333. /**
  73334. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  73335. * @param left defines the start value
  73336. * @param right defines the end value
  73337. * @param amount defines the gradient factor
  73338. * @param result defines the Color4 object where to store data
  73339. */
  73340. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  73341. /**
  73342. * Creates a new Color4 from a Color3 and an alpha value
  73343. * @param color3 defines the source Color3 to read from
  73344. * @param alpha defines the alpha component (1.0 by default)
  73345. * @returns a new Color4 object
  73346. */
  73347. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  73348. /**
  73349. * Creates a new Color4 from the starting index element of the given array
  73350. * @param array defines the source array to read from
  73351. * @param offset defines the offset in the source array
  73352. * @returns a new Color4 object
  73353. */
  73354. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  73355. /**
  73356. * Creates a new Color3 from integer values (< 256)
  73357. * @param r defines the red component to read from (value between 0 and 255)
  73358. * @param g defines the green component to read from (value between 0 and 255)
  73359. * @param b defines the blue component to read from (value between 0 and 255)
  73360. * @param a defines the alpha component to read from (value between 0 and 255)
  73361. * @returns a new Color3 object
  73362. */
  73363. static FromInts(r: number, g: number, b: number, a: number): Color4;
  73364. /**
  73365. * Check the content of a given array and convert it to an array containing RGBA data
  73366. * If the original array was already containing count * 4 values then it is returned directly
  73367. * @param colors defines the array to check
  73368. * @param count defines the number of RGBA data to expect
  73369. * @returns an array containing count * 4 values (RGBA)
  73370. */
  73371. static CheckColors4(colors: number[], count: number): number[];
  73372. }
  73373. /**
  73374. * @hidden
  73375. */
  73376. export class TmpColors {
  73377. static Color3: Color3[];
  73378. static Color4: Color4[];
  73379. }
  73380. }
  73381. declare module BABYLON {
  73382. /**
  73383. * Defines an interface which represents an animation key frame
  73384. */
  73385. export interface IAnimationKey {
  73386. /**
  73387. * Frame of the key frame
  73388. */
  73389. frame: number;
  73390. /**
  73391. * Value at the specifies key frame
  73392. */
  73393. value: any;
  73394. /**
  73395. * The input tangent for the cubic hermite spline
  73396. */
  73397. inTangent?: any;
  73398. /**
  73399. * The output tangent for the cubic hermite spline
  73400. */
  73401. outTangent?: any;
  73402. /**
  73403. * The animation interpolation type
  73404. */
  73405. interpolation?: AnimationKeyInterpolation;
  73406. }
  73407. /**
  73408. * Enum for the animation key frame interpolation type
  73409. */
  73410. export enum AnimationKeyInterpolation {
  73411. /**
  73412. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  73413. */
  73414. STEP = 1
  73415. }
  73416. }
  73417. declare module BABYLON {
  73418. /**
  73419. * Represents the range of an animation
  73420. */
  73421. export class AnimationRange {
  73422. /**The name of the animation range**/
  73423. name: string;
  73424. /**The starting frame of the animation */
  73425. from: number;
  73426. /**The ending frame of the animation*/
  73427. to: number;
  73428. /**
  73429. * Initializes the range of an animation
  73430. * @param name The name of the animation range
  73431. * @param from The starting frame of the animation
  73432. * @param to The ending frame of the animation
  73433. */
  73434. constructor(
  73435. /**The name of the animation range**/
  73436. name: string,
  73437. /**The starting frame of the animation */
  73438. from: number,
  73439. /**The ending frame of the animation*/
  73440. to: number);
  73441. /**
  73442. * Makes a copy of the animation range
  73443. * @returns A copy of the animation range
  73444. */
  73445. clone(): AnimationRange;
  73446. }
  73447. }
  73448. declare module BABYLON {
  73449. /**
  73450. * Composed of a frame, and an action function
  73451. */
  73452. export class AnimationEvent {
  73453. /** The frame for which the event is triggered **/
  73454. frame: number;
  73455. /** The event to perform when triggered **/
  73456. action: (currentFrame: number) => void;
  73457. /** Specifies if the event should be triggered only once**/
  73458. onlyOnce?: boolean | undefined;
  73459. /**
  73460. * Specifies if the animation event is done
  73461. */
  73462. isDone: boolean;
  73463. /**
  73464. * Initializes the animation event
  73465. * @param frame The frame for which the event is triggered
  73466. * @param action The event to perform when triggered
  73467. * @param onlyOnce Specifies if the event should be triggered only once
  73468. */
  73469. constructor(
  73470. /** The frame for which the event is triggered **/
  73471. frame: number,
  73472. /** The event to perform when triggered **/
  73473. action: (currentFrame: number) => void,
  73474. /** Specifies if the event should be triggered only once**/
  73475. onlyOnce?: boolean | undefined);
  73476. /** @hidden */
  73477. _clone(): AnimationEvent;
  73478. }
  73479. }
  73480. declare module BABYLON {
  73481. /**
  73482. * Interface used to define a behavior
  73483. */
  73484. export interface Behavior<T> {
  73485. /** gets or sets behavior's name */
  73486. name: string;
  73487. /**
  73488. * Function called when the behavior needs to be initialized (after attaching it to a target)
  73489. */
  73490. init(): void;
  73491. /**
  73492. * Called when the behavior is attached to a target
  73493. * @param target defines the target where the behavior is attached to
  73494. */
  73495. attach(target: T): void;
  73496. /**
  73497. * Called when the behavior is detached from its target
  73498. */
  73499. detach(): void;
  73500. }
  73501. /**
  73502. * Interface implemented by classes supporting behaviors
  73503. */
  73504. export interface IBehaviorAware<T> {
  73505. /**
  73506. * Attach a behavior
  73507. * @param behavior defines the behavior to attach
  73508. * @returns the current host
  73509. */
  73510. addBehavior(behavior: Behavior<T>): T;
  73511. /**
  73512. * Remove a behavior from the current object
  73513. * @param behavior defines the behavior to detach
  73514. * @returns the current host
  73515. */
  73516. removeBehavior(behavior: Behavior<T>): T;
  73517. /**
  73518. * Gets a behavior using its name to search
  73519. * @param name defines the name to search
  73520. * @returns the behavior or null if not found
  73521. */
  73522. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  73523. }
  73524. }
  73525. declare module BABYLON {
  73526. /**
  73527. * Defines an array and its length.
  73528. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  73529. */
  73530. export interface ISmartArrayLike<T> {
  73531. /**
  73532. * The data of the array.
  73533. */
  73534. data: Array<T>;
  73535. /**
  73536. * The active length of the array.
  73537. */
  73538. length: number;
  73539. }
  73540. /**
  73541. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73542. */
  73543. export class SmartArray<T> implements ISmartArrayLike<T> {
  73544. /**
  73545. * The full set of data from the array.
  73546. */
  73547. data: Array<T>;
  73548. /**
  73549. * The active length of the array.
  73550. */
  73551. length: number;
  73552. protected _id: number;
  73553. /**
  73554. * Instantiates a Smart Array.
  73555. * @param capacity defines the default capacity of the array.
  73556. */
  73557. constructor(capacity: number);
  73558. /**
  73559. * Pushes a value at the end of the active data.
  73560. * @param value defines the object to push in the array.
  73561. */
  73562. push(value: T): void;
  73563. /**
  73564. * Iterates over the active data and apply the lambda to them.
  73565. * @param func defines the action to apply on each value.
  73566. */
  73567. forEach(func: (content: T) => void): void;
  73568. /**
  73569. * Sorts the full sets of data.
  73570. * @param compareFn defines the comparison function to apply.
  73571. */
  73572. sort(compareFn: (a: T, b: T) => number): void;
  73573. /**
  73574. * Resets the active data to an empty array.
  73575. */
  73576. reset(): void;
  73577. /**
  73578. * Releases all the data from the array as well as the array.
  73579. */
  73580. dispose(): void;
  73581. /**
  73582. * Concats the active data with a given array.
  73583. * @param array defines the data to concatenate with.
  73584. */
  73585. concat(array: any): void;
  73586. /**
  73587. * Returns the position of a value in the active data.
  73588. * @param value defines the value to find the index for
  73589. * @returns the index if found in the active data otherwise -1
  73590. */
  73591. indexOf(value: T): number;
  73592. /**
  73593. * Returns whether an element is part of the active data.
  73594. * @param value defines the value to look for
  73595. * @returns true if found in the active data otherwise false
  73596. */
  73597. contains(value: T): boolean;
  73598. private static _GlobalId;
  73599. }
  73600. /**
  73601. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  73602. * The data in this array can only be present once
  73603. */
  73604. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  73605. private _duplicateId;
  73606. /**
  73607. * Pushes a value at the end of the active data.
  73608. * THIS DOES NOT PREVENT DUPPLICATE DATA
  73609. * @param value defines the object to push in the array.
  73610. */
  73611. push(value: T): void;
  73612. /**
  73613. * Pushes a value at the end of the active data.
  73614. * If the data is already present, it won t be added again
  73615. * @param value defines the object to push in the array.
  73616. * @returns true if added false if it was already present
  73617. */
  73618. pushNoDuplicate(value: T): boolean;
  73619. /**
  73620. * Resets the active data to an empty array.
  73621. */
  73622. reset(): void;
  73623. /**
  73624. * Concats the active data with a given array.
  73625. * This ensures no dupplicate will be present in the result.
  73626. * @param array defines the data to concatenate with.
  73627. */
  73628. concatWithNoDuplicate(array: any): void;
  73629. }
  73630. }
  73631. declare module BABYLON {
  73632. /**
  73633. * @ignore
  73634. * This is a list of all the different input types that are available in the application.
  73635. * Fo instance: ArcRotateCameraGamepadInput...
  73636. */
  73637. export var CameraInputTypes: {};
  73638. /**
  73639. * This is the contract to implement in order to create a new input class.
  73640. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  73641. */
  73642. export interface ICameraInput<TCamera extends Camera> {
  73643. /**
  73644. * Defines the camera the input is attached to.
  73645. */
  73646. camera: Nullable<TCamera>;
  73647. /**
  73648. * Gets the class name of the current intput.
  73649. * @returns the class name
  73650. */
  73651. getClassName(): string;
  73652. /**
  73653. * Get the friendly name associated with the input class.
  73654. * @returns the input friendly name
  73655. */
  73656. getSimpleName(): string;
  73657. /**
  73658. * Attach the input controls to a specific dom element to get the input from.
  73659. * @param element Defines the element the controls should be listened from
  73660. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73661. */
  73662. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  73663. /**
  73664. * Detach the current controls from the specified dom element.
  73665. * @param element Defines the element to stop listening the inputs from
  73666. */
  73667. detachControl(element: Nullable<HTMLElement>): void;
  73668. /**
  73669. * Update the current camera state depending on the inputs that have been used this frame.
  73670. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73671. */
  73672. checkInputs?: () => void;
  73673. }
  73674. /**
  73675. * Represents a map of input types to input instance or input index to input instance.
  73676. */
  73677. export interface CameraInputsMap<TCamera extends Camera> {
  73678. /**
  73679. * Accessor to the input by input type.
  73680. */
  73681. [name: string]: ICameraInput<TCamera>;
  73682. /**
  73683. * Accessor to the input by input index.
  73684. */
  73685. [idx: number]: ICameraInput<TCamera>;
  73686. }
  73687. /**
  73688. * This represents the input manager used within a camera.
  73689. * It helps dealing with all the different kind of input attached to a camera.
  73690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73691. */
  73692. export class CameraInputsManager<TCamera extends Camera> {
  73693. /**
  73694. * Defines the list of inputs attahed to the camera.
  73695. */
  73696. attached: CameraInputsMap<TCamera>;
  73697. /**
  73698. * Defines the dom element the camera is collecting inputs from.
  73699. * This is null if the controls have not been attached.
  73700. */
  73701. attachedElement: Nullable<HTMLElement>;
  73702. /**
  73703. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73704. */
  73705. noPreventDefault: boolean;
  73706. /**
  73707. * Defined the camera the input manager belongs to.
  73708. */
  73709. camera: TCamera;
  73710. /**
  73711. * Update the current camera state depending on the inputs that have been used this frame.
  73712. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  73713. */
  73714. checkInputs: () => void;
  73715. /**
  73716. * Instantiate a new Camera Input Manager.
  73717. * @param camera Defines the camera the input manager blongs to
  73718. */
  73719. constructor(camera: TCamera);
  73720. /**
  73721. * Add an input method to a camera
  73722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  73723. * @param input camera input method
  73724. */
  73725. add(input: ICameraInput<TCamera>): void;
  73726. /**
  73727. * Remove a specific input method from a camera
  73728. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  73729. * @param inputToRemove camera input method
  73730. */
  73731. remove(inputToRemove: ICameraInput<TCamera>): void;
  73732. /**
  73733. * Remove a specific input type from a camera
  73734. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  73735. * @param inputType the type of the input to remove
  73736. */
  73737. removeByType(inputType: string): void;
  73738. private _addCheckInputs;
  73739. /**
  73740. * Attach the input controls to the currently attached dom element to listen the events from.
  73741. * @param input Defines the input to attach
  73742. */
  73743. attachInput(input: ICameraInput<TCamera>): void;
  73744. /**
  73745. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  73746. * @param element Defines the dom element to collect the events from
  73747. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  73748. */
  73749. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  73750. /**
  73751. * Detach the current manager inputs controls from a specific dom element.
  73752. * @param element Defines the dom element to collect the events from
  73753. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  73754. */
  73755. detachElement(element: HTMLElement, disconnect?: boolean): void;
  73756. /**
  73757. * Rebuild the dynamic inputCheck function from the current list of
  73758. * defined inputs in the manager.
  73759. */
  73760. rebuildInputCheck(): void;
  73761. /**
  73762. * Remove all attached input methods from a camera
  73763. */
  73764. clear(): void;
  73765. /**
  73766. * Serialize the current input manager attached to a camera.
  73767. * This ensures than once parsed,
  73768. * the input associated to the camera will be identical to the current ones
  73769. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  73770. */
  73771. serialize(serializedCamera: any): void;
  73772. /**
  73773. * Parses an input manager serialized JSON to restore the previous list of inputs
  73774. * and states associated to a camera.
  73775. * @param parsedCamera Defines the JSON to parse
  73776. */
  73777. parse(parsedCamera: any): void;
  73778. }
  73779. }
  73780. declare module BABYLON {
  73781. /**
  73782. * Class used to store data that will be store in GPU memory
  73783. */
  73784. export class Buffer {
  73785. private _engine;
  73786. private _buffer;
  73787. /** @hidden */
  73788. _data: Nullable<DataArray>;
  73789. private _updatable;
  73790. private _instanced;
  73791. private _divisor;
  73792. /**
  73793. * Gets the byte stride.
  73794. */
  73795. readonly byteStride: number;
  73796. /**
  73797. * Constructor
  73798. * @param engine the engine
  73799. * @param data the data to use for this buffer
  73800. * @param updatable whether the data is updatable
  73801. * @param stride the stride (optional)
  73802. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73803. * @param instanced whether the buffer is instanced (optional)
  73804. * @param useBytes set to true if the stride in in bytes (optional)
  73805. * @param divisor sets an optional divisor for instances (1 by default)
  73806. */
  73807. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  73808. /**
  73809. * Create a new VertexBuffer based on the current buffer
  73810. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73811. * @param offset defines offset in the buffer (0 by default)
  73812. * @param size defines the size in floats of attributes (position is 3 for instance)
  73813. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73814. * @param instanced defines if the vertex buffer contains indexed data
  73815. * @param useBytes defines if the offset and stride are in bytes *
  73816. * @param divisor sets an optional divisor for instances (1 by default)
  73817. * @returns the new vertex buffer
  73818. */
  73819. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  73820. /**
  73821. * Gets a boolean indicating if the Buffer is updatable?
  73822. * @returns true if the buffer is updatable
  73823. */
  73824. isUpdatable(): boolean;
  73825. /**
  73826. * Gets current buffer's data
  73827. * @returns a DataArray or null
  73828. */
  73829. getData(): Nullable<DataArray>;
  73830. /**
  73831. * Gets underlying native buffer
  73832. * @returns underlying native buffer
  73833. */
  73834. getBuffer(): Nullable<DataBuffer>;
  73835. /**
  73836. * Gets the stride in float32 units (i.e. byte stride / 4).
  73837. * May not be an integer if the byte stride is not divisible by 4.
  73838. * DEPRECATED. Use byteStride instead.
  73839. * @returns the stride in float32 units
  73840. */
  73841. getStrideSize(): number;
  73842. /**
  73843. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73844. * @param data defines the data to store
  73845. */
  73846. create(data?: Nullable<DataArray>): void;
  73847. /** @hidden */
  73848. _rebuild(): void;
  73849. /**
  73850. * Update current buffer data
  73851. * @param data defines the data to store
  73852. */
  73853. update(data: DataArray): void;
  73854. /**
  73855. * Updates the data directly.
  73856. * @param data the new data
  73857. * @param offset the new offset
  73858. * @param vertexCount the vertex count (optional)
  73859. * @param useBytes set to true if the offset is in bytes
  73860. */
  73861. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73862. /**
  73863. * Release all resources
  73864. */
  73865. dispose(): void;
  73866. }
  73867. /**
  73868. * Specialized buffer used to store vertex data
  73869. */
  73870. export class VertexBuffer {
  73871. /** @hidden */
  73872. _buffer: Buffer;
  73873. private _kind;
  73874. private _size;
  73875. private _ownsBuffer;
  73876. private _instanced;
  73877. private _instanceDivisor;
  73878. /**
  73879. * The byte type.
  73880. */
  73881. static readonly BYTE: number;
  73882. /**
  73883. * The unsigned byte type.
  73884. */
  73885. static readonly UNSIGNED_BYTE: number;
  73886. /**
  73887. * The short type.
  73888. */
  73889. static readonly SHORT: number;
  73890. /**
  73891. * The unsigned short type.
  73892. */
  73893. static readonly UNSIGNED_SHORT: number;
  73894. /**
  73895. * The integer type.
  73896. */
  73897. static readonly INT: number;
  73898. /**
  73899. * The unsigned integer type.
  73900. */
  73901. static readonly UNSIGNED_INT: number;
  73902. /**
  73903. * The float type.
  73904. */
  73905. static readonly FLOAT: number;
  73906. /**
  73907. * Gets or sets the instance divisor when in instanced mode
  73908. */
  73909. instanceDivisor: number;
  73910. /**
  73911. * Gets the byte stride.
  73912. */
  73913. readonly byteStride: number;
  73914. /**
  73915. * Gets the byte offset.
  73916. */
  73917. readonly byteOffset: number;
  73918. /**
  73919. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73920. */
  73921. readonly normalized: boolean;
  73922. /**
  73923. * Gets the data type of each component in the array.
  73924. */
  73925. readonly type: number;
  73926. /**
  73927. * Constructor
  73928. * @param engine the engine
  73929. * @param data the data to use for this vertex buffer
  73930. * @param kind the vertex buffer kind
  73931. * @param updatable whether the data is updatable
  73932. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73933. * @param stride the stride (optional)
  73934. * @param instanced whether the buffer is instanced (optional)
  73935. * @param offset the offset of the data (optional)
  73936. * @param size the number of components (optional)
  73937. * @param type the type of the component (optional)
  73938. * @param normalized whether the data contains normalized data (optional)
  73939. * @param useBytes set to true if stride and offset are in bytes (optional)
  73940. * @param divisor defines the instance divisor to use (1 by default)
  73941. */
  73942. 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, divisor?: number);
  73943. /** @hidden */
  73944. _rebuild(): void;
  73945. /**
  73946. * Returns the kind of the VertexBuffer (string)
  73947. * @returns a string
  73948. */
  73949. getKind(): string;
  73950. /**
  73951. * Gets a boolean indicating if the VertexBuffer is updatable?
  73952. * @returns true if the buffer is updatable
  73953. */
  73954. isUpdatable(): boolean;
  73955. /**
  73956. * Gets current buffer's data
  73957. * @returns a DataArray or null
  73958. */
  73959. getData(): Nullable<DataArray>;
  73960. /**
  73961. * Gets underlying native buffer
  73962. * @returns underlying native buffer
  73963. */
  73964. getBuffer(): Nullable<DataBuffer>;
  73965. /**
  73966. * Gets the stride in float32 units (i.e. byte stride / 4).
  73967. * May not be an integer if the byte stride is not divisible by 4.
  73968. * DEPRECATED. Use byteStride instead.
  73969. * @returns the stride in float32 units
  73970. */
  73971. getStrideSize(): number;
  73972. /**
  73973. * Returns the offset as a multiple of the type byte length.
  73974. * DEPRECATED. Use byteOffset instead.
  73975. * @returns the offset in bytes
  73976. */
  73977. getOffset(): number;
  73978. /**
  73979. * Returns the number of components per vertex attribute (integer)
  73980. * @returns the size in float
  73981. */
  73982. getSize(): number;
  73983. /**
  73984. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73985. * @returns true if this buffer is instanced
  73986. */
  73987. getIsInstanced(): boolean;
  73988. /**
  73989. * Returns the instancing divisor, zero for non-instanced (integer).
  73990. * @returns a number
  73991. */
  73992. getInstanceDivisor(): number;
  73993. /**
  73994. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73995. * @param data defines the data to store
  73996. */
  73997. create(data?: DataArray): void;
  73998. /**
  73999. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74000. * This function will create a new buffer if the current one is not updatable
  74001. * @param data defines the data to store
  74002. */
  74003. update(data: DataArray): void;
  74004. /**
  74005. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74006. * Returns the directly updated WebGLBuffer.
  74007. * @param data the new data
  74008. * @param offset the new offset
  74009. * @param useBytes set to true if the offset is in bytes
  74010. */
  74011. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74012. /**
  74013. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74014. */
  74015. dispose(): void;
  74016. /**
  74017. * Enumerates each value of this vertex buffer as numbers.
  74018. * @param count the number of values to enumerate
  74019. * @param callback the callback function called for each value
  74020. */
  74021. forEach(count: number, callback: (value: number, index: number) => void): void;
  74022. /**
  74023. * Positions
  74024. */
  74025. static readonly PositionKind: string;
  74026. /**
  74027. * Normals
  74028. */
  74029. static readonly NormalKind: string;
  74030. /**
  74031. * Tangents
  74032. */
  74033. static readonly TangentKind: string;
  74034. /**
  74035. * Texture coordinates
  74036. */
  74037. static readonly UVKind: string;
  74038. /**
  74039. * Texture coordinates 2
  74040. */
  74041. static readonly UV2Kind: string;
  74042. /**
  74043. * Texture coordinates 3
  74044. */
  74045. static readonly UV3Kind: string;
  74046. /**
  74047. * Texture coordinates 4
  74048. */
  74049. static readonly UV4Kind: string;
  74050. /**
  74051. * Texture coordinates 5
  74052. */
  74053. static readonly UV5Kind: string;
  74054. /**
  74055. * Texture coordinates 6
  74056. */
  74057. static readonly UV6Kind: string;
  74058. /**
  74059. * Colors
  74060. */
  74061. static readonly ColorKind: string;
  74062. /**
  74063. * Matrix indices (for bones)
  74064. */
  74065. static readonly MatricesIndicesKind: string;
  74066. /**
  74067. * Matrix weights (for bones)
  74068. */
  74069. static readonly MatricesWeightsKind: string;
  74070. /**
  74071. * Additional matrix indices (for bones)
  74072. */
  74073. static readonly MatricesIndicesExtraKind: string;
  74074. /**
  74075. * Additional matrix weights (for bones)
  74076. */
  74077. static readonly MatricesWeightsExtraKind: string;
  74078. /**
  74079. * Deduces the stride given a kind.
  74080. * @param kind The kind string to deduce
  74081. * @returns The deduced stride
  74082. */
  74083. static DeduceStride(kind: string): number;
  74084. /**
  74085. * Gets the byte length of the given type.
  74086. * @param type the type
  74087. * @returns the number of bytes
  74088. */
  74089. static GetTypeByteLength(type: number): number;
  74090. /**
  74091. * Enumerates each value of the given parameters as numbers.
  74092. * @param data the data to enumerate
  74093. * @param byteOffset the byte offset of the data
  74094. * @param byteStride the byte stride of the data
  74095. * @param componentCount the number of components per element
  74096. * @param componentType the type of the component
  74097. * @param count the number of values to enumerate
  74098. * @param normalized whether the data is normalized
  74099. * @param callback the callback function called for each value
  74100. */
  74101. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74102. private static _GetFloatValue;
  74103. }
  74104. }
  74105. declare module BABYLON {
  74106. /**
  74107. * @hidden
  74108. */
  74109. export class IntersectionInfo {
  74110. bu: Nullable<number>;
  74111. bv: Nullable<number>;
  74112. distance: number;
  74113. faceId: number;
  74114. subMeshId: number;
  74115. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74116. }
  74117. }
  74118. declare module BABYLON {
  74119. /**
  74120. * Represens a plane by the equation ax + by + cz + d = 0
  74121. */
  74122. export class Plane {
  74123. private static _TmpMatrix;
  74124. /**
  74125. * Normal of the plane (a,b,c)
  74126. */
  74127. normal: Vector3;
  74128. /**
  74129. * d component of the plane
  74130. */
  74131. d: number;
  74132. /**
  74133. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74134. * @param a a component of the plane
  74135. * @param b b component of the plane
  74136. * @param c c component of the plane
  74137. * @param d d component of the plane
  74138. */
  74139. constructor(a: number, b: number, c: number, d: number);
  74140. /**
  74141. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74142. */
  74143. asArray(): number[];
  74144. /**
  74145. * @returns a new plane copied from the current Plane.
  74146. */
  74147. clone(): Plane;
  74148. /**
  74149. * @returns the string "Plane".
  74150. */
  74151. getClassName(): string;
  74152. /**
  74153. * @returns the Plane hash code.
  74154. */
  74155. getHashCode(): number;
  74156. /**
  74157. * Normalize the current Plane in place.
  74158. * @returns the updated Plane.
  74159. */
  74160. normalize(): Plane;
  74161. /**
  74162. * Applies a transformation the plane and returns the result
  74163. * @param transformation the transformation matrix to be applied to the plane
  74164. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74165. */
  74166. transform(transformation: DeepImmutable<Matrix>): Plane;
  74167. /**
  74168. * Calcualtte the dot product between the point and the plane normal
  74169. * @param point point to calculate the dot product with
  74170. * @returns the dot product (float) of the point coordinates and the plane normal.
  74171. */
  74172. dotCoordinate(point: DeepImmutable<Vector3>): number;
  74173. /**
  74174. * Updates the current Plane from the plane defined by the three given points.
  74175. * @param point1 one of the points used to contruct the plane
  74176. * @param point2 one of the points used to contruct the plane
  74177. * @param point3 one of the points used to contruct the plane
  74178. * @returns the updated Plane.
  74179. */
  74180. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74181. /**
  74182. * Checks if the plane is facing a given direction
  74183. * @param direction the direction to check if the plane is facing
  74184. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  74185. * @returns True is the vector "direction" is the same side than the plane normal.
  74186. */
  74187. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  74188. /**
  74189. * Calculates the distance to a point
  74190. * @param point point to calculate distance to
  74191. * @returns the signed distance (float) from the given point to the Plane.
  74192. */
  74193. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  74194. /**
  74195. * Creates a plane from an array
  74196. * @param array the array to create a plane from
  74197. * @returns a new Plane from the given array.
  74198. */
  74199. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  74200. /**
  74201. * Creates a plane from three points
  74202. * @param point1 point used to create the plane
  74203. * @param point2 point used to create the plane
  74204. * @param point3 point used to create the plane
  74205. * @returns a new Plane defined by the three given points.
  74206. */
  74207. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  74208. /**
  74209. * Creates a plane from an origin point and a normal
  74210. * @param origin origin of the plane to be constructed
  74211. * @param normal normal of the plane to be constructed
  74212. * @returns a new Plane the normal vector to this plane at the given origin point.
  74213. * Note : the vector "normal" is updated because normalized.
  74214. */
  74215. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  74216. /**
  74217. * Calculates the distance from a plane and a point
  74218. * @param origin origin of the plane to be constructed
  74219. * @param normal normal of the plane to be constructed
  74220. * @param point point to calculate distance to
  74221. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74222. */
  74223. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  74224. }
  74225. }
  74226. declare module BABYLON {
  74227. /**
  74228. * Class used to store bounding sphere information
  74229. */
  74230. export class BoundingSphere {
  74231. /**
  74232. * Gets the center of the bounding sphere in local space
  74233. */
  74234. readonly center: Vector3;
  74235. /**
  74236. * Radius of the bounding sphere in local space
  74237. */
  74238. radius: number;
  74239. /**
  74240. * Gets the center of the bounding sphere in world space
  74241. */
  74242. readonly centerWorld: Vector3;
  74243. /**
  74244. * Radius of the bounding sphere in world space
  74245. */
  74246. radiusWorld: number;
  74247. /**
  74248. * Gets the minimum vector in local space
  74249. */
  74250. readonly minimum: Vector3;
  74251. /**
  74252. * Gets the maximum vector in local space
  74253. */
  74254. readonly maximum: Vector3;
  74255. private _worldMatrix;
  74256. private static readonly TmpVector3;
  74257. /**
  74258. * Creates a new bounding sphere
  74259. * @param min defines the minimum vector (in local space)
  74260. * @param max defines the maximum vector (in local space)
  74261. * @param worldMatrix defines the new world matrix
  74262. */
  74263. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74264. /**
  74265. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  74266. * @param min defines the new minimum vector (in local space)
  74267. * @param max defines the new maximum vector (in local space)
  74268. * @param worldMatrix defines the new world matrix
  74269. */
  74270. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74271. /**
  74272. * Scale the current bounding sphere by applying a scale factor
  74273. * @param factor defines the scale factor to apply
  74274. * @returns the current bounding box
  74275. */
  74276. scale(factor: number): BoundingSphere;
  74277. /**
  74278. * Gets the world matrix of the bounding box
  74279. * @returns a matrix
  74280. */
  74281. getWorldMatrix(): DeepImmutable<Matrix>;
  74282. /** @hidden */
  74283. _update(worldMatrix: DeepImmutable<Matrix>): void;
  74284. /**
  74285. * Tests if the bounding sphere is intersecting the frustum planes
  74286. * @param frustumPlanes defines the frustum planes to test
  74287. * @returns true if there is an intersection
  74288. */
  74289. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74290. /**
  74291. * Tests if the bounding sphere center is in between the frustum planes.
  74292. * Used for optimistic fast inclusion.
  74293. * @param frustumPlanes defines the frustum planes to test
  74294. * @returns true if the sphere center is in between the frustum planes
  74295. */
  74296. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74297. /**
  74298. * Tests if a point is inside the bounding sphere
  74299. * @param point defines the point to test
  74300. * @returns true if the point is inside the bounding sphere
  74301. */
  74302. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74303. /**
  74304. * Checks if two sphere intersct
  74305. * @param sphere0 sphere 0
  74306. * @param sphere1 sphere 1
  74307. * @returns true if the speres intersect
  74308. */
  74309. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  74310. }
  74311. }
  74312. declare module BABYLON {
  74313. /**
  74314. * Class used to store bounding box information
  74315. */
  74316. export class BoundingBox implements ICullable {
  74317. /**
  74318. * Gets the 8 vectors representing the bounding box in local space
  74319. */
  74320. readonly vectors: Vector3[];
  74321. /**
  74322. * Gets the center of the bounding box in local space
  74323. */
  74324. readonly center: Vector3;
  74325. /**
  74326. * Gets the center of the bounding box in world space
  74327. */
  74328. readonly centerWorld: Vector3;
  74329. /**
  74330. * Gets the extend size in local space
  74331. */
  74332. readonly extendSize: Vector3;
  74333. /**
  74334. * Gets the extend size in world space
  74335. */
  74336. readonly extendSizeWorld: Vector3;
  74337. /**
  74338. * Gets the OBB (object bounding box) directions
  74339. */
  74340. readonly directions: Vector3[];
  74341. /**
  74342. * Gets the 8 vectors representing the bounding box in world space
  74343. */
  74344. readonly vectorsWorld: Vector3[];
  74345. /**
  74346. * Gets the minimum vector in world space
  74347. */
  74348. readonly minimumWorld: Vector3;
  74349. /**
  74350. * Gets the maximum vector in world space
  74351. */
  74352. readonly maximumWorld: Vector3;
  74353. /**
  74354. * Gets the minimum vector in local space
  74355. */
  74356. readonly minimum: Vector3;
  74357. /**
  74358. * Gets the maximum vector in local space
  74359. */
  74360. readonly maximum: Vector3;
  74361. private _worldMatrix;
  74362. private static readonly TmpVector3;
  74363. /**
  74364. * @hidden
  74365. */
  74366. _tag: number;
  74367. /**
  74368. * Creates a new bounding box
  74369. * @param min defines the minimum vector (in local space)
  74370. * @param max defines the maximum vector (in local space)
  74371. * @param worldMatrix defines the new world matrix
  74372. */
  74373. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74374. /**
  74375. * Recreates the entire bounding box from scratch as if we call the constructor in place
  74376. * @param min defines the new minimum vector (in local space)
  74377. * @param max defines the new maximum vector (in local space)
  74378. * @param worldMatrix defines the new world matrix
  74379. */
  74380. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74381. /**
  74382. * Scale the current bounding box by applying a scale factor
  74383. * @param factor defines the scale factor to apply
  74384. * @returns the current bounding box
  74385. */
  74386. scale(factor: number): BoundingBox;
  74387. /**
  74388. * Gets the world matrix of the bounding box
  74389. * @returns a matrix
  74390. */
  74391. getWorldMatrix(): DeepImmutable<Matrix>;
  74392. /** @hidden */
  74393. _update(world: DeepImmutable<Matrix>): void;
  74394. /**
  74395. * Tests if the bounding box is intersecting the frustum planes
  74396. * @param frustumPlanes defines the frustum planes to test
  74397. * @returns true if there is an intersection
  74398. */
  74399. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74400. /**
  74401. * Tests if the bounding box is entirely inside the frustum planes
  74402. * @param frustumPlanes defines the frustum planes to test
  74403. * @returns true if there is an inclusion
  74404. */
  74405. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74406. /**
  74407. * Tests if a point is inside the bounding box
  74408. * @param point defines the point to test
  74409. * @returns true if the point is inside the bounding box
  74410. */
  74411. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74412. /**
  74413. * Tests if the bounding box intersects with a bounding sphere
  74414. * @param sphere defines the sphere to test
  74415. * @returns true if there is an intersection
  74416. */
  74417. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  74418. /**
  74419. * Tests if the bounding box intersects with a box defined by a min and max vectors
  74420. * @param min defines the min vector to use
  74421. * @param max defines the max vector to use
  74422. * @returns true if there is an intersection
  74423. */
  74424. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  74425. /**
  74426. * Tests if two bounding boxes are intersections
  74427. * @param box0 defines the first box to test
  74428. * @param box1 defines the second box to test
  74429. * @returns true if there is an intersection
  74430. */
  74431. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  74432. /**
  74433. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  74434. * @param minPoint defines the minimum vector of the bounding box
  74435. * @param maxPoint defines the maximum vector of the bounding box
  74436. * @param sphereCenter defines the sphere center
  74437. * @param sphereRadius defines the sphere radius
  74438. * @returns true if there is an intersection
  74439. */
  74440. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  74441. /**
  74442. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  74443. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74444. * @param frustumPlanes defines the frustum planes to test
  74445. * @return true if there is an inclusion
  74446. */
  74447. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74448. /**
  74449. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  74450. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  74451. * @param frustumPlanes defines the frustum planes to test
  74452. * @return true if there is an intersection
  74453. */
  74454. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74455. }
  74456. }
  74457. declare module BABYLON {
  74458. /** @hidden */
  74459. export class Collider {
  74460. /** Define if a collision was found */
  74461. collisionFound: boolean;
  74462. /**
  74463. * Define last intersection point in local space
  74464. */
  74465. intersectionPoint: Vector3;
  74466. /**
  74467. * Define last collided mesh
  74468. */
  74469. collidedMesh: Nullable<AbstractMesh>;
  74470. private _collisionPoint;
  74471. private _planeIntersectionPoint;
  74472. private _tempVector;
  74473. private _tempVector2;
  74474. private _tempVector3;
  74475. private _tempVector4;
  74476. private _edge;
  74477. private _baseToVertex;
  74478. private _destinationPoint;
  74479. private _slidePlaneNormal;
  74480. private _displacementVector;
  74481. /** @hidden */
  74482. _radius: Vector3;
  74483. /** @hidden */
  74484. _retry: number;
  74485. private _velocity;
  74486. private _basePoint;
  74487. private _epsilon;
  74488. /** @hidden */
  74489. _velocityWorldLength: number;
  74490. /** @hidden */
  74491. _basePointWorld: Vector3;
  74492. private _velocityWorld;
  74493. private _normalizedVelocity;
  74494. /** @hidden */
  74495. _initialVelocity: Vector3;
  74496. /** @hidden */
  74497. _initialPosition: Vector3;
  74498. private _nearestDistance;
  74499. private _collisionMask;
  74500. collisionMask: number;
  74501. /**
  74502. * Gets the plane normal used to compute the sliding response (in local space)
  74503. */
  74504. readonly slidePlaneNormal: Vector3;
  74505. /** @hidden */
  74506. _initialize(source: Vector3, dir: Vector3, e: number): void;
  74507. /** @hidden */
  74508. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  74509. /** @hidden */
  74510. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  74511. /** @hidden */
  74512. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74513. /** @hidden */
  74514. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  74515. /** @hidden */
  74516. _getResponse(pos: Vector3, vel: Vector3): void;
  74517. }
  74518. }
  74519. declare module BABYLON {
  74520. /**
  74521. * Interface for cullable objects
  74522. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  74523. */
  74524. export interface ICullable {
  74525. /**
  74526. * Checks if the object or part of the object is in the frustum
  74527. * @param frustumPlanes Camera near/planes
  74528. * @returns true if the object is in frustum otherwise false
  74529. */
  74530. isInFrustum(frustumPlanes: Plane[]): boolean;
  74531. /**
  74532. * Checks if a cullable object (mesh...) is in the camera frustum
  74533. * Unlike isInFrustum this cheks the full bounding box
  74534. * @param frustumPlanes Camera near/planes
  74535. * @returns true if the object is in frustum otherwise false
  74536. */
  74537. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  74538. }
  74539. /**
  74540. * Info for a bounding data of a mesh
  74541. */
  74542. export class BoundingInfo implements ICullable {
  74543. /**
  74544. * Bounding box for the mesh
  74545. */
  74546. readonly boundingBox: BoundingBox;
  74547. /**
  74548. * Bounding sphere for the mesh
  74549. */
  74550. readonly boundingSphere: BoundingSphere;
  74551. private _isLocked;
  74552. private static readonly TmpVector3;
  74553. /**
  74554. * Constructs bounding info
  74555. * @param minimum min vector of the bounding box/sphere
  74556. * @param maximum max vector of the bounding box/sphere
  74557. * @param worldMatrix defines the new world matrix
  74558. */
  74559. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  74560. /**
  74561. * Recreates the entire bounding info from scratch as if we call the constructor in place
  74562. * @param min defines the new minimum vector (in local space)
  74563. * @param max defines the new maximum vector (in local space)
  74564. * @param worldMatrix defines the new world matrix
  74565. */
  74566. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  74567. /**
  74568. * min vector of the bounding box/sphere
  74569. */
  74570. readonly minimum: Vector3;
  74571. /**
  74572. * max vector of the bounding box/sphere
  74573. */
  74574. readonly maximum: Vector3;
  74575. /**
  74576. * If the info is locked and won't be updated to avoid perf overhead
  74577. */
  74578. isLocked: boolean;
  74579. /**
  74580. * Updates the bounding sphere and box
  74581. * @param world world matrix to be used to update
  74582. */
  74583. update(world: DeepImmutable<Matrix>): void;
  74584. /**
  74585. * Recreate the bounding info to be centered around a specific point given a specific extend.
  74586. * @param center New center of the bounding info
  74587. * @param extend New extend of the bounding info
  74588. * @returns the current bounding info
  74589. */
  74590. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  74591. /**
  74592. * Scale the current bounding info by applying a scale factor
  74593. * @param factor defines the scale factor to apply
  74594. * @returns the current bounding info
  74595. */
  74596. scale(factor: number): BoundingInfo;
  74597. /**
  74598. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  74599. * @param frustumPlanes defines the frustum to test
  74600. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  74601. * @returns true if the bounding info is in the frustum planes
  74602. */
  74603. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  74604. /**
  74605. * Gets the world distance between the min and max points of the bounding box
  74606. */
  74607. readonly diagonalLength: number;
  74608. /**
  74609. * Checks if a cullable object (mesh...) is in the camera frustum
  74610. * Unlike isInFrustum this cheks the full bounding box
  74611. * @param frustumPlanes Camera near/planes
  74612. * @returns true if the object is in frustum otherwise false
  74613. */
  74614. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  74615. /** @hidden */
  74616. _checkCollision(collider: Collider): boolean;
  74617. /**
  74618. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  74619. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74620. * @param point the point to check intersection with
  74621. * @returns if the point intersects
  74622. */
  74623. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  74624. /**
  74625. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  74626. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  74627. * @param boundingInfo the bounding info to check intersection with
  74628. * @param precise if the intersection should be done using OBB
  74629. * @returns if the bounding info intersects
  74630. */
  74631. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  74632. }
  74633. }
  74634. declare module BABYLON {
  74635. /**
  74636. * Extracts minimum and maximum values from a list of indexed positions
  74637. * @param positions defines the positions to use
  74638. * @param indices defines the indices to the positions
  74639. * @param indexStart defines the start index
  74640. * @param indexCount defines the end index
  74641. * @param bias defines bias value to add to the result
  74642. * @return minimum and maximum values
  74643. */
  74644. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  74645. minimum: Vector3;
  74646. maximum: Vector3;
  74647. };
  74648. /**
  74649. * Extracts minimum and maximum values from a list of positions
  74650. * @param positions defines the positions to use
  74651. * @param start defines the start index in the positions array
  74652. * @param count defines the number of positions to handle
  74653. * @param bias defines bias value to add to the result
  74654. * @param stride defines the stride size to use (distance between two positions in the positions array)
  74655. * @return minimum and maximum values
  74656. */
  74657. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  74658. minimum: Vector3;
  74659. maximum: Vector3;
  74660. };
  74661. }
  74662. declare module BABYLON {
  74663. /** @hidden */
  74664. export class WebGLDataBuffer extends DataBuffer {
  74665. private _buffer;
  74666. constructor(resource: WebGLBuffer);
  74667. readonly underlyingResource: any;
  74668. }
  74669. }
  74670. declare module BABYLON {
  74671. /** @hidden */
  74672. export class WebGLPipelineContext implements IPipelineContext {
  74673. engine: ThinEngine;
  74674. program: Nullable<WebGLProgram>;
  74675. context?: WebGLRenderingContext;
  74676. vertexShader?: WebGLShader;
  74677. fragmentShader?: WebGLShader;
  74678. isParallelCompiled: boolean;
  74679. onCompiled?: () => void;
  74680. transformFeedback?: WebGLTransformFeedback | null;
  74681. readonly isAsync: boolean;
  74682. readonly isReady: boolean;
  74683. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  74684. }
  74685. }
  74686. declare module BABYLON {
  74687. interface ThinEngine {
  74688. /**
  74689. * Create an uniform buffer
  74690. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74691. * @param elements defines the content of the uniform buffer
  74692. * @returns the webGL uniform buffer
  74693. */
  74694. createUniformBuffer(elements: FloatArray): DataBuffer;
  74695. /**
  74696. * Create a dynamic uniform buffer
  74697. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74698. * @param elements defines the content of the uniform buffer
  74699. * @returns the webGL uniform buffer
  74700. */
  74701. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  74702. /**
  74703. * Update an existing uniform buffer
  74704. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  74705. * @param uniformBuffer defines the target uniform buffer
  74706. * @param elements defines the content to update
  74707. * @param offset defines the offset in the uniform buffer where update should start
  74708. * @param count defines the size of the data to update
  74709. */
  74710. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  74711. /**
  74712. * Bind an uniform buffer to the current webGL context
  74713. * @param buffer defines the buffer to bind
  74714. */
  74715. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  74716. /**
  74717. * Bind a buffer to the current webGL context at a given location
  74718. * @param buffer defines the buffer to bind
  74719. * @param location defines the index where to bind the buffer
  74720. */
  74721. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  74722. /**
  74723. * Bind a specific block at a given index in a specific shader program
  74724. * @param pipelineContext defines the pipeline context to use
  74725. * @param blockName defines the block name
  74726. * @param index defines the index where to bind the block
  74727. */
  74728. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  74729. }
  74730. }
  74731. declare module BABYLON {
  74732. /**
  74733. * Uniform buffer objects.
  74734. *
  74735. * Handles blocks of uniform on the GPU.
  74736. *
  74737. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74738. *
  74739. * For more information, please refer to :
  74740. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74741. */
  74742. export class UniformBuffer {
  74743. private _engine;
  74744. private _buffer;
  74745. private _data;
  74746. private _bufferData;
  74747. private _dynamic?;
  74748. private _uniformLocations;
  74749. private _uniformSizes;
  74750. private _uniformLocationPointer;
  74751. private _needSync;
  74752. private _noUBO;
  74753. private _currentEffect;
  74754. /** @hidden */
  74755. _alreadyBound: boolean;
  74756. private static _MAX_UNIFORM_SIZE;
  74757. private static _tempBuffer;
  74758. /**
  74759. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  74760. * This is dynamic to allow compat with webgl 1 and 2.
  74761. * You will need to pass the name of the uniform as well as the value.
  74762. */
  74763. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  74764. /**
  74765. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  74766. * This is dynamic to allow compat with webgl 1 and 2.
  74767. * You will need to pass the name of the uniform as well as the value.
  74768. */
  74769. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  74770. /**
  74771. * Lambda to Update a single float in a uniform buffer.
  74772. * This is dynamic to allow compat with webgl 1 and 2.
  74773. * You will need to pass the name of the uniform as well as the value.
  74774. */
  74775. updateFloat: (name: string, x: number) => void;
  74776. /**
  74777. * Lambda to Update a vec2 of float in a uniform buffer.
  74778. * This is dynamic to allow compat with webgl 1 and 2.
  74779. * You will need to pass the name of the uniform as well as the value.
  74780. */
  74781. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  74782. /**
  74783. * Lambda to Update a vec3 of float in a uniform buffer.
  74784. * This is dynamic to allow compat with webgl 1 and 2.
  74785. * You will need to pass the name of the uniform as well as the value.
  74786. */
  74787. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  74788. /**
  74789. * Lambda to Update a vec4 of float in a uniform buffer.
  74790. * This is dynamic to allow compat with webgl 1 and 2.
  74791. * You will need to pass the name of the uniform as well as the value.
  74792. */
  74793. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74794. /**
  74795. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74796. * This is dynamic to allow compat with webgl 1 and 2.
  74797. * You will need to pass the name of the uniform as well as the value.
  74798. */
  74799. updateMatrix: (name: string, mat: Matrix) => void;
  74800. /**
  74801. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74802. * This is dynamic to allow compat with webgl 1 and 2.
  74803. * You will need to pass the name of the uniform as well as the value.
  74804. */
  74805. updateVector3: (name: string, vector: Vector3) => void;
  74806. /**
  74807. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74808. * This is dynamic to allow compat with webgl 1 and 2.
  74809. * You will need to pass the name of the uniform as well as the value.
  74810. */
  74811. updateVector4: (name: string, vector: Vector4) => void;
  74812. /**
  74813. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74814. * This is dynamic to allow compat with webgl 1 and 2.
  74815. * You will need to pass the name of the uniform as well as the value.
  74816. */
  74817. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74818. /**
  74819. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74820. * This is dynamic to allow compat with webgl 1 and 2.
  74821. * You will need to pass the name of the uniform as well as the value.
  74822. */
  74823. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74824. /**
  74825. * Instantiates a new Uniform buffer objects.
  74826. *
  74827. * Handles blocks of uniform on the GPU.
  74828. *
  74829. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74830. *
  74831. * For more information, please refer to :
  74832. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74833. * @param engine Define the engine the buffer is associated with
  74834. * @param data Define the data contained in the buffer
  74835. * @param dynamic Define if the buffer is updatable
  74836. */
  74837. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74838. /**
  74839. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74840. * or just falling back on setUniformXXX calls.
  74841. */
  74842. readonly useUbo: boolean;
  74843. /**
  74844. * Indicates if the WebGL underlying uniform buffer is in sync
  74845. * with the javascript cache data.
  74846. */
  74847. readonly isSync: boolean;
  74848. /**
  74849. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74850. * Also, a dynamic UniformBuffer will disable cache verification and always
  74851. * update the underlying WebGL uniform buffer to the GPU.
  74852. * @returns if Dynamic, otherwise false
  74853. */
  74854. isDynamic(): boolean;
  74855. /**
  74856. * The data cache on JS side.
  74857. * @returns the underlying data as a float array
  74858. */
  74859. getData(): Float32Array;
  74860. /**
  74861. * The underlying WebGL Uniform buffer.
  74862. * @returns the webgl buffer
  74863. */
  74864. getBuffer(): Nullable<DataBuffer>;
  74865. /**
  74866. * std140 layout specifies how to align data within an UBO structure.
  74867. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74868. * for specs.
  74869. */
  74870. private _fillAlignment;
  74871. /**
  74872. * Adds an uniform in the buffer.
  74873. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74874. * for the layout to be correct !
  74875. * @param name Name of the uniform, as used in the uniform block in the shader.
  74876. * @param size Data size, or data directly.
  74877. */
  74878. addUniform(name: string, size: number | number[]): void;
  74879. /**
  74880. * Adds a Matrix 4x4 to the uniform buffer.
  74881. * @param name Name of the uniform, as used in the uniform block in the shader.
  74882. * @param mat A 4x4 matrix.
  74883. */
  74884. addMatrix(name: string, mat: Matrix): void;
  74885. /**
  74886. * Adds a vec2 to the uniform buffer.
  74887. * @param name Name of the uniform, as used in the uniform block in the shader.
  74888. * @param x Define the x component value of the vec2
  74889. * @param y Define the y component value of the vec2
  74890. */
  74891. addFloat2(name: string, x: number, y: number): void;
  74892. /**
  74893. * Adds a vec3 to the uniform buffer.
  74894. * @param name Name of the uniform, as used in the uniform block in the shader.
  74895. * @param x Define the x component value of the vec3
  74896. * @param y Define the y component value of the vec3
  74897. * @param z Define the z component value of the vec3
  74898. */
  74899. addFloat3(name: string, x: number, y: number, z: number): void;
  74900. /**
  74901. * Adds a vec3 to the uniform buffer.
  74902. * @param name Name of the uniform, as used in the uniform block in the shader.
  74903. * @param color Define the vec3 from a Color
  74904. */
  74905. addColor3(name: string, color: Color3): void;
  74906. /**
  74907. * Adds a vec4 to the uniform buffer.
  74908. * @param name Name of the uniform, as used in the uniform block in the shader.
  74909. * @param color Define the rgb components from a Color
  74910. * @param alpha Define the a component of the vec4
  74911. */
  74912. addColor4(name: string, color: Color3, alpha: number): void;
  74913. /**
  74914. * Adds a vec3 to the uniform buffer.
  74915. * @param name Name of the uniform, as used in the uniform block in the shader.
  74916. * @param vector Define the vec3 components from a Vector
  74917. */
  74918. addVector3(name: string, vector: Vector3): void;
  74919. /**
  74920. * Adds a Matrix 3x3 to the uniform buffer.
  74921. * @param name Name of the uniform, as used in the uniform block in the shader.
  74922. */
  74923. addMatrix3x3(name: string): void;
  74924. /**
  74925. * Adds a Matrix 2x2 to the uniform buffer.
  74926. * @param name Name of the uniform, as used in the uniform block in the shader.
  74927. */
  74928. addMatrix2x2(name: string): void;
  74929. /**
  74930. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74931. */
  74932. create(): void;
  74933. /** @hidden */
  74934. _rebuild(): void;
  74935. /**
  74936. * Updates the WebGL Uniform Buffer on the GPU.
  74937. * If the `dynamic` flag is set to true, no cache comparison is done.
  74938. * Otherwise, the buffer will be updated only if the cache differs.
  74939. */
  74940. update(): void;
  74941. /**
  74942. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74943. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74944. * @param data Define the flattened data
  74945. * @param size Define the size of the data.
  74946. */
  74947. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74948. private _valueCache;
  74949. private _cacheMatrix;
  74950. private _updateMatrix3x3ForUniform;
  74951. private _updateMatrix3x3ForEffect;
  74952. private _updateMatrix2x2ForEffect;
  74953. private _updateMatrix2x2ForUniform;
  74954. private _updateFloatForEffect;
  74955. private _updateFloatForUniform;
  74956. private _updateFloat2ForEffect;
  74957. private _updateFloat2ForUniform;
  74958. private _updateFloat3ForEffect;
  74959. private _updateFloat3ForUniform;
  74960. private _updateFloat4ForEffect;
  74961. private _updateFloat4ForUniform;
  74962. private _updateMatrixForEffect;
  74963. private _updateMatrixForUniform;
  74964. private _updateVector3ForEffect;
  74965. private _updateVector3ForUniform;
  74966. private _updateVector4ForEffect;
  74967. private _updateVector4ForUniform;
  74968. private _updateColor3ForEffect;
  74969. private _updateColor3ForUniform;
  74970. private _updateColor4ForEffect;
  74971. private _updateColor4ForUniform;
  74972. /**
  74973. * Sets a sampler uniform on the effect.
  74974. * @param name Define the name of the sampler.
  74975. * @param texture Define the texture to set in the sampler
  74976. */
  74977. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74978. /**
  74979. * Directly updates the value of the uniform in the cache AND on the GPU.
  74980. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74981. * @param data Define the flattened data
  74982. */
  74983. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74984. /**
  74985. * Binds this uniform buffer to an effect.
  74986. * @param effect Define the effect to bind the buffer to
  74987. * @param name Name of the uniform block in the shader.
  74988. */
  74989. bindToEffect(effect: Effect, name: string): void;
  74990. /**
  74991. * Disposes the uniform buffer.
  74992. */
  74993. dispose(): void;
  74994. }
  74995. }
  74996. declare module BABYLON {
  74997. /**
  74998. * Enum that determines the text-wrapping mode to use.
  74999. */
  75000. export enum InspectableType {
  75001. /**
  75002. * Checkbox for booleans
  75003. */
  75004. Checkbox = 0,
  75005. /**
  75006. * Sliders for numbers
  75007. */
  75008. Slider = 1,
  75009. /**
  75010. * Vector3
  75011. */
  75012. Vector3 = 2,
  75013. /**
  75014. * Quaternions
  75015. */
  75016. Quaternion = 3,
  75017. /**
  75018. * Color3
  75019. */
  75020. Color3 = 4,
  75021. /**
  75022. * String
  75023. */
  75024. String = 5
  75025. }
  75026. /**
  75027. * Interface used to define custom inspectable properties.
  75028. * This interface is used by the inspector to display custom property grids
  75029. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75030. */
  75031. export interface IInspectable {
  75032. /**
  75033. * Gets the label to display
  75034. */
  75035. label: string;
  75036. /**
  75037. * Gets the name of the property to edit
  75038. */
  75039. propertyName: string;
  75040. /**
  75041. * Gets the type of the editor to use
  75042. */
  75043. type: InspectableType;
  75044. /**
  75045. * Gets the minimum value of the property when using in "slider" mode
  75046. */
  75047. min?: number;
  75048. /**
  75049. * Gets the maximum value of the property when using in "slider" mode
  75050. */
  75051. max?: number;
  75052. /**
  75053. * Gets the setp to use when using in "slider" mode
  75054. */
  75055. step?: number;
  75056. }
  75057. }
  75058. declare module BABYLON {
  75059. /**
  75060. * Class used to provide helper for timing
  75061. */
  75062. export class TimingTools {
  75063. /**
  75064. * Polyfill for setImmediate
  75065. * @param action defines the action to execute after the current execution block
  75066. */
  75067. static SetImmediate(action: () => void): void;
  75068. }
  75069. }
  75070. declare module BABYLON {
  75071. /**
  75072. * Class used to enable instatition of objects by class name
  75073. */
  75074. export class InstantiationTools {
  75075. /**
  75076. * Use this object to register external classes like custom textures or material
  75077. * to allow the laoders to instantiate them
  75078. */
  75079. static RegisteredExternalClasses: {
  75080. [key: string]: Object;
  75081. };
  75082. /**
  75083. * Tries to instantiate a new object from a given class name
  75084. * @param className defines the class name to instantiate
  75085. * @returns the new object or null if the system was not able to do the instantiation
  75086. */
  75087. static Instantiate(className: string): any;
  75088. }
  75089. }
  75090. declare module BABYLON {
  75091. /**
  75092. * Define options used to create a depth texture
  75093. */
  75094. export class DepthTextureCreationOptions {
  75095. /** Specifies whether or not a stencil should be allocated in the texture */
  75096. generateStencil?: boolean;
  75097. /** Specifies whether or not bilinear filtering is enable on the texture */
  75098. bilinearFiltering?: boolean;
  75099. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75100. comparisonFunction?: number;
  75101. /** Specifies if the created texture is a cube texture */
  75102. isCube?: boolean;
  75103. }
  75104. }
  75105. declare module BABYLON {
  75106. interface ThinEngine {
  75107. /**
  75108. * Creates a depth stencil cube texture.
  75109. * This is only available in WebGL 2.
  75110. * @param size The size of face edge in the cube texture.
  75111. * @param options The options defining the cube texture.
  75112. * @returns The cube texture
  75113. */
  75114. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75115. /**
  75116. * Creates a cube texture
  75117. * @param rootUrl defines the url where the files to load is located
  75118. * @param scene defines the current scene
  75119. * @param files defines the list of files to load (1 per face)
  75120. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75121. * @param onLoad defines an optional callback raised when the texture is loaded
  75122. * @param onError defines an optional callback raised if there is an issue to load the texture
  75123. * @param format defines the format of the data
  75124. * @param forcedExtension defines the extension to use to pick the right loader
  75125. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75126. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75127. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75128. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75129. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75130. * @returns the cube texture as an InternalTexture
  75131. */
  75132. 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;
  75133. /**
  75134. * Creates a cube texture
  75135. * @param rootUrl defines the url where the files to load is located
  75136. * @param scene defines the current scene
  75137. * @param files defines the list of files to load (1 per face)
  75138. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75139. * @param onLoad defines an optional callback raised when the texture is loaded
  75140. * @param onError defines an optional callback raised if there is an issue to load the texture
  75141. * @param format defines the format of the data
  75142. * @param forcedExtension defines the extension to use to pick the right loader
  75143. * @returns the cube texture as an InternalTexture
  75144. */
  75145. 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;
  75146. /**
  75147. * Creates a cube texture
  75148. * @param rootUrl defines the url where the files to load is located
  75149. * @param scene defines the current scene
  75150. * @param files defines the list of files to load (1 per face)
  75151. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75152. * @param onLoad defines an optional callback raised when the texture is loaded
  75153. * @param onError defines an optional callback raised if there is an issue to load the texture
  75154. * @param format defines the format of the data
  75155. * @param forcedExtension defines the extension to use to pick the right loader
  75156. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75157. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75158. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75159. * @returns the cube texture as an InternalTexture
  75160. */
  75161. 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;
  75162. /** @hidden */
  75163. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75164. /** @hidden */
  75165. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75166. /** @hidden */
  75167. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75168. /** @hidden */
  75169. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  75170. /**
  75171. * @hidden
  75172. */
  75173. _setCubeMapTextureParams(loadMipmap: boolean): void;
  75174. }
  75175. }
  75176. declare module BABYLON {
  75177. /**
  75178. * Class for creating a cube texture
  75179. */
  75180. export class CubeTexture extends BaseTexture {
  75181. private _delayedOnLoad;
  75182. /**
  75183. * The url of the texture
  75184. */
  75185. url: string;
  75186. /**
  75187. * Gets or sets the center of the bounding box associated with the cube texture.
  75188. * It must define where the camera used to render the texture was set
  75189. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75190. */
  75191. boundingBoxPosition: Vector3;
  75192. private _boundingBoxSize;
  75193. /**
  75194. * Gets or sets the size of the bounding box associated with the cube texture
  75195. * When defined, the cubemap will switch to local mode
  75196. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75197. * @example https://www.babylonjs-playground.com/#RNASML
  75198. */
  75199. /**
  75200. * Returns the bounding box size
  75201. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  75202. */
  75203. boundingBoxSize: Vector3;
  75204. protected _rotationY: number;
  75205. /**
  75206. * Sets texture matrix rotation angle around Y axis in radians.
  75207. */
  75208. /**
  75209. * Gets texture matrix rotation angle around Y axis radians.
  75210. */
  75211. rotationY: number;
  75212. /**
  75213. * Are mip maps generated for this texture or not.
  75214. */
  75215. readonly noMipmap: boolean;
  75216. private _noMipmap;
  75217. private _files;
  75218. protected _forcedExtension: Nullable<string>;
  75219. private _extensions;
  75220. private _textureMatrix;
  75221. private _format;
  75222. private _createPolynomials;
  75223. /** @hidden */
  75224. _prefiltered: boolean;
  75225. /**
  75226. * Creates a cube texture from an array of image urls
  75227. * @param files defines an array of image urls
  75228. * @param scene defines the hosting scene
  75229. * @param noMipmap specifies if mip maps are not used
  75230. * @returns a cube texture
  75231. */
  75232. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  75233. /**
  75234. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  75235. * @param url defines the url of the prefiltered texture
  75236. * @param scene defines the scene the texture is attached to
  75237. * @param forcedExtension defines the extension of the file if different from the url
  75238. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75239. * @return the prefiltered texture
  75240. */
  75241. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  75242. /**
  75243. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  75244. * as prefiltered data.
  75245. * @param rootUrl defines the url of the texture or the root name of the six images
  75246. * @param scene defines the scene the texture is attached to
  75247. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  75248. * @param noMipmap defines if mipmaps should be created or not
  75249. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  75250. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  75251. * @param onError defines a callback triggered in case of error during load
  75252. * @param format defines the internal format to use for the texture once loaded
  75253. * @param prefiltered defines whether or not the texture is created from prefiltered data
  75254. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  75255. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  75256. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75257. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75258. * @return the cube texture
  75259. */
  75260. 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);
  75261. /**
  75262. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  75263. */
  75264. readonly isPrefiltered: boolean;
  75265. /**
  75266. * Get the current class name of the texture useful for serialization or dynamic coding.
  75267. * @returns "CubeTexture"
  75268. */
  75269. getClassName(): string;
  75270. /**
  75271. * Update the url (and optional buffer) of this texture if url was null during construction.
  75272. * @param url the url of the texture
  75273. * @param forcedExtension defines the extension to use
  75274. * @param onLoad callback called when the texture is loaded (defaults to null)
  75275. */
  75276. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  75277. /**
  75278. * Delays loading of the cube texture
  75279. * @param forcedExtension defines the extension to use
  75280. */
  75281. delayLoad(forcedExtension?: string): void;
  75282. /**
  75283. * Returns the reflection texture matrix
  75284. * @returns the reflection texture matrix
  75285. */
  75286. getReflectionTextureMatrix(): Matrix;
  75287. /**
  75288. * Sets the reflection texture matrix
  75289. * @param value Reflection texture matrix
  75290. */
  75291. setReflectionTextureMatrix(value: Matrix): void;
  75292. /**
  75293. * Parses text to create a cube texture
  75294. * @param parsedTexture define the serialized text to read from
  75295. * @param scene defines the hosting scene
  75296. * @param rootUrl defines the root url of the cube texture
  75297. * @returns a cube texture
  75298. */
  75299. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  75300. /**
  75301. * Makes a clone, or deep copy, of the cube texture
  75302. * @returns a new cube texture
  75303. */
  75304. clone(): CubeTexture;
  75305. }
  75306. }
  75307. declare module BABYLON {
  75308. /**
  75309. * Manages the defines for the Material
  75310. */
  75311. export class MaterialDefines {
  75312. /** @hidden */
  75313. protected _keys: string[];
  75314. private _isDirty;
  75315. /** @hidden */
  75316. _renderId: number;
  75317. /** @hidden */
  75318. _areLightsDirty: boolean;
  75319. /** @hidden */
  75320. _areLightsDisposed: boolean;
  75321. /** @hidden */
  75322. _areAttributesDirty: boolean;
  75323. /** @hidden */
  75324. _areTexturesDirty: boolean;
  75325. /** @hidden */
  75326. _areFresnelDirty: boolean;
  75327. /** @hidden */
  75328. _areMiscDirty: boolean;
  75329. /** @hidden */
  75330. _areImageProcessingDirty: boolean;
  75331. /** @hidden */
  75332. _normals: boolean;
  75333. /** @hidden */
  75334. _uvs: boolean;
  75335. /** @hidden */
  75336. _needNormals: boolean;
  75337. /** @hidden */
  75338. _needUVs: boolean;
  75339. [id: string]: any;
  75340. /**
  75341. * Specifies if the material needs to be re-calculated
  75342. */
  75343. readonly isDirty: boolean;
  75344. /**
  75345. * Marks the material to indicate that it has been re-calculated
  75346. */
  75347. markAsProcessed(): void;
  75348. /**
  75349. * Marks the material to indicate that it needs to be re-calculated
  75350. */
  75351. markAsUnprocessed(): void;
  75352. /**
  75353. * Marks the material to indicate all of its defines need to be re-calculated
  75354. */
  75355. markAllAsDirty(): void;
  75356. /**
  75357. * Marks the material to indicate that image processing needs to be re-calculated
  75358. */
  75359. markAsImageProcessingDirty(): void;
  75360. /**
  75361. * Marks the material to indicate the lights need to be re-calculated
  75362. * @param disposed Defines whether the light is dirty due to dispose or not
  75363. */
  75364. markAsLightDirty(disposed?: boolean): void;
  75365. /**
  75366. * Marks the attribute state as changed
  75367. */
  75368. markAsAttributesDirty(): void;
  75369. /**
  75370. * Marks the texture state as changed
  75371. */
  75372. markAsTexturesDirty(): void;
  75373. /**
  75374. * Marks the fresnel state as changed
  75375. */
  75376. markAsFresnelDirty(): void;
  75377. /**
  75378. * Marks the misc state as changed
  75379. */
  75380. markAsMiscDirty(): void;
  75381. /**
  75382. * Rebuilds the material defines
  75383. */
  75384. rebuild(): void;
  75385. /**
  75386. * Specifies if two material defines are equal
  75387. * @param other - A material define instance to compare to
  75388. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  75389. */
  75390. isEqual(other: MaterialDefines): boolean;
  75391. /**
  75392. * Clones this instance's defines to another instance
  75393. * @param other - material defines to clone values to
  75394. */
  75395. cloneTo(other: MaterialDefines): void;
  75396. /**
  75397. * Resets the material define values
  75398. */
  75399. reset(): void;
  75400. /**
  75401. * Converts the material define values to a string
  75402. * @returns - String of material define information
  75403. */
  75404. toString(): string;
  75405. }
  75406. }
  75407. declare module BABYLON {
  75408. /**
  75409. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  75410. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  75411. * 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;
  75412. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  75413. */
  75414. export class ColorCurves {
  75415. private _dirty;
  75416. private _tempColor;
  75417. private _globalCurve;
  75418. private _highlightsCurve;
  75419. private _midtonesCurve;
  75420. private _shadowsCurve;
  75421. private _positiveCurve;
  75422. private _negativeCurve;
  75423. private _globalHue;
  75424. private _globalDensity;
  75425. private _globalSaturation;
  75426. private _globalExposure;
  75427. /**
  75428. * Gets the global Hue value.
  75429. * 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).
  75430. */
  75431. /**
  75432. * Sets the global Hue value.
  75433. * 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).
  75434. */
  75435. globalHue: number;
  75436. /**
  75437. * Gets the global Density value.
  75438. * 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.
  75439. * Values less than zero provide a filter of opposite hue.
  75440. */
  75441. /**
  75442. * Sets the global Density value.
  75443. * 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.
  75444. * Values less than zero provide a filter of opposite hue.
  75445. */
  75446. globalDensity: number;
  75447. /**
  75448. * Gets the global Saturation value.
  75449. * 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.
  75450. */
  75451. /**
  75452. * Sets the global Saturation value.
  75453. * 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.
  75454. */
  75455. globalSaturation: number;
  75456. /**
  75457. * Gets the global Exposure value.
  75458. * 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.
  75459. */
  75460. /**
  75461. * Sets the global Exposure value.
  75462. * 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.
  75463. */
  75464. globalExposure: number;
  75465. private _highlightsHue;
  75466. private _highlightsDensity;
  75467. private _highlightsSaturation;
  75468. private _highlightsExposure;
  75469. /**
  75470. * Gets the highlights Hue value.
  75471. * 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).
  75472. */
  75473. /**
  75474. * Sets the highlights Hue value.
  75475. * 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).
  75476. */
  75477. highlightsHue: number;
  75478. /**
  75479. * Gets the highlights Density value.
  75480. * 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.
  75481. * Values less than zero provide a filter of opposite hue.
  75482. */
  75483. /**
  75484. * Sets the highlights Density value.
  75485. * 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.
  75486. * Values less than zero provide a filter of opposite hue.
  75487. */
  75488. highlightsDensity: number;
  75489. /**
  75490. * Gets the highlights Saturation value.
  75491. * 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.
  75492. */
  75493. /**
  75494. * Sets the highlights Saturation value.
  75495. * 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.
  75496. */
  75497. highlightsSaturation: number;
  75498. /**
  75499. * Gets the highlights Exposure value.
  75500. * 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.
  75501. */
  75502. /**
  75503. * Sets the highlights Exposure value.
  75504. * 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.
  75505. */
  75506. highlightsExposure: number;
  75507. private _midtonesHue;
  75508. private _midtonesDensity;
  75509. private _midtonesSaturation;
  75510. private _midtonesExposure;
  75511. /**
  75512. * Gets the midtones Hue value.
  75513. * 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).
  75514. */
  75515. /**
  75516. * Sets the midtones Hue value.
  75517. * 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).
  75518. */
  75519. midtonesHue: number;
  75520. /**
  75521. * Gets the midtones Density value.
  75522. * 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.
  75523. * Values less than zero provide a filter of opposite hue.
  75524. */
  75525. /**
  75526. * Sets the midtones Density value.
  75527. * 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.
  75528. * Values less than zero provide a filter of opposite hue.
  75529. */
  75530. midtonesDensity: number;
  75531. /**
  75532. * Gets the midtones Saturation value.
  75533. * 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.
  75534. */
  75535. /**
  75536. * Sets the midtones Saturation value.
  75537. * 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.
  75538. */
  75539. midtonesSaturation: number;
  75540. /**
  75541. * Gets the midtones Exposure value.
  75542. * 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.
  75543. */
  75544. /**
  75545. * Sets the midtones Exposure value.
  75546. * 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.
  75547. */
  75548. midtonesExposure: number;
  75549. private _shadowsHue;
  75550. private _shadowsDensity;
  75551. private _shadowsSaturation;
  75552. private _shadowsExposure;
  75553. /**
  75554. * Gets the shadows Hue value.
  75555. * 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).
  75556. */
  75557. /**
  75558. * Sets the shadows Hue value.
  75559. * 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).
  75560. */
  75561. shadowsHue: number;
  75562. /**
  75563. * Gets the shadows Density value.
  75564. * 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.
  75565. * Values less than zero provide a filter of opposite hue.
  75566. */
  75567. /**
  75568. * Sets the shadows Density value.
  75569. * 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.
  75570. * Values less than zero provide a filter of opposite hue.
  75571. */
  75572. shadowsDensity: number;
  75573. /**
  75574. * Gets the shadows Saturation value.
  75575. * 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.
  75576. */
  75577. /**
  75578. * Sets the shadows Saturation value.
  75579. * 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.
  75580. */
  75581. shadowsSaturation: number;
  75582. /**
  75583. * Gets the shadows Exposure value.
  75584. * 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.
  75585. */
  75586. /**
  75587. * Sets the shadows Exposure value.
  75588. * 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.
  75589. */
  75590. shadowsExposure: number;
  75591. /**
  75592. * Returns the class name
  75593. * @returns The class name
  75594. */
  75595. getClassName(): string;
  75596. /**
  75597. * Binds the color curves to the shader.
  75598. * @param colorCurves The color curve to bind
  75599. * @param effect The effect to bind to
  75600. * @param positiveUniform The positive uniform shader parameter
  75601. * @param neutralUniform The neutral uniform shader parameter
  75602. * @param negativeUniform The negative uniform shader parameter
  75603. */
  75604. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  75605. /**
  75606. * Prepare the list of uniforms associated with the ColorCurves effects.
  75607. * @param uniformsList The list of uniforms used in the effect
  75608. */
  75609. static PrepareUniforms(uniformsList: string[]): void;
  75610. /**
  75611. * Returns color grading data based on a hue, density, saturation and exposure value.
  75612. * @param filterHue The hue of the color filter.
  75613. * @param filterDensity The density of the color filter.
  75614. * @param saturation The saturation.
  75615. * @param exposure The exposure.
  75616. * @param result The result data container.
  75617. */
  75618. private getColorGradingDataToRef;
  75619. /**
  75620. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  75621. * @param value The input slider value in range [-100,100].
  75622. * @returns Adjusted value.
  75623. */
  75624. private static applyColorGradingSliderNonlinear;
  75625. /**
  75626. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  75627. * @param hue The hue (H) input.
  75628. * @param saturation The saturation (S) input.
  75629. * @param brightness The brightness (B) input.
  75630. * @result An RGBA color represented as Vector4.
  75631. */
  75632. private static fromHSBToRef;
  75633. /**
  75634. * Returns a value clamped between min and max
  75635. * @param value The value to clamp
  75636. * @param min The minimum of value
  75637. * @param max The maximum of value
  75638. * @returns The clamped value.
  75639. */
  75640. private static clamp;
  75641. /**
  75642. * Clones the current color curve instance.
  75643. * @return The cloned curves
  75644. */
  75645. clone(): ColorCurves;
  75646. /**
  75647. * Serializes the current color curve instance to a json representation.
  75648. * @return a JSON representation
  75649. */
  75650. serialize(): any;
  75651. /**
  75652. * Parses the color curve from a json representation.
  75653. * @param source the JSON source to parse
  75654. * @return The parsed curves
  75655. */
  75656. static Parse(source: any): ColorCurves;
  75657. }
  75658. }
  75659. declare module BABYLON {
  75660. /**
  75661. * Interface to follow in your material defines to integrate easily the
  75662. * Image proccessing functions.
  75663. * @hidden
  75664. */
  75665. export interface IImageProcessingConfigurationDefines {
  75666. IMAGEPROCESSING: boolean;
  75667. VIGNETTE: boolean;
  75668. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75669. VIGNETTEBLENDMODEOPAQUE: boolean;
  75670. TONEMAPPING: boolean;
  75671. TONEMAPPING_ACES: boolean;
  75672. CONTRAST: boolean;
  75673. EXPOSURE: boolean;
  75674. COLORCURVES: boolean;
  75675. COLORGRADING: boolean;
  75676. COLORGRADING3D: boolean;
  75677. SAMPLER3DGREENDEPTH: boolean;
  75678. SAMPLER3DBGRMAP: boolean;
  75679. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75680. }
  75681. /**
  75682. * @hidden
  75683. */
  75684. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  75685. IMAGEPROCESSING: boolean;
  75686. VIGNETTE: boolean;
  75687. VIGNETTEBLENDMODEMULTIPLY: boolean;
  75688. VIGNETTEBLENDMODEOPAQUE: boolean;
  75689. TONEMAPPING: boolean;
  75690. TONEMAPPING_ACES: boolean;
  75691. CONTRAST: boolean;
  75692. COLORCURVES: boolean;
  75693. COLORGRADING: boolean;
  75694. COLORGRADING3D: boolean;
  75695. SAMPLER3DGREENDEPTH: boolean;
  75696. SAMPLER3DBGRMAP: boolean;
  75697. IMAGEPROCESSINGPOSTPROCESS: boolean;
  75698. EXPOSURE: boolean;
  75699. constructor();
  75700. }
  75701. /**
  75702. * This groups together the common properties used for image processing either in direct forward pass
  75703. * or through post processing effect depending on the use of the image processing pipeline in your scene
  75704. * or not.
  75705. */
  75706. export class ImageProcessingConfiguration {
  75707. /**
  75708. * Default tone mapping applied in BabylonJS.
  75709. */
  75710. static readonly TONEMAPPING_STANDARD: number;
  75711. /**
  75712. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  75713. * to other engines rendering to increase portability.
  75714. */
  75715. static readonly TONEMAPPING_ACES: number;
  75716. /**
  75717. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  75718. */
  75719. colorCurves: Nullable<ColorCurves>;
  75720. private _colorCurvesEnabled;
  75721. /**
  75722. * Gets wether the color curves effect is enabled.
  75723. */
  75724. /**
  75725. * Sets wether the color curves effect is enabled.
  75726. */
  75727. colorCurvesEnabled: boolean;
  75728. private _colorGradingTexture;
  75729. /**
  75730. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75731. */
  75732. /**
  75733. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  75734. */
  75735. colorGradingTexture: Nullable<BaseTexture>;
  75736. private _colorGradingEnabled;
  75737. /**
  75738. * Gets wether the color grading effect is enabled.
  75739. */
  75740. /**
  75741. * Sets wether the color grading effect is enabled.
  75742. */
  75743. colorGradingEnabled: boolean;
  75744. private _colorGradingWithGreenDepth;
  75745. /**
  75746. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  75747. */
  75748. /**
  75749. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  75750. */
  75751. colorGradingWithGreenDepth: boolean;
  75752. private _colorGradingBGR;
  75753. /**
  75754. * Gets wether the color grading texture contains BGR values.
  75755. */
  75756. /**
  75757. * Sets wether the color grading texture contains BGR values.
  75758. */
  75759. colorGradingBGR: boolean;
  75760. /** @hidden */
  75761. _exposure: number;
  75762. /**
  75763. * Gets the Exposure used in the effect.
  75764. */
  75765. /**
  75766. * Sets the Exposure used in the effect.
  75767. */
  75768. exposure: number;
  75769. private _toneMappingEnabled;
  75770. /**
  75771. * Gets wether the tone mapping effect is enabled.
  75772. */
  75773. /**
  75774. * Sets wether the tone mapping effect is enabled.
  75775. */
  75776. toneMappingEnabled: boolean;
  75777. private _toneMappingType;
  75778. /**
  75779. * Gets the type of tone mapping effect.
  75780. */
  75781. /**
  75782. * Sets the type of tone mapping effect used in BabylonJS.
  75783. */
  75784. toneMappingType: number;
  75785. protected _contrast: number;
  75786. /**
  75787. * Gets the contrast used in the effect.
  75788. */
  75789. /**
  75790. * Sets the contrast used in the effect.
  75791. */
  75792. contrast: number;
  75793. /**
  75794. * Vignette stretch size.
  75795. */
  75796. vignetteStretch: number;
  75797. /**
  75798. * Vignette centre X Offset.
  75799. */
  75800. vignetteCentreX: number;
  75801. /**
  75802. * Vignette centre Y Offset.
  75803. */
  75804. vignetteCentreY: number;
  75805. /**
  75806. * Vignette weight or intensity of the vignette effect.
  75807. */
  75808. vignetteWeight: number;
  75809. /**
  75810. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75811. * if vignetteEnabled is set to true.
  75812. */
  75813. vignetteColor: Color4;
  75814. /**
  75815. * Camera field of view used by the Vignette effect.
  75816. */
  75817. vignetteCameraFov: number;
  75818. private _vignetteBlendMode;
  75819. /**
  75820. * Gets the vignette blend mode allowing different kind of effect.
  75821. */
  75822. /**
  75823. * Sets the vignette blend mode allowing different kind of effect.
  75824. */
  75825. vignetteBlendMode: number;
  75826. private _vignetteEnabled;
  75827. /**
  75828. * Gets wether the vignette effect is enabled.
  75829. */
  75830. /**
  75831. * Sets wether the vignette effect is enabled.
  75832. */
  75833. vignetteEnabled: boolean;
  75834. private _applyByPostProcess;
  75835. /**
  75836. * Gets wether the image processing is applied through a post process or not.
  75837. */
  75838. /**
  75839. * Sets wether the image processing is applied through a post process or not.
  75840. */
  75841. applyByPostProcess: boolean;
  75842. private _isEnabled;
  75843. /**
  75844. * Gets wether the image processing is enabled or not.
  75845. */
  75846. /**
  75847. * Sets wether the image processing is enabled or not.
  75848. */
  75849. isEnabled: boolean;
  75850. /**
  75851. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75852. */
  75853. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75854. /**
  75855. * Method called each time the image processing information changes requires to recompile the effect.
  75856. */
  75857. protected _updateParameters(): void;
  75858. /**
  75859. * Gets the current class name.
  75860. * @return "ImageProcessingConfiguration"
  75861. */
  75862. getClassName(): string;
  75863. /**
  75864. * Prepare the list of uniforms associated with the Image Processing effects.
  75865. * @param uniforms The list of uniforms used in the effect
  75866. * @param defines the list of defines currently in use
  75867. */
  75868. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75869. /**
  75870. * Prepare the list of samplers associated with the Image Processing effects.
  75871. * @param samplersList The list of uniforms used in the effect
  75872. * @param defines the list of defines currently in use
  75873. */
  75874. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75875. /**
  75876. * Prepare the list of defines associated to the shader.
  75877. * @param defines the list of defines to complete
  75878. * @param forPostProcess Define if we are currently in post process mode or not
  75879. */
  75880. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75881. /**
  75882. * Returns true if all the image processing information are ready.
  75883. * @returns True if ready, otherwise, false
  75884. */
  75885. isReady(): boolean;
  75886. /**
  75887. * Binds the image processing to the shader.
  75888. * @param effect The effect to bind to
  75889. * @param overrideAspectRatio Override the aspect ratio of the effect
  75890. */
  75891. bind(effect: Effect, overrideAspectRatio?: number): void;
  75892. /**
  75893. * Clones the current image processing instance.
  75894. * @return The cloned image processing
  75895. */
  75896. clone(): ImageProcessingConfiguration;
  75897. /**
  75898. * Serializes the current image processing instance to a json representation.
  75899. * @return a JSON representation
  75900. */
  75901. serialize(): any;
  75902. /**
  75903. * Parses the image processing from a json representation.
  75904. * @param source the JSON source to parse
  75905. * @return The parsed image processing
  75906. */
  75907. static Parse(source: any): ImageProcessingConfiguration;
  75908. private static _VIGNETTEMODE_MULTIPLY;
  75909. private static _VIGNETTEMODE_OPAQUE;
  75910. /**
  75911. * Used to apply the vignette as a mix with the pixel color.
  75912. */
  75913. static readonly VIGNETTEMODE_MULTIPLY: number;
  75914. /**
  75915. * Used to apply the vignette as a replacement of the pixel color.
  75916. */
  75917. static readonly VIGNETTEMODE_OPAQUE: number;
  75918. }
  75919. }
  75920. declare module BABYLON {
  75921. /** @hidden */
  75922. export var postprocessVertexShader: {
  75923. name: string;
  75924. shader: string;
  75925. };
  75926. }
  75927. declare module BABYLON {
  75928. interface ThinEngine {
  75929. /**
  75930. * Creates a new render target texture
  75931. * @param size defines the size of the texture
  75932. * @param options defines the options used to create the texture
  75933. * @returns a new render target texture stored in an InternalTexture
  75934. */
  75935. createRenderTargetTexture(size: number | {
  75936. width: number;
  75937. height: number;
  75938. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75939. /**
  75940. * Creates a depth stencil texture.
  75941. * This is only available in WebGL 2 or with the depth texture extension available.
  75942. * @param size The size of face edge in the texture.
  75943. * @param options The options defining the texture.
  75944. * @returns The texture
  75945. */
  75946. createDepthStencilTexture(size: number | {
  75947. width: number;
  75948. height: number;
  75949. }, options: DepthTextureCreationOptions): InternalTexture;
  75950. /** @hidden */
  75951. _createDepthStencilTexture(size: number | {
  75952. width: number;
  75953. height: number;
  75954. }, options: DepthTextureCreationOptions): InternalTexture;
  75955. }
  75956. }
  75957. declare module BABYLON {
  75958. /** Defines supported spaces */
  75959. export enum Space {
  75960. /** Local (object) space */
  75961. LOCAL = 0,
  75962. /** World space */
  75963. WORLD = 1,
  75964. /** Bone space */
  75965. BONE = 2
  75966. }
  75967. /** Defines the 3 main axes */
  75968. export class Axis {
  75969. /** X axis */
  75970. static X: Vector3;
  75971. /** Y axis */
  75972. static Y: Vector3;
  75973. /** Z axis */
  75974. static Z: Vector3;
  75975. }
  75976. }
  75977. declare module BABYLON {
  75978. /**
  75979. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75980. * This is the base of the follow, arc rotate cameras and Free camera
  75981. * @see http://doc.babylonjs.com/features/cameras
  75982. */
  75983. export class TargetCamera extends Camera {
  75984. private static _RigCamTransformMatrix;
  75985. private static _TargetTransformMatrix;
  75986. private static _TargetFocalPoint;
  75987. /**
  75988. * Define the current direction the camera is moving to
  75989. */
  75990. cameraDirection: Vector3;
  75991. /**
  75992. * Define the current rotation the camera is rotating to
  75993. */
  75994. cameraRotation: Vector2;
  75995. /**
  75996. * When set, the up vector of the camera will be updated by the rotation of the camera
  75997. */
  75998. updateUpVectorFromRotation: boolean;
  75999. private _tmpQuaternion;
  76000. /**
  76001. * Define the current rotation of the camera
  76002. */
  76003. rotation: Vector3;
  76004. /**
  76005. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76006. */
  76007. rotationQuaternion: Quaternion;
  76008. /**
  76009. * Define the current speed of the camera
  76010. */
  76011. speed: number;
  76012. /**
  76013. * Add cconstraint to the camera to prevent it to move freely in all directions and
  76014. * around all axis.
  76015. */
  76016. noRotationConstraint: boolean;
  76017. /**
  76018. * Define the current target of the camera as an object or a position.
  76019. */
  76020. lockedTarget: any;
  76021. /** @hidden */
  76022. _currentTarget: Vector3;
  76023. /** @hidden */
  76024. _initialFocalDistance: number;
  76025. /** @hidden */
  76026. _viewMatrix: Matrix;
  76027. /** @hidden */
  76028. _camMatrix: Matrix;
  76029. /** @hidden */
  76030. _cameraTransformMatrix: Matrix;
  76031. /** @hidden */
  76032. _cameraRotationMatrix: Matrix;
  76033. /** @hidden */
  76034. _referencePoint: Vector3;
  76035. /** @hidden */
  76036. _transformedReferencePoint: Vector3;
  76037. protected _globalCurrentTarget: Vector3;
  76038. protected _globalCurrentUpVector: Vector3;
  76039. /** @hidden */
  76040. _reset: () => void;
  76041. private _defaultUp;
  76042. /**
  76043. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76044. * This is the base of the follow, arc rotate cameras and Free camera
  76045. * @see http://doc.babylonjs.com/features/cameras
  76046. * @param name Defines the name of the camera in the scene
  76047. * @param position Defines the start position of the camera in the scene
  76048. * @param scene Defines the scene the camera belongs to
  76049. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76050. */
  76051. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76052. /**
  76053. * Gets the position in front of the camera at a given distance.
  76054. * @param distance The distance from the camera we want the position to be
  76055. * @returns the position
  76056. */
  76057. getFrontPosition(distance: number): Vector3;
  76058. /** @hidden */
  76059. _getLockedTargetPosition(): Nullable<Vector3>;
  76060. private _storedPosition;
  76061. private _storedRotation;
  76062. private _storedRotationQuaternion;
  76063. /**
  76064. * Store current camera state of the camera (fov, position, rotation, etc..)
  76065. * @returns the camera
  76066. */
  76067. storeState(): Camera;
  76068. /**
  76069. * Restored camera state. You must call storeState() first
  76070. * @returns whether it was successful or not
  76071. * @hidden
  76072. */
  76073. _restoreStateValues(): boolean;
  76074. /** @hidden */
  76075. _initCache(): void;
  76076. /** @hidden */
  76077. _updateCache(ignoreParentClass?: boolean): void;
  76078. /** @hidden */
  76079. _isSynchronizedViewMatrix(): boolean;
  76080. /** @hidden */
  76081. _computeLocalCameraSpeed(): number;
  76082. /**
  76083. * Defines the target the camera should look at.
  76084. * @param target Defines the new target as a Vector or a mesh
  76085. */
  76086. setTarget(target: Vector3): void;
  76087. /**
  76088. * Return the current target position of the camera. This value is expressed in local space.
  76089. * @returns the target position
  76090. */
  76091. getTarget(): Vector3;
  76092. /** @hidden */
  76093. _decideIfNeedsToMove(): boolean;
  76094. /** @hidden */
  76095. _updatePosition(): void;
  76096. /** @hidden */
  76097. _checkInputs(): void;
  76098. protected _updateCameraRotationMatrix(): void;
  76099. /**
  76100. * 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)
  76101. * @returns the current camera
  76102. */
  76103. private _rotateUpVectorWithCameraRotationMatrix;
  76104. private _cachedRotationZ;
  76105. private _cachedQuaternionRotationZ;
  76106. /** @hidden */
  76107. _getViewMatrix(): Matrix;
  76108. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76109. /**
  76110. * @hidden
  76111. */
  76112. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76113. /**
  76114. * @hidden
  76115. */
  76116. _updateRigCameras(): void;
  76117. private _getRigCamPositionAndTarget;
  76118. /**
  76119. * Gets the current object class name.
  76120. * @return the class name
  76121. */
  76122. getClassName(): string;
  76123. }
  76124. }
  76125. declare module BABYLON {
  76126. /**
  76127. * Gather the list of keyboard event types as constants.
  76128. */
  76129. export class KeyboardEventTypes {
  76130. /**
  76131. * The keydown event is fired when a key becomes active (pressed).
  76132. */
  76133. static readonly KEYDOWN: number;
  76134. /**
  76135. * The keyup event is fired when a key has been released.
  76136. */
  76137. static readonly KEYUP: number;
  76138. }
  76139. /**
  76140. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76141. */
  76142. export class KeyboardInfo {
  76143. /**
  76144. * Defines the type of event (KeyboardEventTypes)
  76145. */
  76146. type: number;
  76147. /**
  76148. * Defines the related dom event
  76149. */
  76150. event: KeyboardEvent;
  76151. /**
  76152. * Instantiates a new keyboard info.
  76153. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76154. * @param type Defines the type of event (KeyboardEventTypes)
  76155. * @param event Defines the related dom event
  76156. */
  76157. constructor(
  76158. /**
  76159. * Defines the type of event (KeyboardEventTypes)
  76160. */
  76161. type: number,
  76162. /**
  76163. * Defines the related dom event
  76164. */
  76165. event: KeyboardEvent);
  76166. }
  76167. /**
  76168. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76169. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  76170. */
  76171. export class KeyboardInfoPre extends KeyboardInfo {
  76172. /**
  76173. * Defines the type of event (KeyboardEventTypes)
  76174. */
  76175. type: number;
  76176. /**
  76177. * Defines the related dom event
  76178. */
  76179. event: KeyboardEvent;
  76180. /**
  76181. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  76182. */
  76183. skipOnPointerObservable: boolean;
  76184. /**
  76185. * Instantiates a new keyboard pre info.
  76186. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  76187. * @param type Defines the type of event (KeyboardEventTypes)
  76188. * @param event Defines the related dom event
  76189. */
  76190. constructor(
  76191. /**
  76192. * Defines the type of event (KeyboardEventTypes)
  76193. */
  76194. type: number,
  76195. /**
  76196. * Defines the related dom event
  76197. */
  76198. event: KeyboardEvent);
  76199. }
  76200. }
  76201. declare module BABYLON {
  76202. /**
  76203. * Manage the keyboard inputs to control the movement of a free camera.
  76204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76205. */
  76206. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  76207. /**
  76208. * Defines the camera the input is attached to.
  76209. */
  76210. camera: FreeCamera;
  76211. /**
  76212. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76213. */
  76214. keysUp: number[];
  76215. /**
  76216. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76217. */
  76218. keysDown: number[];
  76219. /**
  76220. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76221. */
  76222. keysLeft: number[];
  76223. /**
  76224. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76225. */
  76226. keysRight: number[];
  76227. private _keys;
  76228. private _onCanvasBlurObserver;
  76229. private _onKeyboardObserver;
  76230. private _engine;
  76231. private _scene;
  76232. /**
  76233. * Attach the input controls to a specific dom element to get the input from.
  76234. * @param element Defines the element the controls should be listened from
  76235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76236. */
  76237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76238. /**
  76239. * Detach the current controls from the specified dom element.
  76240. * @param element Defines the element to stop listening the inputs from
  76241. */
  76242. detachControl(element: Nullable<HTMLElement>): void;
  76243. /**
  76244. * Update the current camera state depending on the inputs that have been used this frame.
  76245. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76246. */
  76247. checkInputs(): void;
  76248. /**
  76249. * Gets the class name of the current intput.
  76250. * @returns the class name
  76251. */
  76252. getClassName(): string;
  76253. /** @hidden */
  76254. _onLostFocus(): void;
  76255. /**
  76256. * Get the friendly name associated with the input class.
  76257. * @returns the input friendly name
  76258. */
  76259. getSimpleName(): string;
  76260. }
  76261. }
  76262. declare module BABYLON {
  76263. /**
  76264. * Interface describing all the common properties and methods a shadow light needs to implement.
  76265. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  76266. * as well as binding the different shadow properties to the effects.
  76267. */
  76268. export interface IShadowLight extends Light {
  76269. /**
  76270. * The light id in the scene (used in scene.findLighById for instance)
  76271. */
  76272. id: string;
  76273. /**
  76274. * The position the shdow will be casted from.
  76275. */
  76276. position: Vector3;
  76277. /**
  76278. * In 2d mode (needCube being false), the direction used to cast the shadow.
  76279. */
  76280. direction: Vector3;
  76281. /**
  76282. * The transformed position. Position of the light in world space taking parenting in account.
  76283. */
  76284. transformedPosition: Vector3;
  76285. /**
  76286. * The transformed direction. Direction of the light in world space taking parenting in account.
  76287. */
  76288. transformedDirection: Vector3;
  76289. /**
  76290. * The friendly name of the light in the scene.
  76291. */
  76292. name: string;
  76293. /**
  76294. * Defines the shadow projection clipping minimum z value.
  76295. */
  76296. shadowMinZ: number;
  76297. /**
  76298. * Defines the shadow projection clipping maximum z value.
  76299. */
  76300. shadowMaxZ: number;
  76301. /**
  76302. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76303. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76304. */
  76305. computeTransformedInformation(): boolean;
  76306. /**
  76307. * Gets the scene the light belongs to.
  76308. * @returns The scene
  76309. */
  76310. getScene(): Scene;
  76311. /**
  76312. * Callback defining a custom Projection Matrix Builder.
  76313. * This can be used to override the default projection matrix computation.
  76314. */
  76315. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76316. /**
  76317. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76318. * @param matrix The materix to updated with the projection information
  76319. * @param viewMatrix The transform matrix of the light
  76320. * @param renderList The list of mesh to render in the map
  76321. * @returns The current light
  76322. */
  76323. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76324. /**
  76325. * Gets the current depth scale used in ESM.
  76326. * @returns The scale
  76327. */
  76328. getDepthScale(): number;
  76329. /**
  76330. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76331. * @returns true if a cube texture needs to be use
  76332. */
  76333. needCube(): boolean;
  76334. /**
  76335. * Detects if the projection matrix requires to be recomputed this frame.
  76336. * @returns true if it requires to be recomputed otherwise, false.
  76337. */
  76338. needProjectionMatrixCompute(): boolean;
  76339. /**
  76340. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76341. */
  76342. forceProjectionMatrixCompute(): void;
  76343. /**
  76344. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76345. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76346. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76347. */
  76348. getShadowDirection(faceIndex?: number): Vector3;
  76349. /**
  76350. * Gets the minZ used for shadow according to both the scene and the light.
  76351. * @param activeCamera The camera we are returning the min for
  76352. * @returns the depth min z
  76353. */
  76354. getDepthMinZ(activeCamera: Camera): number;
  76355. /**
  76356. * Gets the maxZ used for shadow according to both the scene and the light.
  76357. * @param activeCamera The camera we are returning the max for
  76358. * @returns the depth max z
  76359. */
  76360. getDepthMaxZ(activeCamera: Camera): number;
  76361. }
  76362. /**
  76363. * Base implementation IShadowLight
  76364. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  76365. */
  76366. export abstract class ShadowLight extends Light implements IShadowLight {
  76367. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  76368. protected _position: Vector3;
  76369. protected _setPosition(value: Vector3): void;
  76370. /**
  76371. * Sets the position the shadow will be casted from. Also use as the light position for both
  76372. * point and spot lights.
  76373. */
  76374. /**
  76375. * Sets the position the shadow will be casted from. Also use as the light position for both
  76376. * point and spot lights.
  76377. */
  76378. position: Vector3;
  76379. protected _direction: Vector3;
  76380. protected _setDirection(value: Vector3): void;
  76381. /**
  76382. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  76383. * Also use as the light direction on spot and directional lights.
  76384. */
  76385. /**
  76386. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  76387. * Also use as the light direction on spot and directional lights.
  76388. */
  76389. direction: Vector3;
  76390. private _shadowMinZ;
  76391. /**
  76392. * Gets the shadow projection clipping minimum z value.
  76393. */
  76394. /**
  76395. * Sets the shadow projection clipping minimum z value.
  76396. */
  76397. shadowMinZ: number;
  76398. private _shadowMaxZ;
  76399. /**
  76400. * Sets the shadow projection clipping maximum z value.
  76401. */
  76402. /**
  76403. * Gets the shadow projection clipping maximum z value.
  76404. */
  76405. shadowMaxZ: number;
  76406. /**
  76407. * Callback defining a custom Projection Matrix Builder.
  76408. * This can be used to override the default projection matrix computation.
  76409. */
  76410. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  76411. /**
  76412. * The transformed position. Position of the light in world space taking parenting in account.
  76413. */
  76414. transformedPosition: Vector3;
  76415. /**
  76416. * The transformed direction. Direction of the light in world space taking parenting in account.
  76417. */
  76418. transformedDirection: Vector3;
  76419. private _needProjectionMatrixCompute;
  76420. /**
  76421. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  76422. * @returns true if the information has been computed, false if it does not need to (no parenting)
  76423. */
  76424. computeTransformedInformation(): boolean;
  76425. /**
  76426. * Return the depth scale used for the shadow map.
  76427. * @returns the depth scale.
  76428. */
  76429. getDepthScale(): number;
  76430. /**
  76431. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  76432. * @param faceIndex The index of the face we are computed the direction to generate shadow
  76433. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  76434. */
  76435. getShadowDirection(faceIndex?: number): Vector3;
  76436. /**
  76437. * Returns the ShadowLight absolute position in the World.
  76438. * @returns the position vector in world space
  76439. */
  76440. getAbsolutePosition(): Vector3;
  76441. /**
  76442. * Sets the ShadowLight direction toward the passed target.
  76443. * @param target The point to target in local space
  76444. * @returns the updated ShadowLight direction
  76445. */
  76446. setDirectionToTarget(target: Vector3): Vector3;
  76447. /**
  76448. * Returns the light rotation in euler definition.
  76449. * @returns the x y z rotation in local space.
  76450. */
  76451. getRotation(): Vector3;
  76452. /**
  76453. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  76454. * @returns true if a cube texture needs to be use
  76455. */
  76456. needCube(): boolean;
  76457. /**
  76458. * Detects if the projection matrix requires to be recomputed this frame.
  76459. * @returns true if it requires to be recomputed otherwise, false.
  76460. */
  76461. needProjectionMatrixCompute(): boolean;
  76462. /**
  76463. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  76464. */
  76465. forceProjectionMatrixCompute(): void;
  76466. /** @hidden */
  76467. _initCache(): void;
  76468. /** @hidden */
  76469. _isSynchronized(): boolean;
  76470. /**
  76471. * Computes the world matrix of the node
  76472. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  76473. * @returns the world matrix
  76474. */
  76475. computeWorldMatrix(force?: boolean): Matrix;
  76476. /**
  76477. * Gets the minZ used for shadow according to both the scene and the light.
  76478. * @param activeCamera The camera we are returning the min for
  76479. * @returns the depth min z
  76480. */
  76481. getDepthMinZ(activeCamera: Camera): number;
  76482. /**
  76483. * Gets the maxZ used for shadow according to both the scene and the light.
  76484. * @param activeCamera The camera we are returning the max for
  76485. * @returns the depth max z
  76486. */
  76487. getDepthMaxZ(activeCamera: Camera): number;
  76488. /**
  76489. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  76490. * @param matrix The materix to updated with the projection information
  76491. * @param viewMatrix The transform matrix of the light
  76492. * @param renderList The list of mesh to render in the map
  76493. * @returns The current light
  76494. */
  76495. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  76496. }
  76497. }
  76498. declare module BABYLON {
  76499. /**
  76500. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  76501. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  76502. */
  76503. export class EffectFallbacks implements IEffectFallbacks {
  76504. private _defines;
  76505. private _currentRank;
  76506. private _maxRank;
  76507. private _mesh;
  76508. /**
  76509. * Removes the fallback from the bound mesh.
  76510. */
  76511. unBindMesh(): void;
  76512. /**
  76513. * Adds a fallback on the specified property.
  76514. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76515. * @param define The name of the define in the shader
  76516. */
  76517. addFallback(rank: number, define: string): void;
  76518. /**
  76519. * Sets the mesh to use CPU skinning when needing to fallback.
  76520. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  76521. * @param mesh The mesh to use the fallbacks.
  76522. */
  76523. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  76524. /**
  76525. * Checks to see if more fallbacks are still availible.
  76526. */
  76527. readonly hasMoreFallbacks: boolean;
  76528. /**
  76529. * Removes the defines that should be removed when falling back.
  76530. * @param currentDefines defines the current define statements for the shader.
  76531. * @param effect defines the current effect we try to compile
  76532. * @returns The resulting defines with defines of the current rank removed.
  76533. */
  76534. reduce(currentDefines: string, effect: Effect): string;
  76535. }
  76536. }
  76537. declare module BABYLON {
  76538. /**
  76539. * "Static Class" containing the most commonly used helper while dealing with material for
  76540. * rendering purpose.
  76541. *
  76542. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  76543. *
  76544. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  76545. */
  76546. export class MaterialHelper {
  76547. /**
  76548. * Bind the current view position to an effect.
  76549. * @param effect The effect to be bound
  76550. * @param scene The scene the eyes position is used from
  76551. */
  76552. static BindEyePosition(effect: Effect, scene: Scene): void;
  76553. /**
  76554. * Helps preparing the defines values about the UVs in used in the effect.
  76555. * UVs are shared as much as we can accross channels in the shaders.
  76556. * @param texture The texture we are preparing the UVs for
  76557. * @param defines The defines to update
  76558. * @param key The channel key "diffuse", "specular"... used in the shader
  76559. */
  76560. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  76561. /**
  76562. * Binds a texture matrix value to its corrsponding uniform
  76563. * @param texture The texture to bind the matrix for
  76564. * @param uniformBuffer The uniform buffer receivin the data
  76565. * @param key The channel key "diffuse", "specular"... used in the shader
  76566. */
  76567. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  76568. /**
  76569. * Gets the current status of the fog (should it be enabled?)
  76570. * @param mesh defines the mesh to evaluate for fog support
  76571. * @param scene defines the hosting scene
  76572. * @returns true if fog must be enabled
  76573. */
  76574. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  76575. /**
  76576. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  76577. * @param mesh defines the current mesh
  76578. * @param scene defines the current scene
  76579. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  76580. * @param pointsCloud defines if point cloud rendering has to be turned on
  76581. * @param fogEnabled defines if fog has to be turned on
  76582. * @param alphaTest defines if alpha testing has to be turned on
  76583. * @param defines defines the current list of defines
  76584. */
  76585. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  76586. /**
  76587. * Helper used to prepare the list of defines associated with frame values for shader compilation
  76588. * @param scene defines the current scene
  76589. * @param engine defines the current engine
  76590. * @param defines specifies the list of active defines
  76591. * @param useInstances defines if instances have to be turned on
  76592. * @param useClipPlane defines if clip plane have to be turned on
  76593. */
  76594. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  76595. /**
  76596. * Prepares the defines for bones
  76597. * @param mesh The mesh containing the geometry data we will draw
  76598. * @param defines The defines to update
  76599. */
  76600. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  76601. /**
  76602. * Prepares the defines for morph targets
  76603. * @param mesh The mesh containing the geometry data we will draw
  76604. * @param defines The defines to update
  76605. */
  76606. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  76607. /**
  76608. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  76609. * @param mesh The mesh containing the geometry data we will draw
  76610. * @param defines The defines to update
  76611. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  76612. * @param useBones Precise whether bones should be used or not (override mesh info)
  76613. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  76614. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  76615. * @returns false if defines are considered not dirty and have not been checked
  76616. */
  76617. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  76618. /**
  76619. * Prepares the defines related to multiview
  76620. * @param scene The scene we are intending to draw
  76621. * @param defines The defines to update
  76622. */
  76623. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  76624. /**
  76625. * Prepares the defines related to the light information passed in parameter
  76626. * @param scene The scene we are intending to draw
  76627. * @param mesh The mesh the effect is compiling for
  76628. * @param light The light the effect is compiling for
  76629. * @param lightIndex The index of the light
  76630. * @param defines The defines to update
  76631. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76632. * @param state Defines the current state regarding what is needed (normals, etc...)
  76633. */
  76634. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  76635. needNormals: boolean;
  76636. needRebuild: boolean;
  76637. shadowEnabled: boolean;
  76638. specularEnabled: boolean;
  76639. lightmapMode: boolean;
  76640. }): void;
  76641. /**
  76642. * Prepares the defines related to the light information passed in parameter
  76643. * @param scene The scene we are intending to draw
  76644. * @param mesh The mesh the effect is compiling for
  76645. * @param defines The defines to update
  76646. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  76647. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  76648. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  76649. * @returns true if normals will be required for the rest of the effect
  76650. */
  76651. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  76652. /**
  76653. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  76654. * @param lightIndex defines the light index
  76655. * @param uniformsList The uniform list
  76656. * @param samplersList The sampler list
  76657. * @param projectedLightTexture defines if projected texture must be used
  76658. * @param uniformBuffersList defines an optional list of uniform buffers
  76659. */
  76660. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  76661. /**
  76662. * Prepares the uniforms and samplers list to be used in the effect
  76663. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  76664. * @param samplersList The sampler list
  76665. * @param defines The defines helping in the list generation
  76666. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  76667. */
  76668. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  76669. /**
  76670. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  76671. * @param defines The defines to update while falling back
  76672. * @param fallbacks The authorized effect fallbacks
  76673. * @param maxSimultaneousLights The maximum number of lights allowed
  76674. * @param rank the current rank of the Effect
  76675. * @returns The newly affected rank
  76676. */
  76677. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  76678. private static _TmpMorphInfluencers;
  76679. /**
  76680. * Prepares the list of attributes required for morph targets according to the effect defines.
  76681. * @param attribs The current list of supported attribs
  76682. * @param mesh The mesh to prepare the morph targets attributes for
  76683. * @param influencers The number of influencers
  76684. */
  76685. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  76686. /**
  76687. * Prepares the list of attributes required for morph targets according to the effect defines.
  76688. * @param attribs The current list of supported attribs
  76689. * @param mesh The mesh to prepare the morph targets attributes for
  76690. * @param defines The current Defines of the effect
  76691. */
  76692. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  76693. /**
  76694. * Prepares the list of attributes required for bones according to the effect defines.
  76695. * @param attribs The current list of supported attribs
  76696. * @param mesh The mesh to prepare the bones attributes for
  76697. * @param defines The current Defines of the effect
  76698. * @param fallbacks The current efffect fallback strategy
  76699. */
  76700. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  76701. /**
  76702. * Check and prepare the list of attributes required for instances according to the effect defines.
  76703. * @param attribs The current list of supported attribs
  76704. * @param defines The current MaterialDefines of the effect
  76705. */
  76706. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  76707. /**
  76708. * Add the list of attributes required for instances to the attribs array.
  76709. * @param attribs The current list of supported attribs
  76710. */
  76711. static PushAttributesForInstances(attribs: string[]): void;
  76712. /**
  76713. * Binds the light information to the effect.
  76714. * @param light The light containing the generator
  76715. * @param effect The effect we are binding the data to
  76716. * @param lightIndex The light index in the effect used to render
  76717. */
  76718. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  76719. /**
  76720. * Binds the lights information from the scene to the effect for the given mesh.
  76721. * @param light Light to bind
  76722. * @param lightIndex Light index
  76723. * @param scene The scene where the light belongs to
  76724. * @param effect The effect we are binding the data to
  76725. * @param useSpecular Defines if specular is supported
  76726. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76727. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76728. */
  76729. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76730. /**
  76731. * Binds the lights information from the scene to the effect for the given mesh.
  76732. * @param scene The scene the lights belongs to
  76733. * @param mesh The mesh we are binding the information to render
  76734. * @param effect The effect we are binding the data to
  76735. * @param defines The generated defines for the effect
  76736. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  76737. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  76738. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  76739. */
  76740. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  76741. private static _tempFogColor;
  76742. /**
  76743. * Binds the fog information from the scene to the effect for the given mesh.
  76744. * @param scene The scene the lights belongs to
  76745. * @param mesh The mesh we are binding the information to render
  76746. * @param effect The effect we are binding the data to
  76747. * @param linearSpace Defines if the fog effect is applied in linear space
  76748. */
  76749. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  76750. /**
  76751. * Binds the bones information from the mesh to the effect.
  76752. * @param mesh The mesh we are binding the information to render
  76753. * @param effect The effect we are binding the data to
  76754. */
  76755. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  76756. /**
  76757. * Binds the morph targets information from the mesh to the effect.
  76758. * @param abstractMesh The mesh we are binding the information to render
  76759. * @param effect The effect we are binding the data to
  76760. */
  76761. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  76762. /**
  76763. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  76764. * @param defines The generated defines used in the effect
  76765. * @param effect The effect we are binding the data to
  76766. * @param scene The scene we are willing to render with logarithmic scale for
  76767. */
  76768. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  76769. /**
  76770. * Binds the clip plane information from the scene to the effect.
  76771. * @param scene The scene the clip plane information are extracted from
  76772. * @param effect The effect we are binding the data to
  76773. */
  76774. static BindClipPlane(effect: Effect, scene: Scene): void;
  76775. }
  76776. }
  76777. declare module BABYLON {
  76778. /** @hidden */
  76779. export var packingFunctions: {
  76780. name: string;
  76781. shader: string;
  76782. };
  76783. }
  76784. declare module BABYLON {
  76785. /** @hidden */
  76786. export var shadowMapPixelShader: {
  76787. name: string;
  76788. shader: string;
  76789. };
  76790. }
  76791. declare module BABYLON {
  76792. /** @hidden */
  76793. export var bonesDeclaration: {
  76794. name: string;
  76795. shader: string;
  76796. };
  76797. }
  76798. declare module BABYLON {
  76799. /** @hidden */
  76800. export var morphTargetsVertexGlobalDeclaration: {
  76801. name: string;
  76802. shader: string;
  76803. };
  76804. }
  76805. declare module BABYLON {
  76806. /** @hidden */
  76807. export var morphTargetsVertexDeclaration: {
  76808. name: string;
  76809. shader: string;
  76810. };
  76811. }
  76812. declare module BABYLON {
  76813. /** @hidden */
  76814. export var instancesDeclaration: {
  76815. name: string;
  76816. shader: string;
  76817. };
  76818. }
  76819. declare module BABYLON {
  76820. /** @hidden */
  76821. export var helperFunctions: {
  76822. name: string;
  76823. shader: string;
  76824. };
  76825. }
  76826. declare module BABYLON {
  76827. /** @hidden */
  76828. export var morphTargetsVertex: {
  76829. name: string;
  76830. shader: string;
  76831. };
  76832. }
  76833. declare module BABYLON {
  76834. /** @hidden */
  76835. export var instancesVertex: {
  76836. name: string;
  76837. shader: string;
  76838. };
  76839. }
  76840. declare module BABYLON {
  76841. /** @hidden */
  76842. export var bonesVertex: {
  76843. name: string;
  76844. shader: string;
  76845. };
  76846. }
  76847. declare module BABYLON {
  76848. /** @hidden */
  76849. export var shadowMapVertexShader: {
  76850. name: string;
  76851. shader: string;
  76852. };
  76853. }
  76854. declare module BABYLON {
  76855. /** @hidden */
  76856. export var depthBoxBlurPixelShader: {
  76857. name: string;
  76858. shader: string;
  76859. };
  76860. }
  76861. declare module BABYLON {
  76862. /**
  76863. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76864. */
  76865. export interface ICustomShaderOptions {
  76866. /**
  76867. * Gets or sets the custom shader name to use
  76868. */
  76869. shaderName: string;
  76870. /**
  76871. * The list of attribute names used in the shader
  76872. */
  76873. attributes?: string[];
  76874. /**
  76875. * The list of unifrom names used in the shader
  76876. */
  76877. uniforms?: string[];
  76878. /**
  76879. * The list of sampler names used in the shader
  76880. */
  76881. samplers?: string[];
  76882. /**
  76883. * The list of defines used in the shader
  76884. */
  76885. defines?: string[];
  76886. }
  76887. /**
  76888. * Interface to implement to create a shadow generator compatible with BJS.
  76889. */
  76890. export interface IShadowGenerator {
  76891. /**
  76892. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76893. * @returns The render target texture if present otherwise, null
  76894. */
  76895. getShadowMap(): Nullable<RenderTargetTexture>;
  76896. /**
  76897. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76898. * @returns The render target texture if the shadow map is present otherwise, null
  76899. */
  76900. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76901. /**
  76902. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76903. * @param subMesh The submesh we want to render in the shadow map
  76904. * @param useInstances Defines wether will draw in the map using instances
  76905. * @returns true if ready otherwise, false
  76906. */
  76907. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76908. /**
  76909. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76910. * @param defines Defines of the material we want to update
  76911. * @param lightIndex Index of the light in the enabled light list of the material
  76912. */
  76913. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76914. /**
  76915. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76916. * defined in the generator but impacting the effect).
  76917. * It implies the unifroms available on the materials are the standard BJS ones.
  76918. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76919. * @param effect The effect we are binfing the information for
  76920. */
  76921. bindShadowLight(lightIndex: string, effect: Effect): void;
  76922. /**
  76923. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76924. * (eq to shadow prjection matrix * light transform matrix)
  76925. * @returns The transform matrix used to create the shadow map
  76926. */
  76927. getTransformMatrix(): Matrix;
  76928. /**
  76929. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76930. * Cube and 2D textures for instance.
  76931. */
  76932. recreateShadowMap(): void;
  76933. /**
  76934. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76935. * @param onCompiled Callback triggered at the and of the effects compilation
  76936. * @param options Sets of optional options forcing the compilation with different modes
  76937. */
  76938. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76939. useInstances: boolean;
  76940. }>): void;
  76941. /**
  76942. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76943. * @param options Sets of optional options forcing the compilation with different modes
  76944. * @returns A promise that resolves when the compilation completes
  76945. */
  76946. forceCompilationAsync(options?: Partial<{
  76947. useInstances: boolean;
  76948. }>): Promise<void>;
  76949. /**
  76950. * Serializes the shadow generator setup to a json object.
  76951. * @returns The serialized JSON object
  76952. */
  76953. serialize(): any;
  76954. /**
  76955. * Disposes the Shadow map and related Textures and effects.
  76956. */
  76957. dispose(): void;
  76958. }
  76959. /**
  76960. * Default implementation IShadowGenerator.
  76961. * This is the main object responsible of generating shadows in the framework.
  76962. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76963. */
  76964. export class ShadowGenerator implements IShadowGenerator {
  76965. /**
  76966. * Shadow generator mode None: no filtering applied.
  76967. */
  76968. static readonly FILTER_NONE: number;
  76969. /**
  76970. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76971. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76972. */
  76973. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76974. /**
  76975. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76976. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76977. */
  76978. static readonly FILTER_POISSONSAMPLING: number;
  76979. /**
  76980. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76981. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76982. */
  76983. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76984. /**
  76985. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76986. * edge artifacts on steep falloff.
  76987. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76988. */
  76989. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76990. /**
  76991. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76992. * edge artifacts on steep falloff.
  76993. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76994. */
  76995. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76996. /**
  76997. * Shadow generator mode PCF: Percentage Closer Filtering
  76998. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76999. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77000. */
  77001. static readonly FILTER_PCF: number;
  77002. /**
  77003. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77004. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77005. * Contact Hardening
  77006. */
  77007. static readonly FILTER_PCSS: number;
  77008. /**
  77009. * Reserved for PCF and PCSS
  77010. * Highest Quality.
  77011. *
  77012. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77013. *
  77014. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77015. */
  77016. static readonly QUALITY_HIGH: number;
  77017. /**
  77018. * Reserved for PCF and PCSS
  77019. * Good tradeoff for quality/perf cross devices
  77020. *
  77021. * Execute PCF on a 3*3 kernel.
  77022. *
  77023. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77024. */
  77025. static readonly QUALITY_MEDIUM: number;
  77026. /**
  77027. * Reserved for PCF and PCSS
  77028. * The lowest quality but the fastest.
  77029. *
  77030. * Execute PCF on a 1*1 kernel.
  77031. *
  77032. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77033. */
  77034. static readonly QUALITY_LOW: number;
  77035. /** Gets or sets the custom shader name to use */
  77036. customShaderOptions: ICustomShaderOptions;
  77037. /**
  77038. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77039. */
  77040. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77041. /**
  77042. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77043. */
  77044. onAfterShadowMapRenderObservable: Observable<Effect>;
  77045. /**
  77046. * Observable triggered before a mesh is rendered in the shadow map.
  77047. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77048. */
  77049. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77050. /**
  77051. * Observable triggered after a mesh is rendered in the shadow map.
  77052. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77053. */
  77054. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77055. private _bias;
  77056. /**
  77057. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77058. */
  77059. /**
  77060. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77061. */
  77062. bias: number;
  77063. private _normalBias;
  77064. /**
  77065. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77066. */
  77067. /**
  77068. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77069. */
  77070. normalBias: number;
  77071. private _blurBoxOffset;
  77072. /**
  77073. * Gets the blur box offset: offset applied during the blur pass.
  77074. * Only useful if useKernelBlur = false
  77075. */
  77076. /**
  77077. * Sets the blur box offset: offset applied during the blur pass.
  77078. * Only useful if useKernelBlur = false
  77079. */
  77080. blurBoxOffset: number;
  77081. private _blurScale;
  77082. /**
  77083. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77084. * 2 means half of the size.
  77085. */
  77086. /**
  77087. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77088. * 2 means half of the size.
  77089. */
  77090. blurScale: number;
  77091. private _blurKernel;
  77092. /**
  77093. * Gets the blur kernel: kernel size of the blur pass.
  77094. * Only useful if useKernelBlur = true
  77095. */
  77096. /**
  77097. * Sets the blur kernel: kernel size of the blur pass.
  77098. * Only useful if useKernelBlur = true
  77099. */
  77100. blurKernel: number;
  77101. private _useKernelBlur;
  77102. /**
  77103. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77104. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77105. */
  77106. /**
  77107. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77108. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77109. */
  77110. useKernelBlur: boolean;
  77111. private _depthScale;
  77112. /**
  77113. * Gets the depth scale used in ESM mode.
  77114. */
  77115. /**
  77116. * Sets the depth scale used in ESM mode.
  77117. * This can override the scale stored on the light.
  77118. */
  77119. depthScale: number;
  77120. private _filter;
  77121. /**
  77122. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77123. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77124. */
  77125. /**
  77126. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77127. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77128. */
  77129. filter: number;
  77130. /**
  77131. * Gets if the current filter is set to Poisson Sampling.
  77132. */
  77133. /**
  77134. * Sets the current filter to Poisson Sampling.
  77135. */
  77136. usePoissonSampling: boolean;
  77137. /**
  77138. * Gets if the current filter is set to ESM.
  77139. */
  77140. /**
  77141. * Sets the current filter is to ESM.
  77142. */
  77143. useExponentialShadowMap: boolean;
  77144. /**
  77145. * Gets if the current filter is set to filtered ESM.
  77146. */
  77147. /**
  77148. * Gets if the current filter is set to filtered ESM.
  77149. */
  77150. useBlurExponentialShadowMap: boolean;
  77151. /**
  77152. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77153. * exponential to prevent steep falloff artifacts).
  77154. */
  77155. /**
  77156. * Sets the current filter to "close ESM" (using the inverse of the
  77157. * exponential to prevent steep falloff artifacts).
  77158. */
  77159. useCloseExponentialShadowMap: boolean;
  77160. /**
  77161. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77162. * exponential to prevent steep falloff artifacts).
  77163. */
  77164. /**
  77165. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77166. * exponential to prevent steep falloff artifacts).
  77167. */
  77168. useBlurCloseExponentialShadowMap: boolean;
  77169. /**
  77170. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  77171. */
  77172. /**
  77173. * Sets the current filter to "PCF" (percentage closer filtering).
  77174. */
  77175. usePercentageCloserFiltering: boolean;
  77176. private _filteringQuality;
  77177. /**
  77178. * Gets the PCF or PCSS Quality.
  77179. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77180. */
  77181. /**
  77182. * Sets the PCF or PCSS Quality.
  77183. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  77184. */
  77185. filteringQuality: number;
  77186. /**
  77187. * Gets if the current filter is set to "PCSS" (contact hardening).
  77188. */
  77189. /**
  77190. * Sets the current filter to "PCSS" (contact hardening).
  77191. */
  77192. useContactHardeningShadow: boolean;
  77193. private _contactHardeningLightSizeUVRatio;
  77194. /**
  77195. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77196. * Using a ratio helps keeping shape stability independently of the map size.
  77197. *
  77198. * It does not account for the light projection as it was having too much
  77199. * instability during the light setup or during light position changes.
  77200. *
  77201. * Only valid if useContactHardeningShadow is true.
  77202. */
  77203. /**
  77204. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  77205. * Using a ratio helps keeping shape stability independently of the map size.
  77206. *
  77207. * It does not account for the light projection as it was having too much
  77208. * instability during the light setup or during light position changes.
  77209. *
  77210. * Only valid if useContactHardeningShadow is true.
  77211. */
  77212. contactHardeningLightSizeUVRatio: number;
  77213. private _darkness;
  77214. /** Gets or sets the actual darkness of a shadow */
  77215. darkness: number;
  77216. /**
  77217. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  77218. * 0 means strongest and 1 would means no shadow.
  77219. * @returns the darkness.
  77220. */
  77221. getDarkness(): number;
  77222. /**
  77223. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  77224. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  77225. * @returns the shadow generator allowing fluent coding.
  77226. */
  77227. setDarkness(darkness: number): ShadowGenerator;
  77228. private _transparencyShadow;
  77229. /** Gets or sets the ability to have transparent shadow */
  77230. transparencyShadow: boolean;
  77231. /**
  77232. * Sets the ability to have transparent shadow (boolean).
  77233. * @param transparent True if transparent else False
  77234. * @returns the shadow generator allowing fluent coding
  77235. */
  77236. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  77237. private _shadowMap;
  77238. private _shadowMap2;
  77239. /**
  77240. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77241. * @returns The render target texture if present otherwise, null
  77242. */
  77243. getShadowMap(): Nullable<RenderTargetTexture>;
  77244. /**
  77245. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77246. * @returns The render target texture if the shadow map is present otherwise, null
  77247. */
  77248. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77249. /**
  77250. * Gets the class name of that object
  77251. * @returns "ShadowGenerator"
  77252. */
  77253. getClassName(): string;
  77254. /**
  77255. * Helper function to add a mesh and its descendants to the list of shadow casters.
  77256. * @param mesh Mesh to add
  77257. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  77258. * @returns the Shadow Generator itself
  77259. */
  77260. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77261. /**
  77262. * Helper function to remove a mesh and its descendants from the list of shadow casters
  77263. * @param mesh Mesh to remove
  77264. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  77265. * @returns the Shadow Generator itself
  77266. */
  77267. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  77268. /**
  77269. * Controls the extent to which the shadows fade out at the edge of the frustum
  77270. * Used only by directionals and spots
  77271. */
  77272. frustumEdgeFalloff: number;
  77273. private _light;
  77274. /**
  77275. * Returns the associated light object.
  77276. * @returns the light generating the shadow
  77277. */
  77278. getLight(): IShadowLight;
  77279. /**
  77280. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  77281. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  77282. * It might on the other hand introduce peter panning.
  77283. */
  77284. forceBackFacesOnly: boolean;
  77285. private _scene;
  77286. private _lightDirection;
  77287. private _effect;
  77288. private _viewMatrix;
  77289. private _projectionMatrix;
  77290. private _transformMatrix;
  77291. private _cachedPosition;
  77292. private _cachedDirection;
  77293. private _cachedDefines;
  77294. private _currentRenderID;
  77295. private _boxBlurPostprocess;
  77296. private _kernelBlurXPostprocess;
  77297. private _kernelBlurYPostprocess;
  77298. private _blurPostProcesses;
  77299. private _mapSize;
  77300. private _currentFaceIndex;
  77301. private _currentFaceIndexCache;
  77302. private _textureType;
  77303. private _defaultTextureMatrix;
  77304. private _storedUniqueId;
  77305. /** @hidden */
  77306. static _SceneComponentInitialization: (scene: Scene) => void;
  77307. /**
  77308. * Creates a ShadowGenerator object.
  77309. * A ShadowGenerator is the required tool to use the shadows.
  77310. * Each light casting shadows needs to use its own ShadowGenerator.
  77311. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  77312. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  77313. * @param light The light object generating the shadows.
  77314. * @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.
  77315. */
  77316. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  77317. private _initializeGenerator;
  77318. private _initializeShadowMap;
  77319. private _initializeBlurRTTAndPostProcesses;
  77320. private _renderForShadowMap;
  77321. private _renderSubMeshForShadowMap;
  77322. private _applyFilterValues;
  77323. /**
  77324. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77325. * @param onCompiled Callback triggered at the and of the effects compilation
  77326. * @param options Sets of optional options forcing the compilation with different modes
  77327. */
  77328. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77329. useInstances: boolean;
  77330. }>): void;
  77331. /**
  77332. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77333. * @param options Sets of optional options forcing the compilation with different modes
  77334. * @returns A promise that resolves when the compilation completes
  77335. */
  77336. forceCompilationAsync(options?: Partial<{
  77337. useInstances: boolean;
  77338. }>): Promise<void>;
  77339. /**
  77340. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77341. * @param subMesh The submesh we want to render in the shadow map
  77342. * @param useInstances Defines wether will draw in the map using instances
  77343. * @returns true if ready otherwise, false
  77344. */
  77345. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77346. /**
  77347. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77348. * @param defines Defines of the material we want to update
  77349. * @param lightIndex Index of the light in the enabled light list of the material
  77350. */
  77351. prepareDefines(defines: any, lightIndex: number): void;
  77352. /**
  77353. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77354. * defined in the generator but impacting the effect).
  77355. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77356. * @param effect The effect we are binfing the information for
  77357. */
  77358. bindShadowLight(lightIndex: string, effect: Effect): void;
  77359. /**
  77360. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77361. * (eq to shadow prjection matrix * light transform matrix)
  77362. * @returns The transform matrix used to create the shadow map
  77363. */
  77364. getTransformMatrix(): Matrix;
  77365. /**
  77366. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77367. * Cube and 2D textures for instance.
  77368. */
  77369. recreateShadowMap(): void;
  77370. private _disposeBlurPostProcesses;
  77371. private _disposeRTTandPostProcesses;
  77372. /**
  77373. * Disposes the ShadowGenerator.
  77374. * Returns nothing.
  77375. */
  77376. dispose(): void;
  77377. /**
  77378. * Serializes the shadow generator setup to a json object.
  77379. * @returns The serialized JSON object
  77380. */
  77381. serialize(): any;
  77382. /**
  77383. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  77384. * @param parsedShadowGenerator The JSON object to parse
  77385. * @param scene The scene to create the shadow map for
  77386. * @returns The parsed shadow generator
  77387. */
  77388. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  77389. }
  77390. }
  77391. declare module BABYLON {
  77392. /**
  77393. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  77394. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  77395. * 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.
  77396. */
  77397. export abstract class Light extends Node {
  77398. /**
  77399. * Falloff Default: light is falling off following the material specification:
  77400. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  77401. */
  77402. static readonly FALLOFF_DEFAULT: number;
  77403. /**
  77404. * Falloff Physical: light is falling off following the inverse squared distance law.
  77405. */
  77406. static readonly FALLOFF_PHYSICAL: number;
  77407. /**
  77408. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  77409. * to enhance interoperability with other engines.
  77410. */
  77411. static readonly FALLOFF_GLTF: number;
  77412. /**
  77413. * Falloff Standard: light is falling off like in the standard material
  77414. * to enhance interoperability with other materials.
  77415. */
  77416. static readonly FALLOFF_STANDARD: number;
  77417. /**
  77418. * If every light affecting the material is in this lightmapMode,
  77419. * material.lightmapTexture adds or multiplies
  77420. * (depends on material.useLightmapAsShadowmap)
  77421. * after every other light calculations.
  77422. */
  77423. static readonly LIGHTMAP_DEFAULT: number;
  77424. /**
  77425. * material.lightmapTexture as only diffuse lighting from this light
  77426. * adds only specular lighting from this light
  77427. * adds dynamic shadows
  77428. */
  77429. static readonly LIGHTMAP_SPECULAR: number;
  77430. /**
  77431. * material.lightmapTexture as only lighting
  77432. * no light calculation from this light
  77433. * only adds dynamic shadows from this light
  77434. */
  77435. static readonly LIGHTMAP_SHADOWSONLY: number;
  77436. /**
  77437. * Each light type uses the default quantity according to its type:
  77438. * point/spot lights use luminous intensity
  77439. * directional lights use illuminance
  77440. */
  77441. static readonly INTENSITYMODE_AUTOMATIC: number;
  77442. /**
  77443. * lumen (lm)
  77444. */
  77445. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  77446. /**
  77447. * candela (lm/sr)
  77448. */
  77449. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  77450. /**
  77451. * lux (lm/m^2)
  77452. */
  77453. static readonly INTENSITYMODE_ILLUMINANCE: number;
  77454. /**
  77455. * nit (cd/m^2)
  77456. */
  77457. static readonly INTENSITYMODE_LUMINANCE: number;
  77458. /**
  77459. * Light type const id of the point light.
  77460. */
  77461. static readonly LIGHTTYPEID_POINTLIGHT: number;
  77462. /**
  77463. * Light type const id of the directional light.
  77464. */
  77465. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  77466. /**
  77467. * Light type const id of the spot light.
  77468. */
  77469. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  77470. /**
  77471. * Light type const id of the hemispheric light.
  77472. */
  77473. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  77474. /**
  77475. * Diffuse gives the basic color to an object.
  77476. */
  77477. diffuse: Color3;
  77478. /**
  77479. * Specular produces a highlight color on an object.
  77480. * Note: This is note affecting PBR materials.
  77481. */
  77482. specular: Color3;
  77483. /**
  77484. * Defines the falloff type for this light. This lets overrriding how punctual light are
  77485. * falling off base on range or angle.
  77486. * This can be set to any values in Light.FALLOFF_x.
  77487. *
  77488. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  77489. * other types of materials.
  77490. */
  77491. falloffType: number;
  77492. /**
  77493. * Strength of the light.
  77494. * Note: By default it is define in the framework own unit.
  77495. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  77496. */
  77497. intensity: number;
  77498. private _range;
  77499. protected _inverseSquaredRange: number;
  77500. /**
  77501. * Defines how far from the source the light is impacting in scene units.
  77502. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77503. */
  77504. /**
  77505. * Defines how far from the source the light is impacting in scene units.
  77506. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  77507. */
  77508. range: number;
  77509. /**
  77510. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  77511. * of light.
  77512. */
  77513. private _photometricScale;
  77514. private _intensityMode;
  77515. /**
  77516. * Gets the photometric scale used to interpret the intensity.
  77517. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77518. */
  77519. /**
  77520. * Sets the photometric scale used to interpret the intensity.
  77521. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  77522. */
  77523. intensityMode: number;
  77524. private _radius;
  77525. /**
  77526. * Gets the light radius used by PBR Materials to simulate soft area lights.
  77527. */
  77528. /**
  77529. * sets the light radius used by PBR Materials to simulate soft area lights.
  77530. */
  77531. radius: number;
  77532. private _renderPriority;
  77533. /**
  77534. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  77535. * exceeding the number allowed of the materials.
  77536. */
  77537. renderPriority: number;
  77538. private _shadowEnabled;
  77539. /**
  77540. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77541. * the current shadow generator.
  77542. */
  77543. /**
  77544. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  77545. * the current shadow generator.
  77546. */
  77547. shadowEnabled: boolean;
  77548. private _includedOnlyMeshes;
  77549. /**
  77550. * Gets the only meshes impacted by this light.
  77551. */
  77552. /**
  77553. * Sets the only meshes impacted by this light.
  77554. */
  77555. includedOnlyMeshes: AbstractMesh[];
  77556. private _excludedMeshes;
  77557. /**
  77558. * Gets the meshes not impacted by this light.
  77559. */
  77560. /**
  77561. * Sets the meshes not impacted by this light.
  77562. */
  77563. excludedMeshes: AbstractMesh[];
  77564. private _excludeWithLayerMask;
  77565. /**
  77566. * Gets the layer id use to find what meshes are not impacted by the light.
  77567. * Inactive if 0
  77568. */
  77569. /**
  77570. * Sets the layer id use to find what meshes are not impacted by the light.
  77571. * Inactive if 0
  77572. */
  77573. excludeWithLayerMask: number;
  77574. private _includeOnlyWithLayerMask;
  77575. /**
  77576. * Gets the layer id use to find what meshes are impacted by the light.
  77577. * Inactive if 0
  77578. */
  77579. /**
  77580. * Sets the layer id use to find what meshes are impacted by the light.
  77581. * Inactive if 0
  77582. */
  77583. includeOnlyWithLayerMask: number;
  77584. private _lightmapMode;
  77585. /**
  77586. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77587. */
  77588. /**
  77589. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  77590. */
  77591. lightmapMode: number;
  77592. /**
  77593. * Shadow generator associted to the light.
  77594. * @hidden Internal use only.
  77595. */
  77596. _shadowGenerator: Nullable<IShadowGenerator>;
  77597. /**
  77598. * @hidden Internal use only.
  77599. */
  77600. _excludedMeshesIds: string[];
  77601. /**
  77602. * @hidden Internal use only.
  77603. */
  77604. _includedOnlyMeshesIds: string[];
  77605. /**
  77606. * The current light unifom buffer.
  77607. * @hidden Internal use only.
  77608. */
  77609. _uniformBuffer: UniformBuffer;
  77610. /** @hidden */
  77611. _renderId: number;
  77612. /**
  77613. * Creates a Light object in the scene.
  77614. * Documentation : https://doc.babylonjs.com/babylon101/lights
  77615. * @param name The firendly name of the light
  77616. * @param scene The scene the light belongs too
  77617. */
  77618. constructor(name: string, scene: Scene);
  77619. protected abstract _buildUniformLayout(): void;
  77620. /**
  77621. * Sets the passed Effect "effect" with the Light information.
  77622. * @param effect The effect to update
  77623. * @param lightIndex The index of the light in the effect to update
  77624. * @returns The light
  77625. */
  77626. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  77627. /**
  77628. * Sets the passed Effect "effect" with the Light information.
  77629. * @param effect The effect to update
  77630. * @param lightDataUniformName The uniform used to store light data (position or direction)
  77631. * @returns The light
  77632. */
  77633. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  77634. /**
  77635. * Returns the string "Light".
  77636. * @returns the class name
  77637. */
  77638. getClassName(): string;
  77639. /** @hidden */
  77640. readonly _isLight: boolean;
  77641. /**
  77642. * Converts the light information to a readable string for debug purpose.
  77643. * @param fullDetails Supports for multiple levels of logging within scene loading
  77644. * @returns the human readable light info
  77645. */
  77646. toString(fullDetails?: boolean): string;
  77647. /** @hidden */
  77648. protected _syncParentEnabledState(): void;
  77649. /**
  77650. * Set the enabled state of this node.
  77651. * @param value - the new enabled state
  77652. */
  77653. setEnabled(value: boolean): void;
  77654. /**
  77655. * Returns the Light associated shadow generator if any.
  77656. * @return the associated shadow generator.
  77657. */
  77658. getShadowGenerator(): Nullable<IShadowGenerator>;
  77659. /**
  77660. * Returns a Vector3, the absolute light position in the World.
  77661. * @returns the world space position of the light
  77662. */
  77663. getAbsolutePosition(): Vector3;
  77664. /**
  77665. * Specifies if the light will affect the passed mesh.
  77666. * @param mesh The mesh to test against the light
  77667. * @return true the mesh is affected otherwise, false.
  77668. */
  77669. canAffectMesh(mesh: AbstractMesh): boolean;
  77670. /**
  77671. * Sort function to order lights for rendering.
  77672. * @param a First Light object to compare to second.
  77673. * @param b Second Light object to compare first.
  77674. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  77675. */
  77676. static CompareLightsPriority(a: Light, b: Light): number;
  77677. /**
  77678. * Releases resources associated with this node.
  77679. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77680. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77681. */
  77682. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77683. /**
  77684. * Returns the light type ID (integer).
  77685. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  77686. */
  77687. getTypeID(): number;
  77688. /**
  77689. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  77690. * @returns the scaled intensity in intensity mode unit
  77691. */
  77692. getScaledIntensity(): number;
  77693. /**
  77694. * Returns a new Light object, named "name", from the current one.
  77695. * @param name The name of the cloned light
  77696. * @returns the new created light
  77697. */
  77698. clone(name: string): Nullable<Light>;
  77699. /**
  77700. * Serializes the current light into a Serialization object.
  77701. * @returns the serialized object.
  77702. */
  77703. serialize(): any;
  77704. /**
  77705. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  77706. * This new light is named "name" and added to the passed scene.
  77707. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  77708. * @param name The friendly name of the light
  77709. * @param scene The scene the new light will belong to
  77710. * @returns the constructor function
  77711. */
  77712. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  77713. /**
  77714. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  77715. * @param parsedLight The JSON representation of the light
  77716. * @param scene The scene to create the parsed light in
  77717. * @returns the created light after parsing
  77718. */
  77719. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  77720. private _hookArrayForExcluded;
  77721. private _hookArrayForIncludedOnly;
  77722. private _resyncMeshes;
  77723. /**
  77724. * Forces the meshes to update their light related information in their rendering used effects
  77725. * @hidden Internal Use Only
  77726. */
  77727. _markMeshesAsLightDirty(): void;
  77728. /**
  77729. * Recomputes the cached photometric scale if needed.
  77730. */
  77731. private _computePhotometricScale;
  77732. /**
  77733. * Returns the Photometric Scale according to the light type and intensity mode.
  77734. */
  77735. private _getPhotometricScale;
  77736. /**
  77737. * Reorder the light in the scene according to their defined priority.
  77738. * @hidden Internal Use Only
  77739. */
  77740. _reorderLightsInScene(): void;
  77741. /**
  77742. * Prepares the list of defines specific to the light type.
  77743. * @param defines the list of defines
  77744. * @param lightIndex defines the index of the light for the effect
  77745. */
  77746. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  77747. }
  77748. }
  77749. declare module BABYLON {
  77750. /**
  77751. * Interface used to define Action
  77752. */
  77753. export interface IAction {
  77754. /**
  77755. * Trigger for the action
  77756. */
  77757. trigger: number;
  77758. /** Options of the trigger */
  77759. triggerOptions: any;
  77760. /**
  77761. * Gets the trigger parameters
  77762. * @returns the trigger parameters
  77763. */
  77764. getTriggerParameter(): any;
  77765. /**
  77766. * Internal only - executes current action event
  77767. * @hidden
  77768. */
  77769. _executeCurrent(evt?: ActionEvent): void;
  77770. /**
  77771. * Serialize placeholder for child classes
  77772. * @param parent of child
  77773. * @returns the serialized object
  77774. */
  77775. serialize(parent: any): any;
  77776. /**
  77777. * Internal only
  77778. * @hidden
  77779. */
  77780. _prepare(): void;
  77781. /**
  77782. * Internal only - manager for action
  77783. * @hidden
  77784. */
  77785. _actionManager: AbstractActionManager;
  77786. /**
  77787. * Adds action to chain of actions, may be a DoNothingAction
  77788. * @param action defines the next action to execute
  77789. * @returns The action passed in
  77790. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77791. */
  77792. then(action: IAction): IAction;
  77793. }
  77794. /**
  77795. * The action to be carried out following a trigger
  77796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77797. */
  77798. export class Action implements IAction {
  77799. /** the trigger, with or without parameters, for the action */
  77800. triggerOptions: any;
  77801. /**
  77802. * Trigger for the action
  77803. */
  77804. trigger: number;
  77805. /**
  77806. * Internal only - manager for action
  77807. * @hidden
  77808. */
  77809. _actionManager: ActionManager;
  77810. private _nextActiveAction;
  77811. private _child;
  77812. private _condition?;
  77813. private _triggerParameter;
  77814. /**
  77815. * An event triggered prior to action being executed.
  77816. */
  77817. onBeforeExecuteObservable: Observable<Action>;
  77818. /**
  77819. * Creates a new Action
  77820. * @param triggerOptions the trigger, with or without parameters, for the action
  77821. * @param condition an optional determinant of action
  77822. */
  77823. constructor(
  77824. /** the trigger, with or without parameters, for the action */
  77825. triggerOptions: any, condition?: Condition);
  77826. /**
  77827. * Internal only
  77828. * @hidden
  77829. */
  77830. _prepare(): void;
  77831. /**
  77832. * Gets the trigger parameters
  77833. * @returns the trigger parameters
  77834. */
  77835. getTriggerParameter(): any;
  77836. /**
  77837. * Internal only - executes current action event
  77838. * @hidden
  77839. */
  77840. _executeCurrent(evt?: ActionEvent): void;
  77841. /**
  77842. * Execute placeholder for child classes
  77843. * @param evt optional action event
  77844. */
  77845. execute(evt?: ActionEvent): void;
  77846. /**
  77847. * Skips to next active action
  77848. */
  77849. skipToNextActiveAction(): void;
  77850. /**
  77851. * Adds action to chain of actions, may be a DoNothingAction
  77852. * @param action defines the next action to execute
  77853. * @returns The action passed in
  77854. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77855. */
  77856. then(action: Action): Action;
  77857. /**
  77858. * Internal only
  77859. * @hidden
  77860. */
  77861. _getProperty(propertyPath: string): string;
  77862. /**
  77863. * Internal only
  77864. * @hidden
  77865. */
  77866. _getEffectiveTarget(target: any, propertyPath: string): any;
  77867. /**
  77868. * Serialize placeholder for child classes
  77869. * @param parent of child
  77870. * @returns the serialized object
  77871. */
  77872. serialize(parent: any): any;
  77873. /**
  77874. * Internal only called by serialize
  77875. * @hidden
  77876. */
  77877. protected _serialize(serializedAction: any, parent?: any): any;
  77878. /**
  77879. * Internal only
  77880. * @hidden
  77881. */
  77882. static _SerializeValueAsString: (value: any) => string;
  77883. /**
  77884. * Internal only
  77885. * @hidden
  77886. */
  77887. static _GetTargetProperty: (target: Node | Scene) => {
  77888. name: string;
  77889. targetType: string;
  77890. value: string;
  77891. };
  77892. }
  77893. }
  77894. declare module BABYLON {
  77895. /**
  77896. * A Condition applied to an Action
  77897. */
  77898. export class Condition {
  77899. /**
  77900. * Internal only - manager for action
  77901. * @hidden
  77902. */
  77903. _actionManager: ActionManager;
  77904. /**
  77905. * Internal only
  77906. * @hidden
  77907. */
  77908. _evaluationId: number;
  77909. /**
  77910. * Internal only
  77911. * @hidden
  77912. */
  77913. _currentResult: boolean;
  77914. /**
  77915. * Creates a new Condition
  77916. * @param actionManager the manager of the action the condition is applied to
  77917. */
  77918. constructor(actionManager: ActionManager);
  77919. /**
  77920. * Check if the current condition is valid
  77921. * @returns a boolean
  77922. */
  77923. isValid(): boolean;
  77924. /**
  77925. * Internal only
  77926. * @hidden
  77927. */
  77928. _getProperty(propertyPath: string): string;
  77929. /**
  77930. * Internal only
  77931. * @hidden
  77932. */
  77933. _getEffectiveTarget(target: any, propertyPath: string): any;
  77934. /**
  77935. * Serialize placeholder for child classes
  77936. * @returns the serialized object
  77937. */
  77938. serialize(): any;
  77939. /**
  77940. * Internal only
  77941. * @hidden
  77942. */
  77943. protected _serialize(serializedCondition: any): any;
  77944. }
  77945. /**
  77946. * Defines specific conditional operators as extensions of Condition
  77947. */
  77948. export class ValueCondition extends Condition {
  77949. /** path to specify the property of the target the conditional operator uses */
  77950. propertyPath: string;
  77951. /** the value compared by the conditional operator against the current value of the property */
  77952. value: any;
  77953. /** the conditional operator, default ValueCondition.IsEqual */
  77954. operator: number;
  77955. /**
  77956. * Internal only
  77957. * @hidden
  77958. */
  77959. private static _IsEqual;
  77960. /**
  77961. * Internal only
  77962. * @hidden
  77963. */
  77964. private static _IsDifferent;
  77965. /**
  77966. * Internal only
  77967. * @hidden
  77968. */
  77969. private static _IsGreater;
  77970. /**
  77971. * Internal only
  77972. * @hidden
  77973. */
  77974. private static _IsLesser;
  77975. /**
  77976. * returns the number for IsEqual
  77977. */
  77978. static readonly IsEqual: number;
  77979. /**
  77980. * Returns the number for IsDifferent
  77981. */
  77982. static readonly IsDifferent: number;
  77983. /**
  77984. * Returns the number for IsGreater
  77985. */
  77986. static readonly IsGreater: number;
  77987. /**
  77988. * Returns the number for IsLesser
  77989. */
  77990. static readonly IsLesser: number;
  77991. /**
  77992. * Internal only The action manager for the condition
  77993. * @hidden
  77994. */
  77995. _actionManager: ActionManager;
  77996. /**
  77997. * Internal only
  77998. * @hidden
  77999. */
  78000. private _target;
  78001. /**
  78002. * Internal only
  78003. * @hidden
  78004. */
  78005. private _effectiveTarget;
  78006. /**
  78007. * Internal only
  78008. * @hidden
  78009. */
  78010. private _property;
  78011. /**
  78012. * Creates a new ValueCondition
  78013. * @param actionManager manager for the action the condition applies to
  78014. * @param target for the action
  78015. * @param propertyPath path to specify the property of the target the conditional operator uses
  78016. * @param value the value compared by the conditional operator against the current value of the property
  78017. * @param operator the conditional operator, default ValueCondition.IsEqual
  78018. */
  78019. constructor(actionManager: ActionManager, target: any,
  78020. /** path to specify the property of the target the conditional operator uses */
  78021. propertyPath: string,
  78022. /** the value compared by the conditional operator against the current value of the property */
  78023. value: any,
  78024. /** the conditional operator, default ValueCondition.IsEqual */
  78025. operator?: number);
  78026. /**
  78027. * Compares the given value with the property value for the specified conditional operator
  78028. * @returns the result of the comparison
  78029. */
  78030. isValid(): boolean;
  78031. /**
  78032. * Serialize the ValueCondition into a JSON compatible object
  78033. * @returns serialization object
  78034. */
  78035. serialize(): any;
  78036. /**
  78037. * Gets the name of the conditional operator for the ValueCondition
  78038. * @param operator the conditional operator
  78039. * @returns the name
  78040. */
  78041. static GetOperatorName(operator: number): string;
  78042. }
  78043. /**
  78044. * Defines a predicate condition as an extension of Condition
  78045. */
  78046. export class PredicateCondition extends Condition {
  78047. /** defines the predicate function used to validate the condition */
  78048. predicate: () => boolean;
  78049. /**
  78050. * Internal only - manager for action
  78051. * @hidden
  78052. */
  78053. _actionManager: ActionManager;
  78054. /**
  78055. * Creates a new PredicateCondition
  78056. * @param actionManager manager for the action the condition applies to
  78057. * @param predicate defines the predicate function used to validate the condition
  78058. */
  78059. constructor(actionManager: ActionManager,
  78060. /** defines the predicate function used to validate the condition */
  78061. predicate: () => boolean);
  78062. /**
  78063. * @returns the validity of the predicate condition
  78064. */
  78065. isValid(): boolean;
  78066. }
  78067. /**
  78068. * Defines a state condition as an extension of Condition
  78069. */
  78070. export class StateCondition extends Condition {
  78071. /** Value to compare with target state */
  78072. value: string;
  78073. /**
  78074. * Internal only - manager for action
  78075. * @hidden
  78076. */
  78077. _actionManager: ActionManager;
  78078. /**
  78079. * Internal only
  78080. * @hidden
  78081. */
  78082. private _target;
  78083. /**
  78084. * Creates a new StateCondition
  78085. * @param actionManager manager for the action the condition applies to
  78086. * @param target of the condition
  78087. * @param value to compare with target state
  78088. */
  78089. constructor(actionManager: ActionManager, target: any,
  78090. /** Value to compare with target state */
  78091. value: string);
  78092. /**
  78093. * Gets a boolean indicating if the current condition is met
  78094. * @returns the validity of the state
  78095. */
  78096. isValid(): boolean;
  78097. /**
  78098. * Serialize the StateCondition into a JSON compatible object
  78099. * @returns serialization object
  78100. */
  78101. serialize(): any;
  78102. }
  78103. }
  78104. declare module BABYLON {
  78105. /**
  78106. * This defines an action responsible to toggle a boolean once triggered.
  78107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78108. */
  78109. export class SwitchBooleanAction extends Action {
  78110. /**
  78111. * The path to the boolean property in the target object
  78112. */
  78113. propertyPath: string;
  78114. private _target;
  78115. private _effectiveTarget;
  78116. private _property;
  78117. /**
  78118. * Instantiate the action
  78119. * @param triggerOptions defines the trigger options
  78120. * @param target defines the object containing the boolean
  78121. * @param propertyPath defines the path to the boolean property in the target object
  78122. * @param condition defines the trigger related conditions
  78123. */
  78124. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78125. /** @hidden */
  78126. _prepare(): void;
  78127. /**
  78128. * Execute the action toggle the boolean value.
  78129. */
  78130. execute(): void;
  78131. /**
  78132. * Serializes the actions and its related information.
  78133. * @param parent defines the object to serialize in
  78134. * @returns the serialized object
  78135. */
  78136. serialize(parent: any): any;
  78137. }
  78138. /**
  78139. * This defines an action responsible to set a the state field of the target
  78140. * to a desired value once triggered.
  78141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78142. */
  78143. export class SetStateAction extends Action {
  78144. /**
  78145. * The value to store in the state field.
  78146. */
  78147. value: string;
  78148. private _target;
  78149. /**
  78150. * Instantiate the action
  78151. * @param triggerOptions defines the trigger options
  78152. * @param target defines the object containing the state property
  78153. * @param value defines the value to store in the state field
  78154. * @param condition defines the trigger related conditions
  78155. */
  78156. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78157. /**
  78158. * Execute the action and store the value on the target state property.
  78159. */
  78160. execute(): void;
  78161. /**
  78162. * Serializes the actions and its related information.
  78163. * @param parent defines the object to serialize in
  78164. * @returns the serialized object
  78165. */
  78166. serialize(parent: any): any;
  78167. }
  78168. /**
  78169. * This defines an action responsible to set a property of the target
  78170. * to a desired value once triggered.
  78171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78172. */
  78173. export class SetValueAction extends Action {
  78174. /**
  78175. * The path of the property to set in the target.
  78176. */
  78177. propertyPath: string;
  78178. /**
  78179. * The value to set in the property
  78180. */
  78181. value: any;
  78182. private _target;
  78183. private _effectiveTarget;
  78184. private _property;
  78185. /**
  78186. * Instantiate the action
  78187. * @param triggerOptions defines the trigger options
  78188. * @param target defines the object containing the property
  78189. * @param propertyPath defines the path of the property to set in the target
  78190. * @param value defines the value to set in the property
  78191. * @param condition defines the trigger related conditions
  78192. */
  78193. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78194. /** @hidden */
  78195. _prepare(): void;
  78196. /**
  78197. * Execute the action and set the targetted property to the desired value.
  78198. */
  78199. execute(): void;
  78200. /**
  78201. * Serializes the actions and its related information.
  78202. * @param parent defines the object to serialize in
  78203. * @returns the serialized object
  78204. */
  78205. serialize(parent: any): any;
  78206. }
  78207. /**
  78208. * This defines an action responsible to increment the target value
  78209. * to a desired value once triggered.
  78210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78211. */
  78212. export class IncrementValueAction extends Action {
  78213. /**
  78214. * The path of the property to increment in the target.
  78215. */
  78216. propertyPath: string;
  78217. /**
  78218. * The value we should increment the property by.
  78219. */
  78220. value: any;
  78221. private _target;
  78222. private _effectiveTarget;
  78223. private _property;
  78224. /**
  78225. * Instantiate the action
  78226. * @param triggerOptions defines the trigger options
  78227. * @param target defines the object containing the property
  78228. * @param propertyPath defines the path of the property to increment in the target
  78229. * @param value defines the value value we should increment the property by
  78230. * @param condition defines the trigger related conditions
  78231. */
  78232. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78233. /** @hidden */
  78234. _prepare(): void;
  78235. /**
  78236. * Execute the action and increment the target of the value amount.
  78237. */
  78238. execute(): void;
  78239. /**
  78240. * Serializes the actions and its related information.
  78241. * @param parent defines the object to serialize in
  78242. * @returns the serialized object
  78243. */
  78244. serialize(parent: any): any;
  78245. }
  78246. /**
  78247. * This defines an action responsible to start an animation once triggered.
  78248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78249. */
  78250. export class PlayAnimationAction extends Action {
  78251. /**
  78252. * Where the animation should start (animation frame)
  78253. */
  78254. from: number;
  78255. /**
  78256. * Where the animation should stop (animation frame)
  78257. */
  78258. to: number;
  78259. /**
  78260. * Define if the animation should loop or stop after the first play.
  78261. */
  78262. loop?: boolean;
  78263. private _target;
  78264. /**
  78265. * Instantiate the action
  78266. * @param triggerOptions defines the trigger options
  78267. * @param target defines the target animation or animation name
  78268. * @param from defines from where the animation should start (animation frame)
  78269. * @param end defines where the animation should stop (animation frame)
  78270. * @param loop defines if the animation should loop or stop after the first play
  78271. * @param condition defines the trigger related conditions
  78272. */
  78273. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78274. /** @hidden */
  78275. _prepare(): void;
  78276. /**
  78277. * Execute the action and play the animation.
  78278. */
  78279. execute(): void;
  78280. /**
  78281. * Serializes the actions and its related information.
  78282. * @param parent defines the object to serialize in
  78283. * @returns the serialized object
  78284. */
  78285. serialize(parent: any): any;
  78286. }
  78287. /**
  78288. * This defines an action responsible to stop an animation once triggered.
  78289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78290. */
  78291. export class StopAnimationAction extends Action {
  78292. private _target;
  78293. /**
  78294. * Instantiate the action
  78295. * @param triggerOptions defines the trigger options
  78296. * @param target defines the target animation or animation name
  78297. * @param condition defines the trigger related conditions
  78298. */
  78299. constructor(triggerOptions: any, target: any, condition?: Condition);
  78300. /** @hidden */
  78301. _prepare(): void;
  78302. /**
  78303. * Execute the action and stop the animation.
  78304. */
  78305. execute(): void;
  78306. /**
  78307. * Serializes the actions and its related information.
  78308. * @param parent defines the object to serialize in
  78309. * @returns the serialized object
  78310. */
  78311. serialize(parent: any): any;
  78312. }
  78313. /**
  78314. * This defines an action responsible that does nothing once triggered.
  78315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78316. */
  78317. export class DoNothingAction extends Action {
  78318. /**
  78319. * Instantiate the action
  78320. * @param triggerOptions defines the trigger options
  78321. * @param condition defines the trigger related conditions
  78322. */
  78323. constructor(triggerOptions?: any, condition?: Condition);
  78324. /**
  78325. * Execute the action and do nothing.
  78326. */
  78327. execute(): void;
  78328. /**
  78329. * Serializes the actions and its related information.
  78330. * @param parent defines the object to serialize in
  78331. * @returns the serialized object
  78332. */
  78333. serialize(parent: any): any;
  78334. }
  78335. /**
  78336. * This defines an action responsible to trigger several actions once triggered.
  78337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78338. */
  78339. export class CombineAction extends Action {
  78340. /**
  78341. * The list of aggregated animations to run.
  78342. */
  78343. children: Action[];
  78344. /**
  78345. * Instantiate the action
  78346. * @param triggerOptions defines the trigger options
  78347. * @param children defines the list of aggregated animations to run
  78348. * @param condition defines the trigger related conditions
  78349. */
  78350. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78351. /** @hidden */
  78352. _prepare(): void;
  78353. /**
  78354. * Execute the action and executes all the aggregated actions.
  78355. */
  78356. execute(evt: ActionEvent): void;
  78357. /**
  78358. * Serializes the actions and its related information.
  78359. * @param parent defines the object to serialize in
  78360. * @returns the serialized object
  78361. */
  78362. serialize(parent: any): any;
  78363. }
  78364. /**
  78365. * This defines an action responsible to run code (external event) once triggered.
  78366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78367. */
  78368. export class ExecuteCodeAction extends Action {
  78369. /**
  78370. * The callback function to run.
  78371. */
  78372. func: (evt: ActionEvent) => void;
  78373. /**
  78374. * Instantiate the action
  78375. * @param triggerOptions defines the trigger options
  78376. * @param func defines the callback function to run
  78377. * @param condition defines the trigger related conditions
  78378. */
  78379. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78380. /**
  78381. * Execute the action and run the attached code.
  78382. */
  78383. execute(evt: ActionEvent): void;
  78384. }
  78385. /**
  78386. * This defines an action responsible to set the parent property of the target once triggered.
  78387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78388. */
  78389. export class SetParentAction extends Action {
  78390. private _parent;
  78391. private _target;
  78392. /**
  78393. * Instantiate the action
  78394. * @param triggerOptions defines the trigger options
  78395. * @param target defines the target containing the parent property
  78396. * @param parent defines from where the animation should start (animation frame)
  78397. * @param condition defines the trigger related conditions
  78398. */
  78399. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78400. /** @hidden */
  78401. _prepare(): void;
  78402. /**
  78403. * Execute the action and set the parent property.
  78404. */
  78405. execute(): void;
  78406. /**
  78407. * Serializes the actions and its related information.
  78408. * @param parent defines the object to serialize in
  78409. * @returns the serialized object
  78410. */
  78411. serialize(parent: any): any;
  78412. }
  78413. }
  78414. declare module BABYLON {
  78415. /**
  78416. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78417. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78419. */
  78420. export class ActionManager extends AbstractActionManager {
  78421. /**
  78422. * Nothing
  78423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78424. */
  78425. static readonly NothingTrigger: number;
  78426. /**
  78427. * On pick
  78428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78429. */
  78430. static readonly OnPickTrigger: number;
  78431. /**
  78432. * On left pick
  78433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78434. */
  78435. static readonly OnLeftPickTrigger: number;
  78436. /**
  78437. * On right pick
  78438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78439. */
  78440. static readonly OnRightPickTrigger: number;
  78441. /**
  78442. * On center pick
  78443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78444. */
  78445. static readonly OnCenterPickTrigger: number;
  78446. /**
  78447. * On pick down
  78448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78449. */
  78450. static readonly OnPickDownTrigger: number;
  78451. /**
  78452. * On double pick
  78453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78454. */
  78455. static readonly OnDoublePickTrigger: number;
  78456. /**
  78457. * On pick up
  78458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78459. */
  78460. static readonly OnPickUpTrigger: number;
  78461. /**
  78462. * On pick out.
  78463. * This trigger will only be raised if you also declared a OnPickDown
  78464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78465. */
  78466. static readonly OnPickOutTrigger: number;
  78467. /**
  78468. * On long press
  78469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78470. */
  78471. static readonly OnLongPressTrigger: number;
  78472. /**
  78473. * On pointer over
  78474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78475. */
  78476. static readonly OnPointerOverTrigger: number;
  78477. /**
  78478. * On pointer out
  78479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78480. */
  78481. static readonly OnPointerOutTrigger: number;
  78482. /**
  78483. * On every frame
  78484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78485. */
  78486. static readonly OnEveryFrameTrigger: number;
  78487. /**
  78488. * On intersection enter
  78489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78490. */
  78491. static readonly OnIntersectionEnterTrigger: number;
  78492. /**
  78493. * On intersection exit
  78494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78495. */
  78496. static readonly OnIntersectionExitTrigger: number;
  78497. /**
  78498. * On key down
  78499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78500. */
  78501. static readonly OnKeyDownTrigger: number;
  78502. /**
  78503. * On key up
  78504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78505. */
  78506. static readonly OnKeyUpTrigger: number;
  78507. private _scene;
  78508. /**
  78509. * Creates a new action manager
  78510. * @param scene defines the hosting scene
  78511. */
  78512. constructor(scene: Scene);
  78513. /**
  78514. * Releases all associated resources
  78515. */
  78516. dispose(): void;
  78517. /**
  78518. * Gets hosting scene
  78519. * @returns the hosting scene
  78520. */
  78521. getScene(): Scene;
  78522. /**
  78523. * Does this action manager handles actions of any of the given triggers
  78524. * @param triggers defines the triggers to be tested
  78525. * @return a boolean indicating whether one (or more) of the triggers is handled
  78526. */
  78527. hasSpecificTriggers(triggers: number[]): boolean;
  78528. /**
  78529. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78530. * speed.
  78531. * @param triggerA defines the trigger to be tested
  78532. * @param triggerB defines the trigger to be tested
  78533. * @return a boolean indicating whether one (or more) of the triggers is handled
  78534. */
  78535. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78536. /**
  78537. * Does this action manager handles actions of a given trigger
  78538. * @param trigger defines the trigger to be tested
  78539. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78540. * @return whether the trigger is handled
  78541. */
  78542. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78543. /**
  78544. * Does this action manager has pointer triggers
  78545. */
  78546. readonly hasPointerTriggers: boolean;
  78547. /**
  78548. * Does this action manager has pick triggers
  78549. */
  78550. readonly hasPickTriggers: boolean;
  78551. /**
  78552. * Registers an action to this action manager
  78553. * @param action defines the action to be registered
  78554. * @return the action amended (prepared) after registration
  78555. */
  78556. registerAction(action: IAction): Nullable<IAction>;
  78557. /**
  78558. * Unregisters an action to this action manager
  78559. * @param action defines the action to be unregistered
  78560. * @return a boolean indicating whether the action has been unregistered
  78561. */
  78562. unregisterAction(action: IAction): Boolean;
  78563. /**
  78564. * Process a specific trigger
  78565. * @param trigger defines the trigger to process
  78566. * @param evt defines the event details to be processed
  78567. */
  78568. processTrigger(trigger: number, evt?: IActionEvent): void;
  78569. /** @hidden */
  78570. _getEffectiveTarget(target: any, propertyPath: string): any;
  78571. /** @hidden */
  78572. _getProperty(propertyPath: string): string;
  78573. /**
  78574. * Serialize this manager to a JSON object
  78575. * @param name defines the property name to store this manager
  78576. * @returns a JSON representation of this manager
  78577. */
  78578. serialize(name: string): any;
  78579. /**
  78580. * Creates a new ActionManager from a JSON data
  78581. * @param parsedActions defines the JSON data to read from
  78582. * @param object defines the hosting mesh
  78583. * @param scene defines the hosting scene
  78584. */
  78585. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78586. /**
  78587. * Get a trigger name by index
  78588. * @param trigger defines the trigger index
  78589. * @returns a trigger name
  78590. */
  78591. static GetTriggerName(trigger: number): string;
  78592. }
  78593. }
  78594. declare module BABYLON {
  78595. /**
  78596. * Class representing a ray with position and direction
  78597. */
  78598. export class Ray {
  78599. /** origin point */
  78600. origin: Vector3;
  78601. /** direction */
  78602. direction: Vector3;
  78603. /** length of the ray */
  78604. length: number;
  78605. private static readonly TmpVector3;
  78606. private _tmpRay;
  78607. /**
  78608. * Creates a new ray
  78609. * @param origin origin point
  78610. * @param direction direction
  78611. * @param length length of the ray
  78612. */
  78613. constructor(
  78614. /** origin point */
  78615. origin: Vector3,
  78616. /** direction */
  78617. direction: Vector3,
  78618. /** length of the ray */
  78619. length?: number);
  78620. /**
  78621. * Checks if the ray intersects a box
  78622. * @param minimum bound of the box
  78623. * @param maximum bound of the box
  78624. * @param intersectionTreshold extra extend to be added to the box in all direction
  78625. * @returns if the box was hit
  78626. */
  78627. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78628. /**
  78629. * Checks if the ray intersects a box
  78630. * @param box the bounding box to check
  78631. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78632. * @returns if the box was hit
  78633. */
  78634. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78635. /**
  78636. * If the ray hits a sphere
  78637. * @param sphere the bounding sphere to check
  78638. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78639. * @returns true if it hits the sphere
  78640. */
  78641. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78642. /**
  78643. * If the ray hits a triange
  78644. * @param vertex0 triangle vertex
  78645. * @param vertex1 triangle vertex
  78646. * @param vertex2 triangle vertex
  78647. * @returns intersection information if hit
  78648. */
  78649. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78650. /**
  78651. * Checks if ray intersects a plane
  78652. * @param plane the plane to check
  78653. * @returns the distance away it was hit
  78654. */
  78655. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78656. /**
  78657. * Calculate the intercept of a ray on a given axis
  78658. * @param axis to check 'x' | 'y' | 'z'
  78659. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  78660. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  78661. */
  78662. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  78663. /**
  78664. * Checks if ray intersects a mesh
  78665. * @param mesh the mesh to check
  78666. * @param fastCheck if only the bounding box should checked
  78667. * @returns picking info of the intersecton
  78668. */
  78669. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78670. /**
  78671. * Checks if ray intersects a mesh
  78672. * @param meshes the meshes to check
  78673. * @param fastCheck if only the bounding box should checked
  78674. * @param results array to store result in
  78675. * @returns Array of picking infos
  78676. */
  78677. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78678. private _comparePickingInfo;
  78679. private static smallnum;
  78680. private static rayl;
  78681. /**
  78682. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78683. * @param sega the first point of the segment to test the intersection against
  78684. * @param segb the second point of the segment to test the intersection against
  78685. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78686. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78687. */
  78688. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78689. /**
  78690. * Update the ray from viewport position
  78691. * @param x position
  78692. * @param y y position
  78693. * @param viewportWidth viewport width
  78694. * @param viewportHeight viewport height
  78695. * @param world world matrix
  78696. * @param view view matrix
  78697. * @param projection projection matrix
  78698. * @returns this ray updated
  78699. */
  78700. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78701. /**
  78702. * Creates a ray with origin and direction of 0,0,0
  78703. * @returns the new ray
  78704. */
  78705. static Zero(): Ray;
  78706. /**
  78707. * Creates a new ray from screen space and viewport
  78708. * @param x position
  78709. * @param y y position
  78710. * @param viewportWidth viewport width
  78711. * @param viewportHeight viewport height
  78712. * @param world world matrix
  78713. * @param view view matrix
  78714. * @param projection projection matrix
  78715. * @returns new ray
  78716. */
  78717. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78718. /**
  78719. * 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
  78720. * transformed to the given world matrix.
  78721. * @param origin The origin point
  78722. * @param end The end point
  78723. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78724. * @returns the new ray
  78725. */
  78726. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78727. /**
  78728. * Transforms a ray by a matrix
  78729. * @param ray ray to transform
  78730. * @param matrix matrix to apply
  78731. * @returns the resulting new ray
  78732. */
  78733. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78734. /**
  78735. * Transforms a ray by a matrix
  78736. * @param ray ray to transform
  78737. * @param matrix matrix to apply
  78738. * @param result ray to store result in
  78739. */
  78740. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78741. /**
  78742. * Unproject a ray from screen space to object space
  78743. * @param sourceX defines the screen space x coordinate to use
  78744. * @param sourceY defines the screen space y coordinate to use
  78745. * @param viewportWidth defines the current width of the viewport
  78746. * @param viewportHeight defines the current height of the viewport
  78747. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78748. * @param view defines the view matrix to use
  78749. * @param projection defines the projection matrix to use
  78750. */
  78751. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78752. }
  78753. /**
  78754. * Type used to define predicate used to select faces when a mesh intersection is detected
  78755. */
  78756. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78757. interface Scene {
  78758. /** @hidden */
  78759. _tempPickingRay: Nullable<Ray>;
  78760. /** @hidden */
  78761. _cachedRayForTransform: Ray;
  78762. /** @hidden */
  78763. _pickWithRayInverseMatrix: Matrix;
  78764. /** @hidden */
  78765. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78766. /** @hidden */
  78767. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78768. }
  78769. }
  78770. declare module BABYLON {
  78771. /**
  78772. * Groups all the scene component constants in one place to ease maintenance.
  78773. * @hidden
  78774. */
  78775. export class SceneComponentConstants {
  78776. static readonly NAME_EFFECTLAYER: string;
  78777. static readonly NAME_LAYER: string;
  78778. static readonly NAME_LENSFLARESYSTEM: string;
  78779. static readonly NAME_BOUNDINGBOXRENDERER: string;
  78780. static readonly NAME_PARTICLESYSTEM: string;
  78781. static readonly NAME_GAMEPAD: string;
  78782. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  78783. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  78784. static readonly NAME_DEPTHRENDERER: string;
  78785. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  78786. static readonly NAME_SPRITE: string;
  78787. static readonly NAME_OUTLINERENDERER: string;
  78788. static readonly NAME_PROCEDURALTEXTURE: string;
  78789. static readonly NAME_SHADOWGENERATOR: string;
  78790. static readonly NAME_OCTREE: string;
  78791. static readonly NAME_PHYSICSENGINE: string;
  78792. static readonly NAME_AUDIO: string;
  78793. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  78794. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78795. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  78796. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  78797. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  78798. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  78799. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  78800. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  78801. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  78802. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  78803. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  78804. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  78805. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  78806. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  78807. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  78808. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  78809. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  78810. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  78811. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  78812. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  78813. static readonly STEP_AFTERRENDER_AUDIO: number;
  78814. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78815. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78816. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78817. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78818. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78819. static readonly STEP_POINTERMOVE_SPRITE: number;
  78820. static readonly STEP_POINTERDOWN_SPRITE: number;
  78821. static readonly STEP_POINTERUP_SPRITE: number;
  78822. }
  78823. /**
  78824. * This represents a scene component.
  78825. *
  78826. * This is used to decouple the dependency the scene is having on the different workloads like
  78827. * layers, post processes...
  78828. */
  78829. export interface ISceneComponent {
  78830. /**
  78831. * The name of the component. Each component must have a unique name.
  78832. */
  78833. name: string;
  78834. /**
  78835. * The scene the component belongs to.
  78836. */
  78837. scene: Scene;
  78838. /**
  78839. * Register the component to one instance of a scene.
  78840. */
  78841. register(): void;
  78842. /**
  78843. * Rebuilds the elements related to this component in case of
  78844. * context lost for instance.
  78845. */
  78846. rebuild(): void;
  78847. /**
  78848. * Disposes the component and the associated ressources.
  78849. */
  78850. dispose(): void;
  78851. }
  78852. /**
  78853. * This represents a SERIALIZABLE scene component.
  78854. *
  78855. * This extends Scene Component to add Serialization methods on top.
  78856. */
  78857. export interface ISceneSerializableComponent extends ISceneComponent {
  78858. /**
  78859. * Adds all the elements from the container to the scene
  78860. * @param container the container holding the elements
  78861. */
  78862. addFromContainer(container: AbstractScene): void;
  78863. /**
  78864. * Removes all the elements in the container from the scene
  78865. * @param container contains the elements to remove
  78866. * @param dispose if the removed element should be disposed (default: false)
  78867. */
  78868. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78869. /**
  78870. * Serializes the component data to the specified json object
  78871. * @param serializationObject The object to serialize to
  78872. */
  78873. serialize(serializationObject: any): void;
  78874. }
  78875. /**
  78876. * Strong typing of a Mesh related stage step action
  78877. */
  78878. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78879. /**
  78880. * Strong typing of a Evaluate Sub Mesh related stage step action
  78881. */
  78882. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78883. /**
  78884. * Strong typing of a Active Mesh related stage step action
  78885. */
  78886. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78887. /**
  78888. * Strong typing of a Camera related stage step action
  78889. */
  78890. export type CameraStageAction = (camera: Camera) => void;
  78891. /**
  78892. * Strong typing of a Camera Frame buffer related stage step action
  78893. */
  78894. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78895. /**
  78896. * Strong typing of a Render Target related stage step action
  78897. */
  78898. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78899. /**
  78900. * Strong typing of a RenderingGroup related stage step action
  78901. */
  78902. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78903. /**
  78904. * Strong typing of a Mesh Render related stage step action
  78905. */
  78906. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78907. /**
  78908. * Strong typing of a simple stage step action
  78909. */
  78910. export type SimpleStageAction = () => void;
  78911. /**
  78912. * Strong typing of a render target action.
  78913. */
  78914. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78915. /**
  78916. * Strong typing of a pointer move action.
  78917. */
  78918. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78919. /**
  78920. * Strong typing of a pointer up/down action.
  78921. */
  78922. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78923. /**
  78924. * Representation of a stage in the scene (Basically a list of ordered steps)
  78925. * @hidden
  78926. */
  78927. export class Stage<T extends Function> extends Array<{
  78928. index: number;
  78929. component: ISceneComponent;
  78930. action: T;
  78931. }> {
  78932. /**
  78933. * Hide ctor from the rest of the world.
  78934. * @param items The items to add.
  78935. */
  78936. private constructor();
  78937. /**
  78938. * Creates a new Stage.
  78939. * @returns A new instance of a Stage
  78940. */
  78941. static Create<T extends Function>(): Stage<T>;
  78942. /**
  78943. * Registers a step in an ordered way in the targeted stage.
  78944. * @param index Defines the position to register the step in
  78945. * @param component Defines the component attached to the step
  78946. * @param action Defines the action to launch during the step
  78947. */
  78948. registerStep(index: number, component: ISceneComponent, action: T): void;
  78949. /**
  78950. * Clears all the steps from the stage.
  78951. */
  78952. clear(): void;
  78953. }
  78954. }
  78955. declare module BABYLON {
  78956. interface Scene {
  78957. /** @hidden */
  78958. _pointerOverSprite: Nullable<Sprite>;
  78959. /** @hidden */
  78960. _pickedDownSprite: Nullable<Sprite>;
  78961. /** @hidden */
  78962. _tempSpritePickingRay: Nullable<Ray>;
  78963. /**
  78964. * All of the sprite managers added to this scene
  78965. * @see http://doc.babylonjs.com/babylon101/sprites
  78966. */
  78967. spriteManagers: Array<ISpriteManager>;
  78968. /**
  78969. * An event triggered when sprites rendering is about to start
  78970. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78971. */
  78972. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78973. /**
  78974. * An event triggered when sprites rendering is done
  78975. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78976. */
  78977. onAfterSpritesRenderingObservable: Observable<Scene>;
  78978. /** @hidden */
  78979. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78980. /** Launch a ray to try to pick a sprite in the scene
  78981. * @param x position on screen
  78982. * @param y position on screen
  78983. * @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
  78984. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78985. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78986. * @returns a PickingInfo
  78987. */
  78988. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78989. /** Use the given ray to pick a sprite in the scene
  78990. * @param ray The ray (in world space) to use to pick meshes
  78991. * @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
  78992. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78993. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78994. * @returns a PickingInfo
  78995. */
  78996. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78997. /** @hidden */
  78998. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78999. /** Launch a ray to try to pick sprites in the scene
  79000. * @param x position on screen
  79001. * @param y position on screen
  79002. * @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
  79003. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79004. * @returns a PickingInfo array
  79005. */
  79006. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79007. /** Use the given ray to pick sprites in the scene
  79008. * @param ray The ray (in world space) to use to pick meshes
  79009. * @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
  79010. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79011. * @returns a PickingInfo array
  79012. */
  79013. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79014. /**
  79015. * Force the sprite under the pointer
  79016. * @param sprite defines the sprite to use
  79017. */
  79018. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79019. /**
  79020. * Gets the sprite under the pointer
  79021. * @returns a Sprite or null if no sprite is under the pointer
  79022. */
  79023. getPointerOverSprite(): Nullable<Sprite>;
  79024. }
  79025. /**
  79026. * Defines the sprite scene component responsible to manage sprites
  79027. * in a given scene.
  79028. */
  79029. export class SpriteSceneComponent implements ISceneComponent {
  79030. /**
  79031. * The component name helpfull to identify the component in the list of scene components.
  79032. */
  79033. readonly name: string;
  79034. /**
  79035. * The scene the component belongs to.
  79036. */
  79037. scene: Scene;
  79038. /** @hidden */
  79039. private _spritePredicate;
  79040. /**
  79041. * Creates a new instance of the component for the given scene
  79042. * @param scene Defines the scene to register the component in
  79043. */
  79044. constructor(scene: Scene);
  79045. /**
  79046. * Registers the component in a given scene
  79047. */
  79048. register(): void;
  79049. /**
  79050. * Rebuilds the elements related to this component in case of
  79051. * context lost for instance.
  79052. */
  79053. rebuild(): void;
  79054. /**
  79055. * Disposes the component and the associated ressources.
  79056. */
  79057. dispose(): void;
  79058. private _pickSpriteButKeepRay;
  79059. private _pointerMove;
  79060. private _pointerDown;
  79061. private _pointerUp;
  79062. }
  79063. }
  79064. declare module BABYLON {
  79065. /** @hidden */
  79066. export var fogFragmentDeclaration: {
  79067. name: string;
  79068. shader: string;
  79069. };
  79070. }
  79071. declare module BABYLON {
  79072. /** @hidden */
  79073. export var fogFragment: {
  79074. name: string;
  79075. shader: string;
  79076. };
  79077. }
  79078. declare module BABYLON {
  79079. /** @hidden */
  79080. export var spritesPixelShader: {
  79081. name: string;
  79082. shader: string;
  79083. };
  79084. }
  79085. declare module BABYLON {
  79086. /** @hidden */
  79087. export var fogVertexDeclaration: {
  79088. name: string;
  79089. shader: string;
  79090. };
  79091. }
  79092. declare module BABYLON {
  79093. /** @hidden */
  79094. export var spritesVertexShader: {
  79095. name: string;
  79096. shader: string;
  79097. };
  79098. }
  79099. declare module BABYLON {
  79100. /**
  79101. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79102. */
  79103. export interface ISpriteManager extends IDisposable {
  79104. /**
  79105. * Restricts the camera to viewing objects with the same layerMask.
  79106. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79107. */
  79108. layerMask: number;
  79109. /**
  79110. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79111. */
  79112. isPickable: boolean;
  79113. /**
  79114. * Specifies the rendering group id for this mesh (0 by default)
  79115. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79116. */
  79117. renderingGroupId: number;
  79118. /**
  79119. * Defines the list of sprites managed by the manager.
  79120. */
  79121. sprites: Array<Sprite>;
  79122. /**
  79123. * Tests the intersection of a sprite with a specific ray.
  79124. * @param ray The ray we are sending to test the collision
  79125. * @param camera The camera space we are sending rays in
  79126. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79127. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79128. * @returns picking info or null.
  79129. */
  79130. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79131. /**
  79132. * Intersects the sprites with a ray
  79133. * @param ray defines the ray to intersect with
  79134. * @param camera defines the current active camera
  79135. * @param predicate defines a predicate used to select candidate sprites
  79136. * @returns null if no hit or a PickingInfo array
  79137. */
  79138. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79139. /**
  79140. * Renders the list of sprites on screen.
  79141. */
  79142. render(): void;
  79143. }
  79144. /**
  79145. * Class used to manage multiple sprites on the same spritesheet
  79146. * @see http://doc.babylonjs.com/babylon101/sprites
  79147. */
  79148. export class SpriteManager implements ISpriteManager {
  79149. /** defines the manager's name */
  79150. name: string;
  79151. /** Gets the list of sprites */
  79152. sprites: Sprite[];
  79153. /** Gets or sets the rendering group id (0 by default) */
  79154. renderingGroupId: number;
  79155. /** Gets or sets camera layer mask */
  79156. layerMask: number;
  79157. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79158. fogEnabled: boolean;
  79159. /** Gets or sets a boolean indicating if the sprites are pickable */
  79160. isPickable: boolean;
  79161. /** Defines the default width of a cell in the spritesheet */
  79162. cellWidth: number;
  79163. /** Defines the default height of a cell in the spritesheet */
  79164. cellHeight: number;
  79165. /** Associative array from JSON sprite data file */
  79166. private _cellData;
  79167. /** Array of sprite names from JSON sprite data file */
  79168. private _spriteMap;
  79169. /** True when packed cell data from JSON file is ready*/
  79170. private _packedAndReady;
  79171. /**
  79172. * An event triggered when the manager is disposed.
  79173. */
  79174. onDisposeObservable: Observable<SpriteManager>;
  79175. private _onDisposeObserver;
  79176. /**
  79177. * Callback called when the manager is disposed
  79178. */
  79179. onDispose: () => void;
  79180. private _capacity;
  79181. private _fromPacked;
  79182. private _spriteTexture;
  79183. private _epsilon;
  79184. private _scene;
  79185. private _vertexData;
  79186. private _buffer;
  79187. private _vertexBuffers;
  79188. private _indexBuffer;
  79189. private _effectBase;
  79190. private _effectFog;
  79191. /**
  79192. * Gets or sets the spritesheet texture
  79193. */
  79194. texture: Texture;
  79195. /**
  79196. * Creates a new sprite manager
  79197. * @param name defines the manager's name
  79198. * @param imgUrl defines the sprite sheet url
  79199. * @param capacity defines the maximum allowed number of sprites
  79200. * @param cellSize defines the size of a sprite cell
  79201. * @param scene defines the hosting scene
  79202. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  79203. * @param samplingMode defines the smapling mode to use with spritesheet
  79204. * @param fromPacked set to false; do not alter
  79205. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  79206. */
  79207. constructor(
  79208. /** defines the manager's name */
  79209. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  79210. private _makePacked;
  79211. private _appendSpriteVertex;
  79212. /**
  79213. * Intersects the sprites with a ray
  79214. * @param ray defines the ray to intersect with
  79215. * @param camera defines the current active camera
  79216. * @param predicate defines a predicate used to select candidate sprites
  79217. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  79218. * @returns null if no hit or a PickingInfo
  79219. */
  79220. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79221. /**
  79222. * Intersects the sprites with a ray
  79223. * @param ray defines the ray to intersect with
  79224. * @param camera defines the current active camera
  79225. * @param predicate defines a predicate used to select candidate sprites
  79226. * @returns null if no hit or a PickingInfo array
  79227. */
  79228. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79229. /**
  79230. * Render all child sprites
  79231. */
  79232. render(): void;
  79233. /**
  79234. * Release associated resources
  79235. */
  79236. dispose(): void;
  79237. }
  79238. }
  79239. declare module BABYLON {
  79240. /**
  79241. * Class used to represent a sprite
  79242. * @see http://doc.babylonjs.com/babylon101/sprites
  79243. */
  79244. export class Sprite {
  79245. /** defines the name */
  79246. name: string;
  79247. /** Gets or sets the current world position */
  79248. position: Vector3;
  79249. /** Gets or sets the main color */
  79250. color: Color4;
  79251. /** Gets or sets the width */
  79252. width: number;
  79253. /** Gets or sets the height */
  79254. height: number;
  79255. /** Gets or sets rotation angle */
  79256. angle: number;
  79257. /** Gets or sets the cell index in the sprite sheet */
  79258. cellIndex: number;
  79259. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  79260. cellRef: string;
  79261. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  79262. invertU: number;
  79263. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  79264. invertV: number;
  79265. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  79266. disposeWhenFinishedAnimating: boolean;
  79267. /** Gets the list of attached animations */
  79268. animations: Animation[];
  79269. /** Gets or sets a boolean indicating if the sprite can be picked */
  79270. isPickable: boolean;
  79271. /**
  79272. * Gets or sets the associated action manager
  79273. */
  79274. actionManager: Nullable<ActionManager>;
  79275. private _animationStarted;
  79276. private _loopAnimation;
  79277. private _fromIndex;
  79278. private _toIndex;
  79279. private _delay;
  79280. private _direction;
  79281. private _manager;
  79282. private _time;
  79283. private _onAnimationEnd;
  79284. /**
  79285. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  79286. */
  79287. isVisible: boolean;
  79288. /**
  79289. * Gets or sets the sprite size
  79290. */
  79291. size: number;
  79292. /**
  79293. * Creates a new Sprite
  79294. * @param name defines the name
  79295. * @param manager defines the manager
  79296. */
  79297. constructor(
  79298. /** defines the name */
  79299. name: string, manager: ISpriteManager);
  79300. /**
  79301. * Starts an animation
  79302. * @param from defines the initial key
  79303. * @param to defines the end key
  79304. * @param loop defines if the animation must loop
  79305. * @param delay defines the start delay (in ms)
  79306. * @param onAnimationEnd defines a callback to call when animation ends
  79307. */
  79308. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  79309. /** Stops current animation (if any) */
  79310. stopAnimation(): void;
  79311. /** @hidden */
  79312. _animate(deltaTime: number): void;
  79313. /** Release associated resources */
  79314. dispose(): void;
  79315. }
  79316. }
  79317. declare module BABYLON {
  79318. /**
  79319. * Information about the result of picking within a scene
  79320. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  79321. */
  79322. export class PickingInfo {
  79323. /** @hidden */
  79324. _pickingUnavailable: boolean;
  79325. /**
  79326. * If the pick collided with an object
  79327. */
  79328. hit: boolean;
  79329. /**
  79330. * Distance away where the pick collided
  79331. */
  79332. distance: number;
  79333. /**
  79334. * The location of pick collision
  79335. */
  79336. pickedPoint: Nullable<Vector3>;
  79337. /**
  79338. * The mesh corresponding the the pick collision
  79339. */
  79340. pickedMesh: Nullable<AbstractMesh>;
  79341. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  79342. bu: number;
  79343. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  79344. bv: number;
  79345. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  79346. faceId: number;
  79347. /** Id of the the submesh that was picked */
  79348. subMeshId: number;
  79349. /** If a sprite was picked, this will be the sprite the pick collided with */
  79350. pickedSprite: Nullable<Sprite>;
  79351. /**
  79352. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  79353. */
  79354. originMesh: Nullable<AbstractMesh>;
  79355. /**
  79356. * The ray that was used to perform the picking.
  79357. */
  79358. ray: Nullable<Ray>;
  79359. /**
  79360. * Gets the normal correspodning to the face the pick collided with
  79361. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79362. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79363. * @returns The normal correspodning to the face the pick collided with
  79364. */
  79365. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79366. /**
  79367. * Gets the texture coordinates of where the pick occured
  79368. * @returns the vector containing the coordnates of the texture
  79369. */
  79370. getTextureCoordinates(): Nullable<Vector2>;
  79371. }
  79372. }
  79373. declare module BABYLON {
  79374. /**
  79375. * Gather the list of pointer event types as constants.
  79376. */
  79377. export class PointerEventTypes {
  79378. /**
  79379. * 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.
  79380. */
  79381. static readonly POINTERDOWN: number;
  79382. /**
  79383. * The pointerup event is fired when a pointer is no longer active.
  79384. */
  79385. static readonly POINTERUP: number;
  79386. /**
  79387. * The pointermove event is fired when a pointer changes coordinates.
  79388. */
  79389. static readonly POINTERMOVE: number;
  79390. /**
  79391. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79392. */
  79393. static readonly POINTERWHEEL: number;
  79394. /**
  79395. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79396. */
  79397. static readonly POINTERPICK: number;
  79398. /**
  79399. * The pointertap event is fired when a the object has been touched and released without drag.
  79400. */
  79401. static readonly POINTERTAP: number;
  79402. /**
  79403. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79404. */
  79405. static readonly POINTERDOUBLETAP: number;
  79406. }
  79407. /**
  79408. * Base class of pointer info types.
  79409. */
  79410. export class PointerInfoBase {
  79411. /**
  79412. * Defines the type of event (PointerEventTypes)
  79413. */
  79414. type: number;
  79415. /**
  79416. * Defines the related dom event
  79417. */
  79418. event: PointerEvent | MouseWheelEvent;
  79419. /**
  79420. * Instantiates the base class of pointers info.
  79421. * @param type Defines the type of event (PointerEventTypes)
  79422. * @param event Defines the related dom event
  79423. */
  79424. constructor(
  79425. /**
  79426. * Defines the type of event (PointerEventTypes)
  79427. */
  79428. type: number,
  79429. /**
  79430. * Defines the related dom event
  79431. */
  79432. event: PointerEvent | MouseWheelEvent);
  79433. }
  79434. /**
  79435. * This class is used to store pointer related info for the onPrePointerObservable event.
  79436. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79437. */
  79438. export class PointerInfoPre extends PointerInfoBase {
  79439. /**
  79440. * Ray from a pointer if availible (eg. 6dof controller)
  79441. */
  79442. ray: Nullable<Ray>;
  79443. /**
  79444. * Defines the local position of the pointer on the canvas.
  79445. */
  79446. localPosition: Vector2;
  79447. /**
  79448. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79449. */
  79450. skipOnPointerObservable: boolean;
  79451. /**
  79452. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79453. * @param type Defines the type of event (PointerEventTypes)
  79454. * @param event Defines the related dom event
  79455. * @param localX Defines the local x coordinates of the pointer when the event occured
  79456. * @param localY Defines the local y coordinates of the pointer when the event occured
  79457. */
  79458. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79459. }
  79460. /**
  79461. * This type contains all the data related to a pointer event in Babylon.js.
  79462. * 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.
  79463. */
  79464. export class PointerInfo extends PointerInfoBase {
  79465. /**
  79466. * Defines the picking info associated to the info (if any)\
  79467. */
  79468. pickInfo: Nullable<PickingInfo>;
  79469. /**
  79470. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79471. * @param type Defines the type of event (PointerEventTypes)
  79472. * @param event Defines the related dom event
  79473. * @param pickInfo Defines the picking info associated to the info (if any)\
  79474. */
  79475. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79476. /**
  79477. * Defines the picking info associated to the info (if any)\
  79478. */
  79479. pickInfo: Nullable<PickingInfo>);
  79480. }
  79481. /**
  79482. * Data relating to a touch event on the screen.
  79483. */
  79484. export interface PointerTouch {
  79485. /**
  79486. * X coordinate of touch.
  79487. */
  79488. x: number;
  79489. /**
  79490. * Y coordinate of touch.
  79491. */
  79492. y: number;
  79493. /**
  79494. * Id of touch. Unique for each finger.
  79495. */
  79496. pointerId: number;
  79497. /**
  79498. * Event type passed from DOM.
  79499. */
  79500. type: any;
  79501. }
  79502. }
  79503. declare module BABYLON {
  79504. /**
  79505. * Manage the mouse inputs to control the movement of a free camera.
  79506. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79507. */
  79508. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79509. /**
  79510. * Define if touch is enabled in the mouse input
  79511. */
  79512. touchEnabled: boolean;
  79513. /**
  79514. * Defines the camera the input is attached to.
  79515. */
  79516. camera: FreeCamera;
  79517. /**
  79518. * Defines the buttons associated with the input to handle camera move.
  79519. */
  79520. buttons: number[];
  79521. /**
  79522. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79523. */
  79524. angularSensibility: number;
  79525. private _pointerInput;
  79526. private _onMouseMove;
  79527. private _observer;
  79528. private previousPosition;
  79529. /**
  79530. * Observable for when a pointer move event occurs containing the move offset
  79531. */
  79532. onPointerMovedObservable: Observable<{
  79533. offsetX: number;
  79534. offsetY: number;
  79535. }>;
  79536. /**
  79537. * @hidden
  79538. * If the camera should be rotated automatically based on pointer movement
  79539. */
  79540. _allowCameraRotation: boolean;
  79541. /**
  79542. * Manage the mouse inputs to control the movement of a free camera.
  79543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79544. * @param touchEnabled Defines if touch is enabled or not
  79545. */
  79546. constructor(
  79547. /**
  79548. * Define if touch is enabled in the mouse input
  79549. */
  79550. touchEnabled?: boolean);
  79551. /**
  79552. * Attach the input controls to a specific dom element to get the input from.
  79553. * @param element Defines the element the controls should be listened from
  79554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79555. */
  79556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79557. /**
  79558. * Called on JS contextmenu event.
  79559. * Override this method to provide functionality.
  79560. */
  79561. protected onContextMenu(evt: PointerEvent): void;
  79562. /**
  79563. * Detach the current controls from the specified dom element.
  79564. * @param element Defines the element to stop listening the inputs from
  79565. */
  79566. detachControl(element: Nullable<HTMLElement>): void;
  79567. /**
  79568. * Gets the class name of the current intput.
  79569. * @returns the class name
  79570. */
  79571. getClassName(): string;
  79572. /**
  79573. * Get the friendly name associated with the input class.
  79574. * @returns the input friendly name
  79575. */
  79576. getSimpleName(): string;
  79577. }
  79578. }
  79579. declare module BABYLON {
  79580. /**
  79581. * Manage the touch inputs to control the movement of a free camera.
  79582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79583. */
  79584. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79585. /**
  79586. * Defines the camera the input is attached to.
  79587. */
  79588. camera: FreeCamera;
  79589. /**
  79590. * Defines the touch sensibility for rotation.
  79591. * The higher the faster.
  79592. */
  79593. touchAngularSensibility: number;
  79594. /**
  79595. * Defines the touch sensibility for move.
  79596. * The higher the faster.
  79597. */
  79598. touchMoveSensibility: number;
  79599. private _offsetX;
  79600. private _offsetY;
  79601. private _pointerPressed;
  79602. private _pointerInput;
  79603. private _observer;
  79604. private _onLostFocus;
  79605. /**
  79606. * Attach the input controls to a specific dom element to get the input from.
  79607. * @param element Defines the element the controls should be listened from
  79608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79609. */
  79610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79611. /**
  79612. * Detach the current controls from the specified dom element.
  79613. * @param element Defines the element to stop listening the inputs from
  79614. */
  79615. detachControl(element: Nullable<HTMLElement>): void;
  79616. /**
  79617. * Update the current camera state depending on the inputs that have been used this frame.
  79618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79619. */
  79620. checkInputs(): void;
  79621. /**
  79622. * Gets the class name of the current intput.
  79623. * @returns the class name
  79624. */
  79625. getClassName(): string;
  79626. /**
  79627. * Get the friendly name associated with the input class.
  79628. * @returns the input friendly name
  79629. */
  79630. getSimpleName(): string;
  79631. }
  79632. }
  79633. declare module BABYLON {
  79634. /**
  79635. * Default Inputs manager for the FreeCamera.
  79636. * It groups all the default supported inputs for ease of use.
  79637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79638. */
  79639. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79640. /**
  79641. * @hidden
  79642. */
  79643. _mouseInput: Nullable<FreeCameraMouseInput>;
  79644. /**
  79645. * Instantiates a new FreeCameraInputsManager.
  79646. * @param camera Defines the camera the inputs belong to
  79647. */
  79648. constructor(camera: FreeCamera);
  79649. /**
  79650. * Add keyboard input support to the input manager.
  79651. * @returns the current input manager
  79652. */
  79653. addKeyboard(): FreeCameraInputsManager;
  79654. /**
  79655. * Add mouse input support to the input manager.
  79656. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79657. * @returns the current input manager
  79658. */
  79659. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79660. /**
  79661. * Removes the mouse input support from the manager
  79662. * @returns the current input manager
  79663. */
  79664. removeMouse(): FreeCameraInputsManager;
  79665. /**
  79666. * Add touch input support to the input manager.
  79667. * @returns the current input manager
  79668. */
  79669. addTouch(): FreeCameraInputsManager;
  79670. /**
  79671. * Remove all attached input methods from a camera
  79672. */
  79673. clear(): void;
  79674. }
  79675. }
  79676. declare module BABYLON {
  79677. /**
  79678. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79679. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79680. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79681. */
  79682. export class FreeCamera extends TargetCamera {
  79683. /**
  79684. * Define the collision ellipsoid of the camera.
  79685. * This is helpful to simulate a camera body like the player body around the camera
  79686. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79687. */
  79688. ellipsoid: Vector3;
  79689. /**
  79690. * Define an offset for the position of the ellipsoid around the camera.
  79691. * This can be helpful to determine the center of the body near the gravity center of the body
  79692. * instead of its head.
  79693. */
  79694. ellipsoidOffset: Vector3;
  79695. /**
  79696. * Enable or disable collisions of the camera with the rest of the scene objects.
  79697. */
  79698. checkCollisions: boolean;
  79699. /**
  79700. * Enable or disable gravity on the camera.
  79701. */
  79702. applyGravity: boolean;
  79703. /**
  79704. * Define the input manager associated to the camera.
  79705. */
  79706. inputs: FreeCameraInputsManager;
  79707. /**
  79708. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79709. * Higher values reduce sensitivity.
  79710. */
  79711. /**
  79712. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79713. * Higher values reduce sensitivity.
  79714. */
  79715. angularSensibility: number;
  79716. /**
  79717. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79718. */
  79719. keysUp: number[];
  79720. /**
  79721. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79722. */
  79723. keysDown: number[];
  79724. /**
  79725. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79726. */
  79727. keysLeft: number[];
  79728. /**
  79729. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79730. */
  79731. keysRight: number[];
  79732. /**
  79733. * Event raised when the camera collide with a mesh in the scene.
  79734. */
  79735. onCollide: (collidedMesh: AbstractMesh) => void;
  79736. private _collider;
  79737. private _needMoveForGravity;
  79738. private _oldPosition;
  79739. private _diffPosition;
  79740. private _newPosition;
  79741. /** @hidden */
  79742. _localDirection: Vector3;
  79743. /** @hidden */
  79744. _transformedDirection: Vector3;
  79745. /**
  79746. * Instantiates a Free Camera.
  79747. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79748. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79749. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79750. * @param name Define the name of the camera in the scene
  79751. * @param position Define the start position of the camera in the scene
  79752. * @param scene Define the scene the camera belongs to
  79753. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79754. */
  79755. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79756. /**
  79757. * Attached controls to the current camera.
  79758. * @param element Defines the element the controls should be listened from
  79759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79760. */
  79761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79762. /**
  79763. * Detach the current controls from the camera.
  79764. * The camera will stop reacting to inputs.
  79765. * @param element Defines the element to stop listening the inputs from
  79766. */
  79767. detachControl(element: HTMLElement): void;
  79768. private _collisionMask;
  79769. /**
  79770. * Define a collision mask to limit the list of object the camera can collide with
  79771. */
  79772. collisionMask: number;
  79773. /** @hidden */
  79774. _collideWithWorld(displacement: Vector3): void;
  79775. private _onCollisionPositionChange;
  79776. /** @hidden */
  79777. _checkInputs(): void;
  79778. /** @hidden */
  79779. _decideIfNeedsToMove(): boolean;
  79780. /** @hidden */
  79781. _updatePosition(): void;
  79782. /**
  79783. * Destroy the camera and release the current resources hold by it.
  79784. */
  79785. dispose(): void;
  79786. /**
  79787. * Gets the current object class name.
  79788. * @return the class name
  79789. */
  79790. getClassName(): string;
  79791. }
  79792. }
  79793. declare module BABYLON {
  79794. /**
  79795. * Represents a gamepad control stick position
  79796. */
  79797. export class StickValues {
  79798. /**
  79799. * The x component of the control stick
  79800. */
  79801. x: number;
  79802. /**
  79803. * The y component of the control stick
  79804. */
  79805. y: number;
  79806. /**
  79807. * Initializes the gamepad x and y control stick values
  79808. * @param x The x component of the gamepad control stick value
  79809. * @param y The y component of the gamepad control stick value
  79810. */
  79811. constructor(
  79812. /**
  79813. * The x component of the control stick
  79814. */
  79815. x: number,
  79816. /**
  79817. * The y component of the control stick
  79818. */
  79819. y: number);
  79820. }
  79821. /**
  79822. * An interface which manages callbacks for gamepad button changes
  79823. */
  79824. export interface GamepadButtonChanges {
  79825. /**
  79826. * Called when a gamepad has been changed
  79827. */
  79828. changed: boolean;
  79829. /**
  79830. * Called when a gamepad press event has been triggered
  79831. */
  79832. pressChanged: boolean;
  79833. /**
  79834. * Called when a touch event has been triggered
  79835. */
  79836. touchChanged: boolean;
  79837. /**
  79838. * Called when a value has changed
  79839. */
  79840. valueChanged: boolean;
  79841. }
  79842. /**
  79843. * Represents a gamepad
  79844. */
  79845. export class Gamepad {
  79846. /**
  79847. * The id of the gamepad
  79848. */
  79849. id: string;
  79850. /**
  79851. * The index of the gamepad
  79852. */
  79853. index: number;
  79854. /**
  79855. * The browser gamepad
  79856. */
  79857. browserGamepad: any;
  79858. /**
  79859. * Specifies what type of gamepad this represents
  79860. */
  79861. type: number;
  79862. private _leftStick;
  79863. private _rightStick;
  79864. /** @hidden */
  79865. _isConnected: boolean;
  79866. private _leftStickAxisX;
  79867. private _leftStickAxisY;
  79868. private _rightStickAxisX;
  79869. private _rightStickAxisY;
  79870. /**
  79871. * Triggered when the left control stick has been changed
  79872. */
  79873. private _onleftstickchanged;
  79874. /**
  79875. * Triggered when the right control stick has been changed
  79876. */
  79877. private _onrightstickchanged;
  79878. /**
  79879. * Represents a gamepad controller
  79880. */
  79881. static GAMEPAD: number;
  79882. /**
  79883. * Represents a generic controller
  79884. */
  79885. static GENERIC: number;
  79886. /**
  79887. * Represents an XBox controller
  79888. */
  79889. static XBOX: number;
  79890. /**
  79891. * Represents a pose-enabled controller
  79892. */
  79893. static POSE_ENABLED: number;
  79894. /**
  79895. * Represents an Dual Shock controller
  79896. */
  79897. static DUALSHOCK: number;
  79898. /**
  79899. * Specifies whether the left control stick should be Y-inverted
  79900. */
  79901. protected _invertLeftStickY: boolean;
  79902. /**
  79903. * Specifies if the gamepad has been connected
  79904. */
  79905. readonly isConnected: boolean;
  79906. /**
  79907. * Initializes the gamepad
  79908. * @param id The id of the gamepad
  79909. * @param index The index of the gamepad
  79910. * @param browserGamepad The browser gamepad
  79911. * @param leftStickX The x component of the left joystick
  79912. * @param leftStickY The y component of the left joystick
  79913. * @param rightStickX The x component of the right joystick
  79914. * @param rightStickY The y component of the right joystick
  79915. */
  79916. constructor(
  79917. /**
  79918. * The id of the gamepad
  79919. */
  79920. id: string,
  79921. /**
  79922. * The index of the gamepad
  79923. */
  79924. index: number,
  79925. /**
  79926. * The browser gamepad
  79927. */
  79928. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79929. /**
  79930. * Callback triggered when the left joystick has changed
  79931. * @param callback
  79932. */
  79933. onleftstickchanged(callback: (values: StickValues) => void): void;
  79934. /**
  79935. * Callback triggered when the right joystick has changed
  79936. * @param callback
  79937. */
  79938. onrightstickchanged(callback: (values: StickValues) => void): void;
  79939. /**
  79940. * Gets the left joystick
  79941. */
  79942. /**
  79943. * Sets the left joystick values
  79944. */
  79945. leftStick: StickValues;
  79946. /**
  79947. * Gets the right joystick
  79948. */
  79949. /**
  79950. * Sets the right joystick value
  79951. */
  79952. rightStick: StickValues;
  79953. /**
  79954. * Updates the gamepad joystick positions
  79955. */
  79956. update(): void;
  79957. /**
  79958. * Disposes the gamepad
  79959. */
  79960. dispose(): void;
  79961. }
  79962. /**
  79963. * Represents a generic gamepad
  79964. */
  79965. export class GenericPad extends Gamepad {
  79966. private _buttons;
  79967. private _onbuttondown;
  79968. private _onbuttonup;
  79969. /**
  79970. * Observable triggered when a button has been pressed
  79971. */
  79972. onButtonDownObservable: Observable<number>;
  79973. /**
  79974. * Observable triggered when a button has been released
  79975. */
  79976. onButtonUpObservable: Observable<number>;
  79977. /**
  79978. * Callback triggered when a button has been pressed
  79979. * @param callback Called when a button has been pressed
  79980. */
  79981. onbuttondown(callback: (buttonPressed: number) => void): void;
  79982. /**
  79983. * Callback triggered when a button has been released
  79984. * @param callback Called when a button has been released
  79985. */
  79986. onbuttonup(callback: (buttonReleased: number) => void): void;
  79987. /**
  79988. * Initializes the generic gamepad
  79989. * @param id The id of the generic gamepad
  79990. * @param index The index of the generic gamepad
  79991. * @param browserGamepad The browser gamepad
  79992. */
  79993. constructor(id: string, index: number, browserGamepad: any);
  79994. private _setButtonValue;
  79995. /**
  79996. * Updates the generic gamepad
  79997. */
  79998. update(): void;
  79999. /**
  80000. * Disposes the generic gamepad
  80001. */
  80002. dispose(): void;
  80003. }
  80004. }
  80005. declare module BABYLON {
  80006. interface Engine {
  80007. /**
  80008. * Creates a raw texture
  80009. * @param data defines the data to store in the texture
  80010. * @param width defines the width of the texture
  80011. * @param height defines the height of the texture
  80012. * @param format defines the format of the data
  80013. * @param generateMipMaps defines if the engine should generate the mip levels
  80014. * @param invertY defines if data must be stored with Y axis inverted
  80015. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80016. * @param compression defines the compression used (null by default)
  80017. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80018. * @returns the raw texture inside an InternalTexture
  80019. */
  80020. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80021. /**
  80022. * Update a raw texture
  80023. * @param texture defines the texture to update
  80024. * @param data defines the data to store in the texture
  80025. * @param format defines the format of the data
  80026. * @param invertY defines if data must be stored with Y axis inverted
  80027. */
  80028. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80029. /**
  80030. * Update a raw texture
  80031. * @param texture defines the texture to update
  80032. * @param data defines the data to store in the texture
  80033. * @param format defines the format of the data
  80034. * @param invertY defines if data must be stored with Y axis inverted
  80035. * @param compression defines the compression used (null by default)
  80036. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80037. */
  80038. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80039. /**
  80040. * Creates a new raw cube texture
  80041. * @param data defines the array of data to use to create each face
  80042. * @param size defines the size of the textures
  80043. * @param format defines the format of the data
  80044. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80045. * @param generateMipMaps defines if the engine should generate the mip levels
  80046. * @param invertY defines if data must be stored with Y axis inverted
  80047. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80048. * @param compression defines the compression used (null by default)
  80049. * @returns the cube texture as an InternalTexture
  80050. */
  80051. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80052. /**
  80053. * Update a raw cube texture
  80054. * @param texture defines the texture to udpdate
  80055. * @param data defines the data to store
  80056. * @param format defines the data format
  80057. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80058. * @param invertY defines if data must be stored with Y axis inverted
  80059. */
  80060. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80061. /**
  80062. * Update a raw cube texture
  80063. * @param texture defines the texture to udpdate
  80064. * @param data defines the data to store
  80065. * @param format defines the data format
  80066. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80067. * @param invertY defines if data must be stored with Y axis inverted
  80068. * @param compression defines the compression used (null by default)
  80069. */
  80070. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80071. /**
  80072. * Update a raw cube texture
  80073. * @param texture defines the texture to udpdate
  80074. * @param data defines the data to store
  80075. * @param format defines the data format
  80076. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80077. * @param invertY defines if data must be stored with Y axis inverted
  80078. * @param compression defines the compression used (null by default)
  80079. * @param level defines which level of the texture to update
  80080. */
  80081. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80082. /**
  80083. * Creates a new raw cube texture from a specified url
  80084. * @param url defines the url where the data is located
  80085. * @param scene defines the current scene
  80086. * @param size defines the size of the textures
  80087. * @param format defines the format of the data
  80088. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80089. * @param noMipmap defines if the engine should avoid generating the mip levels
  80090. * @param callback defines a callback used to extract texture data from loaded data
  80091. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80092. * @param onLoad defines a callback called when texture is loaded
  80093. * @param onError defines a callback called if there is an error
  80094. * @returns the cube texture as an InternalTexture
  80095. */
  80096. 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;
  80097. /**
  80098. * Creates a new raw cube texture from a specified url
  80099. * @param url defines the url where the data is located
  80100. * @param scene defines the current scene
  80101. * @param size defines the size of the textures
  80102. * @param format defines the format of the data
  80103. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80104. * @param noMipmap defines if the engine should avoid generating the mip levels
  80105. * @param callback defines a callback used to extract texture data from loaded data
  80106. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80107. * @param onLoad defines a callback called when texture is loaded
  80108. * @param onError defines a callback called if there is an error
  80109. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80110. * @param invertY defines if data must be stored with Y axis inverted
  80111. * @returns the cube texture as an InternalTexture
  80112. */
  80113. 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;
  80114. /**
  80115. * Creates a new raw 3D texture
  80116. * @param data defines the data used to create the texture
  80117. * @param width defines the width of the texture
  80118. * @param height defines the height of the texture
  80119. * @param depth defines the depth of the texture
  80120. * @param format defines the format of the texture
  80121. * @param generateMipMaps defines if the engine must generate mip levels
  80122. * @param invertY defines if data must be stored with Y axis inverted
  80123. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80124. * @param compression defines the compressed used (can be null)
  80125. * @param textureType defines the compressed used (can be null)
  80126. * @returns a new raw 3D texture (stored in an InternalTexture)
  80127. */
  80128. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80129. /**
  80130. * Update a raw 3D texture
  80131. * @param texture defines the texture to update
  80132. * @param data defines the data to store
  80133. * @param format defines the data format
  80134. * @param invertY defines if data must be stored with Y axis inverted
  80135. */
  80136. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80137. /**
  80138. * Update a raw 3D texture
  80139. * @param texture defines the texture to update
  80140. * @param data defines the data to store
  80141. * @param format defines the data format
  80142. * @param invertY defines if data must be stored with Y axis inverted
  80143. * @param compression defines the used compression (can be null)
  80144. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80145. */
  80146. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80147. }
  80148. }
  80149. declare module BABYLON {
  80150. /**
  80151. * Raw texture can help creating a texture directly from an array of data.
  80152. * This can be super useful if you either get the data from an uncompressed source or
  80153. * if you wish to create your texture pixel by pixel.
  80154. */
  80155. export class RawTexture extends Texture {
  80156. /**
  80157. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80158. */
  80159. format: number;
  80160. private _engine;
  80161. /**
  80162. * Instantiates a new RawTexture.
  80163. * Raw texture can help creating a texture directly from an array of data.
  80164. * This can be super useful if you either get the data from an uncompressed source or
  80165. * if you wish to create your texture pixel by pixel.
  80166. * @param data define the array of data to use to create the texture
  80167. * @param width define the width of the texture
  80168. * @param height define the height of the texture
  80169. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80170. * @param scene define the scene the texture belongs to
  80171. * @param generateMipMaps define whether mip maps should be generated or not
  80172. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80173. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80174. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80175. */
  80176. constructor(data: ArrayBufferView, width: number, height: number,
  80177. /**
  80178. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80179. */
  80180. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80181. /**
  80182. * Updates the texture underlying data.
  80183. * @param data Define the new data of the texture
  80184. */
  80185. update(data: ArrayBufferView): void;
  80186. /**
  80187. * Creates a luminance texture from some data.
  80188. * @param data Define the texture data
  80189. * @param width Define the width of the texture
  80190. * @param height Define the height of the texture
  80191. * @param scene Define the scene the texture belongs to
  80192. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80193. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80194. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80195. * @returns the luminance texture
  80196. */
  80197. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80198. /**
  80199. * Creates a luminance alpha texture from some data.
  80200. * @param data Define the texture data
  80201. * @param width Define the width of the texture
  80202. * @param height Define the height of the texture
  80203. * @param scene Define the scene the texture belongs to
  80204. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80205. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80206. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80207. * @returns the luminance alpha texture
  80208. */
  80209. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80210. /**
  80211. * Creates an alpha texture from some data.
  80212. * @param data Define the texture data
  80213. * @param width Define the width of the texture
  80214. * @param height Define the height of the texture
  80215. * @param scene Define the scene the texture belongs to
  80216. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80217. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80218. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80219. * @returns the alpha texture
  80220. */
  80221. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80222. /**
  80223. * Creates a RGB texture from some data.
  80224. * @param data Define the texture data
  80225. * @param width Define the width of the texture
  80226. * @param height Define the height of the texture
  80227. * @param scene Define the scene the texture belongs to
  80228. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80229. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80230. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80231. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80232. * @returns the RGB alpha texture
  80233. */
  80234. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80235. /**
  80236. * Creates a RGBA texture from some data.
  80237. * @param data Define the texture data
  80238. * @param width Define the width of the texture
  80239. * @param height Define the height of the texture
  80240. * @param scene Define the scene the texture belongs to
  80241. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80242. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80243. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80244. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80245. * @returns the RGBA texture
  80246. */
  80247. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80248. /**
  80249. * Creates a R texture from some data.
  80250. * @param data Define the texture data
  80251. * @param width Define the width of the texture
  80252. * @param height Define the height of the texture
  80253. * @param scene Define the scene the texture belongs to
  80254. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80255. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80256. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80257. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80258. * @returns the R texture
  80259. */
  80260. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80261. }
  80262. }
  80263. declare module BABYLON {
  80264. /**
  80265. * Interface for the size containing width and height
  80266. */
  80267. export interface ISize {
  80268. /**
  80269. * Width
  80270. */
  80271. width: number;
  80272. /**
  80273. * Heighht
  80274. */
  80275. height: number;
  80276. }
  80277. /**
  80278. * Size containing widht and height
  80279. */
  80280. export class Size implements ISize {
  80281. /**
  80282. * Width
  80283. */
  80284. width: number;
  80285. /**
  80286. * Height
  80287. */
  80288. height: number;
  80289. /**
  80290. * Creates a Size object from the given width and height (floats).
  80291. * @param width width of the new size
  80292. * @param height height of the new size
  80293. */
  80294. constructor(width: number, height: number);
  80295. /**
  80296. * Returns a string with the Size width and height
  80297. * @returns a string with the Size width and height
  80298. */
  80299. toString(): string;
  80300. /**
  80301. * "Size"
  80302. * @returns the string "Size"
  80303. */
  80304. getClassName(): string;
  80305. /**
  80306. * Returns the Size hash code.
  80307. * @returns a hash code for a unique width and height
  80308. */
  80309. getHashCode(): number;
  80310. /**
  80311. * Updates the current size from the given one.
  80312. * @param src the given size
  80313. */
  80314. copyFrom(src: Size): void;
  80315. /**
  80316. * Updates in place the current Size from the given floats.
  80317. * @param width width of the new size
  80318. * @param height height of the new size
  80319. * @returns the updated Size.
  80320. */
  80321. copyFromFloats(width: number, height: number): Size;
  80322. /**
  80323. * Updates in place the current Size from the given floats.
  80324. * @param width width to set
  80325. * @param height height to set
  80326. * @returns the updated Size.
  80327. */
  80328. set(width: number, height: number): Size;
  80329. /**
  80330. * Multiplies the width and height by numbers
  80331. * @param w factor to multiple the width by
  80332. * @param h factor to multiple the height by
  80333. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  80334. */
  80335. multiplyByFloats(w: number, h: number): Size;
  80336. /**
  80337. * Clones the size
  80338. * @returns a new Size copied from the given one.
  80339. */
  80340. clone(): Size;
  80341. /**
  80342. * True if the current Size and the given one width and height are strictly equal.
  80343. * @param other the other size to compare against
  80344. * @returns True if the current Size and the given one width and height are strictly equal.
  80345. */
  80346. equals(other: Size): boolean;
  80347. /**
  80348. * The surface of the Size : width * height (float).
  80349. */
  80350. readonly surface: number;
  80351. /**
  80352. * Create a new size of zero
  80353. * @returns a new Size set to (0.0, 0.0)
  80354. */
  80355. static Zero(): Size;
  80356. /**
  80357. * Sums the width and height of two sizes
  80358. * @param otherSize size to add to this size
  80359. * @returns a new Size set as the addition result of the current Size and the given one.
  80360. */
  80361. add(otherSize: Size): Size;
  80362. /**
  80363. * Subtracts the width and height of two
  80364. * @param otherSize size to subtract to this size
  80365. * @returns a new Size set as the subtraction result of the given one from the current Size.
  80366. */
  80367. subtract(otherSize: Size): Size;
  80368. /**
  80369. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  80370. * @param start starting size to lerp between
  80371. * @param end end size to lerp between
  80372. * @param amount amount to lerp between the start and end values
  80373. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  80374. */
  80375. static Lerp(start: Size, end: Size, amount: number): Size;
  80376. }
  80377. }
  80378. declare module BABYLON {
  80379. /**
  80380. * Defines a runtime animation
  80381. */
  80382. export class RuntimeAnimation {
  80383. private _events;
  80384. /**
  80385. * The current frame of the runtime animation
  80386. */
  80387. private _currentFrame;
  80388. /**
  80389. * The animation used by the runtime animation
  80390. */
  80391. private _animation;
  80392. /**
  80393. * The target of the runtime animation
  80394. */
  80395. private _target;
  80396. /**
  80397. * The initiating animatable
  80398. */
  80399. private _host;
  80400. /**
  80401. * The original value of the runtime animation
  80402. */
  80403. private _originalValue;
  80404. /**
  80405. * The original blend value of the runtime animation
  80406. */
  80407. private _originalBlendValue;
  80408. /**
  80409. * The offsets cache of the runtime animation
  80410. */
  80411. private _offsetsCache;
  80412. /**
  80413. * The high limits cache of the runtime animation
  80414. */
  80415. private _highLimitsCache;
  80416. /**
  80417. * Specifies if the runtime animation has been stopped
  80418. */
  80419. private _stopped;
  80420. /**
  80421. * The blending factor of the runtime animation
  80422. */
  80423. private _blendingFactor;
  80424. /**
  80425. * The BabylonJS scene
  80426. */
  80427. private _scene;
  80428. /**
  80429. * The current value of the runtime animation
  80430. */
  80431. private _currentValue;
  80432. /** @hidden */
  80433. _animationState: _IAnimationState;
  80434. /**
  80435. * The active target of the runtime animation
  80436. */
  80437. private _activeTargets;
  80438. private _currentActiveTarget;
  80439. private _directTarget;
  80440. /**
  80441. * The target path of the runtime animation
  80442. */
  80443. private _targetPath;
  80444. /**
  80445. * The weight of the runtime animation
  80446. */
  80447. private _weight;
  80448. /**
  80449. * The ratio offset of the runtime animation
  80450. */
  80451. private _ratioOffset;
  80452. /**
  80453. * The previous delay of the runtime animation
  80454. */
  80455. private _previousDelay;
  80456. /**
  80457. * The previous ratio of the runtime animation
  80458. */
  80459. private _previousRatio;
  80460. private _enableBlending;
  80461. private _keys;
  80462. private _minFrame;
  80463. private _maxFrame;
  80464. private _minValue;
  80465. private _maxValue;
  80466. private _targetIsArray;
  80467. /**
  80468. * Gets the current frame of the runtime animation
  80469. */
  80470. readonly currentFrame: number;
  80471. /**
  80472. * Gets the weight of the runtime animation
  80473. */
  80474. readonly weight: number;
  80475. /**
  80476. * Gets the current value of the runtime animation
  80477. */
  80478. readonly currentValue: any;
  80479. /**
  80480. * Gets the target path of the runtime animation
  80481. */
  80482. readonly targetPath: string;
  80483. /**
  80484. * Gets the actual target of the runtime animation
  80485. */
  80486. readonly target: any;
  80487. /** @hidden */
  80488. _onLoop: () => void;
  80489. /**
  80490. * Create a new RuntimeAnimation object
  80491. * @param target defines the target of the animation
  80492. * @param animation defines the source animation object
  80493. * @param scene defines the hosting scene
  80494. * @param host defines the initiating Animatable
  80495. */
  80496. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80497. private _preparePath;
  80498. /**
  80499. * Gets the animation from the runtime animation
  80500. */
  80501. readonly animation: Animation;
  80502. /**
  80503. * Resets the runtime animation to the beginning
  80504. * @param restoreOriginal defines whether to restore the target property to the original value
  80505. */
  80506. reset(restoreOriginal?: boolean): void;
  80507. /**
  80508. * Specifies if the runtime animation is stopped
  80509. * @returns Boolean specifying if the runtime animation is stopped
  80510. */
  80511. isStopped(): boolean;
  80512. /**
  80513. * Disposes of the runtime animation
  80514. */
  80515. dispose(): void;
  80516. /**
  80517. * Apply the interpolated value to the target
  80518. * @param currentValue defines the value computed by the animation
  80519. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80520. */
  80521. setValue(currentValue: any, weight: number): void;
  80522. private _getOriginalValues;
  80523. private _setValue;
  80524. /**
  80525. * Gets the loop pmode of the runtime animation
  80526. * @returns Loop Mode
  80527. */
  80528. private _getCorrectLoopMode;
  80529. /**
  80530. * Move the current animation to a given frame
  80531. * @param frame defines the frame to move to
  80532. */
  80533. goToFrame(frame: number): void;
  80534. /**
  80535. * @hidden Internal use only
  80536. */
  80537. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80538. /**
  80539. * Execute the current animation
  80540. * @param delay defines the delay to add to the current frame
  80541. * @param from defines the lower bound of the animation range
  80542. * @param to defines the upper bound of the animation range
  80543. * @param loop defines if the current animation must loop
  80544. * @param speedRatio defines the current speed ratio
  80545. * @param weight defines the weight of the animation (default is -1 so no weight)
  80546. * @param onLoop optional callback called when animation loops
  80547. * @returns a boolean indicating if the animation is running
  80548. */
  80549. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80550. }
  80551. }
  80552. declare module BABYLON {
  80553. /**
  80554. * Class used to store an actual running animation
  80555. */
  80556. export class Animatable {
  80557. /** defines the target object */
  80558. target: any;
  80559. /** defines the starting frame number (default is 0) */
  80560. fromFrame: number;
  80561. /** defines the ending frame number (default is 100) */
  80562. toFrame: number;
  80563. /** defines if the animation must loop (default is false) */
  80564. loopAnimation: boolean;
  80565. /** defines a callback to call when animation ends if it is not looping */
  80566. onAnimationEnd?: (() => void) | null | undefined;
  80567. /** defines a callback to call when animation loops */
  80568. onAnimationLoop?: (() => void) | null | undefined;
  80569. private _localDelayOffset;
  80570. private _pausedDelay;
  80571. private _runtimeAnimations;
  80572. private _paused;
  80573. private _scene;
  80574. private _speedRatio;
  80575. private _weight;
  80576. private _syncRoot;
  80577. /**
  80578. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80579. * This will only apply for non looping animation (default is true)
  80580. */
  80581. disposeOnEnd: boolean;
  80582. /**
  80583. * Gets a boolean indicating if the animation has started
  80584. */
  80585. animationStarted: boolean;
  80586. /**
  80587. * Observer raised when the animation ends
  80588. */
  80589. onAnimationEndObservable: Observable<Animatable>;
  80590. /**
  80591. * Observer raised when the animation loops
  80592. */
  80593. onAnimationLoopObservable: Observable<Animatable>;
  80594. /**
  80595. * Gets the root Animatable used to synchronize and normalize animations
  80596. */
  80597. readonly syncRoot: Nullable<Animatable>;
  80598. /**
  80599. * Gets the current frame of the first RuntimeAnimation
  80600. * Used to synchronize Animatables
  80601. */
  80602. readonly masterFrame: number;
  80603. /**
  80604. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80605. */
  80606. weight: number;
  80607. /**
  80608. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80609. */
  80610. speedRatio: number;
  80611. /**
  80612. * Creates a new Animatable
  80613. * @param scene defines the hosting scene
  80614. * @param target defines the target object
  80615. * @param fromFrame defines the starting frame number (default is 0)
  80616. * @param toFrame defines the ending frame number (default is 100)
  80617. * @param loopAnimation defines if the animation must loop (default is false)
  80618. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80619. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80620. * @param animations defines a group of animation to add to the new Animatable
  80621. * @param onAnimationLoop defines a callback to call when animation loops
  80622. */
  80623. constructor(scene: Scene,
  80624. /** defines the target object */
  80625. target: any,
  80626. /** defines the starting frame number (default is 0) */
  80627. fromFrame?: number,
  80628. /** defines the ending frame number (default is 100) */
  80629. toFrame?: number,
  80630. /** defines if the animation must loop (default is false) */
  80631. loopAnimation?: boolean, speedRatio?: number,
  80632. /** defines a callback to call when animation ends if it is not looping */
  80633. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80634. /** defines a callback to call when animation loops */
  80635. onAnimationLoop?: (() => void) | null | undefined);
  80636. /**
  80637. * Synchronize and normalize current Animatable with a source Animatable
  80638. * This is useful when using animation weights and when animations are not of the same length
  80639. * @param root defines the root Animatable to synchronize with
  80640. * @returns the current Animatable
  80641. */
  80642. syncWith(root: Animatable): Animatable;
  80643. /**
  80644. * Gets the list of runtime animations
  80645. * @returns an array of RuntimeAnimation
  80646. */
  80647. getAnimations(): RuntimeAnimation[];
  80648. /**
  80649. * Adds more animations to the current animatable
  80650. * @param target defines the target of the animations
  80651. * @param animations defines the new animations to add
  80652. */
  80653. appendAnimations(target: any, animations: Animation[]): void;
  80654. /**
  80655. * Gets the source animation for a specific property
  80656. * @param property defines the propertyu to look for
  80657. * @returns null or the source animation for the given property
  80658. */
  80659. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80660. /**
  80661. * Gets the runtime animation for a specific property
  80662. * @param property defines the propertyu to look for
  80663. * @returns null or the runtime animation for the given property
  80664. */
  80665. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80666. /**
  80667. * Resets the animatable to its original state
  80668. */
  80669. reset(): void;
  80670. /**
  80671. * Allows the animatable to blend with current running animations
  80672. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80673. * @param blendingSpeed defines the blending speed to use
  80674. */
  80675. enableBlending(blendingSpeed: number): void;
  80676. /**
  80677. * Disable animation blending
  80678. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80679. */
  80680. disableBlending(): void;
  80681. /**
  80682. * Jump directly to a given frame
  80683. * @param frame defines the frame to jump to
  80684. */
  80685. goToFrame(frame: number): void;
  80686. /**
  80687. * Pause the animation
  80688. */
  80689. pause(): void;
  80690. /**
  80691. * Restart the animation
  80692. */
  80693. restart(): void;
  80694. private _raiseOnAnimationEnd;
  80695. /**
  80696. * Stop and delete the current animation
  80697. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80698. * @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)
  80699. */
  80700. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80701. /**
  80702. * Wait asynchronously for the animation to end
  80703. * @returns a promise which will be fullfilled when the animation ends
  80704. */
  80705. waitAsync(): Promise<Animatable>;
  80706. /** @hidden */
  80707. _animate(delay: number): boolean;
  80708. }
  80709. interface Scene {
  80710. /** @hidden */
  80711. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80712. /** @hidden */
  80713. _processLateAnimationBindingsForMatrices(holder: {
  80714. totalWeight: number;
  80715. animations: RuntimeAnimation[];
  80716. originalValue: Matrix;
  80717. }): any;
  80718. /** @hidden */
  80719. _processLateAnimationBindingsForQuaternions(holder: {
  80720. totalWeight: number;
  80721. animations: RuntimeAnimation[];
  80722. originalValue: Quaternion;
  80723. }, refQuaternion: Quaternion): Quaternion;
  80724. /** @hidden */
  80725. _processLateAnimationBindings(): void;
  80726. /**
  80727. * Will start the animation sequence of a given target
  80728. * @param target defines the target
  80729. * @param from defines from which frame should animation start
  80730. * @param to defines until which frame should animation run.
  80731. * @param weight defines the weight to apply to the animation (1.0 by default)
  80732. * @param loop defines if the animation loops
  80733. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80734. * @param onAnimationEnd defines the function to be executed when the animation ends
  80735. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80736. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80737. * @param onAnimationLoop defines the callback to call when an animation loops
  80738. * @returns the animatable object created for this animation
  80739. */
  80740. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80741. /**
  80742. * Will start the animation sequence of a given target
  80743. * @param target defines the target
  80744. * @param from defines from which frame should animation start
  80745. * @param to defines until which frame should animation run.
  80746. * @param loop defines if the animation loops
  80747. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80748. * @param onAnimationEnd defines the function to be executed when the animation ends
  80749. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80750. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80751. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80752. * @param onAnimationLoop defines the callback to call when an animation loops
  80753. * @returns the animatable object created for this animation
  80754. */
  80755. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80756. /**
  80757. * Will start the animation sequence of a given target and its hierarchy
  80758. * @param target defines the target
  80759. * @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.
  80760. * @param from defines from which frame should animation start
  80761. * @param to defines until which frame should animation run.
  80762. * @param loop defines if the animation loops
  80763. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80764. * @param onAnimationEnd defines the function to be executed when the animation ends
  80765. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80766. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80767. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80768. * @param onAnimationLoop defines the callback to call when an animation loops
  80769. * @returns the list of created animatables
  80770. */
  80771. 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[];
  80772. /**
  80773. * Begin a new animation on a given node
  80774. * @param target defines the target where the animation will take place
  80775. * @param animations defines the list of animations to start
  80776. * @param from defines the initial value
  80777. * @param to defines the final value
  80778. * @param loop defines if you want animation to loop (off by default)
  80779. * @param speedRatio defines the speed ratio to apply to all animations
  80780. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80781. * @param onAnimationLoop defines the callback to call when an animation loops
  80782. * @returns the list of created animatables
  80783. */
  80784. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80785. /**
  80786. * Begin a new animation on a given node and its hierarchy
  80787. * @param target defines the root node where the animation will take place
  80788. * @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.
  80789. * @param animations defines the list of animations to start
  80790. * @param from defines the initial value
  80791. * @param to defines the final value
  80792. * @param loop defines if you want animation to loop (off by default)
  80793. * @param speedRatio defines the speed ratio to apply to all animations
  80794. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80795. * @param onAnimationLoop defines the callback to call when an animation loops
  80796. * @returns the list of animatables created for all nodes
  80797. */
  80798. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80799. /**
  80800. * Gets the animatable associated with a specific target
  80801. * @param target defines the target of the animatable
  80802. * @returns the required animatable if found
  80803. */
  80804. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80805. /**
  80806. * Gets all animatables associated with a given target
  80807. * @param target defines the target to look animatables for
  80808. * @returns an array of Animatables
  80809. */
  80810. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80811. /**
  80812. * Stops and removes all animations that have been applied to the scene
  80813. */
  80814. stopAllAnimations(): void;
  80815. /**
  80816. * Gets the current delta time used by animation engine
  80817. */
  80818. deltaTime: number;
  80819. }
  80820. interface Bone {
  80821. /**
  80822. * Copy an animation range from another bone
  80823. * @param source defines the source bone
  80824. * @param rangeName defines the range name to copy
  80825. * @param frameOffset defines the frame offset
  80826. * @param rescaleAsRequired defines if rescaling must be applied if required
  80827. * @param skelDimensionsRatio defines the scaling ratio
  80828. * @returns true if operation was successful
  80829. */
  80830. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80831. }
  80832. }
  80833. declare module BABYLON {
  80834. /**
  80835. * Class used to override all child animations of a given target
  80836. */
  80837. export class AnimationPropertiesOverride {
  80838. /**
  80839. * Gets or sets a value indicating if animation blending must be used
  80840. */
  80841. enableBlending: boolean;
  80842. /**
  80843. * Gets or sets the blending speed to use when enableBlending is true
  80844. */
  80845. blendingSpeed: number;
  80846. /**
  80847. * Gets or sets the default loop mode to use
  80848. */
  80849. loopMode: number;
  80850. }
  80851. }
  80852. declare module BABYLON {
  80853. /**
  80854. * Class used to handle skinning animations
  80855. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80856. */
  80857. export class Skeleton implements IAnimatable {
  80858. /** defines the skeleton name */
  80859. name: string;
  80860. /** defines the skeleton Id */
  80861. id: string;
  80862. /**
  80863. * Defines the list of child bones
  80864. */
  80865. bones: Bone[];
  80866. /**
  80867. * Defines an estimate of the dimension of the skeleton at rest
  80868. */
  80869. dimensionsAtRest: Vector3;
  80870. /**
  80871. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80872. */
  80873. needInitialSkinMatrix: boolean;
  80874. /**
  80875. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80876. */
  80877. overrideMesh: Nullable<AbstractMesh>;
  80878. /**
  80879. * Gets the list of animations attached to this skeleton
  80880. */
  80881. animations: Array<Animation>;
  80882. private _scene;
  80883. private _isDirty;
  80884. private _transformMatrices;
  80885. private _transformMatrixTexture;
  80886. private _meshesWithPoseMatrix;
  80887. private _animatables;
  80888. private _identity;
  80889. private _synchronizedWithMesh;
  80890. private _ranges;
  80891. private _lastAbsoluteTransformsUpdateId;
  80892. private _canUseTextureForBones;
  80893. private _uniqueId;
  80894. /** @hidden */
  80895. _numBonesWithLinkedTransformNode: number;
  80896. /** @hidden */
  80897. _hasWaitingData: Nullable<boolean>;
  80898. /**
  80899. * Specifies if the skeleton should be serialized
  80900. */
  80901. doNotSerialize: boolean;
  80902. private _useTextureToStoreBoneMatrices;
  80903. /**
  80904. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80905. * Please note that this option is not available if the hardware does not support it
  80906. */
  80907. useTextureToStoreBoneMatrices: boolean;
  80908. private _animationPropertiesOverride;
  80909. /**
  80910. * Gets or sets the animation properties override
  80911. */
  80912. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80913. /**
  80914. * List of inspectable custom properties (used by the Inspector)
  80915. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80916. */
  80917. inspectableCustomProperties: IInspectable[];
  80918. /**
  80919. * An observable triggered before computing the skeleton's matrices
  80920. */
  80921. onBeforeComputeObservable: Observable<Skeleton>;
  80922. /**
  80923. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80924. */
  80925. readonly isUsingTextureForMatrices: boolean;
  80926. /**
  80927. * Gets the unique ID of this skeleton
  80928. */
  80929. readonly uniqueId: number;
  80930. /**
  80931. * Creates a new skeleton
  80932. * @param name defines the skeleton name
  80933. * @param id defines the skeleton Id
  80934. * @param scene defines the hosting scene
  80935. */
  80936. constructor(
  80937. /** defines the skeleton name */
  80938. name: string,
  80939. /** defines the skeleton Id */
  80940. id: string, scene: Scene);
  80941. /**
  80942. * Gets the current object class name.
  80943. * @return the class name
  80944. */
  80945. getClassName(): string;
  80946. /**
  80947. * Returns an array containing the root bones
  80948. * @returns an array containing the root bones
  80949. */
  80950. getChildren(): Array<Bone>;
  80951. /**
  80952. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80953. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80954. * @returns a Float32Array containing matrices data
  80955. */
  80956. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80957. /**
  80958. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80959. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80960. * @returns a raw texture containing the data
  80961. */
  80962. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80963. /**
  80964. * Gets the current hosting scene
  80965. * @returns a scene object
  80966. */
  80967. getScene(): Scene;
  80968. /**
  80969. * Gets a string representing the current skeleton data
  80970. * @param fullDetails defines a boolean indicating if we want a verbose version
  80971. * @returns a string representing the current skeleton data
  80972. */
  80973. toString(fullDetails?: boolean): string;
  80974. /**
  80975. * Get bone's index searching by name
  80976. * @param name defines bone's name to search for
  80977. * @return the indice of the bone. Returns -1 if not found
  80978. */
  80979. getBoneIndexByName(name: string): number;
  80980. /**
  80981. * Creater a new animation range
  80982. * @param name defines the name of the range
  80983. * @param from defines the start key
  80984. * @param to defines the end key
  80985. */
  80986. createAnimationRange(name: string, from: number, to: number): void;
  80987. /**
  80988. * Delete a specific animation range
  80989. * @param name defines the name of the range
  80990. * @param deleteFrames defines if frames must be removed as well
  80991. */
  80992. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80993. /**
  80994. * Gets a specific animation range
  80995. * @param name defines the name of the range to look for
  80996. * @returns the requested animation range or null if not found
  80997. */
  80998. getAnimationRange(name: string): Nullable<AnimationRange>;
  80999. /**
  81000. * Gets the list of all animation ranges defined on this skeleton
  81001. * @returns an array
  81002. */
  81003. getAnimationRanges(): Nullable<AnimationRange>[];
  81004. /**
  81005. * Copy animation range from a source skeleton.
  81006. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81007. * @param source defines the source skeleton
  81008. * @param name defines the name of the range to copy
  81009. * @param rescaleAsRequired defines if rescaling must be applied if required
  81010. * @returns true if operation was successful
  81011. */
  81012. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81013. /**
  81014. * Forces the skeleton to go to rest pose
  81015. */
  81016. returnToRest(): void;
  81017. private _getHighestAnimationFrame;
  81018. /**
  81019. * Begin a specific animation range
  81020. * @param name defines the name of the range to start
  81021. * @param loop defines if looping must be turned on (false by default)
  81022. * @param speedRatio defines the speed ratio to apply (1 by default)
  81023. * @param onAnimationEnd defines a callback which will be called when animation will end
  81024. * @returns a new animatable
  81025. */
  81026. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81027. /** @hidden */
  81028. _markAsDirty(): void;
  81029. /** @hidden */
  81030. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81031. /** @hidden */
  81032. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81033. private _computeTransformMatrices;
  81034. /**
  81035. * Build all resources required to render a skeleton
  81036. */
  81037. prepare(): void;
  81038. /**
  81039. * Gets the list of animatables currently running for this skeleton
  81040. * @returns an array of animatables
  81041. */
  81042. getAnimatables(): IAnimatable[];
  81043. /**
  81044. * Clone the current skeleton
  81045. * @param name defines the name of the new skeleton
  81046. * @param id defines the id of the new skeleton
  81047. * @returns the new skeleton
  81048. */
  81049. clone(name: string, id?: string): Skeleton;
  81050. /**
  81051. * Enable animation blending for this skeleton
  81052. * @param blendingSpeed defines the blending speed to apply
  81053. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81054. */
  81055. enableBlending(blendingSpeed?: number): void;
  81056. /**
  81057. * Releases all resources associated with the current skeleton
  81058. */
  81059. dispose(): void;
  81060. /**
  81061. * Serialize the skeleton in a JSON object
  81062. * @returns a JSON object
  81063. */
  81064. serialize(): any;
  81065. /**
  81066. * Creates a new skeleton from serialized data
  81067. * @param parsedSkeleton defines the serialized data
  81068. * @param scene defines the hosting scene
  81069. * @returns a new skeleton
  81070. */
  81071. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81072. /**
  81073. * Compute all node absolute transforms
  81074. * @param forceUpdate defines if computation must be done even if cache is up to date
  81075. */
  81076. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81077. /**
  81078. * Gets the root pose matrix
  81079. * @returns a matrix
  81080. */
  81081. getPoseMatrix(): Nullable<Matrix>;
  81082. /**
  81083. * Sorts bones per internal index
  81084. */
  81085. sortBones(): void;
  81086. private _sortBones;
  81087. }
  81088. }
  81089. declare module BABYLON {
  81090. /**
  81091. * Class used to store bone information
  81092. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81093. */
  81094. export class Bone extends Node {
  81095. /**
  81096. * defines the bone name
  81097. */
  81098. name: string;
  81099. private static _tmpVecs;
  81100. private static _tmpQuat;
  81101. private static _tmpMats;
  81102. /**
  81103. * Gets the list of child bones
  81104. */
  81105. children: Bone[];
  81106. /** Gets the animations associated with this bone */
  81107. animations: Animation[];
  81108. /**
  81109. * Gets or sets bone length
  81110. */
  81111. length: number;
  81112. /**
  81113. * @hidden Internal only
  81114. * Set this value to map this bone to a different index in the transform matrices
  81115. * Set this value to -1 to exclude the bone from the transform matrices
  81116. */
  81117. _index: Nullable<number>;
  81118. private _skeleton;
  81119. private _localMatrix;
  81120. private _restPose;
  81121. private _baseMatrix;
  81122. private _absoluteTransform;
  81123. private _invertedAbsoluteTransform;
  81124. private _parent;
  81125. private _scalingDeterminant;
  81126. private _worldTransform;
  81127. private _localScaling;
  81128. private _localRotation;
  81129. private _localPosition;
  81130. private _needToDecompose;
  81131. private _needToCompose;
  81132. /** @hidden */
  81133. _linkedTransformNode: Nullable<TransformNode>;
  81134. /** @hidden */
  81135. _waitingTransformNodeId: Nullable<string>;
  81136. /** @hidden */
  81137. /** @hidden */
  81138. _matrix: Matrix;
  81139. /**
  81140. * Create a new bone
  81141. * @param name defines the bone name
  81142. * @param skeleton defines the parent skeleton
  81143. * @param parentBone defines the parent (can be null if the bone is the root)
  81144. * @param localMatrix defines the local matrix
  81145. * @param restPose defines the rest pose matrix
  81146. * @param baseMatrix defines the base matrix
  81147. * @param index defines index of the bone in the hiearchy
  81148. */
  81149. constructor(
  81150. /**
  81151. * defines the bone name
  81152. */
  81153. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  81154. /**
  81155. * Gets the current object class name.
  81156. * @return the class name
  81157. */
  81158. getClassName(): string;
  81159. /**
  81160. * Gets the parent skeleton
  81161. * @returns a skeleton
  81162. */
  81163. getSkeleton(): Skeleton;
  81164. /**
  81165. * Gets parent bone
  81166. * @returns a bone or null if the bone is the root of the bone hierarchy
  81167. */
  81168. getParent(): Nullable<Bone>;
  81169. /**
  81170. * Returns an array containing the root bones
  81171. * @returns an array containing the root bones
  81172. */
  81173. getChildren(): Array<Bone>;
  81174. /**
  81175. * Gets the node index in matrix array generated for rendering
  81176. * @returns the node index
  81177. */
  81178. getIndex(): number;
  81179. /**
  81180. * Sets the parent bone
  81181. * @param parent defines the parent (can be null if the bone is the root)
  81182. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81183. */
  81184. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  81185. /**
  81186. * Gets the local matrix
  81187. * @returns a matrix
  81188. */
  81189. getLocalMatrix(): Matrix;
  81190. /**
  81191. * Gets the base matrix (initial matrix which remains unchanged)
  81192. * @returns a matrix
  81193. */
  81194. getBaseMatrix(): Matrix;
  81195. /**
  81196. * Gets the rest pose matrix
  81197. * @returns a matrix
  81198. */
  81199. getRestPose(): Matrix;
  81200. /**
  81201. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  81202. */
  81203. getWorldMatrix(): Matrix;
  81204. /**
  81205. * Sets the local matrix to rest pose matrix
  81206. */
  81207. returnToRest(): void;
  81208. /**
  81209. * Gets the inverse of the absolute transform matrix.
  81210. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  81211. * @returns a matrix
  81212. */
  81213. getInvertedAbsoluteTransform(): Matrix;
  81214. /**
  81215. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  81216. * @returns a matrix
  81217. */
  81218. getAbsoluteTransform(): Matrix;
  81219. /**
  81220. * Links with the given transform node.
  81221. * The local matrix of this bone is copied from the transform node every frame.
  81222. * @param transformNode defines the transform node to link to
  81223. */
  81224. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  81225. /**
  81226. * Gets the node used to drive the bone's transformation
  81227. * @returns a transform node or null
  81228. */
  81229. getTransformNode(): Nullable<TransformNode>;
  81230. /** Gets or sets current position (in local space) */
  81231. position: Vector3;
  81232. /** Gets or sets current rotation (in local space) */
  81233. rotation: Vector3;
  81234. /** Gets or sets current rotation quaternion (in local space) */
  81235. rotationQuaternion: Quaternion;
  81236. /** Gets or sets current scaling (in local space) */
  81237. scaling: Vector3;
  81238. /**
  81239. * Gets the animation properties override
  81240. */
  81241. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81242. private _decompose;
  81243. private _compose;
  81244. /**
  81245. * Update the base and local matrices
  81246. * @param matrix defines the new base or local matrix
  81247. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  81248. * @param updateLocalMatrix defines if the local matrix should be updated
  81249. */
  81250. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  81251. /** @hidden */
  81252. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  81253. /**
  81254. * Flag the bone as dirty (Forcing it to update everything)
  81255. */
  81256. markAsDirty(): void;
  81257. /** @hidden */
  81258. _markAsDirtyAndCompose(): void;
  81259. private _markAsDirtyAndDecompose;
  81260. /**
  81261. * Translate the bone in local or world space
  81262. * @param vec The amount to translate the bone
  81263. * @param space The space that the translation is in
  81264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81265. */
  81266. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81267. /**
  81268. * Set the postion of the bone in local or world space
  81269. * @param position The position to set the bone
  81270. * @param space The space that the position is in
  81271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81272. */
  81273. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81274. /**
  81275. * Set the absolute position of the bone (world space)
  81276. * @param position The position to set the bone
  81277. * @param mesh The mesh that this bone is attached to
  81278. */
  81279. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  81280. /**
  81281. * Scale the bone on the x, y and z axes (in local space)
  81282. * @param x The amount to scale the bone on the x axis
  81283. * @param y The amount to scale the bone on the y axis
  81284. * @param z The amount to scale the bone on the z axis
  81285. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  81286. */
  81287. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  81288. /**
  81289. * Set the bone scaling in local space
  81290. * @param scale defines the scaling vector
  81291. */
  81292. setScale(scale: Vector3): void;
  81293. /**
  81294. * Gets the current scaling in local space
  81295. * @returns the current scaling vector
  81296. */
  81297. getScale(): Vector3;
  81298. /**
  81299. * Gets the current scaling in local space and stores it in a target vector
  81300. * @param result defines the target vector
  81301. */
  81302. getScaleToRef(result: Vector3): void;
  81303. /**
  81304. * Set the yaw, pitch, and roll of the bone in local or world space
  81305. * @param yaw The rotation of the bone on the y axis
  81306. * @param pitch The rotation of the bone on the x axis
  81307. * @param roll The rotation of the bone on the z axis
  81308. * @param space The space that the axes of rotation are in
  81309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81310. */
  81311. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  81312. /**
  81313. * Add a rotation to the bone on an axis in local or world space
  81314. * @param axis The axis to rotate the bone on
  81315. * @param amount The amount to rotate the bone
  81316. * @param space The space that the axis is in
  81317. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81318. */
  81319. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  81320. /**
  81321. * Set the rotation of the bone to a particular axis angle in local or world space
  81322. * @param axis The axis to rotate the bone on
  81323. * @param angle The angle that the bone should be rotated to
  81324. * @param space The space that the axis is in
  81325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81326. */
  81327. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  81328. /**
  81329. * Set the euler rotation of the bone in local of world space
  81330. * @param rotation The euler rotation that the bone should be set to
  81331. * @param space The space that the rotation is in
  81332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81333. */
  81334. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  81335. /**
  81336. * Set the quaternion rotation of the bone in local of world space
  81337. * @param quat The quaternion rotation that the bone should be set to
  81338. * @param space The space that the rotation is in
  81339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81340. */
  81341. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  81342. /**
  81343. * Set the rotation matrix of the bone in local of world space
  81344. * @param rotMat The rotation matrix that the bone should be set to
  81345. * @param space The space that the rotation is in
  81346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81347. */
  81348. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  81349. private _rotateWithMatrix;
  81350. private _getNegativeRotationToRef;
  81351. /**
  81352. * Get the position of the bone in local or world space
  81353. * @param space The space that the returned position is in
  81354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81355. * @returns The position of the bone
  81356. */
  81357. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81358. /**
  81359. * Copy the position of the bone to a vector3 in local or world space
  81360. * @param space The space that the returned position is in
  81361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81362. * @param result The vector3 to copy the position to
  81363. */
  81364. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  81365. /**
  81366. * Get the absolute position of the bone (world space)
  81367. * @param mesh The mesh that this bone is attached to
  81368. * @returns The absolute position of the bone
  81369. */
  81370. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  81371. /**
  81372. * Copy the absolute position of the bone (world space) to the result param
  81373. * @param mesh The mesh that this bone is attached to
  81374. * @param result The vector3 to copy the absolute position to
  81375. */
  81376. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  81377. /**
  81378. * Compute the absolute transforms of this bone and its children
  81379. */
  81380. computeAbsoluteTransforms(): void;
  81381. /**
  81382. * Get the world direction from an axis that is in the local space of the bone
  81383. * @param localAxis The local direction that is used to compute the world direction
  81384. * @param mesh The mesh that this bone is attached to
  81385. * @returns The world direction
  81386. */
  81387. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81388. /**
  81389. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  81390. * @param localAxis The local direction that is used to compute the world direction
  81391. * @param mesh The mesh that this bone is attached to
  81392. * @param result The vector3 that the world direction will be copied to
  81393. */
  81394. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81395. /**
  81396. * Get the euler rotation of the bone in local or world space
  81397. * @param space The space that the rotation should be in
  81398. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81399. * @returns The euler rotation
  81400. */
  81401. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  81402. /**
  81403. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  81404. * @param space The space that the rotation should be in
  81405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81406. * @param result The vector3 that the rotation should be copied to
  81407. */
  81408. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81409. /**
  81410. * Get the quaternion rotation of the bone in either local or world space
  81411. * @param space The space that the rotation should be in
  81412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81413. * @returns The quaternion rotation
  81414. */
  81415. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  81416. /**
  81417. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  81418. * @param space The space that the rotation should be in
  81419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81420. * @param result The quaternion that the rotation should be copied to
  81421. */
  81422. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  81423. /**
  81424. * Get the rotation matrix of the bone in local or world space
  81425. * @param space The space that the rotation should be in
  81426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81427. * @returns The rotation matrix
  81428. */
  81429. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  81430. /**
  81431. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  81432. * @param space The space that the rotation should be in
  81433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  81434. * @param result The quaternion that the rotation should be copied to
  81435. */
  81436. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  81437. /**
  81438. * Get the world position of a point that is in the local space of the bone
  81439. * @param position The local position
  81440. * @param mesh The mesh that this bone is attached to
  81441. * @returns The world position
  81442. */
  81443. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81444. /**
  81445. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  81446. * @param position The local position
  81447. * @param mesh The mesh that this bone is attached to
  81448. * @param result The vector3 that the world position should be copied to
  81449. */
  81450. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81451. /**
  81452. * Get the local position of a point that is in world space
  81453. * @param position The world position
  81454. * @param mesh The mesh that this bone is attached to
  81455. * @returns The local position
  81456. */
  81457. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  81458. /**
  81459. * Get the local position of a point that is in world space and copy it to the result param
  81460. * @param position The world position
  81461. * @param mesh The mesh that this bone is attached to
  81462. * @param result The vector3 that the local position should be copied to
  81463. */
  81464. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  81465. }
  81466. }
  81467. declare module BABYLON {
  81468. /**
  81469. * 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.
  81470. * @see https://doc.babylonjs.com/how_to/transformnode
  81471. */
  81472. export class TransformNode extends Node {
  81473. /**
  81474. * Object will not rotate to face the camera
  81475. */
  81476. static BILLBOARDMODE_NONE: number;
  81477. /**
  81478. * Object will rotate to face the camera but only on the x axis
  81479. */
  81480. static BILLBOARDMODE_X: number;
  81481. /**
  81482. * Object will rotate to face the camera but only on the y axis
  81483. */
  81484. static BILLBOARDMODE_Y: number;
  81485. /**
  81486. * Object will rotate to face the camera but only on the z axis
  81487. */
  81488. static BILLBOARDMODE_Z: number;
  81489. /**
  81490. * Object will rotate to face the camera
  81491. */
  81492. static BILLBOARDMODE_ALL: number;
  81493. /**
  81494. * Object will rotate to face the camera's position instead of orientation
  81495. */
  81496. static BILLBOARDMODE_USE_POSITION: number;
  81497. private _forward;
  81498. private _forwardInverted;
  81499. private _up;
  81500. private _right;
  81501. private _rightInverted;
  81502. private _position;
  81503. private _rotation;
  81504. private _rotationQuaternion;
  81505. protected _scaling: Vector3;
  81506. protected _isDirty: boolean;
  81507. private _transformToBoneReferal;
  81508. private _isAbsoluteSynced;
  81509. private _billboardMode;
  81510. /**
  81511. * Gets or sets the billboard mode. Default is 0.
  81512. *
  81513. * | Value | Type | Description |
  81514. * | --- | --- | --- |
  81515. * | 0 | BILLBOARDMODE_NONE | |
  81516. * | 1 | BILLBOARDMODE_X | |
  81517. * | 2 | BILLBOARDMODE_Y | |
  81518. * | 4 | BILLBOARDMODE_Z | |
  81519. * | 7 | BILLBOARDMODE_ALL | |
  81520. *
  81521. */
  81522. billboardMode: number;
  81523. private _preserveParentRotationForBillboard;
  81524. /**
  81525. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  81526. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  81527. */
  81528. preserveParentRotationForBillboard: boolean;
  81529. /**
  81530. * 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
  81531. */
  81532. scalingDeterminant: number;
  81533. private _infiniteDistance;
  81534. /**
  81535. * Gets or sets the distance of the object to max, often used by skybox
  81536. */
  81537. infiniteDistance: boolean;
  81538. /**
  81539. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  81540. * By default the system will update normals to compensate
  81541. */
  81542. ignoreNonUniformScaling: boolean;
  81543. /**
  81544. * 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
  81545. */
  81546. reIntegrateRotationIntoRotationQuaternion: boolean;
  81547. /** @hidden */
  81548. _poseMatrix: Nullable<Matrix>;
  81549. /** @hidden */
  81550. _localMatrix: Matrix;
  81551. private _usePivotMatrix;
  81552. private _absolutePosition;
  81553. private _absoluteScaling;
  81554. private _absoluteRotationQuaternion;
  81555. private _pivotMatrix;
  81556. private _pivotMatrixInverse;
  81557. protected _postMultiplyPivotMatrix: boolean;
  81558. protected _isWorldMatrixFrozen: boolean;
  81559. /** @hidden */
  81560. _indexInSceneTransformNodesArray: number;
  81561. /**
  81562. * An event triggered after the world matrix is updated
  81563. */
  81564. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  81565. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  81566. /**
  81567. * Gets a string identifying the name of the class
  81568. * @returns "TransformNode" string
  81569. */
  81570. getClassName(): string;
  81571. /**
  81572. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  81573. */
  81574. position: Vector3;
  81575. /**
  81576. * 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)).
  81577. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  81578. */
  81579. rotation: Vector3;
  81580. /**
  81581. * 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)).
  81582. */
  81583. scaling: Vector3;
  81584. /**
  81585. * 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).
  81586. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  81587. */
  81588. rotationQuaternion: Nullable<Quaternion>;
  81589. /**
  81590. * The forward direction of that transform in world space.
  81591. */
  81592. readonly forward: Vector3;
  81593. /**
  81594. * The up direction of that transform in world space.
  81595. */
  81596. readonly up: Vector3;
  81597. /**
  81598. * The right direction of that transform in world space.
  81599. */
  81600. readonly right: Vector3;
  81601. /**
  81602. * Copies the parameter passed Matrix into the mesh Pose matrix.
  81603. * @param matrix the matrix to copy the pose from
  81604. * @returns this TransformNode.
  81605. */
  81606. updatePoseMatrix(matrix: Matrix): TransformNode;
  81607. /**
  81608. * Returns the mesh Pose matrix.
  81609. * @returns the pose matrix
  81610. */
  81611. getPoseMatrix(): Matrix;
  81612. /** @hidden */
  81613. _isSynchronized(): boolean;
  81614. /** @hidden */
  81615. _initCache(): void;
  81616. /**
  81617. * Flag the transform node as dirty (Forcing it to update everything)
  81618. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  81619. * @returns this transform node
  81620. */
  81621. markAsDirty(property: string): TransformNode;
  81622. /**
  81623. * Returns the current mesh absolute position.
  81624. * Returns a Vector3.
  81625. */
  81626. readonly absolutePosition: Vector3;
  81627. /**
  81628. * Returns the current mesh absolute scaling.
  81629. * Returns a Vector3.
  81630. */
  81631. readonly absoluteScaling: Vector3;
  81632. /**
  81633. * Returns the current mesh absolute rotation.
  81634. * Returns a Quaternion.
  81635. */
  81636. readonly absoluteRotationQuaternion: Quaternion;
  81637. /**
  81638. * Sets a new matrix to apply before all other transformation
  81639. * @param matrix defines the transform matrix
  81640. * @returns the current TransformNode
  81641. */
  81642. setPreTransformMatrix(matrix: Matrix): TransformNode;
  81643. /**
  81644. * Sets a new pivot matrix to the current node
  81645. * @param matrix defines the new pivot matrix to use
  81646. * @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
  81647. * @returns the current TransformNode
  81648. */
  81649. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  81650. /**
  81651. * Returns the mesh pivot matrix.
  81652. * Default : Identity.
  81653. * @returns the matrix
  81654. */
  81655. getPivotMatrix(): Matrix;
  81656. /**
  81657. * Instantiate (when possible) or clone that node with its hierarchy
  81658. * @param newParent defines the new parent to use for the instance (or clone)
  81659. * @param options defines options to configure how copy is done
  81660. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  81661. * @returns an instance (or a clone) of the current node with its hiearchy
  81662. */
  81663. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  81664. doNotInstantiate: boolean;
  81665. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  81666. /**
  81667. * Prevents the World matrix to be computed any longer
  81668. * @param newWorldMatrix defines an optional matrix to use as world matrix
  81669. * @returns the TransformNode.
  81670. */
  81671. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  81672. /**
  81673. * Allows back the World matrix computation.
  81674. * @returns the TransformNode.
  81675. */
  81676. unfreezeWorldMatrix(): this;
  81677. /**
  81678. * True if the World matrix has been frozen.
  81679. */
  81680. readonly isWorldMatrixFrozen: boolean;
  81681. /**
  81682. * Retuns the mesh absolute position in the World.
  81683. * @returns a Vector3.
  81684. */
  81685. getAbsolutePosition(): Vector3;
  81686. /**
  81687. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  81688. * @param absolutePosition the absolute position to set
  81689. * @returns the TransformNode.
  81690. */
  81691. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  81692. /**
  81693. * Sets the mesh position in its local space.
  81694. * @param vector3 the position to set in localspace
  81695. * @returns the TransformNode.
  81696. */
  81697. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  81698. /**
  81699. * Returns the mesh position in the local space from the current World matrix values.
  81700. * @returns a new Vector3.
  81701. */
  81702. getPositionExpressedInLocalSpace(): Vector3;
  81703. /**
  81704. * Translates the mesh along the passed Vector3 in its local space.
  81705. * @param vector3 the distance to translate in localspace
  81706. * @returns the TransformNode.
  81707. */
  81708. locallyTranslate(vector3: Vector3): TransformNode;
  81709. private static _lookAtVectorCache;
  81710. /**
  81711. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  81712. * @param targetPoint the position (must be in same space as current mesh) to look at
  81713. * @param yawCor optional yaw (y-axis) correction in radians
  81714. * @param pitchCor optional pitch (x-axis) correction in radians
  81715. * @param rollCor optional roll (z-axis) correction in radians
  81716. * @param space the choosen space of the target
  81717. * @returns the TransformNode.
  81718. */
  81719. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  81720. /**
  81721. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81722. * This Vector3 is expressed in the World space.
  81723. * @param localAxis axis to rotate
  81724. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  81725. */
  81726. getDirection(localAxis: Vector3): Vector3;
  81727. /**
  81728. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  81729. * localAxis is expressed in the mesh local space.
  81730. * result is computed in the Wordl space from the mesh World matrix.
  81731. * @param localAxis axis to rotate
  81732. * @param result the resulting transformnode
  81733. * @returns this TransformNode.
  81734. */
  81735. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  81736. /**
  81737. * Sets this transform node rotation to the given local axis.
  81738. * @param localAxis the axis in local space
  81739. * @param yawCor optional yaw (y-axis) correction in radians
  81740. * @param pitchCor optional pitch (x-axis) correction in radians
  81741. * @param rollCor optional roll (z-axis) correction in radians
  81742. * @returns this TransformNode
  81743. */
  81744. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  81745. /**
  81746. * Sets a new pivot point to the current node
  81747. * @param point defines the new pivot point to use
  81748. * @param space defines if the point is in world or local space (local by default)
  81749. * @returns the current TransformNode
  81750. */
  81751. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  81752. /**
  81753. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  81754. * @returns the pivot point
  81755. */
  81756. getPivotPoint(): Vector3;
  81757. /**
  81758. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  81759. * @param result the vector3 to store the result
  81760. * @returns this TransformNode.
  81761. */
  81762. getPivotPointToRef(result: Vector3): TransformNode;
  81763. /**
  81764. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  81765. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  81766. */
  81767. getAbsolutePivotPoint(): Vector3;
  81768. /**
  81769. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  81770. * @param result vector3 to store the result
  81771. * @returns this TransformNode.
  81772. */
  81773. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  81774. /**
  81775. * Defines the passed node as the parent of the current node.
  81776. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  81777. * @see https://doc.babylonjs.com/how_to/parenting
  81778. * @param node the node ot set as the parent
  81779. * @returns this TransformNode.
  81780. */
  81781. setParent(node: Nullable<Node>): TransformNode;
  81782. private _nonUniformScaling;
  81783. /**
  81784. * True if the scaling property of this object is non uniform eg. (1,2,1)
  81785. */
  81786. readonly nonUniformScaling: boolean;
  81787. /** @hidden */
  81788. _updateNonUniformScalingState(value: boolean): boolean;
  81789. /**
  81790. * Attach the current TransformNode to another TransformNode associated with a bone
  81791. * @param bone Bone affecting the TransformNode
  81792. * @param affectedTransformNode TransformNode associated with the bone
  81793. * @returns this object
  81794. */
  81795. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  81796. /**
  81797. * Detach the transform node if its associated with a bone
  81798. * @returns this object
  81799. */
  81800. detachFromBone(): TransformNode;
  81801. private static _rotationAxisCache;
  81802. /**
  81803. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  81804. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81805. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81806. * The passed axis is also normalized.
  81807. * @param axis the axis to rotate around
  81808. * @param amount the amount to rotate in radians
  81809. * @param space Space to rotate in (Default: local)
  81810. * @returns the TransformNode.
  81811. */
  81812. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  81813. /**
  81814. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  81815. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  81816. * The passed axis is also normalized. .
  81817. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  81818. * @param point the point to rotate around
  81819. * @param axis the axis to rotate around
  81820. * @param amount the amount to rotate in radians
  81821. * @returns the TransformNode
  81822. */
  81823. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81824. /**
  81825. * Translates the mesh along the axis vector for the passed distance in the given space.
  81826. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81827. * @param axis the axis to translate in
  81828. * @param distance the distance to translate
  81829. * @param space Space to rotate in (Default: local)
  81830. * @returns the TransformNode.
  81831. */
  81832. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81833. /**
  81834. * Adds a rotation step to the mesh current rotation.
  81835. * x, y, z are Euler angles expressed in radians.
  81836. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81837. * This means this rotation is made in the mesh local space only.
  81838. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81839. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81840. * ```javascript
  81841. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81842. * ```
  81843. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81844. * 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.
  81845. * @param x Rotation to add
  81846. * @param y Rotation to add
  81847. * @param z Rotation to add
  81848. * @returns the TransformNode.
  81849. */
  81850. addRotation(x: number, y: number, z: number): TransformNode;
  81851. /**
  81852. * @hidden
  81853. */
  81854. protected _getEffectiveParent(): Nullable<Node>;
  81855. /**
  81856. * Computes the world matrix of the node
  81857. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81858. * @returns the world matrix
  81859. */
  81860. computeWorldMatrix(force?: boolean): Matrix;
  81861. protected _afterComputeWorldMatrix(): void;
  81862. /**
  81863. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81864. * @param func callback function to add
  81865. *
  81866. * @returns the TransformNode.
  81867. */
  81868. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81869. /**
  81870. * Removes a registered callback function.
  81871. * @param func callback function to remove
  81872. * @returns the TransformNode.
  81873. */
  81874. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81875. /**
  81876. * Gets the position of the current mesh in camera space
  81877. * @param camera defines the camera to use
  81878. * @returns a position
  81879. */
  81880. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81881. /**
  81882. * Returns the distance from the mesh to the active camera
  81883. * @param camera defines the camera to use
  81884. * @returns the distance
  81885. */
  81886. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81887. /**
  81888. * Clone the current transform node
  81889. * @param name Name of the new clone
  81890. * @param newParent New parent for the clone
  81891. * @param doNotCloneChildren Do not clone children hierarchy
  81892. * @returns the new transform node
  81893. */
  81894. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81895. /**
  81896. * Serializes the objects information.
  81897. * @param currentSerializationObject defines the object to serialize in
  81898. * @returns the serialized object
  81899. */
  81900. serialize(currentSerializationObject?: any): any;
  81901. /**
  81902. * Returns a new TransformNode object parsed from the source provided.
  81903. * @param parsedTransformNode is the source.
  81904. * @param scene the scne the object belongs to
  81905. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81906. * @returns a new TransformNode object parsed from the source provided.
  81907. */
  81908. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81909. /**
  81910. * Get all child-transformNodes of this node
  81911. * @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
  81912. * @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
  81913. * @returns an array of TransformNode
  81914. */
  81915. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81916. /**
  81917. * Releases resources associated with this transform node.
  81918. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81919. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81920. */
  81921. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81922. /**
  81923. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81924. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81925. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81926. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81927. * @returns the current mesh
  81928. */
  81929. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81930. private _syncAbsoluteScalingAndRotation;
  81931. }
  81932. }
  81933. declare module BABYLON {
  81934. /**
  81935. * Defines the types of pose enabled controllers that are supported
  81936. */
  81937. export enum PoseEnabledControllerType {
  81938. /**
  81939. * HTC Vive
  81940. */
  81941. VIVE = 0,
  81942. /**
  81943. * Oculus Rift
  81944. */
  81945. OCULUS = 1,
  81946. /**
  81947. * Windows mixed reality
  81948. */
  81949. WINDOWS = 2,
  81950. /**
  81951. * Samsung gear VR
  81952. */
  81953. GEAR_VR = 3,
  81954. /**
  81955. * Google Daydream
  81956. */
  81957. DAYDREAM = 4,
  81958. /**
  81959. * Generic
  81960. */
  81961. GENERIC = 5
  81962. }
  81963. /**
  81964. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81965. */
  81966. export interface MutableGamepadButton {
  81967. /**
  81968. * Value of the button/trigger
  81969. */
  81970. value: number;
  81971. /**
  81972. * If the button/trigger is currently touched
  81973. */
  81974. touched: boolean;
  81975. /**
  81976. * If the button/trigger is currently pressed
  81977. */
  81978. pressed: boolean;
  81979. }
  81980. /**
  81981. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81982. * @hidden
  81983. */
  81984. export interface ExtendedGamepadButton extends GamepadButton {
  81985. /**
  81986. * If the button/trigger is currently pressed
  81987. */
  81988. readonly pressed: boolean;
  81989. /**
  81990. * If the button/trigger is currently touched
  81991. */
  81992. readonly touched: boolean;
  81993. /**
  81994. * Value of the button/trigger
  81995. */
  81996. readonly value: number;
  81997. }
  81998. /** @hidden */
  81999. export interface _GamePadFactory {
  82000. /**
  82001. * Returns wether or not the current gamepad can be created for this type of controller.
  82002. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82003. * @returns true if it can be created, otherwise false
  82004. */
  82005. canCreate(gamepadInfo: any): boolean;
  82006. /**
  82007. * Creates a new instance of the Gamepad.
  82008. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82009. * @returns the new gamepad instance
  82010. */
  82011. create(gamepadInfo: any): Gamepad;
  82012. }
  82013. /**
  82014. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82015. */
  82016. export class PoseEnabledControllerHelper {
  82017. /** @hidden */
  82018. static _ControllerFactories: _GamePadFactory[];
  82019. /** @hidden */
  82020. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82021. /**
  82022. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82023. * @param vrGamepad the gamepad to initialized
  82024. * @returns a vr controller of the type the gamepad identified as
  82025. */
  82026. static InitiateController(vrGamepad: any): Gamepad;
  82027. }
  82028. /**
  82029. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82030. */
  82031. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82032. /**
  82033. * If the controller is used in a webXR session
  82034. */
  82035. isXR: boolean;
  82036. private _deviceRoomPosition;
  82037. private _deviceRoomRotationQuaternion;
  82038. /**
  82039. * The device position in babylon space
  82040. */
  82041. devicePosition: Vector3;
  82042. /**
  82043. * The device rotation in babylon space
  82044. */
  82045. deviceRotationQuaternion: Quaternion;
  82046. /**
  82047. * The scale factor of the device in babylon space
  82048. */
  82049. deviceScaleFactor: number;
  82050. /**
  82051. * (Likely devicePosition should be used instead) The device position in its room space
  82052. */
  82053. position: Vector3;
  82054. /**
  82055. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82056. */
  82057. rotationQuaternion: Quaternion;
  82058. /**
  82059. * The type of controller (Eg. Windows mixed reality)
  82060. */
  82061. controllerType: PoseEnabledControllerType;
  82062. protected _calculatedPosition: Vector3;
  82063. private _calculatedRotation;
  82064. /**
  82065. * The raw pose from the device
  82066. */
  82067. rawPose: DevicePose;
  82068. private _trackPosition;
  82069. private _maxRotationDistFromHeadset;
  82070. private _draggedRoomRotation;
  82071. /**
  82072. * @hidden
  82073. */
  82074. _disableTrackPosition(fixedPosition: Vector3): void;
  82075. /**
  82076. * Internal, the mesh attached to the controller
  82077. * @hidden
  82078. */
  82079. _mesh: Nullable<AbstractMesh>;
  82080. private _poseControlledCamera;
  82081. private _leftHandSystemQuaternion;
  82082. /**
  82083. * Internal, matrix used to convert room space to babylon space
  82084. * @hidden
  82085. */
  82086. _deviceToWorld: Matrix;
  82087. /**
  82088. * Node to be used when casting a ray from the controller
  82089. * @hidden
  82090. */
  82091. _pointingPoseNode: Nullable<TransformNode>;
  82092. /**
  82093. * Name of the child mesh that can be used to cast a ray from the controller
  82094. */
  82095. static readonly POINTING_POSE: string;
  82096. /**
  82097. * Creates a new PoseEnabledController from a gamepad
  82098. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82099. */
  82100. constructor(browserGamepad: any);
  82101. private _workingMatrix;
  82102. /**
  82103. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82104. */
  82105. update(): void;
  82106. /**
  82107. * Updates only the pose device and mesh without doing any button event checking
  82108. */
  82109. protected _updatePoseAndMesh(): void;
  82110. /**
  82111. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82112. * @param poseData raw pose fromthe device
  82113. */
  82114. updateFromDevice(poseData: DevicePose): void;
  82115. /**
  82116. * @hidden
  82117. */
  82118. _meshAttachedObservable: Observable<AbstractMesh>;
  82119. /**
  82120. * Attaches a mesh to the controller
  82121. * @param mesh the mesh to be attached
  82122. */
  82123. attachToMesh(mesh: AbstractMesh): void;
  82124. /**
  82125. * Attaches the controllers mesh to a camera
  82126. * @param camera the camera the mesh should be attached to
  82127. */
  82128. attachToPoseControlledCamera(camera: TargetCamera): void;
  82129. /**
  82130. * Disposes of the controller
  82131. */
  82132. dispose(): void;
  82133. /**
  82134. * The mesh that is attached to the controller
  82135. */
  82136. readonly mesh: Nullable<AbstractMesh>;
  82137. /**
  82138. * Gets the ray of the controller in the direction the controller is pointing
  82139. * @param length the length the resulting ray should be
  82140. * @returns a ray in the direction the controller is pointing
  82141. */
  82142. getForwardRay(length?: number): Ray;
  82143. }
  82144. }
  82145. declare module BABYLON {
  82146. /**
  82147. * Defines the WebVRController object that represents controllers tracked in 3D space
  82148. */
  82149. export abstract class WebVRController extends PoseEnabledController {
  82150. /**
  82151. * Internal, the default controller model for the controller
  82152. */
  82153. protected _defaultModel: Nullable<AbstractMesh>;
  82154. /**
  82155. * Fired when the trigger state has changed
  82156. */
  82157. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  82158. /**
  82159. * Fired when the main button state has changed
  82160. */
  82161. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82162. /**
  82163. * Fired when the secondary button state has changed
  82164. */
  82165. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  82166. /**
  82167. * Fired when the pad state has changed
  82168. */
  82169. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  82170. /**
  82171. * Fired when controllers stick values have changed
  82172. */
  82173. onPadValuesChangedObservable: Observable<StickValues>;
  82174. /**
  82175. * Array of button availible on the controller
  82176. */
  82177. protected _buttons: Array<MutableGamepadButton>;
  82178. private _onButtonStateChange;
  82179. /**
  82180. * Fired when a controller button's state has changed
  82181. * @param callback the callback containing the button that was modified
  82182. */
  82183. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  82184. /**
  82185. * X and Y axis corresponding to the controllers joystick
  82186. */
  82187. pad: StickValues;
  82188. /**
  82189. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  82190. */
  82191. hand: string;
  82192. /**
  82193. * The default controller model for the controller
  82194. */
  82195. readonly defaultModel: Nullable<AbstractMesh>;
  82196. /**
  82197. * Creates a new WebVRController from a gamepad
  82198. * @param vrGamepad the gamepad that the WebVRController should be created from
  82199. */
  82200. constructor(vrGamepad: any);
  82201. /**
  82202. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  82203. */
  82204. update(): void;
  82205. /**
  82206. * Function to be called when a button is modified
  82207. */
  82208. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  82209. /**
  82210. * Loads a mesh and attaches it to the controller
  82211. * @param scene the scene the mesh should be added to
  82212. * @param meshLoaded callback for when the mesh has been loaded
  82213. */
  82214. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  82215. private _setButtonValue;
  82216. private _changes;
  82217. private _checkChanges;
  82218. /**
  82219. * Disposes of th webVRCOntroller
  82220. */
  82221. dispose(): void;
  82222. }
  82223. }
  82224. declare module BABYLON {
  82225. /**
  82226. * The HemisphericLight simulates the ambient environment light,
  82227. * so the passed direction is the light reflection direction, not the incoming direction.
  82228. */
  82229. export class HemisphericLight extends Light {
  82230. /**
  82231. * The groundColor is the light in the opposite direction to the one specified during creation.
  82232. * 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.
  82233. */
  82234. groundColor: Color3;
  82235. /**
  82236. * The light reflection direction, not the incoming direction.
  82237. */
  82238. direction: Vector3;
  82239. /**
  82240. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  82241. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  82242. * The HemisphericLight can't cast shadows.
  82243. * Documentation : https://doc.babylonjs.com/babylon101/lights
  82244. * @param name The friendly name of the light
  82245. * @param direction The direction of the light reflection
  82246. * @param scene The scene the light belongs to
  82247. */
  82248. constructor(name: string, direction: Vector3, scene: Scene);
  82249. protected _buildUniformLayout(): void;
  82250. /**
  82251. * Returns the string "HemisphericLight".
  82252. * @return The class name
  82253. */
  82254. getClassName(): string;
  82255. /**
  82256. * Sets the HemisphericLight direction towards the passed target (Vector3).
  82257. * Returns the updated direction.
  82258. * @param target The target the direction should point to
  82259. * @return The computed direction
  82260. */
  82261. setDirectionToTarget(target: Vector3): Vector3;
  82262. /**
  82263. * Returns the shadow generator associated to the light.
  82264. * @returns Always null for hemispheric lights because it does not support shadows.
  82265. */
  82266. getShadowGenerator(): Nullable<IShadowGenerator>;
  82267. /**
  82268. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  82269. * @param effect The effect to update
  82270. * @param lightIndex The index of the light in the effect to update
  82271. * @returns The hemispheric light
  82272. */
  82273. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  82274. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  82275. /**
  82276. * Computes the world matrix of the node
  82277. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82278. * @param useWasUpdatedFlag defines a reserved property
  82279. * @returns the world matrix
  82280. */
  82281. computeWorldMatrix(): Matrix;
  82282. /**
  82283. * Returns the integer 3.
  82284. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  82285. */
  82286. getTypeID(): number;
  82287. /**
  82288. * Prepares the list of defines specific to the light type.
  82289. * @param defines the list of defines
  82290. * @param lightIndex defines the index of the light for the effect
  82291. */
  82292. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  82293. }
  82294. }
  82295. declare module BABYLON {
  82296. /** @hidden */
  82297. export var vrMultiviewToSingleviewPixelShader: {
  82298. name: string;
  82299. shader: string;
  82300. };
  82301. }
  82302. declare module BABYLON {
  82303. /**
  82304. * Renders to multiple views with a single draw call
  82305. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  82306. */
  82307. export class MultiviewRenderTarget extends RenderTargetTexture {
  82308. /**
  82309. * Creates a multiview render target
  82310. * @param scene scene used with the render target
  82311. * @param size the size of the render target (used for each view)
  82312. */
  82313. constructor(scene: Scene, size?: number | {
  82314. width: number;
  82315. height: number;
  82316. } | {
  82317. ratio: number;
  82318. });
  82319. /**
  82320. * @hidden
  82321. * @param faceIndex the face index, if its a cube texture
  82322. */
  82323. _bindFrameBuffer(faceIndex?: number): void;
  82324. /**
  82325. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  82326. * @returns the view count
  82327. */
  82328. getViewCount(): number;
  82329. }
  82330. }
  82331. declare module BABYLON {
  82332. /**
  82333. * Represents a camera frustum
  82334. */
  82335. export class Frustum {
  82336. /**
  82337. * Gets the planes representing the frustum
  82338. * @param transform matrix to be applied to the returned planes
  82339. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  82340. */
  82341. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  82342. /**
  82343. * Gets the near frustum plane transformed by the transform matrix
  82344. * @param transform transformation matrix to be applied to the resulting frustum plane
  82345. * @param frustumPlane the resuling frustum plane
  82346. */
  82347. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82348. /**
  82349. * Gets the far frustum plane transformed by the transform matrix
  82350. * @param transform transformation matrix to be applied to the resulting frustum plane
  82351. * @param frustumPlane the resuling frustum plane
  82352. */
  82353. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82354. /**
  82355. * Gets the left frustum plane transformed by the transform matrix
  82356. * @param transform transformation matrix to be applied to the resulting frustum plane
  82357. * @param frustumPlane the resuling frustum plane
  82358. */
  82359. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82360. /**
  82361. * Gets the right frustum plane transformed by the transform matrix
  82362. * @param transform transformation matrix to be applied to the resulting frustum plane
  82363. * @param frustumPlane the resuling frustum plane
  82364. */
  82365. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82366. /**
  82367. * Gets the top frustum plane transformed by the transform matrix
  82368. * @param transform transformation matrix to be applied to the resulting frustum plane
  82369. * @param frustumPlane the resuling frustum plane
  82370. */
  82371. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82372. /**
  82373. * Gets the bottom frustum plane transformed by the transform matrix
  82374. * @param transform transformation matrix to be applied to the resulting frustum plane
  82375. * @param frustumPlane the resuling frustum plane
  82376. */
  82377. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  82378. /**
  82379. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  82380. * @param transform transformation matrix to be applied to the resulting frustum planes
  82381. * @param frustumPlanes the resuling frustum planes
  82382. */
  82383. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  82384. }
  82385. }
  82386. declare module BABYLON {
  82387. interface Engine {
  82388. /**
  82389. * Creates a new multiview render target
  82390. * @param width defines the width of the texture
  82391. * @param height defines the height of the texture
  82392. * @returns the created multiview texture
  82393. */
  82394. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  82395. /**
  82396. * Binds a multiview framebuffer to be drawn to
  82397. * @param multiviewTexture texture to bind
  82398. */
  82399. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  82400. }
  82401. interface Camera {
  82402. /**
  82403. * @hidden
  82404. * 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)
  82405. */
  82406. _useMultiviewToSingleView: boolean;
  82407. /**
  82408. * @hidden
  82409. * 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)
  82410. */
  82411. _multiviewTexture: Nullable<RenderTargetTexture>;
  82412. /**
  82413. * @hidden
  82414. * ensures the multiview texture of the camera exists and has the specified width/height
  82415. * @param width height to set on the multiview texture
  82416. * @param height width to set on the multiview texture
  82417. */
  82418. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  82419. }
  82420. interface Scene {
  82421. /** @hidden */
  82422. _transformMatrixR: Matrix;
  82423. /** @hidden */
  82424. _multiviewSceneUbo: Nullable<UniformBuffer>;
  82425. /** @hidden */
  82426. _createMultiviewUbo(): void;
  82427. /** @hidden */
  82428. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  82429. /** @hidden */
  82430. _renderMultiviewToSingleView(camera: Camera): void;
  82431. }
  82432. }
  82433. declare module BABYLON {
  82434. /**
  82435. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  82436. * This will not be used for webXR as it supports displaying texture arrays directly
  82437. */
  82438. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  82439. /**
  82440. * Initializes a VRMultiviewToSingleview
  82441. * @param name name of the post process
  82442. * @param camera camera to be applied to
  82443. * @param scaleFactor scaling factor to the size of the output texture
  82444. */
  82445. constructor(name: string, camera: Camera, scaleFactor: number);
  82446. }
  82447. }
  82448. declare module BABYLON {
  82449. interface Engine {
  82450. /** @hidden */
  82451. _vrDisplay: any;
  82452. /** @hidden */
  82453. _vrSupported: boolean;
  82454. /** @hidden */
  82455. _oldSize: Size;
  82456. /** @hidden */
  82457. _oldHardwareScaleFactor: number;
  82458. /** @hidden */
  82459. _vrExclusivePointerMode: boolean;
  82460. /** @hidden */
  82461. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  82462. /** @hidden */
  82463. _onVRDisplayPointerRestricted: () => void;
  82464. /** @hidden */
  82465. _onVRDisplayPointerUnrestricted: () => void;
  82466. /** @hidden */
  82467. _onVrDisplayConnect: Nullable<(display: any) => void>;
  82468. /** @hidden */
  82469. _onVrDisplayDisconnect: Nullable<() => void>;
  82470. /** @hidden */
  82471. _onVrDisplayPresentChange: Nullable<() => void>;
  82472. /**
  82473. * Observable signaled when VR display mode changes
  82474. */
  82475. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82476. /**
  82477. * Observable signaled when VR request present is complete
  82478. */
  82479. onVRRequestPresentComplete: Observable<boolean>;
  82480. /**
  82481. * Observable signaled when VR request present starts
  82482. */
  82483. onVRRequestPresentStart: Observable<Engine>;
  82484. /**
  82485. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82486. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82487. */
  82488. isInVRExclusivePointerMode: boolean;
  82489. /**
  82490. * Gets a boolean indicating if a webVR device was detected
  82491. * @returns true if a webVR device was detected
  82492. */
  82493. isVRDevicePresent(): boolean;
  82494. /**
  82495. * Gets the current webVR device
  82496. * @returns the current webVR device (or null)
  82497. */
  82498. getVRDevice(): any;
  82499. /**
  82500. * Initializes a webVR display and starts listening to display change events
  82501. * The onVRDisplayChangedObservable will be notified upon these changes
  82502. * @returns A promise containing a VRDisplay and if vr is supported
  82503. */
  82504. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  82505. /** @hidden */
  82506. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  82507. /**
  82508. * Call this function to switch to webVR mode
  82509. * Will do nothing if webVR is not supported or if there is no webVR device
  82510. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82511. */
  82512. enableVR(): void;
  82513. /** @hidden */
  82514. _onVRFullScreenTriggered(): void;
  82515. }
  82516. }
  82517. declare module BABYLON {
  82518. /**
  82519. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  82520. * IMPORTANT!! The data is right-hand data.
  82521. * @export
  82522. * @interface DevicePose
  82523. */
  82524. export interface DevicePose {
  82525. /**
  82526. * The position of the device, values in array are [x,y,z].
  82527. */
  82528. readonly position: Nullable<Float32Array>;
  82529. /**
  82530. * The linearVelocity of the device, values in array are [x,y,z].
  82531. */
  82532. readonly linearVelocity: Nullable<Float32Array>;
  82533. /**
  82534. * The linearAcceleration of the device, values in array are [x,y,z].
  82535. */
  82536. readonly linearAcceleration: Nullable<Float32Array>;
  82537. /**
  82538. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  82539. */
  82540. readonly orientation: Nullable<Float32Array>;
  82541. /**
  82542. * The angularVelocity of the device, values in array are [x,y,z].
  82543. */
  82544. readonly angularVelocity: Nullable<Float32Array>;
  82545. /**
  82546. * The angularAcceleration of the device, values in array are [x,y,z].
  82547. */
  82548. readonly angularAcceleration: Nullable<Float32Array>;
  82549. }
  82550. /**
  82551. * Interface representing a pose controlled object in Babylon.
  82552. * A pose controlled object has both regular pose values as well as pose values
  82553. * from an external device such as a VR head mounted display
  82554. */
  82555. export interface PoseControlled {
  82556. /**
  82557. * The position of the object in babylon space.
  82558. */
  82559. position: Vector3;
  82560. /**
  82561. * The rotation quaternion of the object in babylon space.
  82562. */
  82563. rotationQuaternion: Quaternion;
  82564. /**
  82565. * The position of the device in babylon space.
  82566. */
  82567. devicePosition?: Vector3;
  82568. /**
  82569. * The rotation quaternion of the device in babylon space.
  82570. */
  82571. deviceRotationQuaternion: Quaternion;
  82572. /**
  82573. * The raw pose coming from the device.
  82574. */
  82575. rawPose: Nullable<DevicePose>;
  82576. /**
  82577. * The scale of the device to be used when translating from device space to babylon space.
  82578. */
  82579. deviceScaleFactor: number;
  82580. /**
  82581. * Updates the poseControlled values based on the input device pose.
  82582. * @param poseData the pose data to update the object with
  82583. */
  82584. updateFromDevice(poseData: DevicePose): void;
  82585. }
  82586. /**
  82587. * Set of options to customize the webVRCamera
  82588. */
  82589. export interface WebVROptions {
  82590. /**
  82591. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  82592. */
  82593. trackPosition?: boolean;
  82594. /**
  82595. * Sets the scale of the vrDevice in babylon space. (default: 1)
  82596. */
  82597. positionScale?: number;
  82598. /**
  82599. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  82600. */
  82601. displayName?: string;
  82602. /**
  82603. * Should the native controller meshes be initialized. (default: true)
  82604. */
  82605. controllerMeshes?: boolean;
  82606. /**
  82607. * Creating a default HemiLight only on controllers. (default: true)
  82608. */
  82609. defaultLightingOnControllers?: boolean;
  82610. /**
  82611. * If you don't want to use the default VR button of the helper. (default: false)
  82612. */
  82613. useCustomVRButton?: boolean;
  82614. /**
  82615. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  82616. */
  82617. customVRButton?: HTMLButtonElement;
  82618. /**
  82619. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  82620. */
  82621. rayLength?: number;
  82622. /**
  82623. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  82624. */
  82625. defaultHeight?: number;
  82626. /**
  82627. * If multiview should be used if availible (default: false)
  82628. */
  82629. useMultiview?: boolean;
  82630. }
  82631. /**
  82632. * This represents a WebVR camera.
  82633. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  82634. * @example http://doc.babylonjs.com/how_to/webvr_camera
  82635. */
  82636. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  82637. private webVROptions;
  82638. /**
  82639. * @hidden
  82640. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  82641. */
  82642. _vrDevice: any;
  82643. /**
  82644. * The rawPose of the vrDevice.
  82645. */
  82646. rawPose: Nullable<DevicePose>;
  82647. private _onVREnabled;
  82648. private _specsVersion;
  82649. private _attached;
  82650. private _frameData;
  82651. protected _descendants: Array<Node>;
  82652. private _deviceRoomPosition;
  82653. /** @hidden */
  82654. _deviceRoomRotationQuaternion: Quaternion;
  82655. private _standingMatrix;
  82656. /**
  82657. * Represents device position in babylon space.
  82658. */
  82659. devicePosition: Vector3;
  82660. /**
  82661. * Represents device rotation in babylon space.
  82662. */
  82663. deviceRotationQuaternion: Quaternion;
  82664. /**
  82665. * The scale of the device to be used when translating from device space to babylon space.
  82666. */
  82667. deviceScaleFactor: number;
  82668. private _deviceToWorld;
  82669. private _worldToDevice;
  82670. /**
  82671. * References to the webVR controllers for the vrDevice.
  82672. */
  82673. controllers: Array<WebVRController>;
  82674. /**
  82675. * Emits an event when a controller is attached.
  82676. */
  82677. onControllersAttachedObservable: Observable<WebVRController[]>;
  82678. /**
  82679. * Emits an event when a controller's mesh has been loaded;
  82680. */
  82681. onControllerMeshLoadedObservable: Observable<WebVRController>;
  82682. /**
  82683. * Emits an event when the HMD's pose has been updated.
  82684. */
  82685. onPoseUpdatedFromDeviceObservable: Observable<any>;
  82686. private _poseSet;
  82687. /**
  82688. * If the rig cameras be used as parent instead of this camera.
  82689. */
  82690. rigParenting: boolean;
  82691. private _lightOnControllers;
  82692. private _defaultHeight?;
  82693. /**
  82694. * Instantiates a WebVRFreeCamera.
  82695. * @param name The name of the WebVRFreeCamera
  82696. * @param position The starting anchor position for the camera
  82697. * @param scene The scene the camera belongs to
  82698. * @param webVROptions a set of customizable options for the webVRCamera
  82699. */
  82700. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  82701. /**
  82702. * Gets the device distance from the ground in meters.
  82703. * @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.
  82704. */
  82705. deviceDistanceToRoomGround(): number;
  82706. /**
  82707. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82708. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  82709. */
  82710. useStandingMatrix(callback?: (bool: boolean) => void): void;
  82711. /**
  82712. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  82713. * @returns A promise with a boolean set to if the standing matrix is supported.
  82714. */
  82715. useStandingMatrixAsync(): Promise<boolean>;
  82716. /**
  82717. * Disposes the camera
  82718. */
  82719. dispose(): void;
  82720. /**
  82721. * Gets a vrController by name.
  82722. * @param name The name of the controller to retreive
  82723. * @returns the controller matching the name specified or null if not found
  82724. */
  82725. getControllerByName(name: string): Nullable<WebVRController>;
  82726. private _leftController;
  82727. /**
  82728. * The controller corresponding to the users left hand.
  82729. */
  82730. readonly leftController: Nullable<WebVRController>;
  82731. private _rightController;
  82732. /**
  82733. * The controller corresponding to the users right hand.
  82734. */
  82735. readonly rightController: Nullable<WebVRController>;
  82736. /**
  82737. * Casts a ray forward from the vrCamera's gaze.
  82738. * @param length Length of the ray (default: 100)
  82739. * @returns the ray corresponding to the gaze
  82740. */
  82741. getForwardRay(length?: number): Ray;
  82742. /**
  82743. * @hidden
  82744. * Updates the camera based on device's frame data
  82745. */
  82746. _checkInputs(): void;
  82747. /**
  82748. * Updates the poseControlled values based on the input device pose.
  82749. * @param poseData Pose coming from the device
  82750. */
  82751. updateFromDevice(poseData: DevicePose): void;
  82752. private _htmlElementAttached;
  82753. private _detachIfAttached;
  82754. /**
  82755. * WebVR's attach control will start broadcasting frames to the device.
  82756. * Note that in certain browsers (chrome for example) this function must be called
  82757. * within a user-interaction callback. Example:
  82758. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  82759. *
  82760. * @param element html element to attach the vrDevice to
  82761. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  82762. */
  82763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82764. /**
  82765. * Detaches the camera from the html element and disables VR
  82766. *
  82767. * @param element html element to detach from
  82768. */
  82769. detachControl(element: HTMLElement): void;
  82770. /**
  82771. * @returns the name of this class
  82772. */
  82773. getClassName(): string;
  82774. /**
  82775. * Calls resetPose on the vrDisplay
  82776. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  82777. */
  82778. resetToCurrentRotation(): void;
  82779. /**
  82780. * @hidden
  82781. * Updates the rig cameras (left and right eye)
  82782. */
  82783. _updateRigCameras(): void;
  82784. private _workingVector;
  82785. private _oneVector;
  82786. private _workingMatrix;
  82787. private updateCacheCalled;
  82788. private _correctPositionIfNotTrackPosition;
  82789. /**
  82790. * @hidden
  82791. * Updates the cached values of the camera
  82792. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  82793. */
  82794. _updateCache(ignoreParentClass?: boolean): void;
  82795. /**
  82796. * @hidden
  82797. * Get current device position in babylon world
  82798. */
  82799. _computeDevicePosition(): void;
  82800. /**
  82801. * Updates the current device position and rotation in the babylon world
  82802. */
  82803. update(): void;
  82804. /**
  82805. * @hidden
  82806. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  82807. * @returns an identity matrix
  82808. */
  82809. _getViewMatrix(): Matrix;
  82810. private _tmpMatrix;
  82811. /**
  82812. * This function is called by the two RIG cameras.
  82813. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  82814. * @hidden
  82815. */
  82816. _getWebVRViewMatrix(): Matrix;
  82817. /** @hidden */
  82818. _getWebVRProjectionMatrix(): Matrix;
  82819. private _onGamepadConnectedObserver;
  82820. private _onGamepadDisconnectedObserver;
  82821. private _updateCacheWhenTrackingDisabledObserver;
  82822. /**
  82823. * Initializes the controllers and their meshes
  82824. */
  82825. initControllers(): void;
  82826. }
  82827. }
  82828. declare module BABYLON {
  82829. /**
  82830. * Size options for a post process
  82831. */
  82832. export type PostProcessOptions = {
  82833. width: number;
  82834. height: number;
  82835. };
  82836. /**
  82837. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82838. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82839. */
  82840. export class PostProcess {
  82841. /** Name of the PostProcess. */
  82842. name: string;
  82843. /**
  82844. * Gets or sets the unique id of the post process
  82845. */
  82846. uniqueId: number;
  82847. /**
  82848. * Width of the texture to apply the post process on
  82849. */
  82850. width: number;
  82851. /**
  82852. * Height of the texture to apply the post process on
  82853. */
  82854. height: number;
  82855. /**
  82856. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82857. * @hidden
  82858. */
  82859. _outputTexture: Nullable<InternalTexture>;
  82860. /**
  82861. * Sampling mode used by the shader
  82862. * See https://doc.babylonjs.com/classes/3.1/texture
  82863. */
  82864. renderTargetSamplingMode: number;
  82865. /**
  82866. * Clear color to use when screen clearing
  82867. */
  82868. clearColor: Color4;
  82869. /**
  82870. * If the buffer needs to be cleared before applying the post process. (default: true)
  82871. * Should be set to false if shader will overwrite all previous pixels.
  82872. */
  82873. autoClear: boolean;
  82874. /**
  82875. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82876. */
  82877. alphaMode: number;
  82878. /**
  82879. * Sets the setAlphaBlendConstants of the babylon engine
  82880. */
  82881. alphaConstants: Color4;
  82882. /**
  82883. * Animations to be used for the post processing
  82884. */
  82885. animations: Animation[];
  82886. /**
  82887. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82888. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82889. */
  82890. enablePixelPerfectMode: boolean;
  82891. /**
  82892. * Force the postprocess to be applied without taking in account viewport
  82893. */
  82894. forceFullscreenViewport: boolean;
  82895. /**
  82896. * List of inspectable custom properties (used by the Inspector)
  82897. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82898. */
  82899. inspectableCustomProperties: IInspectable[];
  82900. /**
  82901. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82902. *
  82903. * | Value | Type | Description |
  82904. * | ----- | ----------------------------------- | ----------- |
  82905. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82906. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82907. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82908. *
  82909. */
  82910. scaleMode: number;
  82911. /**
  82912. * Force textures to be a power of two (default: false)
  82913. */
  82914. alwaysForcePOT: boolean;
  82915. private _samples;
  82916. /**
  82917. * Number of sample textures (default: 1)
  82918. */
  82919. samples: number;
  82920. /**
  82921. * Modify the scale of the post process to be the same as the viewport (default: false)
  82922. */
  82923. adaptScaleToCurrentViewport: boolean;
  82924. private _camera;
  82925. private _scene;
  82926. private _engine;
  82927. private _options;
  82928. private _reusable;
  82929. private _textureType;
  82930. /**
  82931. * Smart array of input and output textures for the post process.
  82932. * @hidden
  82933. */
  82934. _textures: SmartArray<InternalTexture>;
  82935. /**
  82936. * The index in _textures that corresponds to the output texture.
  82937. * @hidden
  82938. */
  82939. _currentRenderTextureInd: number;
  82940. private _effect;
  82941. private _samplers;
  82942. private _fragmentUrl;
  82943. private _vertexUrl;
  82944. private _parameters;
  82945. private _scaleRatio;
  82946. protected _indexParameters: any;
  82947. private _shareOutputWithPostProcess;
  82948. private _texelSize;
  82949. private _forcedOutputTexture;
  82950. /**
  82951. * Returns the fragment url or shader name used in the post process.
  82952. * @returns the fragment url or name in the shader store.
  82953. */
  82954. getEffectName(): string;
  82955. /**
  82956. * An event triggered when the postprocess is activated.
  82957. */
  82958. onActivateObservable: Observable<Camera>;
  82959. private _onActivateObserver;
  82960. /**
  82961. * A function that is added to the onActivateObservable
  82962. */
  82963. onActivate: Nullable<(camera: Camera) => void>;
  82964. /**
  82965. * An event triggered when the postprocess changes its size.
  82966. */
  82967. onSizeChangedObservable: Observable<PostProcess>;
  82968. private _onSizeChangedObserver;
  82969. /**
  82970. * A function that is added to the onSizeChangedObservable
  82971. */
  82972. onSizeChanged: (postProcess: PostProcess) => void;
  82973. /**
  82974. * An event triggered when the postprocess applies its effect.
  82975. */
  82976. onApplyObservable: Observable<Effect>;
  82977. private _onApplyObserver;
  82978. /**
  82979. * A function that is added to the onApplyObservable
  82980. */
  82981. onApply: (effect: Effect) => void;
  82982. /**
  82983. * An event triggered before rendering the postprocess
  82984. */
  82985. onBeforeRenderObservable: Observable<Effect>;
  82986. private _onBeforeRenderObserver;
  82987. /**
  82988. * A function that is added to the onBeforeRenderObservable
  82989. */
  82990. onBeforeRender: (effect: Effect) => void;
  82991. /**
  82992. * An event triggered after rendering the postprocess
  82993. */
  82994. onAfterRenderObservable: Observable<Effect>;
  82995. private _onAfterRenderObserver;
  82996. /**
  82997. * A function that is added to the onAfterRenderObservable
  82998. */
  82999. onAfterRender: (efect: Effect) => void;
  83000. /**
  83001. * 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
  83002. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83003. */
  83004. inputTexture: InternalTexture;
  83005. /**
  83006. * Gets the camera which post process is applied to.
  83007. * @returns The camera the post process is applied to.
  83008. */
  83009. getCamera(): Camera;
  83010. /**
  83011. * Gets the texel size of the postprocess.
  83012. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83013. */
  83014. readonly texelSize: Vector2;
  83015. /**
  83016. * Creates a new instance PostProcess
  83017. * @param name The name of the PostProcess.
  83018. * @param fragmentUrl The url of the fragment shader to be used.
  83019. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83020. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83021. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83022. * @param camera The camera to apply the render pass to.
  83023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83024. * @param engine The engine which the post process will be applied. (default: current engine)
  83025. * @param reusable If the post process can be reused on the same frame. (default: false)
  83026. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83027. * @param textureType Type of textures used when performing the post process. (default: 0)
  83028. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83029. * @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
  83030. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83031. */
  83032. constructor(
  83033. /** Name of the PostProcess. */
  83034. 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);
  83035. /**
  83036. * Gets a string idenfifying the name of the class
  83037. * @returns "PostProcess" string
  83038. */
  83039. getClassName(): string;
  83040. /**
  83041. * Gets the engine which this post process belongs to.
  83042. * @returns The engine the post process was enabled with.
  83043. */
  83044. getEngine(): Engine;
  83045. /**
  83046. * The effect that is created when initializing the post process.
  83047. * @returns The created effect corresponding the the postprocess.
  83048. */
  83049. getEffect(): Effect;
  83050. /**
  83051. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83052. * @param postProcess The post process to share the output with.
  83053. * @returns This post process.
  83054. */
  83055. shareOutputWith(postProcess: PostProcess): PostProcess;
  83056. /**
  83057. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83058. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83059. */
  83060. useOwnOutput(): void;
  83061. /**
  83062. * Updates the effect with the current post process compile time values and recompiles the shader.
  83063. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83064. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83065. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83066. * @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
  83067. * @param onCompiled Called when the shader has been compiled.
  83068. * @param onError Called if there is an error when compiling a shader.
  83069. */
  83070. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83071. /**
  83072. * The post process is reusable if it can be used multiple times within one frame.
  83073. * @returns If the post process is reusable
  83074. */
  83075. isReusable(): boolean;
  83076. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83077. markTextureDirty(): void;
  83078. /**
  83079. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83080. * 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.
  83081. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83082. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83083. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83084. * @returns The target texture that was bound to be written to.
  83085. */
  83086. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83087. /**
  83088. * If the post process is supported.
  83089. */
  83090. readonly isSupported: boolean;
  83091. /**
  83092. * The aspect ratio of the output texture.
  83093. */
  83094. readonly aspectRatio: number;
  83095. /**
  83096. * Get a value indicating if the post-process is ready to be used
  83097. * @returns true if the post-process is ready (shader is compiled)
  83098. */
  83099. isReady(): boolean;
  83100. /**
  83101. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83102. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83103. */
  83104. apply(): Nullable<Effect>;
  83105. private _disposeTextures;
  83106. /**
  83107. * Disposes the post process.
  83108. * @param camera The camera to dispose the post process on.
  83109. */
  83110. dispose(camera?: Camera): void;
  83111. }
  83112. }
  83113. declare module BABYLON {
  83114. /** @hidden */
  83115. export var kernelBlurVaryingDeclaration: {
  83116. name: string;
  83117. shader: string;
  83118. };
  83119. }
  83120. declare module BABYLON {
  83121. /** @hidden */
  83122. export var kernelBlurFragment: {
  83123. name: string;
  83124. shader: string;
  83125. };
  83126. }
  83127. declare module BABYLON {
  83128. /** @hidden */
  83129. export var kernelBlurFragment2: {
  83130. name: string;
  83131. shader: string;
  83132. };
  83133. }
  83134. declare module BABYLON {
  83135. /** @hidden */
  83136. export var kernelBlurPixelShader: {
  83137. name: string;
  83138. shader: string;
  83139. };
  83140. }
  83141. declare module BABYLON {
  83142. /** @hidden */
  83143. export var kernelBlurVertex: {
  83144. name: string;
  83145. shader: string;
  83146. };
  83147. }
  83148. declare module BABYLON {
  83149. /** @hidden */
  83150. export var kernelBlurVertexShader: {
  83151. name: string;
  83152. shader: string;
  83153. };
  83154. }
  83155. declare module BABYLON {
  83156. /**
  83157. * The Blur Post Process which blurs an image based on a kernel and direction.
  83158. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  83159. */
  83160. export class BlurPostProcess extends PostProcess {
  83161. /** The direction in which to blur the image. */
  83162. direction: Vector2;
  83163. private blockCompilation;
  83164. protected _kernel: number;
  83165. protected _idealKernel: number;
  83166. protected _packedFloat: boolean;
  83167. private _staticDefines;
  83168. /**
  83169. * Sets the length in pixels of the blur sample region
  83170. */
  83171. /**
  83172. * Gets the length in pixels of the blur sample region
  83173. */
  83174. kernel: number;
  83175. /**
  83176. * Sets wether or not the blur needs to unpack/repack floats
  83177. */
  83178. /**
  83179. * Gets wether or not the blur is unpacking/repacking floats
  83180. */
  83181. packedFloat: boolean;
  83182. /**
  83183. * Creates a new instance BlurPostProcess
  83184. * @param name The name of the effect.
  83185. * @param direction The direction in which to blur the image.
  83186. * @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.
  83187. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83188. * @param camera The camera to apply the render pass to.
  83189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83190. * @param engine The engine which the post process will be applied. (default: current engine)
  83191. * @param reusable If the post process can be reused on the same frame. (default: false)
  83192. * @param textureType Type of textures used when performing the post process. (default: 0)
  83193. * @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)
  83194. */
  83195. constructor(name: string,
  83196. /** The direction in which to blur the image. */
  83197. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  83198. /**
  83199. * Updates the effect with the current post process compile time values and recompiles the shader.
  83200. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83201. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83202. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83203. * @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
  83204. * @param onCompiled Called when the shader has been compiled.
  83205. * @param onError Called if there is an error when compiling a shader.
  83206. */
  83207. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83208. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83209. /**
  83210. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  83211. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  83212. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  83213. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  83214. * The gaps between physical kernels are compensated for in the weighting of the samples
  83215. * @param idealKernel Ideal blur kernel.
  83216. * @return Nearest best kernel.
  83217. */
  83218. protected _nearestBestKernel(idealKernel: number): number;
  83219. /**
  83220. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  83221. * @param x The point on the Gaussian distribution to sample.
  83222. * @return the value of the Gaussian function at x.
  83223. */
  83224. protected _gaussianWeight(x: number): number;
  83225. /**
  83226. * Generates a string that can be used as a floating point number in GLSL.
  83227. * @param x Value to print.
  83228. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  83229. * @return GLSL float string.
  83230. */
  83231. protected _glslFloat(x: number, decimalFigures?: number): string;
  83232. }
  83233. }
  83234. declare module BABYLON {
  83235. /**
  83236. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83237. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83238. * You can then easily use it as a reflectionTexture on a flat surface.
  83239. * In case the surface is not a plane, please consider relying on reflection probes.
  83240. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83241. */
  83242. export class MirrorTexture extends RenderTargetTexture {
  83243. private scene;
  83244. /**
  83245. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  83246. * 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.
  83247. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83248. */
  83249. mirrorPlane: Plane;
  83250. /**
  83251. * Define the blur ratio used to blur the reflection if needed.
  83252. */
  83253. blurRatio: number;
  83254. /**
  83255. * Define the adaptive blur kernel used to blur the reflection if needed.
  83256. * This will autocompute the closest best match for the `blurKernel`
  83257. */
  83258. adaptiveBlurKernel: number;
  83259. /**
  83260. * Define the blur kernel used to blur the reflection if needed.
  83261. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83262. */
  83263. blurKernel: number;
  83264. /**
  83265. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  83266. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83267. */
  83268. blurKernelX: number;
  83269. /**
  83270. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  83271. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  83272. */
  83273. blurKernelY: number;
  83274. private _autoComputeBlurKernel;
  83275. protected _onRatioRescale(): void;
  83276. private _updateGammaSpace;
  83277. private _imageProcessingConfigChangeObserver;
  83278. private _transformMatrix;
  83279. private _mirrorMatrix;
  83280. private _savedViewMatrix;
  83281. private _blurX;
  83282. private _blurY;
  83283. private _adaptiveBlurKernel;
  83284. private _blurKernelX;
  83285. private _blurKernelY;
  83286. private _blurRatio;
  83287. /**
  83288. * Instantiates a Mirror Texture.
  83289. * Mirror texture can be used to simulate the view from a mirror in a scene.
  83290. * It will dynamically be rendered every frame to adapt to the camera point of view.
  83291. * You can then easily use it as a reflectionTexture on a flat surface.
  83292. * In case the surface is not a plane, please consider relying on reflection probes.
  83293. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  83294. * @param name
  83295. * @param size
  83296. * @param scene
  83297. * @param generateMipMaps
  83298. * @param type
  83299. * @param samplingMode
  83300. * @param generateDepthBuffer
  83301. */
  83302. constructor(name: string, size: number | {
  83303. width: number;
  83304. height: number;
  83305. } | {
  83306. ratio: number;
  83307. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  83308. private _preparePostProcesses;
  83309. /**
  83310. * Clone the mirror texture.
  83311. * @returns the cloned texture
  83312. */
  83313. clone(): MirrorTexture;
  83314. /**
  83315. * Serialize the texture to a JSON representation you could use in Parse later on
  83316. * @returns the serialized JSON representation
  83317. */
  83318. serialize(): any;
  83319. /**
  83320. * Dispose the texture and release its associated resources.
  83321. */
  83322. dispose(): void;
  83323. }
  83324. }
  83325. declare module BABYLON {
  83326. /**
  83327. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83328. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83329. */
  83330. export class Texture extends BaseTexture {
  83331. /**
  83332. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  83333. */
  83334. static SerializeBuffers: boolean;
  83335. /** @hidden */
  83336. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  83337. /** @hidden */
  83338. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  83339. /** @hidden */
  83340. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  83341. /** nearest is mag = nearest and min = nearest and mip = linear */
  83342. static readonly NEAREST_SAMPLINGMODE: number;
  83343. /** nearest is mag = nearest and min = nearest and mip = linear */
  83344. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  83345. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83346. static readonly BILINEAR_SAMPLINGMODE: number;
  83347. /** Bilinear is mag = linear and min = linear and mip = nearest */
  83348. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  83349. /** Trilinear is mag = linear and min = linear and mip = linear */
  83350. static readonly TRILINEAR_SAMPLINGMODE: number;
  83351. /** Trilinear is mag = linear and min = linear and mip = linear */
  83352. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  83353. /** mag = nearest and min = nearest and mip = nearest */
  83354. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  83355. /** mag = nearest and min = linear and mip = nearest */
  83356. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  83357. /** mag = nearest and min = linear and mip = linear */
  83358. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  83359. /** mag = nearest and min = linear and mip = none */
  83360. static readonly NEAREST_LINEAR: number;
  83361. /** mag = nearest and min = nearest and mip = none */
  83362. static readonly NEAREST_NEAREST: number;
  83363. /** mag = linear and min = nearest and mip = nearest */
  83364. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  83365. /** mag = linear and min = nearest and mip = linear */
  83366. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  83367. /** mag = linear and min = linear and mip = none */
  83368. static readonly LINEAR_LINEAR: number;
  83369. /** mag = linear and min = nearest and mip = none */
  83370. static readonly LINEAR_NEAREST: number;
  83371. /** Explicit coordinates mode */
  83372. static readonly EXPLICIT_MODE: number;
  83373. /** Spherical coordinates mode */
  83374. static readonly SPHERICAL_MODE: number;
  83375. /** Planar coordinates mode */
  83376. static readonly PLANAR_MODE: number;
  83377. /** Cubic coordinates mode */
  83378. static readonly CUBIC_MODE: number;
  83379. /** Projection coordinates mode */
  83380. static readonly PROJECTION_MODE: number;
  83381. /** Inverse Cubic coordinates mode */
  83382. static readonly SKYBOX_MODE: number;
  83383. /** Inverse Cubic coordinates mode */
  83384. static readonly INVCUBIC_MODE: number;
  83385. /** Equirectangular coordinates mode */
  83386. static readonly EQUIRECTANGULAR_MODE: number;
  83387. /** Equirectangular Fixed coordinates mode */
  83388. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  83389. /** Equirectangular Fixed Mirrored coordinates mode */
  83390. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  83391. /** Texture is not repeating outside of 0..1 UVs */
  83392. static readonly CLAMP_ADDRESSMODE: number;
  83393. /** Texture is repeating outside of 0..1 UVs */
  83394. static readonly WRAP_ADDRESSMODE: number;
  83395. /** Texture is repeating and mirrored */
  83396. static readonly MIRROR_ADDRESSMODE: number;
  83397. /**
  83398. * 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
  83399. */
  83400. static UseSerializedUrlIfAny: boolean;
  83401. /**
  83402. * Define the url of the texture.
  83403. */
  83404. url: Nullable<string>;
  83405. /**
  83406. * Define an offset on the texture to offset the u coordinates of the UVs
  83407. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83408. */
  83409. uOffset: number;
  83410. /**
  83411. * Define an offset on the texture to offset the v coordinates of the UVs
  83412. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  83413. */
  83414. vOffset: number;
  83415. /**
  83416. * Define an offset on the texture to scale the u coordinates of the UVs
  83417. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83418. */
  83419. uScale: number;
  83420. /**
  83421. * Define an offset on the texture to scale the v coordinates of the UVs
  83422. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  83423. */
  83424. vScale: number;
  83425. /**
  83426. * Define an offset on the texture to rotate around the u coordinates of the UVs
  83427. * @see http://doc.babylonjs.com/how_to/more_materials
  83428. */
  83429. uAng: number;
  83430. /**
  83431. * Define an offset on the texture to rotate around the v coordinates of the UVs
  83432. * @see http://doc.babylonjs.com/how_to/more_materials
  83433. */
  83434. vAng: number;
  83435. /**
  83436. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  83437. * @see http://doc.babylonjs.com/how_to/more_materials
  83438. */
  83439. wAng: number;
  83440. /**
  83441. * Defines the center of rotation (U)
  83442. */
  83443. uRotationCenter: number;
  83444. /**
  83445. * Defines the center of rotation (V)
  83446. */
  83447. vRotationCenter: number;
  83448. /**
  83449. * Defines the center of rotation (W)
  83450. */
  83451. wRotationCenter: number;
  83452. /**
  83453. * Are mip maps generated for this texture or not.
  83454. */
  83455. readonly noMipmap: boolean;
  83456. /**
  83457. * List of inspectable custom properties (used by the Inspector)
  83458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83459. */
  83460. inspectableCustomProperties: Nullable<IInspectable[]>;
  83461. private _noMipmap;
  83462. /** @hidden */
  83463. _invertY: boolean;
  83464. private _rowGenerationMatrix;
  83465. private _cachedTextureMatrix;
  83466. private _projectionModeMatrix;
  83467. private _t0;
  83468. private _t1;
  83469. private _t2;
  83470. private _cachedUOffset;
  83471. private _cachedVOffset;
  83472. private _cachedUScale;
  83473. private _cachedVScale;
  83474. private _cachedUAng;
  83475. private _cachedVAng;
  83476. private _cachedWAng;
  83477. private _cachedProjectionMatrixId;
  83478. private _cachedCoordinatesMode;
  83479. /** @hidden */
  83480. protected _initialSamplingMode: number;
  83481. /** @hidden */
  83482. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  83483. private _deleteBuffer;
  83484. protected _format: Nullable<number>;
  83485. private _delayedOnLoad;
  83486. private _delayedOnError;
  83487. private _mimeType?;
  83488. /**
  83489. * Observable triggered once the texture has been loaded.
  83490. */
  83491. onLoadObservable: Observable<Texture>;
  83492. protected _isBlocking: boolean;
  83493. /**
  83494. * Is the texture preventing material to render while loading.
  83495. * If false, a default texture will be used instead of the loading one during the preparation step.
  83496. */
  83497. isBlocking: boolean;
  83498. /**
  83499. * Get the current sampling mode associated with the texture.
  83500. */
  83501. readonly samplingMode: number;
  83502. /**
  83503. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  83504. */
  83505. readonly invertY: boolean;
  83506. /**
  83507. * Instantiates a new texture.
  83508. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  83509. * @see http://doc.babylonjs.com/babylon101/materials#texture
  83510. * @param url defines the url of the picture to load as a texture
  83511. * @param scene defines the scene or engine the texture will belong to
  83512. * @param noMipmap defines if the texture will require mip maps or not
  83513. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  83514. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83515. * @param onLoad defines a callback triggered when the texture has been loaded
  83516. * @param onError defines a callback triggered when an error occurred during the loading session
  83517. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  83518. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  83519. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83520. * @param mimeType defines an optional mime type information
  83521. */
  83522. 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 | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  83523. /**
  83524. * Update the url (and optional buffer) of this texture if url was null during construction.
  83525. * @param url the url of the texture
  83526. * @param buffer the buffer of the texture (defaults to null)
  83527. * @param onLoad callback called when the texture is loaded (defaults to null)
  83528. */
  83529. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  83530. /**
  83531. * Finish the loading sequence of a texture flagged as delayed load.
  83532. * @hidden
  83533. */
  83534. delayLoad(): void;
  83535. private _prepareRowForTextureGeneration;
  83536. /**
  83537. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  83538. * @returns the transform matrix of the texture.
  83539. */
  83540. getTextureMatrix(): Matrix;
  83541. /**
  83542. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  83543. * @returns The reflection texture transform
  83544. */
  83545. getReflectionTextureMatrix(): Matrix;
  83546. /**
  83547. * Clones the texture.
  83548. * @returns the cloned texture
  83549. */
  83550. clone(): Texture;
  83551. /**
  83552. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83553. * @returns The JSON representation of the texture
  83554. */
  83555. serialize(): any;
  83556. /**
  83557. * Get the current class name of the texture useful for serialization or dynamic coding.
  83558. * @returns "Texture"
  83559. */
  83560. getClassName(): string;
  83561. /**
  83562. * Dispose the texture and release its associated resources.
  83563. */
  83564. dispose(): void;
  83565. /**
  83566. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  83567. * @param parsedTexture Define the JSON representation of the texture
  83568. * @param scene Define the scene the parsed texture should be instantiated in
  83569. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  83570. * @returns The parsed texture if successful
  83571. */
  83572. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  83573. /**
  83574. * Creates a texture from its base 64 representation.
  83575. * @param data Define the base64 payload without the data: prefix
  83576. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83577. * @param scene Define the scene the texture should belong to
  83578. * @param noMipmap Forces the texture to not create mip map information if true
  83579. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83580. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83581. * @param onLoad define a callback triggered when the texture has been loaded
  83582. * @param onError define a callback triggered when an error occurred during the loading session
  83583. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83584. * @returns the created texture
  83585. */
  83586. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  83587. /**
  83588. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  83589. * @param data Define the base64 payload without the data: prefix
  83590. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  83591. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  83592. * @param scene Define the scene the texture should belong to
  83593. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  83594. * @param noMipmap Forces the texture to not create mip map information if true
  83595. * @param invertY define if the texture needs to be inverted on the y axis during loading
  83596. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  83597. * @param onLoad define a callback triggered when the texture has been loaded
  83598. * @param onError define a callback triggered when an error occurred during the loading session
  83599. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  83600. * @returns the created texture
  83601. */
  83602. 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;
  83603. }
  83604. }
  83605. declare module BABYLON {
  83606. /**
  83607. * PostProcessManager is used to manage one or more post processes or post process pipelines
  83608. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83609. */
  83610. export class PostProcessManager {
  83611. private _scene;
  83612. private _indexBuffer;
  83613. private _vertexBuffers;
  83614. /**
  83615. * Creates a new instance PostProcess
  83616. * @param scene The scene that the post process is associated with.
  83617. */
  83618. constructor(scene: Scene);
  83619. private _prepareBuffers;
  83620. private _buildIndexBuffer;
  83621. /**
  83622. * Rebuilds the vertex buffers of the manager.
  83623. * @hidden
  83624. */
  83625. _rebuild(): void;
  83626. /**
  83627. * Prepares a frame to be run through a post process.
  83628. * @param sourceTexture The input texture to the post procesess. (default: null)
  83629. * @param postProcesses An array of post processes to be run. (default: null)
  83630. * @returns True if the post processes were able to be run.
  83631. * @hidden
  83632. */
  83633. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  83634. /**
  83635. * Manually render a set of post processes to a texture.
  83636. * @param postProcesses An array of post processes to be run.
  83637. * @param targetTexture The target texture to render to.
  83638. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  83639. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  83640. * @param lodLevel defines which lod of the texture to render to
  83641. */
  83642. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  83643. /**
  83644. * Finalize the result of the output of the postprocesses.
  83645. * @param doNotPresent If true the result will not be displayed to the screen.
  83646. * @param targetTexture The target texture to render to.
  83647. * @param faceIndex The index of the face to bind the target texture to.
  83648. * @param postProcesses The array of post processes to render.
  83649. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  83650. * @hidden
  83651. */
  83652. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  83653. /**
  83654. * Disposes of the post process manager.
  83655. */
  83656. dispose(): void;
  83657. }
  83658. }
  83659. declare module BABYLON {
  83660. /** Interface used by value gradients (color, factor, ...) */
  83661. export interface IValueGradient {
  83662. /**
  83663. * Gets or sets the gradient value (between 0 and 1)
  83664. */
  83665. gradient: number;
  83666. }
  83667. /** Class used to store color4 gradient */
  83668. export class ColorGradient implements IValueGradient {
  83669. /**
  83670. * Gets or sets the gradient value (between 0 and 1)
  83671. */
  83672. gradient: number;
  83673. /**
  83674. * Gets or sets first associated color
  83675. */
  83676. color1: Color4;
  83677. /**
  83678. * Gets or sets second associated color
  83679. */
  83680. color2?: Color4;
  83681. /**
  83682. * Will get a color picked randomly between color1 and color2.
  83683. * If color2 is undefined then color1 will be used
  83684. * @param result defines the target Color4 to store the result in
  83685. */
  83686. getColorToRef(result: Color4): void;
  83687. }
  83688. /** Class used to store color 3 gradient */
  83689. export class Color3Gradient implements IValueGradient {
  83690. /**
  83691. * Gets or sets the gradient value (between 0 and 1)
  83692. */
  83693. gradient: number;
  83694. /**
  83695. * Gets or sets the associated color
  83696. */
  83697. color: Color3;
  83698. }
  83699. /** Class used to store factor gradient */
  83700. export class FactorGradient implements IValueGradient {
  83701. /**
  83702. * Gets or sets the gradient value (between 0 and 1)
  83703. */
  83704. gradient: number;
  83705. /**
  83706. * Gets or sets first associated factor
  83707. */
  83708. factor1: number;
  83709. /**
  83710. * Gets or sets second associated factor
  83711. */
  83712. factor2?: number;
  83713. /**
  83714. * Will get a number picked randomly between factor1 and factor2.
  83715. * If factor2 is undefined then factor1 will be used
  83716. * @returns the picked number
  83717. */
  83718. getFactor(): number;
  83719. }
  83720. /**
  83721. * Helper used to simplify some generic gradient tasks
  83722. */
  83723. export class GradientHelper {
  83724. /**
  83725. * Gets the current gradient from an array of IValueGradient
  83726. * @param ratio defines the current ratio to get
  83727. * @param gradients defines the array of IValueGradient
  83728. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83729. */
  83730. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83731. }
  83732. }
  83733. declare module BABYLON {
  83734. interface ThinEngine {
  83735. /**
  83736. * Creates a dynamic texture
  83737. * @param width defines the width of the texture
  83738. * @param height defines the height of the texture
  83739. * @param generateMipMaps defines if the engine should generate the mip levels
  83740. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83741. * @returns the dynamic texture inside an InternalTexture
  83742. */
  83743. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83744. /**
  83745. * Update the content of a dynamic texture
  83746. * @param texture defines the texture to update
  83747. * @param canvas defines the canvas containing the source
  83748. * @param invertY defines if data must be stored with Y axis inverted
  83749. * @param premulAlpha defines if alpha is stored as premultiplied
  83750. * @param format defines the format of the data
  83751. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83752. */
  83753. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83754. }
  83755. }
  83756. declare module BABYLON {
  83757. /**
  83758. * Helper class used to generate a canvas to manipulate images
  83759. */
  83760. export class CanvasGenerator {
  83761. /**
  83762. * Create a new canvas (or offscreen canvas depending on the context)
  83763. * @param width defines the expected width
  83764. * @param height defines the expected height
  83765. * @return a new canvas or offscreen canvas
  83766. */
  83767. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83768. }
  83769. }
  83770. declare module BABYLON {
  83771. /**
  83772. * A class extending Texture allowing drawing on a texture
  83773. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83774. */
  83775. export class DynamicTexture extends Texture {
  83776. private _generateMipMaps;
  83777. private _canvas;
  83778. private _context;
  83779. private _engine;
  83780. /**
  83781. * Creates a DynamicTexture
  83782. * @param name defines the name of the texture
  83783. * @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
  83784. * @param scene defines the scene where you want the texture
  83785. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83786. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83787. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83788. */
  83789. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83790. /**
  83791. * Get the current class name of the texture useful for serialization or dynamic coding.
  83792. * @returns "DynamicTexture"
  83793. */
  83794. getClassName(): string;
  83795. /**
  83796. * Gets the current state of canRescale
  83797. */
  83798. readonly canRescale: boolean;
  83799. private _recreate;
  83800. /**
  83801. * Scales the texture
  83802. * @param ratio the scale factor to apply to both width and height
  83803. */
  83804. scale(ratio: number): void;
  83805. /**
  83806. * Resizes the texture
  83807. * @param width the new width
  83808. * @param height the new height
  83809. */
  83810. scaleTo(width: number, height: number): void;
  83811. /**
  83812. * Gets the context of the canvas used by the texture
  83813. * @returns the canvas context of the dynamic texture
  83814. */
  83815. getContext(): CanvasRenderingContext2D;
  83816. /**
  83817. * Clears the texture
  83818. */
  83819. clear(): void;
  83820. /**
  83821. * Updates the texture
  83822. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83823. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83824. */
  83825. update(invertY?: boolean, premulAlpha?: boolean): void;
  83826. /**
  83827. * Draws text onto the texture
  83828. * @param text defines the text to be drawn
  83829. * @param x defines the placement of the text from the left
  83830. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83831. * @param font defines the font to be used with font-style, font-size, font-name
  83832. * @param color defines the color used for the text
  83833. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83834. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83835. * @param update defines whether texture is immediately update (default is true)
  83836. */
  83837. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83838. /**
  83839. * Clones the texture
  83840. * @returns the clone of the texture.
  83841. */
  83842. clone(): DynamicTexture;
  83843. /**
  83844. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83845. * @returns a serialized dynamic texture object
  83846. */
  83847. serialize(): any;
  83848. /** @hidden */
  83849. _rebuild(): void;
  83850. }
  83851. }
  83852. declare module BABYLON {
  83853. interface AbstractScene {
  83854. /**
  83855. * The list of procedural textures added to the scene
  83856. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83857. */
  83858. proceduralTextures: Array<ProceduralTexture>;
  83859. }
  83860. /**
  83861. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83862. * in a given scene.
  83863. */
  83864. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83865. /**
  83866. * The component name helpfull to identify the component in the list of scene components.
  83867. */
  83868. readonly name: string;
  83869. /**
  83870. * The scene the component belongs to.
  83871. */
  83872. scene: Scene;
  83873. /**
  83874. * Creates a new instance of the component for the given scene
  83875. * @param scene Defines the scene to register the component in
  83876. */
  83877. constructor(scene: Scene);
  83878. /**
  83879. * Registers the component in a given scene
  83880. */
  83881. register(): void;
  83882. /**
  83883. * Rebuilds the elements related to this component in case of
  83884. * context lost for instance.
  83885. */
  83886. rebuild(): void;
  83887. /**
  83888. * Disposes the component and the associated ressources.
  83889. */
  83890. dispose(): void;
  83891. private _beforeClear;
  83892. }
  83893. }
  83894. declare module BABYLON {
  83895. interface ThinEngine {
  83896. /**
  83897. * Creates a new render target cube texture
  83898. * @param size defines the size of the texture
  83899. * @param options defines the options used to create the texture
  83900. * @returns a new render target cube texture stored in an InternalTexture
  83901. */
  83902. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83903. }
  83904. }
  83905. declare module BABYLON {
  83906. /** @hidden */
  83907. export var proceduralVertexShader: {
  83908. name: string;
  83909. shader: string;
  83910. };
  83911. }
  83912. declare module BABYLON {
  83913. /**
  83914. * 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.
  83915. * This is the base class of any Procedural texture and contains most of the shareable code.
  83916. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83917. */
  83918. export class ProceduralTexture extends Texture {
  83919. isCube: boolean;
  83920. /**
  83921. * Define if the texture is enabled or not (disabled texture will not render)
  83922. */
  83923. isEnabled: boolean;
  83924. /**
  83925. * Define if the texture must be cleared before rendering (default is true)
  83926. */
  83927. autoClear: boolean;
  83928. /**
  83929. * Callback called when the texture is generated
  83930. */
  83931. onGenerated: () => void;
  83932. /**
  83933. * Event raised when the texture is generated
  83934. */
  83935. onGeneratedObservable: Observable<ProceduralTexture>;
  83936. /** @hidden */
  83937. _generateMipMaps: boolean;
  83938. /** @hidden **/
  83939. _effect: Effect;
  83940. /** @hidden */
  83941. _textures: {
  83942. [key: string]: Texture;
  83943. };
  83944. private _size;
  83945. private _currentRefreshId;
  83946. private _refreshRate;
  83947. private _vertexBuffers;
  83948. private _indexBuffer;
  83949. private _uniforms;
  83950. private _samplers;
  83951. private _fragment;
  83952. private _floats;
  83953. private _ints;
  83954. private _floatsArrays;
  83955. private _colors3;
  83956. private _colors4;
  83957. private _vectors2;
  83958. private _vectors3;
  83959. private _matrices;
  83960. private _fallbackTexture;
  83961. private _fallbackTextureUsed;
  83962. private _engine;
  83963. private _cachedDefines;
  83964. private _contentUpdateId;
  83965. private _contentData;
  83966. /**
  83967. * Instantiates a new procedural texture.
  83968. * 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.
  83969. * This is the base class of any Procedural texture and contains most of the shareable code.
  83970. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83971. * @param name Define the name of the texture
  83972. * @param size Define the size of the texture to create
  83973. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83974. * @param scene Define the scene the texture belongs to
  83975. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83976. * @param generateMipMaps Define if the texture should creates mip maps or not
  83977. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83978. */
  83979. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83980. /**
  83981. * The effect that is created when initializing the post process.
  83982. * @returns The created effect corresponding the the postprocess.
  83983. */
  83984. getEffect(): Effect;
  83985. /**
  83986. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83987. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83988. */
  83989. getContent(): Nullable<ArrayBufferView>;
  83990. private _createIndexBuffer;
  83991. /** @hidden */
  83992. _rebuild(): void;
  83993. /**
  83994. * Resets the texture in order to recreate its associated resources.
  83995. * This can be called in case of context loss
  83996. */
  83997. reset(): void;
  83998. protected _getDefines(): string;
  83999. /**
  84000. * Is the texture ready to be used ? (rendered at least once)
  84001. * @returns true if ready, otherwise, false.
  84002. */
  84003. isReady(): boolean;
  84004. /**
  84005. * Resets the refresh counter of the texture and start bak from scratch.
  84006. * Could be useful to regenerate the texture if it is setup to render only once.
  84007. */
  84008. resetRefreshCounter(): void;
  84009. /**
  84010. * Set the fragment shader to use in order to render the texture.
  84011. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84012. */
  84013. setFragment(fragment: any): void;
  84014. /**
  84015. * Define the refresh rate of the texture or the rendering frequency.
  84016. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84017. */
  84018. refreshRate: number;
  84019. /** @hidden */
  84020. _shouldRender(): boolean;
  84021. /**
  84022. * Get the size the texture is rendering at.
  84023. * @returns the size (texture is always squared)
  84024. */
  84025. getRenderSize(): number;
  84026. /**
  84027. * Resize the texture to new value.
  84028. * @param size Define the new size the texture should have
  84029. * @param generateMipMaps Define whether the new texture should create mip maps
  84030. */
  84031. resize(size: number, generateMipMaps: boolean): void;
  84032. private _checkUniform;
  84033. /**
  84034. * Set a texture in the shader program used to render.
  84035. * @param name Define the name of the uniform samplers as defined in the shader
  84036. * @param texture Define the texture to bind to this sampler
  84037. * @return the texture itself allowing "fluent" like uniform updates
  84038. */
  84039. setTexture(name: string, texture: Texture): ProceduralTexture;
  84040. /**
  84041. * Set a float in the shader.
  84042. * @param name Define the name of the uniform as defined in the shader
  84043. * @param value Define the value to give to the uniform
  84044. * @return the texture itself allowing "fluent" like uniform updates
  84045. */
  84046. setFloat(name: string, value: number): ProceduralTexture;
  84047. /**
  84048. * Set a int in the shader.
  84049. * @param name Define the name of the uniform as defined in the shader
  84050. * @param value Define the value to give to the uniform
  84051. * @return the texture itself allowing "fluent" like uniform updates
  84052. */
  84053. setInt(name: string, value: number): ProceduralTexture;
  84054. /**
  84055. * Set an array of floats in the shader.
  84056. * @param name Define the name of the uniform as defined in the shader
  84057. * @param value Define the value to give to the uniform
  84058. * @return the texture itself allowing "fluent" like uniform updates
  84059. */
  84060. setFloats(name: string, value: number[]): ProceduralTexture;
  84061. /**
  84062. * Set a vec3 in the shader from a Color3.
  84063. * @param name Define the name of the uniform as defined in the shader
  84064. * @param value Define the value to give to the uniform
  84065. * @return the texture itself allowing "fluent" like uniform updates
  84066. */
  84067. setColor3(name: string, value: Color3): ProceduralTexture;
  84068. /**
  84069. * Set a vec4 in the shader from a Color4.
  84070. * @param name Define the name of the uniform as defined in the shader
  84071. * @param value Define the value to give to the uniform
  84072. * @return the texture itself allowing "fluent" like uniform updates
  84073. */
  84074. setColor4(name: string, value: Color4): ProceduralTexture;
  84075. /**
  84076. * Set a vec2 in the shader from a Vector2.
  84077. * @param name Define the name of the uniform as defined in the shader
  84078. * @param value Define the value to give to the uniform
  84079. * @return the texture itself allowing "fluent" like uniform updates
  84080. */
  84081. setVector2(name: string, value: Vector2): ProceduralTexture;
  84082. /**
  84083. * Set a vec3 in the shader from a Vector3.
  84084. * @param name Define the name of the uniform as defined in the shader
  84085. * @param value Define the value to give to the uniform
  84086. * @return the texture itself allowing "fluent" like uniform updates
  84087. */
  84088. setVector3(name: string, value: Vector3): ProceduralTexture;
  84089. /**
  84090. * Set a mat4 in the shader from a MAtrix.
  84091. * @param name Define the name of the uniform as defined in the shader
  84092. * @param value Define the value to give to the uniform
  84093. * @return the texture itself allowing "fluent" like uniform updates
  84094. */
  84095. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84096. /**
  84097. * Render the texture to its associated render target.
  84098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84099. */
  84100. render(useCameraPostProcess?: boolean): void;
  84101. /**
  84102. * Clone the texture.
  84103. * @returns the cloned texture
  84104. */
  84105. clone(): ProceduralTexture;
  84106. /**
  84107. * Dispose the texture and release its asoociated resources.
  84108. */
  84109. dispose(): void;
  84110. }
  84111. }
  84112. declare module BABYLON {
  84113. /**
  84114. * This represents the base class for particle system in Babylon.
  84115. * 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.
  84116. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84117. * @example https://doc.babylonjs.com/babylon101/particles
  84118. */
  84119. export class BaseParticleSystem {
  84120. /**
  84121. * Source color is added to the destination color without alpha affecting the result
  84122. */
  84123. static BLENDMODE_ONEONE: number;
  84124. /**
  84125. * Blend current color and particle color using particle’s alpha
  84126. */
  84127. static BLENDMODE_STANDARD: number;
  84128. /**
  84129. * Add current color and particle color multiplied by particle’s alpha
  84130. */
  84131. static BLENDMODE_ADD: number;
  84132. /**
  84133. * Multiply current color with particle color
  84134. */
  84135. static BLENDMODE_MULTIPLY: number;
  84136. /**
  84137. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84138. */
  84139. static BLENDMODE_MULTIPLYADD: number;
  84140. /**
  84141. * List of animations used by the particle system.
  84142. */
  84143. animations: Animation[];
  84144. /**
  84145. * The id of the Particle system.
  84146. */
  84147. id: string;
  84148. /**
  84149. * The friendly name of the Particle system.
  84150. */
  84151. name: string;
  84152. /**
  84153. * The rendering group used by the Particle system to chose when to render.
  84154. */
  84155. renderingGroupId: number;
  84156. /**
  84157. * The emitter represents the Mesh or position we are attaching the particle system to.
  84158. */
  84159. emitter: Nullable<AbstractMesh | Vector3>;
  84160. /**
  84161. * The maximum number of particles to emit per frame
  84162. */
  84163. emitRate: number;
  84164. /**
  84165. * If you want to launch only a few particles at once, that can be done, as well.
  84166. */
  84167. manualEmitCount: number;
  84168. /**
  84169. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84170. */
  84171. updateSpeed: number;
  84172. /**
  84173. * The amount of time the particle system is running (depends of the overall update speed).
  84174. */
  84175. targetStopDuration: number;
  84176. /**
  84177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84178. */
  84179. disposeOnStop: boolean;
  84180. /**
  84181. * Minimum power of emitting particles.
  84182. */
  84183. minEmitPower: number;
  84184. /**
  84185. * Maximum power of emitting particles.
  84186. */
  84187. maxEmitPower: number;
  84188. /**
  84189. * Minimum life time of emitting particles.
  84190. */
  84191. minLifeTime: number;
  84192. /**
  84193. * Maximum life time of emitting particles.
  84194. */
  84195. maxLifeTime: number;
  84196. /**
  84197. * Minimum Size of emitting particles.
  84198. */
  84199. minSize: number;
  84200. /**
  84201. * Maximum Size of emitting particles.
  84202. */
  84203. maxSize: number;
  84204. /**
  84205. * Minimum scale of emitting particles on X axis.
  84206. */
  84207. minScaleX: number;
  84208. /**
  84209. * Maximum scale of emitting particles on X axis.
  84210. */
  84211. maxScaleX: number;
  84212. /**
  84213. * Minimum scale of emitting particles on Y axis.
  84214. */
  84215. minScaleY: number;
  84216. /**
  84217. * Maximum scale of emitting particles on Y axis.
  84218. */
  84219. maxScaleY: number;
  84220. /**
  84221. * Gets or sets the minimal initial rotation in radians.
  84222. */
  84223. minInitialRotation: number;
  84224. /**
  84225. * Gets or sets the maximal initial rotation in radians.
  84226. */
  84227. maxInitialRotation: number;
  84228. /**
  84229. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84230. */
  84231. minAngularSpeed: number;
  84232. /**
  84233. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84234. */
  84235. maxAngularSpeed: number;
  84236. /**
  84237. * The texture used to render each particle. (this can be a spritesheet)
  84238. */
  84239. particleTexture: Nullable<Texture>;
  84240. /**
  84241. * The layer mask we are rendering the particles through.
  84242. */
  84243. layerMask: number;
  84244. /**
  84245. * This can help using your own shader to render the particle system.
  84246. * The according effect will be created
  84247. */
  84248. customShader: any;
  84249. /**
  84250. * By default particle system starts as soon as they are created. This prevents the
  84251. * automatic start to happen and let you decide when to start emitting particles.
  84252. */
  84253. preventAutoStart: boolean;
  84254. private _noiseTexture;
  84255. /**
  84256. * Gets or sets a texture used to add random noise to particle positions
  84257. */
  84258. noiseTexture: Nullable<ProceduralTexture>;
  84259. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84260. noiseStrength: Vector3;
  84261. /**
  84262. * Callback triggered when the particle animation is ending.
  84263. */
  84264. onAnimationEnd: Nullable<() => void>;
  84265. /**
  84266. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84267. */
  84268. blendMode: number;
  84269. /**
  84270. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84271. * to override the particles.
  84272. */
  84273. forceDepthWrite: boolean;
  84274. /** 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 */
  84275. preWarmCycles: number;
  84276. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84277. preWarmStepOffset: number;
  84278. /**
  84279. * 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)
  84280. */
  84281. spriteCellChangeSpeed: number;
  84282. /**
  84283. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84284. */
  84285. startSpriteCellID: number;
  84286. /**
  84287. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84288. */
  84289. endSpriteCellID: number;
  84290. /**
  84291. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84292. */
  84293. spriteCellWidth: number;
  84294. /**
  84295. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84296. */
  84297. spriteCellHeight: number;
  84298. /**
  84299. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84300. */
  84301. spriteRandomStartCell: boolean;
  84302. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84303. translationPivot: Vector2;
  84304. /** @hidden */
  84305. protected _isAnimationSheetEnabled: boolean;
  84306. /**
  84307. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84308. */
  84309. beginAnimationOnStart: boolean;
  84310. /**
  84311. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84312. */
  84313. beginAnimationFrom: number;
  84314. /**
  84315. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84316. */
  84317. beginAnimationTo: number;
  84318. /**
  84319. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84320. */
  84321. beginAnimationLoop: boolean;
  84322. /**
  84323. * Gets or sets a world offset applied to all particles
  84324. */
  84325. worldOffset: Vector3;
  84326. /**
  84327. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84328. */
  84329. isAnimationSheetEnabled: boolean;
  84330. /**
  84331. * Get hosting scene
  84332. * @returns the scene
  84333. */
  84334. getScene(): Scene;
  84335. /**
  84336. * You can use gravity if you want to give an orientation to your particles.
  84337. */
  84338. gravity: Vector3;
  84339. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84340. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84341. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84342. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84343. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84344. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84345. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84346. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84347. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84348. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84349. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84350. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84351. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84352. /**
  84353. * Defines the delay in milliseconds before starting the system (0 by default)
  84354. */
  84355. startDelay: number;
  84356. /**
  84357. * Gets the current list of drag gradients.
  84358. * You must use addDragGradient and removeDragGradient to udpate this list
  84359. * @returns the list of drag gradients
  84360. */
  84361. getDragGradients(): Nullable<Array<FactorGradient>>;
  84362. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84363. limitVelocityDamping: number;
  84364. /**
  84365. * Gets the current list of limit velocity gradients.
  84366. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84367. * @returns the list of limit velocity gradients
  84368. */
  84369. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84370. /**
  84371. * Gets the current list of color gradients.
  84372. * You must use addColorGradient and removeColorGradient to udpate this list
  84373. * @returns the list of color gradients
  84374. */
  84375. getColorGradients(): Nullable<Array<ColorGradient>>;
  84376. /**
  84377. * Gets the current list of size gradients.
  84378. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84379. * @returns the list of size gradients
  84380. */
  84381. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84382. /**
  84383. * Gets the current list of color remap gradients.
  84384. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84385. * @returns the list of color remap gradients
  84386. */
  84387. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84388. /**
  84389. * Gets the current list of alpha remap gradients.
  84390. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84391. * @returns the list of alpha remap gradients
  84392. */
  84393. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84394. /**
  84395. * Gets the current list of life time gradients.
  84396. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84397. * @returns the list of life time gradients
  84398. */
  84399. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84400. /**
  84401. * Gets the current list of angular speed gradients.
  84402. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84403. * @returns the list of angular speed gradients
  84404. */
  84405. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84406. /**
  84407. * Gets the current list of velocity gradients.
  84408. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84409. * @returns the list of velocity gradients
  84410. */
  84411. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84412. /**
  84413. * Gets the current list of start size gradients.
  84414. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84415. * @returns the list of start size gradients
  84416. */
  84417. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84418. /**
  84419. * Gets the current list of emit rate gradients.
  84420. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84421. * @returns the list of emit rate gradients
  84422. */
  84423. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84424. /**
  84425. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84426. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84427. */
  84428. direction1: Vector3;
  84429. /**
  84430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84431. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84432. */
  84433. direction2: Vector3;
  84434. /**
  84435. * 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.
  84436. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84437. */
  84438. minEmitBox: Vector3;
  84439. /**
  84440. * 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.
  84441. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84442. */
  84443. maxEmitBox: Vector3;
  84444. /**
  84445. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84446. */
  84447. color1: Color4;
  84448. /**
  84449. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84450. */
  84451. color2: Color4;
  84452. /**
  84453. * Color the particle will have at the end of its lifetime
  84454. */
  84455. colorDead: Color4;
  84456. /**
  84457. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84458. */
  84459. textureMask: Color4;
  84460. /**
  84461. * The particle emitter type defines the emitter used by the particle system.
  84462. * It can be for example box, sphere, or cone...
  84463. */
  84464. particleEmitterType: IParticleEmitterType;
  84465. /** @hidden */
  84466. _isSubEmitter: boolean;
  84467. /**
  84468. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84469. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84470. */
  84471. billboardMode: number;
  84472. protected _isBillboardBased: boolean;
  84473. /**
  84474. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84475. */
  84476. isBillboardBased: boolean;
  84477. /**
  84478. * The scene the particle system belongs to.
  84479. */
  84480. protected _scene: Scene;
  84481. /**
  84482. * Local cache of defines for image processing.
  84483. */
  84484. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84485. /**
  84486. * Default configuration related to image processing available in the standard Material.
  84487. */
  84488. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84489. /**
  84490. * Gets the image processing configuration used either in this material.
  84491. */
  84492. /**
  84493. * Sets the Default image processing configuration used either in the this material.
  84494. *
  84495. * If sets to null, the scene one is in use.
  84496. */
  84497. imageProcessingConfiguration: ImageProcessingConfiguration;
  84498. /**
  84499. * Attaches a new image processing configuration to the Standard Material.
  84500. * @param configuration
  84501. */
  84502. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84503. /** @hidden */
  84504. protected _reset(): void;
  84505. /** @hidden */
  84506. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84507. /**
  84508. * Instantiates a particle system.
  84509. * 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.
  84510. * @param name The name of the particle system
  84511. */
  84512. constructor(name: string);
  84513. /**
  84514. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84515. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84516. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84517. * @returns the emitter
  84518. */
  84519. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84520. /**
  84521. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84522. * @param radius The radius of the hemisphere to emit from
  84523. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84524. * @returns the emitter
  84525. */
  84526. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84527. /**
  84528. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84529. * @param radius The radius of the sphere to emit from
  84530. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84531. * @returns the emitter
  84532. */
  84533. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84534. /**
  84535. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84536. * @param radius The radius of the sphere to emit from
  84537. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84538. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84539. * @returns the emitter
  84540. */
  84541. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84542. /**
  84543. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84544. * @param radius The radius of the emission cylinder
  84545. * @param height The height of the emission cylinder
  84546. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84547. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84548. * @returns the emitter
  84549. */
  84550. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84551. /**
  84552. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84553. * @param radius The radius of the cylinder to emit from
  84554. * @param height The height of the emission cylinder
  84555. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84558. * @returns the emitter
  84559. */
  84560. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84561. /**
  84562. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84563. * @param radius The radius of the cone to emit from
  84564. * @param angle The base angle of the cone
  84565. * @returns the emitter
  84566. */
  84567. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84568. /**
  84569. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84572. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84573. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84574. * @returns the emitter
  84575. */
  84576. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84577. }
  84578. }
  84579. declare module BABYLON {
  84580. /**
  84581. * Type of sub emitter
  84582. */
  84583. export enum SubEmitterType {
  84584. /**
  84585. * Attached to the particle over it's lifetime
  84586. */
  84587. ATTACHED = 0,
  84588. /**
  84589. * Created when the particle dies
  84590. */
  84591. END = 1
  84592. }
  84593. /**
  84594. * Sub emitter class used to emit particles from an existing particle
  84595. */
  84596. export class SubEmitter {
  84597. /**
  84598. * the particle system to be used by the sub emitter
  84599. */
  84600. particleSystem: ParticleSystem;
  84601. /**
  84602. * Type of the submitter (Default: END)
  84603. */
  84604. type: SubEmitterType;
  84605. /**
  84606. * 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)
  84607. * Note: This only is supported when using an emitter of type Mesh
  84608. */
  84609. inheritDirection: boolean;
  84610. /**
  84611. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84612. */
  84613. inheritedVelocityAmount: number;
  84614. /**
  84615. * Creates a sub emitter
  84616. * @param particleSystem the particle system to be used by the sub emitter
  84617. */
  84618. constructor(
  84619. /**
  84620. * the particle system to be used by the sub emitter
  84621. */
  84622. particleSystem: ParticleSystem);
  84623. /**
  84624. * Clones the sub emitter
  84625. * @returns the cloned sub emitter
  84626. */
  84627. clone(): SubEmitter;
  84628. /**
  84629. * Serialize current object to a JSON object
  84630. * @returns the serialized object
  84631. */
  84632. serialize(): any;
  84633. /** @hidden */
  84634. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84635. /**
  84636. * Creates a new SubEmitter from a serialized JSON version
  84637. * @param serializationObject defines the JSON object to read from
  84638. * @param scene defines the hosting scene
  84639. * @param rootUrl defines the rootUrl for data loading
  84640. * @returns a new SubEmitter
  84641. */
  84642. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84643. /** Release associated resources */
  84644. dispose(): void;
  84645. }
  84646. }
  84647. declare module BABYLON {
  84648. /** @hidden */
  84649. export var clipPlaneFragmentDeclaration: {
  84650. name: string;
  84651. shader: string;
  84652. };
  84653. }
  84654. declare module BABYLON {
  84655. /** @hidden */
  84656. export var imageProcessingDeclaration: {
  84657. name: string;
  84658. shader: string;
  84659. };
  84660. }
  84661. declare module BABYLON {
  84662. /** @hidden */
  84663. export var imageProcessingFunctions: {
  84664. name: string;
  84665. shader: string;
  84666. };
  84667. }
  84668. declare module BABYLON {
  84669. /** @hidden */
  84670. export var clipPlaneFragment: {
  84671. name: string;
  84672. shader: string;
  84673. };
  84674. }
  84675. declare module BABYLON {
  84676. /** @hidden */
  84677. export var particlesPixelShader: {
  84678. name: string;
  84679. shader: string;
  84680. };
  84681. }
  84682. declare module BABYLON {
  84683. /** @hidden */
  84684. export var clipPlaneVertexDeclaration: {
  84685. name: string;
  84686. shader: string;
  84687. };
  84688. }
  84689. declare module BABYLON {
  84690. /** @hidden */
  84691. export var clipPlaneVertex: {
  84692. name: string;
  84693. shader: string;
  84694. };
  84695. }
  84696. declare module BABYLON {
  84697. /** @hidden */
  84698. export var particlesVertexShader: {
  84699. name: string;
  84700. shader: string;
  84701. };
  84702. }
  84703. declare module BABYLON {
  84704. /**
  84705. * This represents a particle system in Babylon.
  84706. * 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.
  84707. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84708. * @example https://doc.babylonjs.com/babylon101/particles
  84709. */
  84710. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84711. /**
  84712. * Billboard mode will only apply to Y axis
  84713. */
  84714. static readonly BILLBOARDMODE_Y: number;
  84715. /**
  84716. * Billboard mode will apply to all axes
  84717. */
  84718. static readonly BILLBOARDMODE_ALL: number;
  84719. /**
  84720. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84721. */
  84722. static readonly BILLBOARDMODE_STRETCHED: number;
  84723. /**
  84724. * This function can be defined to provide custom update for active particles.
  84725. * This function will be called instead of regular update (age, position, color, etc.).
  84726. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84727. */
  84728. updateFunction: (particles: Particle[]) => void;
  84729. private _emitterWorldMatrix;
  84730. /**
  84731. * This function can be defined to specify initial direction for every new particle.
  84732. * It by default use the emitterType defined function
  84733. */
  84734. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84735. /**
  84736. * This function can be defined to specify initial position for every new particle.
  84737. * It by default use the emitterType defined function
  84738. */
  84739. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84740. /**
  84741. * @hidden
  84742. */
  84743. _inheritedVelocityOffset: Vector3;
  84744. /**
  84745. * An event triggered when the system is disposed
  84746. */
  84747. onDisposeObservable: Observable<ParticleSystem>;
  84748. private _onDisposeObserver;
  84749. /**
  84750. * Sets a callback that will be triggered when the system is disposed
  84751. */
  84752. onDispose: () => void;
  84753. private _particles;
  84754. private _epsilon;
  84755. private _capacity;
  84756. private _stockParticles;
  84757. private _newPartsExcess;
  84758. private _vertexData;
  84759. private _vertexBuffer;
  84760. private _vertexBuffers;
  84761. private _spriteBuffer;
  84762. private _indexBuffer;
  84763. private _effect;
  84764. private _customEffect;
  84765. private _cachedDefines;
  84766. private _scaledColorStep;
  84767. private _colorDiff;
  84768. private _scaledDirection;
  84769. private _scaledGravity;
  84770. private _currentRenderId;
  84771. private _alive;
  84772. private _useInstancing;
  84773. private _started;
  84774. private _stopped;
  84775. private _actualFrame;
  84776. private _scaledUpdateSpeed;
  84777. private _vertexBufferSize;
  84778. /** @hidden */
  84779. _currentEmitRateGradient: Nullable<FactorGradient>;
  84780. /** @hidden */
  84781. _currentEmitRate1: number;
  84782. /** @hidden */
  84783. _currentEmitRate2: number;
  84784. /** @hidden */
  84785. _currentStartSizeGradient: Nullable<FactorGradient>;
  84786. /** @hidden */
  84787. _currentStartSize1: number;
  84788. /** @hidden */
  84789. _currentStartSize2: number;
  84790. private readonly _rawTextureWidth;
  84791. private _rampGradientsTexture;
  84792. private _useRampGradients;
  84793. /** Gets or sets a boolean indicating that ramp gradients must be used
  84794. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84795. */
  84796. useRampGradients: boolean;
  84797. /**
  84798. * 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.
  84799. * 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: [])
  84800. */
  84801. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84802. private _subEmitters;
  84803. /**
  84804. * @hidden
  84805. * If the particle systems emitter should be disposed when the particle system is disposed
  84806. */
  84807. _disposeEmitterOnDispose: boolean;
  84808. /**
  84809. * The current active Sub-systems, this property is used by the root particle system only.
  84810. */
  84811. activeSubSystems: Array<ParticleSystem>;
  84812. private _rootParticleSystem;
  84813. /**
  84814. * Gets the current list of active particles
  84815. */
  84816. readonly particles: Particle[];
  84817. /**
  84818. * Returns the string "ParticleSystem"
  84819. * @returns a string containing the class name
  84820. */
  84821. getClassName(): string;
  84822. /**
  84823. * Instantiates a particle system.
  84824. * 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.
  84825. * @param name The name of the particle system
  84826. * @param capacity The max number of particles alive at the same time
  84827. * @param scene The scene the particle system belongs to
  84828. * @param customEffect a custom effect used to change the way particles are rendered by default
  84829. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84830. * @param epsilon Offset used to render the particles
  84831. */
  84832. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84833. private _addFactorGradient;
  84834. private _removeFactorGradient;
  84835. /**
  84836. * Adds a new life time gradient
  84837. * @param gradient defines the gradient to use (between 0 and 1)
  84838. * @param factor defines the life time factor to affect to the specified gradient
  84839. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84840. * @returns the current particle system
  84841. */
  84842. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84843. /**
  84844. * Remove a specific life time gradient
  84845. * @param gradient defines the gradient to remove
  84846. * @returns the current particle system
  84847. */
  84848. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84849. /**
  84850. * Adds a new size gradient
  84851. * @param gradient defines the gradient to use (between 0 and 1)
  84852. * @param factor defines the size factor to affect to the specified gradient
  84853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84854. * @returns the current particle system
  84855. */
  84856. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84857. /**
  84858. * Remove a specific size gradient
  84859. * @param gradient defines the gradient to remove
  84860. * @returns the current particle system
  84861. */
  84862. removeSizeGradient(gradient: number): IParticleSystem;
  84863. /**
  84864. * Adds a new color remap gradient
  84865. * @param gradient defines the gradient to use (between 0 and 1)
  84866. * @param min defines the color remap minimal range
  84867. * @param max defines the color remap maximal range
  84868. * @returns the current particle system
  84869. */
  84870. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84871. /**
  84872. * Remove a specific color remap gradient
  84873. * @param gradient defines the gradient to remove
  84874. * @returns the current particle system
  84875. */
  84876. removeColorRemapGradient(gradient: number): IParticleSystem;
  84877. /**
  84878. * Adds a new alpha remap gradient
  84879. * @param gradient defines the gradient to use (between 0 and 1)
  84880. * @param min defines the alpha remap minimal range
  84881. * @param max defines the alpha remap maximal range
  84882. * @returns the current particle system
  84883. */
  84884. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84885. /**
  84886. * Remove a specific alpha remap gradient
  84887. * @param gradient defines the gradient to remove
  84888. * @returns the current particle system
  84889. */
  84890. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84891. /**
  84892. * Adds a new angular speed gradient
  84893. * @param gradient defines the gradient to use (between 0 and 1)
  84894. * @param factor defines the angular speed to affect to the specified gradient
  84895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84896. * @returns the current particle system
  84897. */
  84898. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84899. /**
  84900. * Remove a specific angular speed gradient
  84901. * @param gradient defines the gradient to remove
  84902. * @returns the current particle system
  84903. */
  84904. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84905. /**
  84906. * Adds a new velocity gradient
  84907. * @param gradient defines the gradient to use (between 0 and 1)
  84908. * @param factor defines the velocity to affect to the specified gradient
  84909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84910. * @returns the current particle system
  84911. */
  84912. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84913. /**
  84914. * Remove a specific velocity gradient
  84915. * @param gradient defines the gradient to remove
  84916. * @returns the current particle system
  84917. */
  84918. removeVelocityGradient(gradient: number): IParticleSystem;
  84919. /**
  84920. * Adds a new limit velocity gradient
  84921. * @param gradient defines the gradient to use (between 0 and 1)
  84922. * @param factor defines the limit velocity value to affect to the specified gradient
  84923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84924. * @returns the current particle system
  84925. */
  84926. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84927. /**
  84928. * Remove a specific limit velocity gradient
  84929. * @param gradient defines the gradient to remove
  84930. * @returns the current particle system
  84931. */
  84932. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84933. /**
  84934. * Adds a new drag gradient
  84935. * @param gradient defines the gradient to use (between 0 and 1)
  84936. * @param factor defines the drag value to affect to the specified gradient
  84937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84938. * @returns the current particle system
  84939. */
  84940. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84941. /**
  84942. * Remove a specific drag gradient
  84943. * @param gradient defines the gradient to remove
  84944. * @returns the current particle system
  84945. */
  84946. removeDragGradient(gradient: number): IParticleSystem;
  84947. /**
  84948. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84949. * @param gradient defines the gradient to use (between 0 and 1)
  84950. * @param factor defines the emit rate value to affect to the specified gradient
  84951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84952. * @returns the current particle system
  84953. */
  84954. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84955. /**
  84956. * Remove a specific emit rate gradient
  84957. * @param gradient defines the gradient to remove
  84958. * @returns the current particle system
  84959. */
  84960. removeEmitRateGradient(gradient: number): IParticleSystem;
  84961. /**
  84962. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84963. * @param gradient defines the gradient to use (between 0 and 1)
  84964. * @param factor defines the start size value to affect to the specified gradient
  84965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84966. * @returns the current particle system
  84967. */
  84968. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84969. /**
  84970. * Remove a specific start size gradient
  84971. * @param gradient defines the gradient to remove
  84972. * @returns the current particle system
  84973. */
  84974. removeStartSizeGradient(gradient: number): IParticleSystem;
  84975. private _createRampGradientTexture;
  84976. /**
  84977. * Gets the current list of ramp gradients.
  84978. * You must use addRampGradient and removeRampGradient to udpate this list
  84979. * @returns the list of ramp gradients
  84980. */
  84981. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84982. /**
  84983. * Adds a new ramp gradient used to remap particle colors
  84984. * @param gradient defines the gradient to use (between 0 and 1)
  84985. * @param color defines the color to affect to the specified gradient
  84986. * @returns the current particle system
  84987. */
  84988. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84989. /**
  84990. * Remove a specific ramp gradient
  84991. * @param gradient defines the gradient to remove
  84992. * @returns the current particle system
  84993. */
  84994. removeRampGradient(gradient: number): ParticleSystem;
  84995. /**
  84996. * Adds a new color gradient
  84997. * @param gradient defines the gradient to use (between 0 and 1)
  84998. * @param color1 defines the color to affect to the specified gradient
  84999. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85000. * @returns this particle system
  85001. */
  85002. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85003. /**
  85004. * Remove a specific color gradient
  85005. * @param gradient defines the gradient to remove
  85006. * @returns this particle system
  85007. */
  85008. removeColorGradient(gradient: number): IParticleSystem;
  85009. private _fetchR;
  85010. protected _reset(): void;
  85011. private _resetEffect;
  85012. private _createVertexBuffers;
  85013. private _createIndexBuffer;
  85014. /**
  85015. * Gets the maximum number of particles active at the same time.
  85016. * @returns The max number of active particles.
  85017. */
  85018. getCapacity(): number;
  85019. /**
  85020. * Gets whether there are still active particles in the system.
  85021. * @returns True if it is alive, otherwise false.
  85022. */
  85023. isAlive(): boolean;
  85024. /**
  85025. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85026. * @returns True if it has been started, otherwise false.
  85027. */
  85028. isStarted(): boolean;
  85029. private _prepareSubEmitterInternalArray;
  85030. /**
  85031. * Starts the particle system and begins to emit
  85032. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85033. */
  85034. start(delay?: number): void;
  85035. /**
  85036. * Stops the particle system.
  85037. * @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.
  85038. */
  85039. stop(stopSubEmitters?: boolean): void;
  85040. /**
  85041. * Remove all active particles
  85042. */
  85043. reset(): void;
  85044. /**
  85045. * @hidden (for internal use only)
  85046. */
  85047. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85048. /**
  85049. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85050. * Its lifetime will start back at 0.
  85051. */
  85052. recycleParticle: (particle: Particle) => void;
  85053. private _stopSubEmitters;
  85054. private _createParticle;
  85055. private _removeFromRoot;
  85056. private _emitFromParticle;
  85057. private _update;
  85058. /** @hidden */
  85059. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85060. /** @hidden */
  85061. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85062. /** @hidden */
  85063. private _getEffect;
  85064. /**
  85065. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85066. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85067. */
  85068. animate(preWarmOnly?: boolean): void;
  85069. private _appendParticleVertices;
  85070. /**
  85071. * Rebuilds the particle system.
  85072. */
  85073. rebuild(): void;
  85074. /**
  85075. * Is this system ready to be used/rendered
  85076. * @return true if the system is ready
  85077. */
  85078. isReady(): boolean;
  85079. private _render;
  85080. /**
  85081. * Renders the particle system in its current state.
  85082. * @returns the current number of particles
  85083. */
  85084. render(): number;
  85085. /**
  85086. * Disposes the particle system and free the associated resources
  85087. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85088. */
  85089. dispose(disposeTexture?: boolean): void;
  85090. /**
  85091. * Clones the particle system.
  85092. * @param name The name of the cloned object
  85093. * @param newEmitter The new emitter to use
  85094. * @returns the cloned particle system
  85095. */
  85096. clone(name: string, newEmitter: any): ParticleSystem;
  85097. /**
  85098. * Serializes the particle system to a JSON object.
  85099. * @returns the JSON object
  85100. */
  85101. serialize(): any;
  85102. /** @hidden */
  85103. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85104. /** @hidden */
  85105. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85106. /**
  85107. * Parses a JSON object to create a particle system.
  85108. * @param parsedParticleSystem The JSON object to parse
  85109. * @param scene The scene to create the particle system in
  85110. * @param rootUrl The root url to use to load external dependencies like texture
  85111. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85112. * @returns the Parsed particle system
  85113. */
  85114. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85115. }
  85116. }
  85117. declare module BABYLON {
  85118. /**
  85119. * A particle represents one of the element emitted by a particle system.
  85120. * This is mainly define by its coordinates, direction, velocity and age.
  85121. */
  85122. export class Particle {
  85123. /**
  85124. * The particle system the particle belongs to.
  85125. */
  85126. particleSystem: ParticleSystem;
  85127. private static _Count;
  85128. /**
  85129. * Unique ID of the particle
  85130. */
  85131. id: number;
  85132. /**
  85133. * The world position of the particle in the scene.
  85134. */
  85135. position: Vector3;
  85136. /**
  85137. * The world direction of the particle in the scene.
  85138. */
  85139. direction: Vector3;
  85140. /**
  85141. * The color of the particle.
  85142. */
  85143. color: Color4;
  85144. /**
  85145. * The color change of the particle per step.
  85146. */
  85147. colorStep: Color4;
  85148. /**
  85149. * Defines how long will the life of the particle be.
  85150. */
  85151. lifeTime: number;
  85152. /**
  85153. * The current age of the particle.
  85154. */
  85155. age: number;
  85156. /**
  85157. * The current size of the particle.
  85158. */
  85159. size: number;
  85160. /**
  85161. * The current scale of the particle.
  85162. */
  85163. scale: Vector2;
  85164. /**
  85165. * The current angle of the particle.
  85166. */
  85167. angle: number;
  85168. /**
  85169. * Defines how fast is the angle changing.
  85170. */
  85171. angularSpeed: number;
  85172. /**
  85173. * Defines the cell index used by the particle to be rendered from a sprite.
  85174. */
  85175. cellIndex: number;
  85176. /**
  85177. * The information required to support color remapping
  85178. */
  85179. remapData: Vector4;
  85180. /** @hidden */
  85181. _randomCellOffset?: number;
  85182. /** @hidden */
  85183. _initialDirection: Nullable<Vector3>;
  85184. /** @hidden */
  85185. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85186. /** @hidden */
  85187. _initialStartSpriteCellID: number;
  85188. /** @hidden */
  85189. _initialEndSpriteCellID: number;
  85190. /** @hidden */
  85191. _currentColorGradient: Nullable<ColorGradient>;
  85192. /** @hidden */
  85193. _currentColor1: Color4;
  85194. /** @hidden */
  85195. _currentColor2: Color4;
  85196. /** @hidden */
  85197. _currentSizeGradient: Nullable<FactorGradient>;
  85198. /** @hidden */
  85199. _currentSize1: number;
  85200. /** @hidden */
  85201. _currentSize2: number;
  85202. /** @hidden */
  85203. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85204. /** @hidden */
  85205. _currentAngularSpeed1: number;
  85206. /** @hidden */
  85207. _currentAngularSpeed2: number;
  85208. /** @hidden */
  85209. _currentVelocityGradient: Nullable<FactorGradient>;
  85210. /** @hidden */
  85211. _currentVelocity1: number;
  85212. /** @hidden */
  85213. _currentVelocity2: number;
  85214. /** @hidden */
  85215. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85216. /** @hidden */
  85217. _currentLimitVelocity1: number;
  85218. /** @hidden */
  85219. _currentLimitVelocity2: number;
  85220. /** @hidden */
  85221. _currentDragGradient: Nullable<FactorGradient>;
  85222. /** @hidden */
  85223. _currentDrag1: number;
  85224. /** @hidden */
  85225. _currentDrag2: number;
  85226. /** @hidden */
  85227. _randomNoiseCoordinates1: Vector3;
  85228. /** @hidden */
  85229. _randomNoiseCoordinates2: Vector3;
  85230. /**
  85231. * Creates a new instance Particle
  85232. * @param particleSystem the particle system the particle belongs to
  85233. */
  85234. constructor(
  85235. /**
  85236. * The particle system the particle belongs to.
  85237. */
  85238. particleSystem: ParticleSystem);
  85239. private updateCellInfoFromSystem;
  85240. /**
  85241. * Defines how the sprite cell index is updated for the particle
  85242. */
  85243. updateCellIndex(): void;
  85244. /** @hidden */
  85245. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85246. /** @hidden */
  85247. _inheritParticleInfoToSubEmitters(): void;
  85248. /** @hidden */
  85249. _reset(): void;
  85250. /**
  85251. * Copy the properties of particle to another one.
  85252. * @param other the particle to copy the information to.
  85253. */
  85254. copyTo(other: Particle): void;
  85255. }
  85256. }
  85257. declare module BABYLON {
  85258. /**
  85259. * Particle emitter represents a volume emitting particles.
  85260. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85261. */
  85262. export interface IParticleEmitterType {
  85263. /**
  85264. * Called by the particle System when the direction is computed for the created particle.
  85265. * @param worldMatrix is the world matrix of the particle system
  85266. * @param directionToUpdate is the direction vector to update with the result
  85267. * @param particle is the particle we are computed the direction for
  85268. */
  85269. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85270. /**
  85271. * Called by the particle System when the position is computed for the created particle.
  85272. * @param worldMatrix is the world matrix of the particle system
  85273. * @param positionToUpdate is the position vector to update with the result
  85274. * @param particle is the particle we are computed the position for
  85275. */
  85276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85277. /**
  85278. * Clones the current emitter and returns a copy of it
  85279. * @returns the new emitter
  85280. */
  85281. clone(): IParticleEmitterType;
  85282. /**
  85283. * Called by the GPUParticleSystem to setup the update shader
  85284. * @param effect defines the update shader
  85285. */
  85286. applyToShader(effect: Effect): void;
  85287. /**
  85288. * Returns a string to use to update the GPU particles update shader
  85289. * @returns the effect defines string
  85290. */
  85291. getEffectDefines(): string;
  85292. /**
  85293. * Returns a string representing the class name
  85294. * @returns a string containing the class name
  85295. */
  85296. getClassName(): string;
  85297. /**
  85298. * Serializes the particle system to a JSON object.
  85299. * @returns the JSON object
  85300. */
  85301. serialize(): any;
  85302. /**
  85303. * Parse properties from a JSON object
  85304. * @param serializationObject defines the JSON object
  85305. */
  85306. parse(serializationObject: any): void;
  85307. }
  85308. }
  85309. declare module BABYLON {
  85310. /**
  85311. * Particle emitter emitting particles from the inside of a box.
  85312. * It emits the particles randomly between 2 given directions.
  85313. */
  85314. export class BoxParticleEmitter implements IParticleEmitterType {
  85315. /**
  85316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85317. */
  85318. direction1: Vector3;
  85319. /**
  85320. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85321. */
  85322. direction2: Vector3;
  85323. /**
  85324. * 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.
  85325. */
  85326. minEmitBox: Vector3;
  85327. /**
  85328. * 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.
  85329. */
  85330. maxEmitBox: Vector3;
  85331. /**
  85332. * Creates a new instance BoxParticleEmitter
  85333. */
  85334. constructor();
  85335. /**
  85336. * Called by the particle System when the direction is computed for the created particle.
  85337. * @param worldMatrix is the world matrix of the particle system
  85338. * @param directionToUpdate is the direction vector to update with the result
  85339. * @param particle is the particle we are computed the direction for
  85340. */
  85341. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85342. /**
  85343. * Called by the particle System when the position is computed for the created particle.
  85344. * @param worldMatrix is the world matrix of the particle system
  85345. * @param positionToUpdate is the position vector to update with the result
  85346. * @param particle is the particle we are computed the position for
  85347. */
  85348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85349. /**
  85350. * Clones the current emitter and returns a copy of it
  85351. * @returns the new emitter
  85352. */
  85353. clone(): BoxParticleEmitter;
  85354. /**
  85355. * Called by the GPUParticleSystem to setup the update shader
  85356. * @param effect defines the update shader
  85357. */
  85358. applyToShader(effect: Effect): void;
  85359. /**
  85360. * Returns a string to use to update the GPU particles update shader
  85361. * @returns a string containng the defines string
  85362. */
  85363. getEffectDefines(): string;
  85364. /**
  85365. * Returns the string "BoxParticleEmitter"
  85366. * @returns a string containing the class name
  85367. */
  85368. getClassName(): string;
  85369. /**
  85370. * Serializes the particle system to a JSON object.
  85371. * @returns the JSON object
  85372. */
  85373. serialize(): any;
  85374. /**
  85375. * Parse properties from a JSON object
  85376. * @param serializationObject defines the JSON object
  85377. */
  85378. parse(serializationObject: any): void;
  85379. }
  85380. }
  85381. declare module BABYLON {
  85382. /**
  85383. * Particle emitter emitting particles from the inside of a cone.
  85384. * It emits the particles alongside the cone volume from the base to the particle.
  85385. * The emission direction might be randomized.
  85386. */
  85387. export class ConeParticleEmitter implements IParticleEmitterType {
  85388. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85389. directionRandomizer: number;
  85390. private _radius;
  85391. private _angle;
  85392. private _height;
  85393. /**
  85394. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85395. */
  85396. radiusRange: number;
  85397. /**
  85398. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85399. */
  85400. heightRange: number;
  85401. /**
  85402. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85403. */
  85404. emitFromSpawnPointOnly: boolean;
  85405. /**
  85406. * Gets or sets the radius of the emission cone
  85407. */
  85408. radius: number;
  85409. /**
  85410. * Gets or sets the angle of the emission cone
  85411. */
  85412. angle: number;
  85413. private _buildHeight;
  85414. /**
  85415. * Creates a new instance ConeParticleEmitter
  85416. * @param radius the radius of the emission cone (1 by default)
  85417. * @param angle the cone base angle (PI by default)
  85418. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85419. */
  85420. constructor(radius?: number, angle?: number,
  85421. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85422. directionRandomizer?: number);
  85423. /**
  85424. * Called by the particle System when the direction is computed for the created particle.
  85425. * @param worldMatrix is the world matrix of the particle system
  85426. * @param directionToUpdate is the direction vector to update with the result
  85427. * @param particle is the particle we are computed the direction for
  85428. */
  85429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85430. /**
  85431. * Called by the particle System when the position is computed for the created particle.
  85432. * @param worldMatrix is the world matrix of the particle system
  85433. * @param positionToUpdate is the position vector to update with the result
  85434. * @param particle is the particle we are computed the position for
  85435. */
  85436. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85437. /**
  85438. * Clones the current emitter and returns a copy of it
  85439. * @returns the new emitter
  85440. */
  85441. clone(): ConeParticleEmitter;
  85442. /**
  85443. * Called by the GPUParticleSystem to setup the update shader
  85444. * @param effect defines the update shader
  85445. */
  85446. applyToShader(effect: Effect): void;
  85447. /**
  85448. * Returns a string to use to update the GPU particles update shader
  85449. * @returns a string containng the defines string
  85450. */
  85451. getEffectDefines(): string;
  85452. /**
  85453. * Returns the string "ConeParticleEmitter"
  85454. * @returns a string containing the class name
  85455. */
  85456. getClassName(): string;
  85457. /**
  85458. * Serializes the particle system to a JSON object.
  85459. * @returns the JSON object
  85460. */
  85461. serialize(): any;
  85462. /**
  85463. * Parse properties from a JSON object
  85464. * @param serializationObject defines the JSON object
  85465. */
  85466. parse(serializationObject: any): void;
  85467. }
  85468. }
  85469. declare module BABYLON {
  85470. /**
  85471. * Particle emitter emitting particles from the inside of a cylinder.
  85472. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85473. */
  85474. export class CylinderParticleEmitter implements IParticleEmitterType {
  85475. /**
  85476. * The radius of the emission cylinder.
  85477. */
  85478. radius: number;
  85479. /**
  85480. * The height of the emission cylinder.
  85481. */
  85482. height: number;
  85483. /**
  85484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85485. */
  85486. radiusRange: number;
  85487. /**
  85488. * How much to randomize the particle direction [0-1].
  85489. */
  85490. directionRandomizer: number;
  85491. /**
  85492. * Creates a new instance CylinderParticleEmitter
  85493. * @param radius the radius of the emission cylinder (1 by default)
  85494. * @param height the height of the emission cylinder (1 by default)
  85495. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85496. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85497. */
  85498. constructor(
  85499. /**
  85500. * The radius of the emission cylinder.
  85501. */
  85502. radius?: number,
  85503. /**
  85504. * The height of the emission cylinder.
  85505. */
  85506. height?: number,
  85507. /**
  85508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85509. */
  85510. radiusRange?: number,
  85511. /**
  85512. * How much to randomize the particle direction [0-1].
  85513. */
  85514. directionRandomizer?: number);
  85515. /**
  85516. * Called by the particle System when the direction is computed for the created particle.
  85517. * @param worldMatrix is the world matrix of the particle system
  85518. * @param directionToUpdate is the direction vector to update with the result
  85519. * @param particle is the particle we are computed the direction for
  85520. */
  85521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85522. /**
  85523. * Called by the particle System when the position is computed for the created particle.
  85524. * @param worldMatrix is the world matrix of the particle system
  85525. * @param positionToUpdate is the position vector to update with the result
  85526. * @param particle is the particle we are computed the position for
  85527. */
  85528. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85529. /**
  85530. * Clones the current emitter and returns a copy of it
  85531. * @returns the new emitter
  85532. */
  85533. clone(): CylinderParticleEmitter;
  85534. /**
  85535. * Called by the GPUParticleSystem to setup the update shader
  85536. * @param effect defines the update shader
  85537. */
  85538. applyToShader(effect: Effect): void;
  85539. /**
  85540. * Returns a string to use to update the GPU particles update shader
  85541. * @returns a string containng the defines string
  85542. */
  85543. getEffectDefines(): string;
  85544. /**
  85545. * Returns the string "CylinderParticleEmitter"
  85546. * @returns a string containing the class name
  85547. */
  85548. getClassName(): string;
  85549. /**
  85550. * Serializes the particle system to a JSON object.
  85551. * @returns the JSON object
  85552. */
  85553. serialize(): any;
  85554. /**
  85555. * Parse properties from a JSON object
  85556. * @param serializationObject defines the JSON object
  85557. */
  85558. parse(serializationObject: any): void;
  85559. }
  85560. /**
  85561. * Particle emitter emitting particles from the inside of a cylinder.
  85562. * It emits the particles randomly between two vectors.
  85563. */
  85564. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85565. /**
  85566. * The min limit of the emission direction.
  85567. */
  85568. direction1: Vector3;
  85569. /**
  85570. * The max limit of the emission direction.
  85571. */
  85572. direction2: Vector3;
  85573. /**
  85574. * Creates a new instance CylinderDirectedParticleEmitter
  85575. * @param radius the radius of the emission cylinder (1 by default)
  85576. * @param height the height of the emission cylinder (1 by default)
  85577. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85578. * @param direction1 the min limit of the emission direction (up vector by default)
  85579. * @param direction2 the max limit of the emission direction (up vector by default)
  85580. */
  85581. constructor(radius?: number, height?: number, radiusRange?: number,
  85582. /**
  85583. * The min limit of the emission direction.
  85584. */
  85585. direction1?: Vector3,
  85586. /**
  85587. * The max limit of the emission direction.
  85588. */
  85589. direction2?: Vector3);
  85590. /**
  85591. * Called by the particle System when the direction is computed for the created particle.
  85592. * @param worldMatrix is the world matrix of the particle system
  85593. * @param directionToUpdate is the direction vector to update with the result
  85594. * @param particle is the particle we are computed the direction for
  85595. */
  85596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85597. /**
  85598. * Clones the current emitter and returns a copy of it
  85599. * @returns the new emitter
  85600. */
  85601. clone(): CylinderDirectedParticleEmitter;
  85602. /**
  85603. * Called by the GPUParticleSystem to setup the update shader
  85604. * @param effect defines the update shader
  85605. */
  85606. applyToShader(effect: Effect): void;
  85607. /**
  85608. * Returns a string to use to update the GPU particles update shader
  85609. * @returns a string containng the defines string
  85610. */
  85611. getEffectDefines(): string;
  85612. /**
  85613. * Returns the string "CylinderDirectedParticleEmitter"
  85614. * @returns a string containing the class name
  85615. */
  85616. getClassName(): string;
  85617. /**
  85618. * Serializes the particle system to a JSON object.
  85619. * @returns the JSON object
  85620. */
  85621. serialize(): any;
  85622. /**
  85623. * Parse properties from a JSON object
  85624. * @param serializationObject defines the JSON object
  85625. */
  85626. parse(serializationObject: any): void;
  85627. }
  85628. }
  85629. declare module BABYLON {
  85630. /**
  85631. * Particle emitter emitting particles from the inside of a hemisphere.
  85632. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85633. */
  85634. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85635. /**
  85636. * The radius of the emission hemisphere.
  85637. */
  85638. radius: number;
  85639. /**
  85640. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85641. */
  85642. radiusRange: number;
  85643. /**
  85644. * How much to randomize the particle direction [0-1].
  85645. */
  85646. directionRandomizer: number;
  85647. /**
  85648. * Creates a new instance HemisphericParticleEmitter
  85649. * @param radius the radius of the emission hemisphere (1 by default)
  85650. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85651. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85652. */
  85653. constructor(
  85654. /**
  85655. * The radius of the emission hemisphere.
  85656. */
  85657. radius?: number,
  85658. /**
  85659. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85660. */
  85661. radiusRange?: number,
  85662. /**
  85663. * How much to randomize the particle direction [0-1].
  85664. */
  85665. directionRandomizer?: number);
  85666. /**
  85667. * Called by the particle System when the direction is computed for the created particle.
  85668. * @param worldMatrix is the world matrix of the particle system
  85669. * @param directionToUpdate is the direction vector to update with the result
  85670. * @param particle is the particle we are computed the direction for
  85671. */
  85672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85673. /**
  85674. * Called by the particle System when the position is computed for the created particle.
  85675. * @param worldMatrix is the world matrix of the particle system
  85676. * @param positionToUpdate is the position vector to update with the result
  85677. * @param particle is the particle we are computed the position for
  85678. */
  85679. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85680. /**
  85681. * Clones the current emitter and returns a copy of it
  85682. * @returns the new emitter
  85683. */
  85684. clone(): HemisphericParticleEmitter;
  85685. /**
  85686. * Called by the GPUParticleSystem to setup the update shader
  85687. * @param effect defines the update shader
  85688. */
  85689. applyToShader(effect: Effect): void;
  85690. /**
  85691. * Returns a string to use to update the GPU particles update shader
  85692. * @returns a string containng the defines string
  85693. */
  85694. getEffectDefines(): string;
  85695. /**
  85696. * Returns the string "HemisphericParticleEmitter"
  85697. * @returns a string containing the class name
  85698. */
  85699. getClassName(): string;
  85700. /**
  85701. * Serializes the particle system to a JSON object.
  85702. * @returns the JSON object
  85703. */
  85704. serialize(): any;
  85705. /**
  85706. * Parse properties from a JSON object
  85707. * @param serializationObject defines the JSON object
  85708. */
  85709. parse(serializationObject: any): void;
  85710. }
  85711. }
  85712. declare module BABYLON {
  85713. /**
  85714. * Particle emitter emitting particles from a point.
  85715. * It emits the particles randomly between 2 given directions.
  85716. */
  85717. export class PointParticleEmitter implements IParticleEmitterType {
  85718. /**
  85719. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85720. */
  85721. direction1: Vector3;
  85722. /**
  85723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85724. */
  85725. direction2: Vector3;
  85726. /**
  85727. * Creates a new instance PointParticleEmitter
  85728. */
  85729. constructor();
  85730. /**
  85731. * Called by the particle System when the direction is computed for the created particle.
  85732. * @param worldMatrix is the world matrix of the particle system
  85733. * @param directionToUpdate is the direction vector to update with the result
  85734. * @param particle is the particle we are computed the direction for
  85735. */
  85736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85737. /**
  85738. * Called by the particle System when the position is computed for the created particle.
  85739. * @param worldMatrix is the world matrix of the particle system
  85740. * @param positionToUpdate is the position vector to update with the result
  85741. * @param particle is the particle we are computed the position for
  85742. */
  85743. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85744. /**
  85745. * Clones the current emitter and returns a copy of it
  85746. * @returns the new emitter
  85747. */
  85748. clone(): PointParticleEmitter;
  85749. /**
  85750. * Called by the GPUParticleSystem to setup the update shader
  85751. * @param effect defines the update shader
  85752. */
  85753. applyToShader(effect: Effect): void;
  85754. /**
  85755. * Returns a string to use to update the GPU particles update shader
  85756. * @returns a string containng the defines string
  85757. */
  85758. getEffectDefines(): string;
  85759. /**
  85760. * Returns the string "PointParticleEmitter"
  85761. * @returns a string containing the class name
  85762. */
  85763. getClassName(): string;
  85764. /**
  85765. * Serializes the particle system to a JSON object.
  85766. * @returns the JSON object
  85767. */
  85768. serialize(): any;
  85769. /**
  85770. * Parse properties from a JSON object
  85771. * @param serializationObject defines the JSON object
  85772. */
  85773. parse(serializationObject: any): void;
  85774. }
  85775. }
  85776. declare module BABYLON {
  85777. /**
  85778. * Particle emitter emitting particles from the inside of a sphere.
  85779. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85780. */
  85781. export class SphereParticleEmitter implements IParticleEmitterType {
  85782. /**
  85783. * The radius of the emission sphere.
  85784. */
  85785. radius: number;
  85786. /**
  85787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85788. */
  85789. radiusRange: number;
  85790. /**
  85791. * How much to randomize the particle direction [0-1].
  85792. */
  85793. directionRandomizer: number;
  85794. /**
  85795. * Creates a new instance SphereParticleEmitter
  85796. * @param radius the radius of the emission sphere (1 by default)
  85797. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85798. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85799. */
  85800. constructor(
  85801. /**
  85802. * The radius of the emission sphere.
  85803. */
  85804. radius?: number,
  85805. /**
  85806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85807. */
  85808. radiusRange?: number,
  85809. /**
  85810. * How much to randomize the particle direction [0-1].
  85811. */
  85812. directionRandomizer?: number);
  85813. /**
  85814. * Called by the particle System when the direction is computed for the created particle.
  85815. * @param worldMatrix is the world matrix of the particle system
  85816. * @param directionToUpdate is the direction vector to update with the result
  85817. * @param particle is the particle we are computed the direction for
  85818. */
  85819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85820. /**
  85821. * Called by the particle System when the position is computed for the created particle.
  85822. * @param worldMatrix is the world matrix of the particle system
  85823. * @param positionToUpdate is the position vector to update with the result
  85824. * @param particle is the particle we are computed the position for
  85825. */
  85826. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85827. /**
  85828. * Clones the current emitter and returns a copy of it
  85829. * @returns the new emitter
  85830. */
  85831. clone(): SphereParticleEmitter;
  85832. /**
  85833. * Called by the GPUParticleSystem to setup the update shader
  85834. * @param effect defines the update shader
  85835. */
  85836. applyToShader(effect: Effect): void;
  85837. /**
  85838. * Returns a string to use to update the GPU particles update shader
  85839. * @returns a string containng the defines string
  85840. */
  85841. getEffectDefines(): string;
  85842. /**
  85843. * Returns the string "SphereParticleEmitter"
  85844. * @returns a string containing the class name
  85845. */
  85846. getClassName(): string;
  85847. /**
  85848. * Serializes the particle system to a JSON object.
  85849. * @returns the JSON object
  85850. */
  85851. serialize(): any;
  85852. /**
  85853. * Parse properties from a JSON object
  85854. * @param serializationObject defines the JSON object
  85855. */
  85856. parse(serializationObject: any): void;
  85857. }
  85858. /**
  85859. * Particle emitter emitting particles from the inside of a sphere.
  85860. * It emits the particles randomly between two vectors.
  85861. */
  85862. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85863. /**
  85864. * The min limit of the emission direction.
  85865. */
  85866. direction1: Vector3;
  85867. /**
  85868. * The max limit of the emission direction.
  85869. */
  85870. direction2: Vector3;
  85871. /**
  85872. * Creates a new instance SphereDirectedParticleEmitter
  85873. * @param radius the radius of the emission sphere (1 by default)
  85874. * @param direction1 the min limit of the emission direction (up vector by default)
  85875. * @param direction2 the max limit of the emission direction (up vector by default)
  85876. */
  85877. constructor(radius?: number,
  85878. /**
  85879. * The min limit of the emission direction.
  85880. */
  85881. direction1?: Vector3,
  85882. /**
  85883. * The max limit of the emission direction.
  85884. */
  85885. direction2?: Vector3);
  85886. /**
  85887. * Called by the particle System when the direction is computed for the created particle.
  85888. * @param worldMatrix is the world matrix of the particle system
  85889. * @param directionToUpdate is the direction vector to update with the result
  85890. * @param particle is the particle we are computed the direction for
  85891. */
  85892. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85893. /**
  85894. * Clones the current emitter and returns a copy of it
  85895. * @returns the new emitter
  85896. */
  85897. clone(): SphereDirectedParticleEmitter;
  85898. /**
  85899. * Called by the GPUParticleSystem to setup the update shader
  85900. * @param effect defines the update shader
  85901. */
  85902. applyToShader(effect: Effect): void;
  85903. /**
  85904. * Returns a string to use to update the GPU particles update shader
  85905. * @returns a string containng the defines string
  85906. */
  85907. getEffectDefines(): string;
  85908. /**
  85909. * Returns the string "SphereDirectedParticleEmitter"
  85910. * @returns a string containing the class name
  85911. */
  85912. getClassName(): string;
  85913. /**
  85914. * Serializes the particle system to a JSON object.
  85915. * @returns the JSON object
  85916. */
  85917. serialize(): any;
  85918. /**
  85919. * Parse properties from a JSON object
  85920. * @param serializationObject defines the JSON object
  85921. */
  85922. parse(serializationObject: any): void;
  85923. }
  85924. }
  85925. declare module BABYLON {
  85926. /**
  85927. * Interface representing a particle system in Babylon.js.
  85928. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85929. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85930. */
  85931. export interface IParticleSystem {
  85932. /**
  85933. * List of animations used by the particle system.
  85934. */
  85935. animations: Animation[];
  85936. /**
  85937. * The id of the Particle system.
  85938. */
  85939. id: string;
  85940. /**
  85941. * The name of the Particle system.
  85942. */
  85943. name: string;
  85944. /**
  85945. * The emitter represents the Mesh or position we are attaching the particle system to.
  85946. */
  85947. emitter: Nullable<AbstractMesh | Vector3>;
  85948. /**
  85949. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85950. */
  85951. isBillboardBased: boolean;
  85952. /**
  85953. * The rendering group used by the Particle system to chose when to render.
  85954. */
  85955. renderingGroupId: number;
  85956. /**
  85957. * The layer mask we are rendering the particles through.
  85958. */
  85959. layerMask: number;
  85960. /**
  85961. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85962. */
  85963. updateSpeed: number;
  85964. /**
  85965. * The amount of time the particle system is running (depends of the overall update speed).
  85966. */
  85967. targetStopDuration: number;
  85968. /**
  85969. * The texture used to render each particle. (this can be a spritesheet)
  85970. */
  85971. particleTexture: Nullable<Texture>;
  85972. /**
  85973. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85974. */
  85975. blendMode: number;
  85976. /**
  85977. * Minimum life time of emitting particles.
  85978. */
  85979. minLifeTime: number;
  85980. /**
  85981. * Maximum life time of emitting particles.
  85982. */
  85983. maxLifeTime: number;
  85984. /**
  85985. * Minimum Size of emitting particles.
  85986. */
  85987. minSize: number;
  85988. /**
  85989. * Maximum Size of emitting particles.
  85990. */
  85991. maxSize: number;
  85992. /**
  85993. * Minimum scale of emitting particles on X axis.
  85994. */
  85995. minScaleX: number;
  85996. /**
  85997. * Maximum scale of emitting particles on X axis.
  85998. */
  85999. maxScaleX: number;
  86000. /**
  86001. * Minimum scale of emitting particles on Y axis.
  86002. */
  86003. minScaleY: number;
  86004. /**
  86005. * Maximum scale of emitting particles on Y axis.
  86006. */
  86007. maxScaleY: number;
  86008. /**
  86009. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86010. */
  86011. color1: Color4;
  86012. /**
  86013. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86014. */
  86015. color2: Color4;
  86016. /**
  86017. * Color the particle will have at the end of its lifetime.
  86018. */
  86019. colorDead: Color4;
  86020. /**
  86021. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86022. */
  86023. emitRate: number;
  86024. /**
  86025. * You can use gravity if you want to give an orientation to your particles.
  86026. */
  86027. gravity: Vector3;
  86028. /**
  86029. * Minimum power of emitting particles.
  86030. */
  86031. minEmitPower: number;
  86032. /**
  86033. * Maximum power of emitting particles.
  86034. */
  86035. maxEmitPower: number;
  86036. /**
  86037. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86038. */
  86039. minAngularSpeed: number;
  86040. /**
  86041. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86042. */
  86043. maxAngularSpeed: number;
  86044. /**
  86045. * Gets or sets the minimal initial rotation in radians.
  86046. */
  86047. minInitialRotation: number;
  86048. /**
  86049. * Gets or sets the maximal initial rotation in radians.
  86050. */
  86051. maxInitialRotation: number;
  86052. /**
  86053. * The particle emitter type defines the emitter used by the particle system.
  86054. * It can be for example box, sphere, or cone...
  86055. */
  86056. particleEmitterType: Nullable<IParticleEmitterType>;
  86057. /**
  86058. * Defines the delay in milliseconds before starting the system (0 by default)
  86059. */
  86060. startDelay: number;
  86061. /**
  86062. * 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
  86063. */
  86064. preWarmCycles: number;
  86065. /**
  86066. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86067. */
  86068. preWarmStepOffset: number;
  86069. /**
  86070. * 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)
  86071. */
  86072. spriteCellChangeSpeed: number;
  86073. /**
  86074. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86075. */
  86076. startSpriteCellID: number;
  86077. /**
  86078. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86079. */
  86080. endSpriteCellID: number;
  86081. /**
  86082. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86083. */
  86084. spriteCellWidth: number;
  86085. /**
  86086. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86087. */
  86088. spriteCellHeight: number;
  86089. /**
  86090. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86091. */
  86092. spriteRandomStartCell: boolean;
  86093. /**
  86094. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86095. */
  86096. isAnimationSheetEnabled: boolean;
  86097. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86098. translationPivot: Vector2;
  86099. /**
  86100. * Gets or sets a texture used to add random noise to particle positions
  86101. */
  86102. noiseTexture: Nullable<BaseTexture>;
  86103. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86104. noiseStrength: Vector3;
  86105. /**
  86106. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86107. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86108. */
  86109. billboardMode: number;
  86110. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86111. limitVelocityDamping: number;
  86112. /**
  86113. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86114. */
  86115. beginAnimationOnStart: boolean;
  86116. /**
  86117. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86118. */
  86119. beginAnimationFrom: number;
  86120. /**
  86121. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86122. */
  86123. beginAnimationTo: number;
  86124. /**
  86125. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86126. */
  86127. beginAnimationLoop: boolean;
  86128. /**
  86129. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86130. */
  86131. disposeOnStop: boolean;
  86132. /**
  86133. * Gets the maximum number of particles active at the same time.
  86134. * @returns The max number of active particles.
  86135. */
  86136. getCapacity(): number;
  86137. /**
  86138. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86139. * @returns True if it has been started, otherwise false.
  86140. */
  86141. isStarted(): boolean;
  86142. /**
  86143. * Animates the particle system for this frame.
  86144. */
  86145. animate(): void;
  86146. /**
  86147. * Renders the particle system in its current state.
  86148. * @returns the current number of particles
  86149. */
  86150. render(): number;
  86151. /**
  86152. * Dispose the particle system and frees its associated resources.
  86153. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86154. */
  86155. dispose(disposeTexture?: boolean): void;
  86156. /**
  86157. * Clones the particle system.
  86158. * @param name The name of the cloned object
  86159. * @param newEmitter The new emitter to use
  86160. * @returns the cloned particle system
  86161. */
  86162. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86163. /**
  86164. * Serializes the particle system to a JSON object.
  86165. * @returns the JSON object
  86166. */
  86167. serialize(): any;
  86168. /**
  86169. * Rebuild the particle system
  86170. */
  86171. rebuild(): void;
  86172. /**
  86173. * Starts the particle system and begins to emit
  86174. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86175. */
  86176. start(delay?: number): void;
  86177. /**
  86178. * Stops the particle system.
  86179. */
  86180. stop(): void;
  86181. /**
  86182. * Remove all active particles
  86183. */
  86184. reset(): void;
  86185. /**
  86186. * Is this system ready to be used/rendered
  86187. * @return true if the system is ready
  86188. */
  86189. isReady(): boolean;
  86190. /**
  86191. * Adds a new color gradient
  86192. * @param gradient defines the gradient to use (between 0 and 1)
  86193. * @param color1 defines the color to affect to the specified gradient
  86194. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86195. * @returns the current particle system
  86196. */
  86197. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86198. /**
  86199. * Remove a specific color gradient
  86200. * @param gradient defines the gradient to remove
  86201. * @returns the current particle system
  86202. */
  86203. removeColorGradient(gradient: number): IParticleSystem;
  86204. /**
  86205. * Adds a new size gradient
  86206. * @param gradient defines the gradient to use (between 0 and 1)
  86207. * @param factor defines the size factor to affect to the specified gradient
  86208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86209. * @returns the current particle system
  86210. */
  86211. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86212. /**
  86213. * Remove a specific size gradient
  86214. * @param gradient defines the gradient to remove
  86215. * @returns the current particle system
  86216. */
  86217. removeSizeGradient(gradient: number): IParticleSystem;
  86218. /**
  86219. * Gets the current list of color gradients.
  86220. * You must use addColorGradient and removeColorGradient to udpate this list
  86221. * @returns the list of color gradients
  86222. */
  86223. getColorGradients(): Nullable<Array<ColorGradient>>;
  86224. /**
  86225. * Gets the current list of size gradients.
  86226. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86227. * @returns the list of size gradients
  86228. */
  86229. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86230. /**
  86231. * Gets the current list of angular speed gradients.
  86232. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86233. * @returns the list of angular speed gradients
  86234. */
  86235. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86236. /**
  86237. * Adds a new angular speed gradient
  86238. * @param gradient defines the gradient to use (between 0 and 1)
  86239. * @param factor defines the angular speed to affect to the specified gradient
  86240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86241. * @returns the current particle system
  86242. */
  86243. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86244. /**
  86245. * Remove a specific angular speed gradient
  86246. * @param gradient defines the gradient to remove
  86247. * @returns the current particle system
  86248. */
  86249. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86250. /**
  86251. * Gets the current list of velocity gradients.
  86252. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86253. * @returns the list of velocity gradients
  86254. */
  86255. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86256. /**
  86257. * Adds a new velocity gradient
  86258. * @param gradient defines the gradient to use (between 0 and 1)
  86259. * @param factor defines the velocity to affect to the specified gradient
  86260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86261. * @returns the current particle system
  86262. */
  86263. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86264. /**
  86265. * Remove a specific velocity gradient
  86266. * @param gradient defines the gradient to remove
  86267. * @returns the current particle system
  86268. */
  86269. removeVelocityGradient(gradient: number): IParticleSystem;
  86270. /**
  86271. * Gets the current list of limit velocity gradients.
  86272. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86273. * @returns the list of limit velocity gradients
  86274. */
  86275. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86276. /**
  86277. * Adds a new limit velocity gradient
  86278. * @param gradient defines the gradient to use (between 0 and 1)
  86279. * @param factor defines the limit velocity to affect to the specified gradient
  86280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86281. * @returns the current particle system
  86282. */
  86283. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86284. /**
  86285. * Remove a specific limit velocity gradient
  86286. * @param gradient defines the gradient to remove
  86287. * @returns the current particle system
  86288. */
  86289. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86290. /**
  86291. * Adds a new drag gradient
  86292. * @param gradient defines the gradient to use (between 0 and 1)
  86293. * @param factor defines the drag to affect to the specified gradient
  86294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86295. * @returns the current particle system
  86296. */
  86297. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86298. /**
  86299. * Remove a specific drag gradient
  86300. * @param gradient defines the gradient to remove
  86301. * @returns the current particle system
  86302. */
  86303. removeDragGradient(gradient: number): IParticleSystem;
  86304. /**
  86305. * Gets the current list of drag gradients.
  86306. * You must use addDragGradient and removeDragGradient to udpate this list
  86307. * @returns the list of drag gradients
  86308. */
  86309. getDragGradients(): Nullable<Array<FactorGradient>>;
  86310. /**
  86311. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86312. * @param gradient defines the gradient to use (between 0 and 1)
  86313. * @param factor defines the emit rate to affect to the specified gradient
  86314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86315. * @returns the current particle system
  86316. */
  86317. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86318. /**
  86319. * Remove a specific emit rate gradient
  86320. * @param gradient defines the gradient to remove
  86321. * @returns the current particle system
  86322. */
  86323. removeEmitRateGradient(gradient: number): IParticleSystem;
  86324. /**
  86325. * Gets the current list of emit rate gradients.
  86326. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86327. * @returns the list of emit rate gradients
  86328. */
  86329. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86330. /**
  86331. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86332. * @param gradient defines the gradient to use (between 0 and 1)
  86333. * @param factor defines the start size to affect to the specified gradient
  86334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86335. * @returns the current particle system
  86336. */
  86337. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86338. /**
  86339. * Remove a specific start size gradient
  86340. * @param gradient defines the gradient to remove
  86341. * @returns the current particle system
  86342. */
  86343. removeStartSizeGradient(gradient: number): IParticleSystem;
  86344. /**
  86345. * Gets the current list of start size gradients.
  86346. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86347. * @returns the list of start size gradients
  86348. */
  86349. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86350. /**
  86351. * Adds a new life time gradient
  86352. * @param gradient defines the gradient to use (between 0 and 1)
  86353. * @param factor defines the life time factor to affect to the specified gradient
  86354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86355. * @returns the current particle system
  86356. */
  86357. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86358. /**
  86359. * Remove a specific life time gradient
  86360. * @param gradient defines the gradient to remove
  86361. * @returns the current particle system
  86362. */
  86363. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86364. /**
  86365. * Gets the current list of life time gradients.
  86366. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86367. * @returns the list of life time gradients
  86368. */
  86369. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86370. /**
  86371. * Gets the current list of color gradients.
  86372. * You must use addColorGradient and removeColorGradient to udpate this list
  86373. * @returns the list of color gradients
  86374. */
  86375. getColorGradients(): Nullable<Array<ColorGradient>>;
  86376. /**
  86377. * Adds a new ramp gradient used to remap particle colors
  86378. * @param gradient defines the gradient to use (between 0 and 1)
  86379. * @param color defines the color to affect to the specified gradient
  86380. * @returns the current particle system
  86381. */
  86382. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86383. /**
  86384. * Gets the current list of ramp gradients.
  86385. * You must use addRampGradient and removeRampGradient to udpate this list
  86386. * @returns the list of ramp gradients
  86387. */
  86388. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86389. /** Gets or sets a boolean indicating that ramp gradients must be used
  86390. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86391. */
  86392. useRampGradients: boolean;
  86393. /**
  86394. * Adds a new color remap gradient
  86395. * @param gradient defines the gradient to use (between 0 and 1)
  86396. * @param min defines the color remap minimal range
  86397. * @param max defines the color remap maximal range
  86398. * @returns the current particle system
  86399. */
  86400. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86401. /**
  86402. * Gets the current list of color remap gradients.
  86403. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86404. * @returns the list of color remap gradients
  86405. */
  86406. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86407. /**
  86408. * Adds a new alpha remap gradient
  86409. * @param gradient defines the gradient to use (between 0 and 1)
  86410. * @param min defines the alpha remap minimal range
  86411. * @param max defines the alpha remap maximal range
  86412. * @returns the current particle system
  86413. */
  86414. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86415. /**
  86416. * Gets the current list of alpha remap gradients.
  86417. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86418. * @returns the list of alpha remap gradients
  86419. */
  86420. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86421. /**
  86422. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86423. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86424. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86425. * @returns the emitter
  86426. */
  86427. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86428. /**
  86429. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86430. * @param radius The radius of the hemisphere to emit from
  86431. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86432. * @returns the emitter
  86433. */
  86434. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86435. /**
  86436. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86437. * @param radius The radius of the sphere to emit from
  86438. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86439. * @returns the emitter
  86440. */
  86441. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86442. /**
  86443. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86444. * @param radius The radius of the sphere to emit from
  86445. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86446. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86447. * @returns the emitter
  86448. */
  86449. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86450. /**
  86451. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86452. * @param radius The radius of the emission cylinder
  86453. * @param height The height of the emission cylinder
  86454. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86455. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86456. * @returns the emitter
  86457. */
  86458. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86459. /**
  86460. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86461. * @param radius The radius of the cylinder to emit from
  86462. * @param height The height of the emission cylinder
  86463. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86466. * @returns the emitter
  86467. */
  86468. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86469. /**
  86470. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86471. * @param radius The radius of the cone to emit from
  86472. * @param angle The base angle of the cone
  86473. * @returns the emitter
  86474. */
  86475. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86476. /**
  86477. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86478. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86479. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86480. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86481. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86482. * @returns the emitter
  86483. */
  86484. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86485. /**
  86486. * Get hosting scene
  86487. * @returns the scene
  86488. */
  86489. getScene(): Scene;
  86490. }
  86491. }
  86492. declare module BABYLON {
  86493. /**
  86494. * Creates an instance based on a source mesh.
  86495. */
  86496. export class InstancedMesh extends AbstractMesh {
  86497. private _sourceMesh;
  86498. private _currentLOD;
  86499. /** @hidden */
  86500. _indexInSourceMeshInstanceArray: number;
  86501. constructor(name: string, source: Mesh);
  86502. /**
  86503. * Returns the string "InstancedMesh".
  86504. */
  86505. getClassName(): string;
  86506. /** Gets the list of lights affecting that mesh */
  86507. readonly lightSources: Light[];
  86508. _resyncLightSources(): void;
  86509. _resyncLighSource(light: Light): void;
  86510. _removeLightSource(light: Light, dispose: boolean): void;
  86511. /**
  86512. * If the source mesh receives shadows
  86513. */
  86514. readonly receiveShadows: boolean;
  86515. /**
  86516. * The material of the source mesh
  86517. */
  86518. readonly material: Nullable<Material>;
  86519. /**
  86520. * Visibility of the source mesh
  86521. */
  86522. readonly visibility: number;
  86523. /**
  86524. * Skeleton of the source mesh
  86525. */
  86526. readonly skeleton: Nullable<Skeleton>;
  86527. /**
  86528. * Rendering ground id of the source mesh
  86529. */
  86530. renderingGroupId: number;
  86531. /**
  86532. * Returns the total number of vertices (integer).
  86533. */
  86534. getTotalVertices(): number;
  86535. /**
  86536. * Returns a positive integer : the total number of indices in this mesh geometry.
  86537. * @returns the numner of indices or zero if the mesh has no geometry.
  86538. */
  86539. getTotalIndices(): number;
  86540. /**
  86541. * The source mesh of the instance
  86542. */
  86543. readonly sourceMesh: Mesh;
  86544. /**
  86545. * Is this node ready to be used/rendered
  86546. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86547. * @return {boolean} is it ready
  86548. */
  86549. isReady(completeCheck?: boolean): boolean;
  86550. /**
  86551. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86552. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86553. * @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.
  86554. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86555. */
  86556. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  86557. /**
  86558. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86559. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86560. * The `data` are either a numeric array either a Float32Array.
  86561. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86562. * 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).
  86563. * Note that a new underlying VertexBuffer object is created each call.
  86564. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86565. *
  86566. * Possible `kind` values :
  86567. * - VertexBuffer.PositionKind
  86568. * - VertexBuffer.UVKind
  86569. * - VertexBuffer.UV2Kind
  86570. * - VertexBuffer.UV3Kind
  86571. * - VertexBuffer.UV4Kind
  86572. * - VertexBuffer.UV5Kind
  86573. * - VertexBuffer.UV6Kind
  86574. * - VertexBuffer.ColorKind
  86575. * - VertexBuffer.MatricesIndicesKind
  86576. * - VertexBuffer.MatricesIndicesExtraKind
  86577. * - VertexBuffer.MatricesWeightsKind
  86578. * - VertexBuffer.MatricesWeightsExtraKind
  86579. *
  86580. * Returns the Mesh.
  86581. */
  86582. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86583. /**
  86584. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86585. * If the mesh has no geometry, it is simply returned as it is.
  86586. * The `data` are either a numeric array either a Float32Array.
  86587. * No new underlying VertexBuffer object is created.
  86588. * 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.
  86589. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86590. *
  86591. * Possible `kind` values :
  86592. * - VertexBuffer.PositionKind
  86593. * - VertexBuffer.UVKind
  86594. * - VertexBuffer.UV2Kind
  86595. * - VertexBuffer.UV3Kind
  86596. * - VertexBuffer.UV4Kind
  86597. * - VertexBuffer.UV5Kind
  86598. * - VertexBuffer.UV6Kind
  86599. * - VertexBuffer.ColorKind
  86600. * - VertexBuffer.MatricesIndicesKind
  86601. * - VertexBuffer.MatricesIndicesExtraKind
  86602. * - VertexBuffer.MatricesWeightsKind
  86603. * - VertexBuffer.MatricesWeightsExtraKind
  86604. *
  86605. * Returns the Mesh.
  86606. */
  86607. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  86608. /**
  86609. * Sets the mesh indices.
  86610. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86611. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86612. * This method creates a new index buffer each call.
  86613. * Returns the Mesh.
  86614. */
  86615. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  86616. /**
  86617. * Boolean : True if the mesh owns the requested kind of data.
  86618. */
  86619. isVerticesDataPresent(kind: string): boolean;
  86620. /**
  86621. * Returns an array of indices (IndicesArray).
  86622. */
  86623. getIndices(): Nullable<IndicesArray>;
  86624. readonly _positions: Nullable<Vector3[]>;
  86625. /**
  86626. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86627. * This means the mesh underlying bounding box and sphere are recomputed.
  86628. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86629. * @returns the current mesh
  86630. */
  86631. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  86632. /** @hidden */
  86633. _preActivate(): InstancedMesh;
  86634. /** @hidden */
  86635. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86636. /** @hidden */
  86637. _postActivate(): void;
  86638. getWorldMatrix(): Matrix;
  86639. readonly isAnInstance: boolean;
  86640. /**
  86641. * Returns the current associated LOD AbstractMesh.
  86642. */
  86643. getLOD(camera: Camera): AbstractMesh;
  86644. /** @hidden */
  86645. _syncSubMeshes(): InstancedMesh;
  86646. /** @hidden */
  86647. _generatePointsArray(): boolean;
  86648. /**
  86649. * Creates a new InstancedMesh from the current mesh.
  86650. * - name (string) : the cloned mesh name
  86651. * - newParent (optional Node) : the optional Node to parent the clone to.
  86652. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86653. *
  86654. * Returns the clone.
  86655. */
  86656. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86657. /**
  86658. * Disposes the InstancedMesh.
  86659. * Returns nothing.
  86660. */
  86661. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86662. }
  86663. interface Mesh {
  86664. /**
  86665. * Register a custom buffer that will be instanced
  86666. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86667. * @param kind defines the buffer kind
  86668. * @param stride defines the stride in floats
  86669. */
  86670. registerInstancedBuffer(kind: string, stride: number): void;
  86671. /** @hidden */
  86672. _userInstancedBuffersStorage: {
  86673. data: {
  86674. [key: string]: Float32Array;
  86675. };
  86676. sizes: {
  86677. [key: string]: number;
  86678. };
  86679. vertexBuffers: {
  86680. [key: string]: Nullable<VertexBuffer>;
  86681. };
  86682. strides: {
  86683. [key: string]: number;
  86684. };
  86685. };
  86686. }
  86687. interface AbstractMesh {
  86688. /**
  86689. * Object used to store instanced buffers defined by user
  86690. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  86691. */
  86692. instancedBuffers: {
  86693. [key: string]: any;
  86694. };
  86695. }
  86696. }
  86697. declare module BABYLON {
  86698. /**
  86699. * Defines the options associated with the creation of a shader material.
  86700. */
  86701. export interface IShaderMaterialOptions {
  86702. /**
  86703. * Does the material work in alpha blend mode
  86704. */
  86705. needAlphaBlending: boolean;
  86706. /**
  86707. * Does the material work in alpha test mode
  86708. */
  86709. needAlphaTesting: boolean;
  86710. /**
  86711. * The list of attribute names used in the shader
  86712. */
  86713. attributes: string[];
  86714. /**
  86715. * The list of unifrom names used in the shader
  86716. */
  86717. uniforms: string[];
  86718. /**
  86719. * The list of UBO names used in the shader
  86720. */
  86721. uniformBuffers: string[];
  86722. /**
  86723. * The list of sampler names used in the shader
  86724. */
  86725. samplers: string[];
  86726. /**
  86727. * The list of defines used in the shader
  86728. */
  86729. defines: string[];
  86730. }
  86731. /**
  86732. * 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.
  86733. *
  86734. * This returned material effects how the mesh will look based on the code in the shaders.
  86735. *
  86736. * @see http://doc.babylonjs.com/how_to/shader_material
  86737. */
  86738. export class ShaderMaterial extends Material {
  86739. private _shaderPath;
  86740. private _options;
  86741. private _textures;
  86742. private _textureArrays;
  86743. private _floats;
  86744. private _ints;
  86745. private _floatsArrays;
  86746. private _colors3;
  86747. private _colors3Arrays;
  86748. private _colors4;
  86749. private _colors4Arrays;
  86750. private _vectors2;
  86751. private _vectors3;
  86752. private _vectors4;
  86753. private _matrices;
  86754. private _matrices3x3;
  86755. private _matrices2x2;
  86756. private _vectors2Arrays;
  86757. private _vectors3Arrays;
  86758. private _vectors4Arrays;
  86759. private _cachedWorldViewMatrix;
  86760. private _cachedWorldViewProjectionMatrix;
  86761. private _renderId;
  86762. /**
  86763. * Instantiate a new shader material.
  86764. * 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.
  86765. * This returned material effects how the mesh will look based on the code in the shaders.
  86766. * @see http://doc.babylonjs.com/how_to/shader_material
  86767. * @param name Define the name of the material in the scene
  86768. * @param scene Define the scene the material belongs to
  86769. * @param shaderPath Defines the route to the shader code in one of three ways:
  86770. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  86771. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  86772. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  86773. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  86774. * @param options Define the options used to create the shader
  86775. */
  86776. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  86777. /**
  86778. * Gets the options used to compile the shader.
  86779. * They can be modified to trigger a new compilation
  86780. */
  86781. readonly options: IShaderMaterialOptions;
  86782. /**
  86783. * Gets the current class name of the material e.g. "ShaderMaterial"
  86784. * Mainly use in serialization.
  86785. * @returns the class name
  86786. */
  86787. getClassName(): string;
  86788. /**
  86789. * Specifies if the material will require alpha blending
  86790. * @returns a boolean specifying if alpha blending is needed
  86791. */
  86792. needAlphaBlending(): boolean;
  86793. /**
  86794. * Specifies if this material should be rendered in alpha test mode
  86795. * @returns a boolean specifying if an alpha test is needed.
  86796. */
  86797. needAlphaTesting(): boolean;
  86798. private _checkUniform;
  86799. /**
  86800. * Set a texture in the shader.
  86801. * @param name Define the name of the uniform samplers as defined in the shader
  86802. * @param texture Define the texture to bind to this sampler
  86803. * @return the material itself allowing "fluent" like uniform updates
  86804. */
  86805. setTexture(name: string, texture: Texture): ShaderMaterial;
  86806. /**
  86807. * Set a texture array in the shader.
  86808. * @param name Define the name of the uniform sampler array as defined in the shader
  86809. * @param textures Define the list of textures to bind to this sampler
  86810. * @return the material itself allowing "fluent" like uniform updates
  86811. */
  86812. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  86813. /**
  86814. * Set a float in the shader.
  86815. * @param name Define the name of the uniform as defined in the shader
  86816. * @param value Define the value to give to the uniform
  86817. * @return the material itself allowing "fluent" like uniform updates
  86818. */
  86819. setFloat(name: string, value: number): ShaderMaterial;
  86820. /**
  86821. * Set a int in the shader.
  86822. * @param name Define the name of the uniform as defined in the shader
  86823. * @param value Define the value to give to the uniform
  86824. * @return the material itself allowing "fluent" like uniform updates
  86825. */
  86826. setInt(name: string, value: number): ShaderMaterial;
  86827. /**
  86828. * Set an array of floats in the shader.
  86829. * @param name Define the name of the uniform as defined in the shader
  86830. * @param value Define the value to give to the uniform
  86831. * @return the material itself allowing "fluent" like uniform updates
  86832. */
  86833. setFloats(name: string, value: number[]): ShaderMaterial;
  86834. /**
  86835. * Set a vec3 in the shader from a Color3.
  86836. * @param name Define the name of the uniform as defined in the shader
  86837. * @param value Define the value to give to the uniform
  86838. * @return the material itself allowing "fluent" like uniform updates
  86839. */
  86840. setColor3(name: string, value: Color3): ShaderMaterial;
  86841. /**
  86842. * Set a vec3 array in the shader from a Color3 array.
  86843. * @param name Define the name of the uniform as defined in the shader
  86844. * @param value Define the value to give to the uniform
  86845. * @return the material itself allowing "fluent" like uniform updates
  86846. */
  86847. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  86848. /**
  86849. * Set a vec4 in the shader from a Color4.
  86850. * @param name Define the name of the uniform as defined in the shader
  86851. * @param value Define the value to give to the uniform
  86852. * @return the material itself allowing "fluent" like uniform updates
  86853. */
  86854. setColor4(name: string, value: Color4): ShaderMaterial;
  86855. /**
  86856. * Set a vec4 array in the shader from a Color4 array.
  86857. * @param name Define the name of the uniform as defined in the shader
  86858. * @param value Define the value to give to the uniform
  86859. * @return the material itself allowing "fluent" like uniform updates
  86860. */
  86861. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  86862. /**
  86863. * Set a vec2 in the shader from a Vector2.
  86864. * @param name Define the name of the uniform as defined in the shader
  86865. * @param value Define the value to give to the uniform
  86866. * @return the material itself allowing "fluent" like uniform updates
  86867. */
  86868. setVector2(name: string, value: Vector2): ShaderMaterial;
  86869. /**
  86870. * Set a vec3 in the shader from a Vector3.
  86871. * @param name Define the name of the uniform as defined in the shader
  86872. * @param value Define the value to give to the uniform
  86873. * @return the material itself allowing "fluent" like uniform updates
  86874. */
  86875. setVector3(name: string, value: Vector3): ShaderMaterial;
  86876. /**
  86877. * Set a vec4 in the shader from a Vector4.
  86878. * @param name Define the name of the uniform as defined in the shader
  86879. * @param value Define the value to give to the uniform
  86880. * @return the material itself allowing "fluent" like uniform updates
  86881. */
  86882. setVector4(name: string, value: Vector4): ShaderMaterial;
  86883. /**
  86884. * Set a mat4 in the shader from a Matrix.
  86885. * @param name Define the name of the uniform as defined in the shader
  86886. * @param value Define the value to give to the uniform
  86887. * @return the material itself allowing "fluent" like uniform updates
  86888. */
  86889. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86890. /**
  86891. * Set a mat3 in the shader from a Float32Array.
  86892. * @param name Define the name of the uniform as defined in the shader
  86893. * @param value Define the value to give to the uniform
  86894. * @return the material itself allowing "fluent" like uniform updates
  86895. */
  86896. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86897. /**
  86898. * Set a mat2 in the shader from a Float32Array.
  86899. * @param name Define the name of the uniform as defined in the shader
  86900. * @param value Define the value to give to the uniform
  86901. * @return the material itself allowing "fluent" like uniform updates
  86902. */
  86903. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86904. /**
  86905. * Set a vec2 array in the shader from a number array.
  86906. * @param name Define the name of the uniform as defined in the shader
  86907. * @param value Define the value to give to the uniform
  86908. * @return the material itself allowing "fluent" like uniform updates
  86909. */
  86910. setArray2(name: string, value: number[]): ShaderMaterial;
  86911. /**
  86912. * Set a vec3 array in the shader from a number array.
  86913. * @param name Define the name of the uniform as defined in the shader
  86914. * @param value Define the value to give to the uniform
  86915. * @return the material itself allowing "fluent" like uniform updates
  86916. */
  86917. setArray3(name: string, value: number[]): ShaderMaterial;
  86918. /**
  86919. * Set a vec4 array in the shader from a number array.
  86920. * @param name Define the name of the uniform as defined in the shader
  86921. * @param value Define the value to give to the uniform
  86922. * @return the material itself allowing "fluent" like uniform updates
  86923. */
  86924. setArray4(name: string, value: number[]): ShaderMaterial;
  86925. private _checkCache;
  86926. /**
  86927. * Specifies that the submesh is ready to be used
  86928. * @param mesh defines the mesh to check
  86929. * @param subMesh defines which submesh to check
  86930. * @param useInstances specifies that instances should be used
  86931. * @returns a boolean indicating that the submesh is ready or not
  86932. */
  86933. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86934. /**
  86935. * Checks if the material is ready to render the requested mesh
  86936. * @param mesh Define the mesh to render
  86937. * @param useInstances Define whether or not the material is used with instances
  86938. * @returns true if ready, otherwise false
  86939. */
  86940. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86941. /**
  86942. * Binds the world matrix to the material
  86943. * @param world defines the world transformation matrix
  86944. */
  86945. bindOnlyWorldMatrix(world: Matrix): void;
  86946. /**
  86947. * Binds the material to the mesh
  86948. * @param world defines the world transformation matrix
  86949. * @param mesh defines the mesh to bind the material to
  86950. */
  86951. bind(world: Matrix, mesh?: Mesh): void;
  86952. /**
  86953. * Gets the active textures from the material
  86954. * @returns an array of textures
  86955. */
  86956. getActiveTextures(): BaseTexture[];
  86957. /**
  86958. * Specifies if the material uses a texture
  86959. * @param texture defines the texture to check against the material
  86960. * @returns a boolean specifying if the material uses the texture
  86961. */
  86962. hasTexture(texture: BaseTexture): boolean;
  86963. /**
  86964. * Makes a duplicate of the material, and gives it a new name
  86965. * @param name defines the new name for the duplicated material
  86966. * @returns the cloned material
  86967. */
  86968. clone(name: string): ShaderMaterial;
  86969. /**
  86970. * Disposes the material
  86971. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86972. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86973. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86974. */
  86975. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86976. /**
  86977. * Serializes this material in a JSON representation
  86978. * @returns the serialized material object
  86979. */
  86980. serialize(): any;
  86981. /**
  86982. * Creates a shader material from parsed shader material data
  86983. * @param source defines the JSON represnetation of the material
  86984. * @param scene defines the hosting scene
  86985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86986. * @returns a new material
  86987. */
  86988. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86989. }
  86990. }
  86991. declare module BABYLON {
  86992. /** @hidden */
  86993. export var colorPixelShader: {
  86994. name: string;
  86995. shader: string;
  86996. };
  86997. }
  86998. declare module BABYLON {
  86999. /** @hidden */
  87000. export var colorVertexShader: {
  87001. name: string;
  87002. shader: string;
  87003. };
  87004. }
  87005. declare module BABYLON {
  87006. /**
  87007. * Line mesh
  87008. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87009. */
  87010. export class LinesMesh extends Mesh {
  87011. /**
  87012. * If vertex color should be applied to the mesh
  87013. */
  87014. readonly useVertexColor?: boolean | undefined;
  87015. /**
  87016. * If vertex alpha should be applied to the mesh
  87017. */
  87018. readonly useVertexAlpha?: boolean | undefined;
  87019. /**
  87020. * Color of the line (Default: White)
  87021. */
  87022. color: Color3;
  87023. /**
  87024. * Alpha of the line (Default: 1)
  87025. */
  87026. alpha: number;
  87027. /**
  87028. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87029. * This margin is expressed in world space coordinates, so its value may vary.
  87030. * Default value is 0.1
  87031. */
  87032. intersectionThreshold: number;
  87033. private _colorShader;
  87034. private color4;
  87035. /**
  87036. * Creates a new LinesMesh
  87037. * @param name defines the name
  87038. * @param scene defines the hosting scene
  87039. * @param parent defines the parent mesh if any
  87040. * @param source defines the optional source LinesMesh used to clone data from
  87041. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87042. * When false, achieved by calling a clone(), also passing False.
  87043. * This will make creation of children, recursive.
  87044. * @param useVertexColor defines if this LinesMesh supports vertex color
  87045. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87046. */
  87047. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87048. /**
  87049. * If vertex color should be applied to the mesh
  87050. */
  87051. useVertexColor?: boolean | undefined,
  87052. /**
  87053. * If vertex alpha should be applied to the mesh
  87054. */
  87055. useVertexAlpha?: boolean | undefined);
  87056. private _addClipPlaneDefine;
  87057. private _removeClipPlaneDefine;
  87058. isReady(): boolean;
  87059. /**
  87060. * Returns the string "LineMesh"
  87061. */
  87062. getClassName(): string;
  87063. /**
  87064. * @hidden
  87065. */
  87066. /**
  87067. * @hidden
  87068. */
  87069. material: Material;
  87070. /**
  87071. * @hidden
  87072. */
  87073. readonly checkCollisions: boolean;
  87074. /** @hidden */
  87075. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87076. /** @hidden */
  87077. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87078. /**
  87079. * Disposes of the line mesh
  87080. * @param doNotRecurse If children should be disposed
  87081. */
  87082. dispose(doNotRecurse?: boolean): void;
  87083. /**
  87084. * Returns a new LineMesh object cloned from the current one.
  87085. */
  87086. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87087. /**
  87088. * Creates a new InstancedLinesMesh object from the mesh model.
  87089. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87090. * @param name defines the name of the new instance
  87091. * @returns a new InstancedLinesMesh
  87092. */
  87093. createInstance(name: string): InstancedLinesMesh;
  87094. }
  87095. /**
  87096. * Creates an instance based on a source LinesMesh
  87097. */
  87098. export class InstancedLinesMesh extends InstancedMesh {
  87099. /**
  87100. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87101. * This margin is expressed in world space coordinates, so its value may vary.
  87102. * Initilized with the intersectionThreshold value of the source LinesMesh
  87103. */
  87104. intersectionThreshold: number;
  87105. constructor(name: string, source: LinesMesh);
  87106. /**
  87107. * Returns the string "InstancedLinesMesh".
  87108. */
  87109. getClassName(): string;
  87110. }
  87111. }
  87112. declare module BABYLON {
  87113. /** @hidden */
  87114. export var linePixelShader: {
  87115. name: string;
  87116. shader: string;
  87117. };
  87118. }
  87119. declare module BABYLON {
  87120. /** @hidden */
  87121. export var lineVertexShader: {
  87122. name: string;
  87123. shader: string;
  87124. };
  87125. }
  87126. declare module BABYLON {
  87127. interface AbstractMesh {
  87128. /**
  87129. * Gets the edgesRenderer associated with the mesh
  87130. */
  87131. edgesRenderer: Nullable<EdgesRenderer>;
  87132. }
  87133. interface LinesMesh {
  87134. /**
  87135. * Enables the edge rendering mode on the mesh.
  87136. * This mode makes the mesh edges visible
  87137. * @param epsilon defines the maximal distance between two angles to detect a face
  87138. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87139. * @returns the currentAbstractMesh
  87140. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87141. */
  87142. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87143. }
  87144. interface InstancedLinesMesh {
  87145. /**
  87146. * Enables the edge rendering mode on the mesh.
  87147. * This mode makes the mesh edges visible
  87148. * @param epsilon defines the maximal distance between two angles to detect a face
  87149. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87150. * @returns the current InstancedLinesMesh
  87151. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87152. */
  87153. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  87154. }
  87155. /**
  87156. * Defines the minimum contract an Edges renderer should follow.
  87157. */
  87158. export interface IEdgesRenderer extends IDisposable {
  87159. /**
  87160. * Gets or sets a boolean indicating if the edgesRenderer is active
  87161. */
  87162. isEnabled: boolean;
  87163. /**
  87164. * Renders the edges of the attached mesh,
  87165. */
  87166. render(): void;
  87167. /**
  87168. * Checks wether or not the edges renderer is ready to render.
  87169. * @return true if ready, otherwise false.
  87170. */
  87171. isReady(): boolean;
  87172. }
  87173. /**
  87174. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  87175. */
  87176. export class EdgesRenderer implements IEdgesRenderer {
  87177. /**
  87178. * Define the size of the edges with an orthographic camera
  87179. */
  87180. edgesWidthScalerForOrthographic: number;
  87181. /**
  87182. * Define the size of the edges with a perspective camera
  87183. */
  87184. edgesWidthScalerForPerspective: number;
  87185. protected _source: AbstractMesh;
  87186. protected _linesPositions: number[];
  87187. protected _linesNormals: number[];
  87188. protected _linesIndices: number[];
  87189. protected _epsilon: number;
  87190. protected _indicesCount: number;
  87191. protected _lineShader: ShaderMaterial;
  87192. protected _ib: DataBuffer;
  87193. protected _buffers: {
  87194. [key: string]: Nullable<VertexBuffer>;
  87195. };
  87196. protected _checkVerticesInsteadOfIndices: boolean;
  87197. private _meshRebuildObserver;
  87198. private _meshDisposeObserver;
  87199. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  87200. isEnabled: boolean;
  87201. /**
  87202. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  87203. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  87204. * @param source Mesh used to create edges
  87205. * @param epsilon sum of angles in adjacency to check for edge
  87206. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  87207. * @param generateEdgesLines - should generate Lines or only prepare resources.
  87208. */
  87209. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  87210. protected _prepareRessources(): void;
  87211. /** @hidden */
  87212. _rebuild(): void;
  87213. /**
  87214. * Releases the required resources for the edges renderer
  87215. */
  87216. dispose(): void;
  87217. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  87218. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  87219. /**
  87220. * Checks if the pair of p0 and p1 is en edge
  87221. * @param faceIndex
  87222. * @param edge
  87223. * @param faceNormals
  87224. * @param p0
  87225. * @param p1
  87226. * @private
  87227. */
  87228. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  87229. /**
  87230. * push line into the position, normal and index buffer
  87231. * @protected
  87232. */
  87233. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  87234. /**
  87235. * Generates lines edges from adjacencjes
  87236. * @private
  87237. */
  87238. _generateEdgesLines(): void;
  87239. /**
  87240. * Checks wether or not the edges renderer is ready to render.
  87241. * @return true if ready, otherwise false.
  87242. */
  87243. isReady(): boolean;
  87244. /**
  87245. * Renders the edges of the attached mesh,
  87246. */
  87247. render(): void;
  87248. }
  87249. /**
  87250. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  87251. */
  87252. export class LineEdgesRenderer extends EdgesRenderer {
  87253. /**
  87254. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  87255. * @param source LineMesh used to generate edges
  87256. * @param epsilon not important (specified angle for edge detection)
  87257. * @param checkVerticesInsteadOfIndices not important for LineMesh
  87258. */
  87259. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  87260. /**
  87261. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  87262. */
  87263. _generateEdgesLines(): void;
  87264. }
  87265. }
  87266. declare module BABYLON {
  87267. /**
  87268. * This represents the object necessary to create a rendering group.
  87269. * This is exclusively used and created by the rendering manager.
  87270. * To modify the behavior, you use the available helpers in your scene or meshes.
  87271. * @hidden
  87272. */
  87273. export class RenderingGroup {
  87274. index: number;
  87275. private static _zeroVector;
  87276. private _scene;
  87277. private _opaqueSubMeshes;
  87278. private _transparentSubMeshes;
  87279. private _alphaTestSubMeshes;
  87280. private _depthOnlySubMeshes;
  87281. private _particleSystems;
  87282. private _spriteManagers;
  87283. private _opaqueSortCompareFn;
  87284. private _alphaTestSortCompareFn;
  87285. private _transparentSortCompareFn;
  87286. private _renderOpaque;
  87287. private _renderAlphaTest;
  87288. private _renderTransparent;
  87289. /** @hidden */
  87290. _edgesRenderers: SmartArray<IEdgesRenderer>;
  87291. onBeforeTransparentRendering: () => void;
  87292. /**
  87293. * Set the opaque sort comparison function.
  87294. * If null the sub meshes will be render in the order they were created
  87295. */
  87296. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87297. /**
  87298. * Set the alpha test sort comparison function.
  87299. * If null the sub meshes will be render in the order they were created
  87300. */
  87301. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87302. /**
  87303. * Set the transparent sort comparison function.
  87304. * If null the sub meshes will be render in the order they were created
  87305. */
  87306. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  87307. /**
  87308. * Creates a new rendering group.
  87309. * @param index The rendering group index
  87310. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  87311. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  87312. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  87313. */
  87314. 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>);
  87315. /**
  87316. * Render all the sub meshes contained in the group.
  87317. * @param customRenderFunction Used to override the default render behaviour of the group.
  87318. * @returns true if rendered some submeshes.
  87319. */
  87320. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  87321. /**
  87322. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  87323. * @param subMeshes The submeshes to render
  87324. */
  87325. private renderOpaqueSorted;
  87326. /**
  87327. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  87328. * @param subMeshes The submeshes to render
  87329. */
  87330. private renderAlphaTestSorted;
  87331. /**
  87332. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  87333. * @param subMeshes The submeshes to render
  87334. */
  87335. private renderTransparentSorted;
  87336. /**
  87337. * Renders the submeshes in a specified order.
  87338. * @param subMeshes The submeshes to sort before render
  87339. * @param sortCompareFn The comparison function use to sort
  87340. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  87341. * @param transparent Specifies to activate blending if true
  87342. */
  87343. private static renderSorted;
  87344. /**
  87345. * Renders the submeshes in the order they were dispatched (no sort applied).
  87346. * @param subMeshes The submeshes to render
  87347. */
  87348. private static renderUnsorted;
  87349. /**
  87350. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87351. * are rendered back to front if in the same alpha index.
  87352. *
  87353. * @param a The first submesh
  87354. * @param b The second submesh
  87355. * @returns The result of the comparison
  87356. */
  87357. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  87358. /**
  87359. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87360. * are rendered back to front.
  87361. *
  87362. * @param a The first submesh
  87363. * @param b The second submesh
  87364. * @returns The result of the comparison
  87365. */
  87366. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  87367. /**
  87368. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  87369. * are rendered front to back (prevent overdraw).
  87370. *
  87371. * @param a The first submesh
  87372. * @param b The second submesh
  87373. * @returns The result of the comparison
  87374. */
  87375. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  87376. /**
  87377. * Resets the different lists of submeshes to prepare a new frame.
  87378. */
  87379. prepare(): void;
  87380. dispose(): void;
  87381. /**
  87382. * Inserts the submesh in its correct queue depending on its material.
  87383. * @param subMesh The submesh to dispatch
  87384. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87385. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87386. */
  87387. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87388. dispatchSprites(spriteManager: ISpriteManager): void;
  87389. dispatchParticles(particleSystem: IParticleSystem): void;
  87390. private _renderParticles;
  87391. private _renderSprites;
  87392. }
  87393. }
  87394. declare module BABYLON {
  87395. /**
  87396. * Interface describing the different options available in the rendering manager
  87397. * regarding Auto Clear between groups.
  87398. */
  87399. export interface IRenderingManagerAutoClearSetup {
  87400. /**
  87401. * Defines whether or not autoclear is enable.
  87402. */
  87403. autoClear: boolean;
  87404. /**
  87405. * Defines whether or not to autoclear the depth buffer.
  87406. */
  87407. depth: boolean;
  87408. /**
  87409. * Defines whether or not to autoclear the stencil buffer.
  87410. */
  87411. stencil: boolean;
  87412. }
  87413. /**
  87414. * This class is used by the onRenderingGroupObservable
  87415. */
  87416. export class RenderingGroupInfo {
  87417. /**
  87418. * The Scene that being rendered
  87419. */
  87420. scene: Scene;
  87421. /**
  87422. * The camera currently used for the rendering pass
  87423. */
  87424. camera: Nullable<Camera>;
  87425. /**
  87426. * The ID of the renderingGroup being processed
  87427. */
  87428. renderingGroupId: number;
  87429. }
  87430. /**
  87431. * This is the manager responsible of all the rendering for meshes sprites and particles.
  87432. * It is enable to manage the different groups as well as the different necessary sort functions.
  87433. * This should not be used directly aside of the few static configurations
  87434. */
  87435. export class RenderingManager {
  87436. /**
  87437. * The max id used for rendering groups (not included)
  87438. */
  87439. static MAX_RENDERINGGROUPS: number;
  87440. /**
  87441. * The min id used for rendering groups (included)
  87442. */
  87443. static MIN_RENDERINGGROUPS: number;
  87444. /**
  87445. * Used to globally prevent autoclearing scenes.
  87446. */
  87447. static AUTOCLEAR: boolean;
  87448. /**
  87449. * @hidden
  87450. */
  87451. _useSceneAutoClearSetup: boolean;
  87452. private _scene;
  87453. private _renderingGroups;
  87454. private _depthStencilBufferAlreadyCleaned;
  87455. private _autoClearDepthStencil;
  87456. private _customOpaqueSortCompareFn;
  87457. private _customAlphaTestSortCompareFn;
  87458. private _customTransparentSortCompareFn;
  87459. private _renderingGroupInfo;
  87460. /**
  87461. * Instantiates a new rendering group for a particular scene
  87462. * @param scene Defines the scene the groups belongs to
  87463. */
  87464. constructor(scene: Scene);
  87465. private _clearDepthStencilBuffer;
  87466. /**
  87467. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  87468. * @hidden
  87469. */
  87470. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  87471. /**
  87472. * Resets the different information of the group to prepare a new frame
  87473. * @hidden
  87474. */
  87475. reset(): void;
  87476. /**
  87477. * Dispose and release the group and its associated resources.
  87478. * @hidden
  87479. */
  87480. dispose(): void;
  87481. /**
  87482. * Clear the info related to rendering groups preventing retention points during dispose.
  87483. */
  87484. freeRenderingGroups(): void;
  87485. private _prepareRenderingGroup;
  87486. /**
  87487. * Add a sprite manager to the rendering manager in order to render it this frame.
  87488. * @param spriteManager Define the sprite manager to render
  87489. */
  87490. dispatchSprites(spriteManager: ISpriteManager): void;
  87491. /**
  87492. * Add a particle system to the rendering manager in order to render it this frame.
  87493. * @param particleSystem Define the particle system to render
  87494. */
  87495. dispatchParticles(particleSystem: IParticleSystem): void;
  87496. /**
  87497. * Add a submesh to the manager in order to render it this frame
  87498. * @param subMesh The submesh to dispatch
  87499. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  87500. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  87501. */
  87502. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  87503. /**
  87504. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87505. * This allowed control for front to back rendering or reversly depending of the special needs.
  87506. *
  87507. * @param renderingGroupId The rendering group id corresponding to its index
  87508. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87509. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87510. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87511. */
  87512. 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;
  87513. /**
  87514. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87515. *
  87516. * @param renderingGroupId The rendering group id corresponding to its index
  87517. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87518. * @param depth Automatically clears depth between groups if true and autoClear is true.
  87519. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  87520. */
  87521. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  87522. /**
  87523. * Gets the current auto clear configuration for one rendering group of the rendering
  87524. * manager.
  87525. * @param index the rendering group index to get the information for
  87526. * @returns The auto clear setup for the requested rendering group
  87527. */
  87528. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  87529. }
  87530. }
  87531. declare module BABYLON {
  87532. /**
  87533. * This Helps creating a texture that will be created from a camera in your scene.
  87534. * It is basically a dynamic texture that could be used to create special effects for instance.
  87535. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  87536. */
  87537. export class RenderTargetTexture extends Texture {
  87538. isCube: boolean;
  87539. /**
  87540. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  87541. */
  87542. static readonly REFRESHRATE_RENDER_ONCE: number;
  87543. /**
  87544. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  87545. */
  87546. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  87547. /**
  87548. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  87549. * the central point of your effect and can save a lot of performances.
  87550. */
  87551. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  87552. /**
  87553. * Use this predicate to dynamically define the list of mesh you want to render.
  87554. * If set, the renderList property will be overwritten.
  87555. */
  87556. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  87557. private _renderList;
  87558. /**
  87559. * Use this list to define the list of mesh you want to render.
  87560. */
  87561. renderList: Nullable<Array<AbstractMesh>>;
  87562. private _hookArray;
  87563. /**
  87564. * Define if particles should be rendered in your texture.
  87565. */
  87566. renderParticles: boolean;
  87567. /**
  87568. * Define if sprites should be rendered in your texture.
  87569. */
  87570. renderSprites: boolean;
  87571. /**
  87572. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  87573. */
  87574. coordinatesMode: number;
  87575. /**
  87576. * Define the camera used to render the texture.
  87577. */
  87578. activeCamera: Nullable<Camera>;
  87579. /**
  87580. * Override the render function of the texture with your own one.
  87581. */
  87582. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  87583. /**
  87584. * Define if camera post processes should be use while rendering the texture.
  87585. */
  87586. useCameraPostProcesses: boolean;
  87587. /**
  87588. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  87589. */
  87590. ignoreCameraViewport: boolean;
  87591. private _postProcessManager;
  87592. private _postProcesses;
  87593. private _resizeObserver;
  87594. /**
  87595. * An event triggered when the texture is unbind.
  87596. */
  87597. onBeforeBindObservable: Observable<RenderTargetTexture>;
  87598. /**
  87599. * An event triggered when the texture is unbind.
  87600. */
  87601. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  87602. private _onAfterUnbindObserver;
  87603. /**
  87604. * Set a after unbind callback in the texture.
  87605. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  87606. */
  87607. onAfterUnbind: () => void;
  87608. /**
  87609. * An event triggered before rendering the texture
  87610. */
  87611. onBeforeRenderObservable: Observable<number>;
  87612. private _onBeforeRenderObserver;
  87613. /**
  87614. * Set a before render callback in the texture.
  87615. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  87616. */
  87617. onBeforeRender: (faceIndex: number) => void;
  87618. /**
  87619. * An event triggered after rendering the texture
  87620. */
  87621. onAfterRenderObservable: Observable<number>;
  87622. private _onAfterRenderObserver;
  87623. /**
  87624. * Set a after render callback in the texture.
  87625. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  87626. */
  87627. onAfterRender: (faceIndex: number) => void;
  87628. /**
  87629. * An event triggered after the texture clear
  87630. */
  87631. onClearObservable: Observable<Engine>;
  87632. private _onClearObserver;
  87633. /**
  87634. * Set a clear callback in the texture.
  87635. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  87636. */
  87637. onClear: (Engine: Engine) => void;
  87638. /**
  87639. * An event triggered when the texture is resized.
  87640. */
  87641. onResizeObservable: Observable<RenderTargetTexture>;
  87642. /**
  87643. * Define the clear color of the Render Target if it should be different from the scene.
  87644. */
  87645. clearColor: Color4;
  87646. protected _size: number | {
  87647. width: number;
  87648. height: number;
  87649. };
  87650. protected _initialSizeParameter: number | {
  87651. width: number;
  87652. height: number;
  87653. } | {
  87654. ratio: number;
  87655. };
  87656. protected _sizeRatio: Nullable<number>;
  87657. /** @hidden */
  87658. _generateMipMaps: boolean;
  87659. protected _renderingManager: RenderingManager;
  87660. /** @hidden */
  87661. _waitingRenderList: string[];
  87662. protected _doNotChangeAspectRatio: boolean;
  87663. protected _currentRefreshId: number;
  87664. protected _refreshRate: number;
  87665. protected _textureMatrix: Matrix;
  87666. protected _samples: number;
  87667. protected _renderTargetOptions: RenderTargetCreationOptions;
  87668. /**
  87669. * Gets render target creation options that were used.
  87670. */
  87671. readonly renderTargetOptions: RenderTargetCreationOptions;
  87672. protected _engine: Engine;
  87673. protected _onRatioRescale(): void;
  87674. /**
  87675. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  87676. * It must define where the camera used to render the texture is set
  87677. */
  87678. boundingBoxPosition: Vector3;
  87679. private _boundingBoxSize;
  87680. /**
  87681. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  87682. * When defined, the cubemap will switch to local mode
  87683. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87684. * @example https://www.babylonjs-playground.com/#RNASML
  87685. */
  87686. boundingBoxSize: Vector3;
  87687. /**
  87688. * In case the RTT has been created with a depth texture, get the associated
  87689. * depth texture.
  87690. * Otherwise, return null.
  87691. */
  87692. depthStencilTexture: Nullable<InternalTexture>;
  87693. /**
  87694. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  87695. * or used a shadow, depth texture...
  87696. * @param name The friendly name of the texture
  87697. * @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)
  87698. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  87699. * @param generateMipMaps True if mip maps need to be generated after render.
  87700. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  87701. * @param type The type of the buffer in the RTT (int, half float, float...)
  87702. * @param isCube True if a cube texture needs to be created
  87703. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  87704. * @param generateDepthBuffer True to generate a depth buffer
  87705. * @param generateStencilBuffer True to generate a stencil buffer
  87706. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  87707. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  87708. * @param delayAllocation if the texture allocation should be delayed (default: false)
  87709. */
  87710. constructor(name: string, size: number | {
  87711. width: number;
  87712. height: number;
  87713. } | {
  87714. ratio: number;
  87715. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  87716. /**
  87717. * Creates a depth stencil texture.
  87718. * This is only available in WebGL 2 or with the depth texture extension available.
  87719. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  87720. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  87721. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  87722. */
  87723. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  87724. private _processSizeParameter;
  87725. /**
  87726. * Define the number of samples to use in case of MSAA.
  87727. * It defaults to one meaning no MSAA has been enabled.
  87728. */
  87729. samples: number;
  87730. /**
  87731. * Resets the refresh counter of the texture and start bak from scratch.
  87732. * Could be useful to regenerate the texture if it is setup to render only once.
  87733. */
  87734. resetRefreshCounter(): void;
  87735. /**
  87736. * Define the refresh rate of the texture or the rendering frequency.
  87737. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87738. */
  87739. refreshRate: number;
  87740. /**
  87741. * Adds a post process to the render target rendering passes.
  87742. * @param postProcess define the post process to add
  87743. */
  87744. addPostProcess(postProcess: PostProcess): void;
  87745. /**
  87746. * Clear all the post processes attached to the render target
  87747. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  87748. */
  87749. clearPostProcesses(dispose?: boolean): void;
  87750. /**
  87751. * Remove one of the post process from the list of attached post processes to the texture
  87752. * @param postProcess define the post process to remove from the list
  87753. */
  87754. removePostProcess(postProcess: PostProcess): void;
  87755. /** @hidden */
  87756. _shouldRender(): boolean;
  87757. /**
  87758. * Gets the actual render size of the texture.
  87759. * @returns the width of the render size
  87760. */
  87761. getRenderSize(): number;
  87762. /**
  87763. * Gets the actual render width of the texture.
  87764. * @returns the width of the render size
  87765. */
  87766. getRenderWidth(): number;
  87767. /**
  87768. * Gets the actual render height of the texture.
  87769. * @returns the height of the render size
  87770. */
  87771. getRenderHeight(): number;
  87772. /**
  87773. * Get if the texture can be rescaled or not.
  87774. */
  87775. readonly canRescale: boolean;
  87776. /**
  87777. * Resize the texture using a ratio.
  87778. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  87779. */
  87780. scale(ratio: number): void;
  87781. /**
  87782. * Get the texture reflection matrix used to rotate/transform the reflection.
  87783. * @returns the reflection matrix
  87784. */
  87785. getReflectionTextureMatrix(): Matrix;
  87786. /**
  87787. * Resize the texture to a new desired size.
  87788. * Be carrefull as it will recreate all the data in the new texture.
  87789. * @param size Define the new size. It can be:
  87790. * - a number for squared texture,
  87791. * - an object containing { width: number, height: number }
  87792. * - or an object containing a ratio { ratio: number }
  87793. */
  87794. resize(size: number | {
  87795. width: number;
  87796. height: number;
  87797. } | {
  87798. ratio: number;
  87799. }): void;
  87800. /**
  87801. * Renders all the objects from the render list into the texture.
  87802. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  87803. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  87804. */
  87805. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  87806. private _bestReflectionRenderTargetDimension;
  87807. /**
  87808. * @hidden
  87809. * @param faceIndex face index to bind to if this is a cubetexture
  87810. */
  87811. _bindFrameBuffer(faceIndex?: number): void;
  87812. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  87813. private renderToTarget;
  87814. /**
  87815. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  87816. * This allowed control for front to back rendering or reversly depending of the special needs.
  87817. *
  87818. * @param renderingGroupId The rendering group id corresponding to its index
  87819. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  87820. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  87821. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  87822. */
  87823. 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;
  87824. /**
  87825. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  87826. *
  87827. * @param renderingGroupId The rendering group id corresponding to its index
  87828. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  87829. */
  87830. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  87831. /**
  87832. * Clones the texture.
  87833. * @returns the cloned texture
  87834. */
  87835. clone(): RenderTargetTexture;
  87836. /**
  87837. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87838. * @returns The JSON representation of the texture
  87839. */
  87840. serialize(): any;
  87841. /**
  87842. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  87843. */
  87844. disposeFramebufferObjects(): void;
  87845. /**
  87846. * Dispose the texture and release its associated resources.
  87847. */
  87848. dispose(): void;
  87849. /** @hidden */
  87850. _rebuild(): void;
  87851. /**
  87852. * Clear the info related to rendering groups preventing retention point in material dispose.
  87853. */
  87854. freeRenderingGroups(): void;
  87855. /**
  87856. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  87857. * @returns the view count
  87858. */
  87859. getViewCount(): number;
  87860. }
  87861. }
  87862. declare module BABYLON {
  87863. /**
  87864. * Options for compiling materials.
  87865. */
  87866. export interface IMaterialCompilationOptions {
  87867. /**
  87868. * Defines whether clip planes are enabled.
  87869. */
  87870. clipPlane: boolean;
  87871. /**
  87872. * Defines whether instances are enabled.
  87873. */
  87874. useInstances: boolean;
  87875. }
  87876. /**
  87877. * Base class for the main features of a material in Babylon.js
  87878. */
  87879. export class Material implements IAnimatable {
  87880. /**
  87881. * Returns the triangle fill mode
  87882. */
  87883. static readonly TriangleFillMode: number;
  87884. /**
  87885. * Returns the wireframe mode
  87886. */
  87887. static readonly WireFrameFillMode: number;
  87888. /**
  87889. * Returns the point fill mode
  87890. */
  87891. static readonly PointFillMode: number;
  87892. /**
  87893. * Returns the point list draw mode
  87894. */
  87895. static readonly PointListDrawMode: number;
  87896. /**
  87897. * Returns the line list draw mode
  87898. */
  87899. static readonly LineListDrawMode: number;
  87900. /**
  87901. * Returns the line loop draw mode
  87902. */
  87903. static readonly LineLoopDrawMode: number;
  87904. /**
  87905. * Returns the line strip draw mode
  87906. */
  87907. static readonly LineStripDrawMode: number;
  87908. /**
  87909. * Returns the triangle strip draw mode
  87910. */
  87911. static readonly TriangleStripDrawMode: number;
  87912. /**
  87913. * Returns the triangle fan draw mode
  87914. */
  87915. static readonly TriangleFanDrawMode: number;
  87916. /**
  87917. * Stores the clock-wise side orientation
  87918. */
  87919. static readonly ClockWiseSideOrientation: number;
  87920. /**
  87921. * Stores the counter clock-wise side orientation
  87922. */
  87923. static readonly CounterClockWiseSideOrientation: number;
  87924. /**
  87925. * The dirty texture flag value
  87926. */
  87927. static readonly TextureDirtyFlag: number;
  87928. /**
  87929. * The dirty light flag value
  87930. */
  87931. static readonly LightDirtyFlag: number;
  87932. /**
  87933. * The dirty fresnel flag value
  87934. */
  87935. static readonly FresnelDirtyFlag: number;
  87936. /**
  87937. * The dirty attribute flag value
  87938. */
  87939. static readonly AttributesDirtyFlag: number;
  87940. /**
  87941. * The dirty misc flag value
  87942. */
  87943. static readonly MiscDirtyFlag: number;
  87944. /**
  87945. * The all dirty flag value
  87946. */
  87947. static readonly AllDirtyFlag: number;
  87948. /**
  87949. * The ID of the material
  87950. */
  87951. id: string;
  87952. /**
  87953. * Gets or sets the unique id of the material
  87954. */
  87955. uniqueId: number;
  87956. /**
  87957. * The name of the material
  87958. */
  87959. name: string;
  87960. /**
  87961. * Gets or sets user defined metadata
  87962. */
  87963. metadata: any;
  87964. /**
  87965. * For internal use only. Please do not use.
  87966. */
  87967. reservedDataStore: any;
  87968. /**
  87969. * Specifies if the ready state should be checked on each call
  87970. */
  87971. checkReadyOnEveryCall: boolean;
  87972. /**
  87973. * Specifies if the ready state should be checked once
  87974. */
  87975. checkReadyOnlyOnce: boolean;
  87976. /**
  87977. * The state of the material
  87978. */
  87979. state: string;
  87980. /**
  87981. * The alpha value of the material
  87982. */
  87983. protected _alpha: number;
  87984. /**
  87985. * List of inspectable custom properties (used by the Inspector)
  87986. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87987. */
  87988. inspectableCustomProperties: IInspectable[];
  87989. /**
  87990. * Sets the alpha value of the material
  87991. */
  87992. /**
  87993. * Gets the alpha value of the material
  87994. */
  87995. alpha: number;
  87996. /**
  87997. * Specifies if back face culling is enabled
  87998. */
  87999. protected _backFaceCulling: boolean;
  88000. /**
  88001. * Sets the back-face culling state
  88002. */
  88003. /**
  88004. * Gets the back-face culling state
  88005. */
  88006. backFaceCulling: boolean;
  88007. /**
  88008. * Stores the value for side orientation
  88009. */
  88010. sideOrientation: number;
  88011. /**
  88012. * Callback triggered when the material is compiled
  88013. */
  88014. onCompiled: Nullable<(effect: Effect) => void>;
  88015. /**
  88016. * Callback triggered when an error occurs
  88017. */
  88018. onError: Nullable<(effect: Effect, errors: string) => void>;
  88019. /**
  88020. * Callback triggered to get the render target textures
  88021. */
  88022. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88023. /**
  88024. * Gets a boolean indicating that current material needs to register RTT
  88025. */
  88026. readonly hasRenderTargetTextures: boolean;
  88027. /**
  88028. * Specifies if the material should be serialized
  88029. */
  88030. doNotSerialize: boolean;
  88031. /**
  88032. * @hidden
  88033. */
  88034. _storeEffectOnSubMeshes: boolean;
  88035. /**
  88036. * Stores the animations for the material
  88037. */
  88038. animations: Nullable<Array<Animation>>;
  88039. /**
  88040. * An event triggered when the material is disposed
  88041. */
  88042. onDisposeObservable: Observable<Material>;
  88043. /**
  88044. * An observer which watches for dispose events
  88045. */
  88046. private _onDisposeObserver;
  88047. private _onUnBindObservable;
  88048. /**
  88049. * Called during a dispose event
  88050. */
  88051. onDispose: () => void;
  88052. private _onBindObservable;
  88053. /**
  88054. * An event triggered when the material is bound
  88055. */
  88056. readonly onBindObservable: Observable<AbstractMesh>;
  88057. /**
  88058. * An observer which watches for bind events
  88059. */
  88060. private _onBindObserver;
  88061. /**
  88062. * Called during a bind event
  88063. */
  88064. onBind: (Mesh: AbstractMesh) => void;
  88065. /**
  88066. * An event triggered when the material is unbound
  88067. */
  88068. readonly onUnBindObservable: Observable<Material>;
  88069. /**
  88070. * Stores the value of the alpha mode
  88071. */
  88072. private _alphaMode;
  88073. /**
  88074. * Sets the value of the alpha mode.
  88075. *
  88076. * | Value | Type | Description |
  88077. * | --- | --- | --- |
  88078. * | 0 | ALPHA_DISABLE | |
  88079. * | 1 | ALPHA_ADD | |
  88080. * | 2 | ALPHA_COMBINE | |
  88081. * | 3 | ALPHA_SUBTRACT | |
  88082. * | 4 | ALPHA_MULTIPLY | |
  88083. * | 5 | ALPHA_MAXIMIZED | |
  88084. * | 6 | ALPHA_ONEONE | |
  88085. * | 7 | ALPHA_PREMULTIPLIED | |
  88086. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88087. * | 9 | ALPHA_INTERPOLATE | |
  88088. * | 10 | ALPHA_SCREENMODE | |
  88089. *
  88090. */
  88091. /**
  88092. * Gets the value of the alpha mode
  88093. */
  88094. alphaMode: number;
  88095. /**
  88096. * Stores the state of the need depth pre-pass value
  88097. */
  88098. private _needDepthPrePass;
  88099. /**
  88100. * Sets the need depth pre-pass value
  88101. */
  88102. /**
  88103. * Gets the depth pre-pass value
  88104. */
  88105. needDepthPrePass: boolean;
  88106. /**
  88107. * Specifies if depth writing should be disabled
  88108. */
  88109. disableDepthWrite: boolean;
  88110. /**
  88111. * Specifies if depth writing should be forced
  88112. */
  88113. forceDepthWrite: boolean;
  88114. /**
  88115. * Specifies if there should be a separate pass for culling
  88116. */
  88117. separateCullingPass: boolean;
  88118. /**
  88119. * Stores the state specifing if fog should be enabled
  88120. */
  88121. private _fogEnabled;
  88122. /**
  88123. * Sets the state for enabling fog
  88124. */
  88125. /**
  88126. * Gets the value of the fog enabled state
  88127. */
  88128. fogEnabled: boolean;
  88129. /**
  88130. * Stores the size of points
  88131. */
  88132. pointSize: number;
  88133. /**
  88134. * Stores the z offset value
  88135. */
  88136. zOffset: number;
  88137. /**
  88138. * Gets a value specifying if wireframe mode is enabled
  88139. */
  88140. /**
  88141. * Sets the state of wireframe mode
  88142. */
  88143. wireframe: boolean;
  88144. /**
  88145. * Gets the value specifying if point clouds are enabled
  88146. */
  88147. /**
  88148. * Sets the state of point cloud mode
  88149. */
  88150. pointsCloud: boolean;
  88151. /**
  88152. * Gets the material fill mode
  88153. */
  88154. /**
  88155. * Sets the material fill mode
  88156. */
  88157. fillMode: number;
  88158. /**
  88159. * @hidden
  88160. * Stores the effects for the material
  88161. */
  88162. _effect: Nullable<Effect>;
  88163. /**
  88164. * @hidden
  88165. * Specifies if the material was previously ready
  88166. */
  88167. _wasPreviouslyReady: boolean;
  88168. /**
  88169. * Specifies if uniform buffers should be used
  88170. */
  88171. private _useUBO;
  88172. /**
  88173. * Stores a reference to the scene
  88174. */
  88175. private _scene;
  88176. /**
  88177. * Stores the fill mode state
  88178. */
  88179. private _fillMode;
  88180. /**
  88181. * Specifies if the depth write state should be cached
  88182. */
  88183. private _cachedDepthWriteState;
  88184. /**
  88185. * Stores the uniform buffer
  88186. */
  88187. protected _uniformBuffer: UniformBuffer;
  88188. /** @hidden */
  88189. _indexInSceneMaterialArray: number;
  88190. /** @hidden */
  88191. meshMap: Nullable<{
  88192. [id: string]: AbstractMesh | undefined;
  88193. }>;
  88194. /**
  88195. * Creates a material instance
  88196. * @param name defines the name of the material
  88197. * @param scene defines the scene to reference
  88198. * @param doNotAdd specifies if the material should be added to the scene
  88199. */
  88200. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  88201. /**
  88202. * Returns a string representation of the current material
  88203. * @param fullDetails defines a boolean indicating which levels of logging is desired
  88204. * @returns a string with material information
  88205. */
  88206. toString(fullDetails?: boolean): string;
  88207. /**
  88208. * Gets the class name of the material
  88209. * @returns a string with the class name of the material
  88210. */
  88211. getClassName(): string;
  88212. /**
  88213. * Specifies if updates for the material been locked
  88214. */
  88215. readonly isFrozen: boolean;
  88216. /**
  88217. * Locks updates for the material
  88218. */
  88219. freeze(): void;
  88220. /**
  88221. * Unlocks updates for the material
  88222. */
  88223. unfreeze(): void;
  88224. /**
  88225. * Specifies if the material is ready to be used
  88226. * @param mesh defines the mesh to check
  88227. * @param useInstances specifies if instances should be used
  88228. * @returns a boolean indicating if the material is ready to be used
  88229. */
  88230. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88231. /**
  88232. * Specifies that the submesh is ready to be used
  88233. * @param mesh defines the mesh to check
  88234. * @param subMesh defines which submesh to check
  88235. * @param useInstances specifies that instances should be used
  88236. * @returns a boolean indicating that the submesh is ready or not
  88237. */
  88238. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88239. /**
  88240. * Returns the material effect
  88241. * @returns the effect associated with the material
  88242. */
  88243. getEffect(): Nullable<Effect>;
  88244. /**
  88245. * Returns the current scene
  88246. * @returns a Scene
  88247. */
  88248. getScene(): Scene;
  88249. /**
  88250. * Specifies if the material will require alpha blending
  88251. * @returns a boolean specifying if alpha blending is needed
  88252. */
  88253. needAlphaBlending(): boolean;
  88254. /**
  88255. * Specifies if the mesh will require alpha blending
  88256. * @param mesh defines the mesh to check
  88257. * @returns a boolean specifying if alpha blending is needed for the mesh
  88258. */
  88259. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  88260. /**
  88261. * Specifies if this material should be rendered in alpha test mode
  88262. * @returns a boolean specifying if an alpha test is needed.
  88263. */
  88264. needAlphaTesting(): boolean;
  88265. /**
  88266. * Gets the texture used for the alpha test
  88267. * @returns the texture to use for alpha testing
  88268. */
  88269. getAlphaTestTexture(): Nullable<BaseTexture>;
  88270. /**
  88271. * Marks the material to indicate that it needs to be re-calculated
  88272. */
  88273. markDirty(): void;
  88274. /** @hidden */
  88275. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  88276. /**
  88277. * Binds the material to the mesh
  88278. * @param world defines the world transformation matrix
  88279. * @param mesh defines the mesh to bind the material to
  88280. */
  88281. bind(world: Matrix, mesh?: Mesh): void;
  88282. /**
  88283. * Binds the submesh to the material
  88284. * @param world defines the world transformation matrix
  88285. * @param mesh defines the mesh containing the submesh
  88286. * @param subMesh defines the submesh to bind the material to
  88287. */
  88288. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  88289. /**
  88290. * Binds the world matrix to the material
  88291. * @param world defines the world transformation matrix
  88292. */
  88293. bindOnlyWorldMatrix(world: Matrix): void;
  88294. /**
  88295. * Binds the scene's uniform buffer to the effect.
  88296. * @param effect defines the effect to bind to the scene uniform buffer
  88297. * @param sceneUbo defines the uniform buffer storing scene data
  88298. */
  88299. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  88300. /**
  88301. * Binds the view matrix to the effect
  88302. * @param effect defines the effect to bind the view matrix to
  88303. */
  88304. bindView(effect: Effect): void;
  88305. /**
  88306. * Binds the view projection matrix to the effect
  88307. * @param effect defines the effect to bind the view projection matrix to
  88308. */
  88309. bindViewProjection(effect: Effect): void;
  88310. /**
  88311. * Specifies if material alpha testing should be turned on for the mesh
  88312. * @param mesh defines the mesh to check
  88313. */
  88314. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  88315. /**
  88316. * Processes to execute after binding the material to a mesh
  88317. * @param mesh defines the rendered mesh
  88318. */
  88319. protected _afterBind(mesh?: Mesh): void;
  88320. /**
  88321. * Unbinds the material from the mesh
  88322. */
  88323. unbind(): void;
  88324. /**
  88325. * Gets the active textures from the material
  88326. * @returns an array of textures
  88327. */
  88328. getActiveTextures(): BaseTexture[];
  88329. /**
  88330. * Specifies if the material uses a texture
  88331. * @param texture defines the texture to check against the material
  88332. * @returns a boolean specifying if the material uses the texture
  88333. */
  88334. hasTexture(texture: BaseTexture): boolean;
  88335. /**
  88336. * Makes a duplicate of the material, and gives it a new name
  88337. * @param name defines the new name for the duplicated material
  88338. * @returns the cloned material
  88339. */
  88340. clone(name: string): Nullable<Material>;
  88341. /**
  88342. * Gets the meshes bound to the material
  88343. * @returns an array of meshes bound to the material
  88344. */
  88345. getBindedMeshes(): AbstractMesh[];
  88346. /**
  88347. * Force shader compilation
  88348. * @param mesh defines the mesh associated with this material
  88349. * @param onCompiled defines a function to execute once the material is compiled
  88350. * @param options defines the options to configure the compilation
  88351. * @param onError defines a function to execute if the material fails compiling
  88352. */
  88353. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  88354. /**
  88355. * Force shader compilation
  88356. * @param mesh defines the mesh that will use this material
  88357. * @param options defines additional options for compiling the shaders
  88358. * @returns a promise that resolves when the compilation completes
  88359. */
  88360. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  88361. private static readonly _AllDirtyCallBack;
  88362. private static readonly _ImageProcessingDirtyCallBack;
  88363. private static readonly _TextureDirtyCallBack;
  88364. private static readonly _FresnelDirtyCallBack;
  88365. private static readonly _MiscDirtyCallBack;
  88366. private static readonly _LightsDirtyCallBack;
  88367. private static readonly _AttributeDirtyCallBack;
  88368. private static _FresnelAndMiscDirtyCallBack;
  88369. private static _TextureAndMiscDirtyCallBack;
  88370. private static readonly _DirtyCallbackArray;
  88371. private static readonly _RunDirtyCallBacks;
  88372. /**
  88373. * Marks a define in the material to indicate that it needs to be re-computed
  88374. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  88375. */
  88376. markAsDirty(flag: number): void;
  88377. /**
  88378. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  88379. * @param func defines a function which checks material defines against the submeshes
  88380. */
  88381. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  88382. /**
  88383. * Indicates that we need to re-calculated for all submeshes
  88384. */
  88385. protected _markAllSubMeshesAsAllDirty(): void;
  88386. /**
  88387. * Indicates that image processing needs to be re-calculated for all submeshes
  88388. */
  88389. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  88390. /**
  88391. * Indicates that textures need to be re-calculated for all submeshes
  88392. */
  88393. protected _markAllSubMeshesAsTexturesDirty(): void;
  88394. /**
  88395. * Indicates that fresnel needs to be re-calculated for all submeshes
  88396. */
  88397. protected _markAllSubMeshesAsFresnelDirty(): void;
  88398. /**
  88399. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  88400. */
  88401. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  88402. /**
  88403. * Indicates that lights need to be re-calculated for all submeshes
  88404. */
  88405. protected _markAllSubMeshesAsLightsDirty(): void;
  88406. /**
  88407. * Indicates that attributes need to be re-calculated for all submeshes
  88408. */
  88409. protected _markAllSubMeshesAsAttributesDirty(): void;
  88410. /**
  88411. * Indicates that misc needs to be re-calculated for all submeshes
  88412. */
  88413. protected _markAllSubMeshesAsMiscDirty(): void;
  88414. /**
  88415. * Indicates that textures and misc need to be re-calculated for all submeshes
  88416. */
  88417. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  88418. /**
  88419. * Disposes the material
  88420. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88421. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88422. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88423. */
  88424. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88425. /** @hidden */
  88426. private releaseVertexArrayObject;
  88427. /**
  88428. * Serializes this material
  88429. * @returns the serialized material object
  88430. */
  88431. serialize(): any;
  88432. /**
  88433. * Creates a material from parsed material data
  88434. * @param parsedMaterial defines parsed material data
  88435. * @param scene defines the hosting scene
  88436. * @param rootUrl defines the root URL to use to load textures
  88437. * @returns a new material
  88438. */
  88439. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  88440. }
  88441. }
  88442. declare module BABYLON {
  88443. /**
  88444. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88445. * separate meshes. This can be use to improve performances.
  88446. * @see http://doc.babylonjs.com/how_to/multi_materials
  88447. */
  88448. export class MultiMaterial extends Material {
  88449. private _subMaterials;
  88450. /**
  88451. * Gets or Sets the list of Materials used within the multi material.
  88452. * They need to be ordered according to the submeshes order in the associated mesh
  88453. */
  88454. subMaterials: Nullable<Material>[];
  88455. /**
  88456. * Function used to align with Node.getChildren()
  88457. * @returns the list of Materials used within the multi material
  88458. */
  88459. getChildren(): Nullable<Material>[];
  88460. /**
  88461. * Instantiates a new Multi Material
  88462. * A multi-material is used to apply different materials to different parts of the same object without the need of
  88463. * separate meshes. This can be use to improve performances.
  88464. * @see http://doc.babylonjs.com/how_to/multi_materials
  88465. * @param name Define the name in the scene
  88466. * @param scene Define the scene the material belongs to
  88467. */
  88468. constructor(name: string, scene: Scene);
  88469. private _hookArray;
  88470. /**
  88471. * Get one of the submaterial by its index in the submaterials array
  88472. * @param index The index to look the sub material at
  88473. * @returns The Material if the index has been defined
  88474. */
  88475. getSubMaterial(index: number): Nullable<Material>;
  88476. /**
  88477. * Get the list of active textures for the whole sub materials list.
  88478. * @returns All the textures that will be used during the rendering
  88479. */
  88480. getActiveTextures(): BaseTexture[];
  88481. /**
  88482. * Gets the current class name of the material e.g. "MultiMaterial"
  88483. * Mainly use in serialization.
  88484. * @returns the class name
  88485. */
  88486. getClassName(): string;
  88487. /**
  88488. * Checks if the material is ready to render the requested sub mesh
  88489. * @param mesh Define the mesh the submesh belongs to
  88490. * @param subMesh Define the sub mesh to look readyness for
  88491. * @param useInstances Define whether or not the material is used with instances
  88492. * @returns true if ready, otherwise false
  88493. */
  88494. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88495. /**
  88496. * Clones the current material and its related sub materials
  88497. * @param name Define the name of the newly cloned material
  88498. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  88499. * @returns the cloned material
  88500. */
  88501. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  88502. /**
  88503. * Serializes the materials into a JSON representation.
  88504. * @returns the JSON representation
  88505. */
  88506. serialize(): any;
  88507. /**
  88508. * Dispose the material and release its associated resources
  88509. * @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)
  88510. * @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)
  88511. * @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)
  88512. */
  88513. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  88514. /**
  88515. * Creates a MultiMaterial from parsed MultiMaterial data.
  88516. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  88517. * @param scene defines the hosting scene
  88518. * @returns a new MultiMaterial
  88519. */
  88520. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  88521. }
  88522. }
  88523. declare module BABYLON {
  88524. /**
  88525. * Base class for submeshes
  88526. */
  88527. export class BaseSubMesh {
  88528. /** @hidden */
  88529. _materialDefines: Nullable<MaterialDefines>;
  88530. /** @hidden */
  88531. _materialEffect: Nullable<Effect>;
  88532. /**
  88533. * Gets associated effect
  88534. */
  88535. readonly effect: Nullable<Effect>;
  88536. /**
  88537. * Sets associated effect (effect used to render this submesh)
  88538. * @param effect defines the effect to associate with
  88539. * @param defines defines the set of defines used to compile this effect
  88540. */
  88541. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  88542. }
  88543. /**
  88544. * Defines a subdivision inside a mesh
  88545. */
  88546. export class SubMesh extends BaseSubMesh implements ICullable {
  88547. /** the material index to use */
  88548. materialIndex: number;
  88549. /** vertex index start */
  88550. verticesStart: number;
  88551. /** vertices count */
  88552. verticesCount: number;
  88553. /** index start */
  88554. indexStart: number;
  88555. /** indices count */
  88556. indexCount: number;
  88557. /** @hidden */
  88558. _linesIndexCount: number;
  88559. private _mesh;
  88560. private _renderingMesh;
  88561. private _boundingInfo;
  88562. private _linesIndexBuffer;
  88563. /** @hidden */
  88564. _lastColliderWorldVertices: Nullable<Vector3[]>;
  88565. /** @hidden */
  88566. _trianglePlanes: Plane[];
  88567. /** @hidden */
  88568. _lastColliderTransformMatrix: Nullable<Matrix>;
  88569. /** @hidden */
  88570. _renderId: number;
  88571. /** @hidden */
  88572. _alphaIndex: number;
  88573. /** @hidden */
  88574. _distanceToCamera: number;
  88575. /** @hidden */
  88576. _id: number;
  88577. private _currentMaterial;
  88578. /**
  88579. * Add a new submesh to a mesh
  88580. * @param materialIndex defines the material index to use
  88581. * @param verticesStart defines vertex index start
  88582. * @param verticesCount defines vertices count
  88583. * @param indexStart defines index start
  88584. * @param indexCount defines indices count
  88585. * @param mesh defines the parent mesh
  88586. * @param renderingMesh defines an optional rendering mesh
  88587. * @param createBoundingBox defines if bounding box should be created for this submesh
  88588. * @returns the new submesh
  88589. */
  88590. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  88591. /**
  88592. * Creates a new submesh
  88593. * @param materialIndex defines the material index to use
  88594. * @param verticesStart defines vertex index start
  88595. * @param verticesCount defines vertices count
  88596. * @param indexStart defines index start
  88597. * @param indexCount defines indices count
  88598. * @param mesh defines the parent mesh
  88599. * @param renderingMesh defines an optional rendering mesh
  88600. * @param createBoundingBox defines if bounding box should be created for this submesh
  88601. */
  88602. constructor(
  88603. /** the material index to use */
  88604. materialIndex: number,
  88605. /** vertex index start */
  88606. verticesStart: number,
  88607. /** vertices count */
  88608. verticesCount: number,
  88609. /** index start */
  88610. indexStart: number,
  88611. /** indices count */
  88612. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  88613. /**
  88614. * Returns true if this submesh covers the entire parent mesh
  88615. * @ignorenaming
  88616. */
  88617. readonly IsGlobal: boolean;
  88618. /**
  88619. * Returns the submesh BoudingInfo object
  88620. * @returns current bounding info (or mesh's one if the submesh is global)
  88621. */
  88622. getBoundingInfo(): BoundingInfo;
  88623. /**
  88624. * Sets the submesh BoundingInfo
  88625. * @param boundingInfo defines the new bounding info to use
  88626. * @returns the SubMesh
  88627. */
  88628. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  88629. /**
  88630. * Returns the mesh of the current submesh
  88631. * @return the parent mesh
  88632. */
  88633. getMesh(): AbstractMesh;
  88634. /**
  88635. * Returns the rendering mesh of the submesh
  88636. * @returns the rendering mesh (could be different from parent mesh)
  88637. */
  88638. getRenderingMesh(): Mesh;
  88639. /**
  88640. * Returns the submesh material
  88641. * @returns null or the current material
  88642. */
  88643. getMaterial(): Nullable<Material>;
  88644. /**
  88645. * Sets a new updated BoundingInfo object to the submesh
  88646. * @param data defines an optional position array to use to determine the bounding info
  88647. * @returns the SubMesh
  88648. */
  88649. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  88650. /** @hidden */
  88651. _checkCollision(collider: Collider): boolean;
  88652. /**
  88653. * Updates the submesh BoundingInfo
  88654. * @param world defines the world matrix to use to update the bounding info
  88655. * @returns the submesh
  88656. */
  88657. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  88658. /**
  88659. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  88660. * @param frustumPlanes defines the frustum planes
  88661. * @returns true if the submesh is intersecting with the frustum
  88662. */
  88663. isInFrustum(frustumPlanes: Plane[]): boolean;
  88664. /**
  88665. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  88666. * @param frustumPlanes defines the frustum planes
  88667. * @returns true if the submesh is inside the frustum
  88668. */
  88669. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88670. /**
  88671. * Renders the submesh
  88672. * @param enableAlphaMode defines if alpha needs to be used
  88673. * @returns the submesh
  88674. */
  88675. render(enableAlphaMode: boolean): SubMesh;
  88676. /**
  88677. * @hidden
  88678. */
  88679. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  88680. /**
  88681. * Checks if the submesh intersects with a ray
  88682. * @param ray defines the ray to test
  88683. * @returns true is the passed ray intersects the submesh bounding box
  88684. */
  88685. canIntersects(ray: Ray): boolean;
  88686. /**
  88687. * Intersects current submesh with a ray
  88688. * @param ray defines the ray to test
  88689. * @param positions defines mesh's positions array
  88690. * @param indices defines mesh's indices array
  88691. * @param fastCheck defines if only bounding info should be used
  88692. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  88693. * @returns intersection info or null if no intersection
  88694. */
  88695. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  88696. /** @hidden */
  88697. private _intersectLines;
  88698. /** @hidden */
  88699. private _intersectUnIndexedLines;
  88700. /** @hidden */
  88701. private _intersectTriangles;
  88702. /** @hidden */
  88703. private _intersectUnIndexedTriangles;
  88704. /** @hidden */
  88705. _rebuild(): void;
  88706. /**
  88707. * Creates a new submesh from the passed mesh
  88708. * @param newMesh defines the new hosting mesh
  88709. * @param newRenderingMesh defines an optional rendering mesh
  88710. * @returns the new submesh
  88711. */
  88712. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  88713. /**
  88714. * Release associated resources
  88715. */
  88716. dispose(): void;
  88717. /**
  88718. * Gets the class name
  88719. * @returns the string "SubMesh".
  88720. */
  88721. getClassName(): string;
  88722. /**
  88723. * Creates a new submesh from indices data
  88724. * @param materialIndex the index of the main mesh material
  88725. * @param startIndex the index where to start the copy in the mesh indices array
  88726. * @param indexCount the number of indices to copy then from the startIndex
  88727. * @param mesh the main mesh to create the submesh from
  88728. * @param renderingMesh the optional rendering mesh
  88729. * @returns a new submesh
  88730. */
  88731. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  88732. }
  88733. }
  88734. declare module BABYLON {
  88735. /**
  88736. * Class used to represent data loading progression
  88737. */
  88738. export class SceneLoaderFlags {
  88739. private static _ForceFullSceneLoadingForIncremental;
  88740. private static _ShowLoadingScreen;
  88741. private static _CleanBoneMatrixWeights;
  88742. private static _loggingLevel;
  88743. /**
  88744. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  88745. */
  88746. static ForceFullSceneLoadingForIncremental: boolean;
  88747. /**
  88748. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  88749. */
  88750. static ShowLoadingScreen: boolean;
  88751. /**
  88752. * Defines the current logging level (while loading the scene)
  88753. * @ignorenaming
  88754. */
  88755. static loggingLevel: number;
  88756. /**
  88757. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  88758. */
  88759. static CleanBoneMatrixWeights: boolean;
  88760. }
  88761. }
  88762. declare module BABYLON {
  88763. /**
  88764. * Class used to store geometry data (vertex buffers + index buffer)
  88765. */
  88766. export class Geometry implements IGetSetVerticesData {
  88767. /**
  88768. * Gets or sets the ID of the geometry
  88769. */
  88770. id: string;
  88771. /**
  88772. * Gets or sets the unique ID of the geometry
  88773. */
  88774. uniqueId: number;
  88775. /**
  88776. * Gets the delay loading state of the geometry (none by default which means not delayed)
  88777. */
  88778. delayLoadState: number;
  88779. /**
  88780. * Gets the file containing the data to load when running in delay load state
  88781. */
  88782. delayLoadingFile: Nullable<string>;
  88783. /**
  88784. * Callback called when the geometry is updated
  88785. */
  88786. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  88787. private _scene;
  88788. private _engine;
  88789. private _meshes;
  88790. private _totalVertices;
  88791. /** @hidden */
  88792. _indices: IndicesArray;
  88793. /** @hidden */
  88794. _vertexBuffers: {
  88795. [key: string]: VertexBuffer;
  88796. };
  88797. private _isDisposed;
  88798. private _extend;
  88799. private _boundingBias;
  88800. /** @hidden */
  88801. _delayInfo: Array<string>;
  88802. private _indexBuffer;
  88803. private _indexBufferIsUpdatable;
  88804. /** @hidden */
  88805. _boundingInfo: Nullable<BoundingInfo>;
  88806. /** @hidden */
  88807. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  88808. /** @hidden */
  88809. _softwareSkinningFrameId: number;
  88810. private _vertexArrayObjects;
  88811. private _updatable;
  88812. /** @hidden */
  88813. _positions: Nullable<Vector3[]>;
  88814. /**
  88815. * 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
  88816. */
  88817. /**
  88818. * 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
  88819. */
  88820. boundingBias: Vector2;
  88821. /**
  88822. * Static function used to attach a new empty geometry to a mesh
  88823. * @param mesh defines the mesh to attach the geometry to
  88824. * @returns the new Geometry
  88825. */
  88826. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  88827. /**
  88828. * Creates a new geometry
  88829. * @param id defines the unique ID
  88830. * @param scene defines the hosting scene
  88831. * @param vertexData defines the VertexData used to get geometry data
  88832. * @param updatable defines if geometry must be updatable (false by default)
  88833. * @param mesh defines the mesh that will be associated with the geometry
  88834. */
  88835. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  88836. /**
  88837. * Gets the current extend of the geometry
  88838. */
  88839. readonly extend: {
  88840. minimum: Vector3;
  88841. maximum: Vector3;
  88842. };
  88843. /**
  88844. * Gets the hosting scene
  88845. * @returns the hosting Scene
  88846. */
  88847. getScene(): Scene;
  88848. /**
  88849. * Gets the hosting engine
  88850. * @returns the hosting Engine
  88851. */
  88852. getEngine(): Engine;
  88853. /**
  88854. * Defines if the geometry is ready to use
  88855. * @returns true if the geometry is ready to be used
  88856. */
  88857. isReady(): boolean;
  88858. /**
  88859. * Gets a value indicating that the geometry should not be serialized
  88860. */
  88861. readonly doNotSerialize: boolean;
  88862. /** @hidden */
  88863. _rebuild(): void;
  88864. /**
  88865. * Affects all geometry data in one call
  88866. * @param vertexData defines the geometry data
  88867. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  88868. */
  88869. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  88870. /**
  88871. * Set specific vertex data
  88872. * @param kind defines the data kind (Position, normal, etc...)
  88873. * @param data defines the vertex data to use
  88874. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88875. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88876. */
  88877. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  88878. /**
  88879. * Removes a specific vertex data
  88880. * @param kind defines the data kind (Position, normal, etc...)
  88881. */
  88882. removeVerticesData(kind: string): void;
  88883. /**
  88884. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88885. * @param buffer defines the vertex buffer to use
  88886. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88887. */
  88888. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88889. /**
  88890. * Update a specific vertex buffer
  88891. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88892. * It will do nothing if the buffer is not updatable
  88893. * @param kind defines the data kind (Position, normal, etc...)
  88894. * @param data defines the data to use
  88895. * @param offset defines the offset in the target buffer where to store the data
  88896. * @param useBytes set to true if the offset is in bytes
  88897. */
  88898. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88899. /**
  88900. * Update a specific vertex buffer
  88901. * This function will create a new buffer if the current one is not updatable
  88902. * @param kind defines the data kind (Position, normal, etc...)
  88903. * @param data defines the data to use
  88904. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88905. */
  88906. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88907. private _updateBoundingInfo;
  88908. /** @hidden */
  88909. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88910. /**
  88911. * Gets total number of vertices
  88912. * @returns the total number of vertices
  88913. */
  88914. getTotalVertices(): number;
  88915. /**
  88916. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88917. * @param kind defines the data kind (Position, normal, etc...)
  88918. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88919. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88920. * @returns a float array containing vertex data
  88921. */
  88922. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88923. /**
  88924. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88925. * @param kind defines the data kind (Position, normal, etc...)
  88926. * @returns true if the vertex buffer with the specified kind is updatable
  88927. */
  88928. isVertexBufferUpdatable(kind: string): boolean;
  88929. /**
  88930. * Gets a specific vertex buffer
  88931. * @param kind defines the data kind (Position, normal, etc...)
  88932. * @returns a VertexBuffer
  88933. */
  88934. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88935. /**
  88936. * Returns all vertex buffers
  88937. * @return an object holding all vertex buffers indexed by kind
  88938. */
  88939. getVertexBuffers(): Nullable<{
  88940. [key: string]: VertexBuffer;
  88941. }>;
  88942. /**
  88943. * Gets a boolean indicating if specific vertex buffer is present
  88944. * @param kind defines the data kind (Position, normal, etc...)
  88945. * @returns true if data is present
  88946. */
  88947. isVerticesDataPresent(kind: string): boolean;
  88948. /**
  88949. * Gets a list of all attached data kinds (Position, normal, etc...)
  88950. * @returns a list of string containing all kinds
  88951. */
  88952. getVerticesDataKinds(): string[];
  88953. /**
  88954. * Update index buffer
  88955. * @param indices defines the indices to store in the index buffer
  88956. * @param offset defines the offset in the target buffer where to store the data
  88957. * @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)
  88958. */
  88959. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88960. /**
  88961. * Creates a new index buffer
  88962. * @param indices defines the indices to store in the index buffer
  88963. * @param totalVertices defines the total number of vertices (could be null)
  88964. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88965. */
  88966. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88967. /**
  88968. * Return the total number of indices
  88969. * @returns the total number of indices
  88970. */
  88971. getTotalIndices(): number;
  88972. /**
  88973. * Gets the index buffer array
  88974. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88975. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88976. * @returns the index buffer array
  88977. */
  88978. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88979. /**
  88980. * Gets the index buffer
  88981. * @return the index buffer
  88982. */
  88983. getIndexBuffer(): Nullable<DataBuffer>;
  88984. /** @hidden */
  88985. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88986. /**
  88987. * Release the associated resources for a specific mesh
  88988. * @param mesh defines the source mesh
  88989. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88990. */
  88991. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88992. /**
  88993. * Apply current geometry to a given mesh
  88994. * @param mesh defines the mesh to apply geometry to
  88995. */
  88996. applyToMesh(mesh: Mesh): void;
  88997. private _updateExtend;
  88998. private _applyToMesh;
  88999. private notifyUpdate;
  89000. /**
  89001. * Load the geometry if it was flagged as delay loaded
  89002. * @param scene defines the hosting scene
  89003. * @param onLoaded defines a callback called when the geometry is loaded
  89004. */
  89005. load(scene: Scene, onLoaded?: () => void): void;
  89006. private _queueLoad;
  89007. /**
  89008. * Invert the geometry to move from a right handed system to a left handed one.
  89009. */
  89010. toLeftHanded(): void;
  89011. /** @hidden */
  89012. _resetPointsArrayCache(): void;
  89013. /** @hidden */
  89014. _generatePointsArray(): boolean;
  89015. /**
  89016. * Gets a value indicating if the geometry is disposed
  89017. * @returns true if the geometry was disposed
  89018. */
  89019. isDisposed(): boolean;
  89020. private _disposeVertexArrayObjects;
  89021. /**
  89022. * Free all associated resources
  89023. */
  89024. dispose(): void;
  89025. /**
  89026. * Clone the current geometry into a new geometry
  89027. * @param id defines the unique ID of the new geometry
  89028. * @returns a new geometry object
  89029. */
  89030. copy(id: string): Geometry;
  89031. /**
  89032. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89033. * @return a JSON representation of the current geometry data (without the vertices data)
  89034. */
  89035. serialize(): any;
  89036. private toNumberArray;
  89037. /**
  89038. * Serialize all vertices data into a JSON oject
  89039. * @returns a JSON representation of the current geometry data
  89040. */
  89041. serializeVerticeData(): any;
  89042. /**
  89043. * Extracts a clone of a mesh geometry
  89044. * @param mesh defines the source mesh
  89045. * @param id defines the unique ID of the new geometry object
  89046. * @returns the new geometry object
  89047. */
  89048. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89049. /**
  89050. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89051. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89052. * Be aware Math.random() could cause collisions, but:
  89053. * "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"
  89054. * @returns a string containing a new GUID
  89055. */
  89056. static RandomId(): string;
  89057. /** @hidden */
  89058. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89059. private static _CleanMatricesWeights;
  89060. /**
  89061. * Create a new geometry from persisted data (Using .babylon file format)
  89062. * @param parsedVertexData defines the persisted data
  89063. * @param scene defines the hosting scene
  89064. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89065. * @returns the new geometry object
  89066. */
  89067. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89068. }
  89069. }
  89070. declare module BABYLON {
  89071. /**
  89072. * Define an interface for all classes that will get and set the data on vertices
  89073. */
  89074. export interface IGetSetVerticesData {
  89075. /**
  89076. * Gets a boolean indicating if specific vertex data is present
  89077. * @param kind defines the vertex data kind to use
  89078. * @returns true is data kind is present
  89079. */
  89080. isVerticesDataPresent(kind: string): boolean;
  89081. /**
  89082. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89083. * @param kind defines the data kind (Position, normal, etc...)
  89084. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89085. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89086. * @returns a float array containing vertex data
  89087. */
  89088. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89089. /**
  89090. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89091. * @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.
  89092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89093. * @returns the indices array or an empty array if the mesh has no geometry
  89094. */
  89095. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89096. /**
  89097. * Set specific vertex data
  89098. * @param kind defines the data kind (Position, normal, etc...)
  89099. * @param data defines the vertex data to use
  89100. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89101. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89102. */
  89103. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  89104. /**
  89105. * Update a specific associated vertex buffer
  89106. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89107. * - VertexBuffer.PositionKind
  89108. * - VertexBuffer.UVKind
  89109. * - VertexBuffer.UV2Kind
  89110. * - VertexBuffer.UV3Kind
  89111. * - VertexBuffer.UV4Kind
  89112. * - VertexBuffer.UV5Kind
  89113. * - VertexBuffer.UV6Kind
  89114. * - VertexBuffer.ColorKind
  89115. * - VertexBuffer.MatricesIndicesKind
  89116. * - VertexBuffer.MatricesIndicesExtraKind
  89117. * - VertexBuffer.MatricesWeightsKind
  89118. * - VertexBuffer.MatricesWeightsExtraKind
  89119. * @param data defines the data source
  89120. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89121. * @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)
  89122. */
  89123. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  89124. /**
  89125. * Creates a new index buffer
  89126. * @param indices defines the indices to store in the index buffer
  89127. * @param totalVertices defines the total number of vertices (could be null)
  89128. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89129. */
  89130. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  89131. }
  89132. /**
  89133. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  89134. */
  89135. export class VertexData {
  89136. /**
  89137. * Mesh side orientation : usually the external or front surface
  89138. */
  89139. static readonly FRONTSIDE: number;
  89140. /**
  89141. * Mesh side orientation : usually the internal or back surface
  89142. */
  89143. static readonly BACKSIDE: number;
  89144. /**
  89145. * Mesh side orientation : both internal and external or front and back surfaces
  89146. */
  89147. static readonly DOUBLESIDE: number;
  89148. /**
  89149. * Mesh side orientation : by default, `FRONTSIDE`
  89150. */
  89151. static readonly DEFAULTSIDE: number;
  89152. /**
  89153. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  89154. */
  89155. positions: Nullable<FloatArray>;
  89156. /**
  89157. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  89158. */
  89159. normals: Nullable<FloatArray>;
  89160. /**
  89161. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  89162. */
  89163. tangents: Nullable<FloatArray>;
  89164. /**
  89165. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89166. */
  89167. uvs: Nullable<FloatArray>;
  89168. /**
  89169. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89170. */
  89171. uvs2: Nullable<FloatArray>;
  89172. /**
  89173. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89174. */
  89175. uvs3: Nullable<FloatArray>;
  89176. /**
  89177. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89178. */
  89179. uvs4: Nullable<FloatArray>;
  89180. /**
  89181. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89182. */
  89183. uvs5: Nullable<FloatArray>;
  89184. /**
  89185. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  89186. */
  89187. uvs6: Nullable<FloatArray>;
  89188. /**
  89189. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  89190. */
  89191. colors: Nullable<FloatArray>;
  89192. /**
  89193. * 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).
  89194. */
  89195. matricesIndices: Nullable<FloatArray>;
  89196. /**
  89197. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  89198. */
  89199. matricesWeights: Nullable<FloatArray>;
  89200. /**
  89201. * An array extending the number of possible indices
  89202. */
  89203. matricesIndicesExtra: Nullable<FloatArray>;
  89204. /**
  89205. * An array extending the number of possible weights when the number of indices is extended
  89206. */
  89207. matricesWeightsExtra: Nullable<FloatArray>;
  89208. /**
  89209. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  89210. */
  89211. indices: Nullable<IndicesArray>;
  89212. /**
  89213. * Uses the passed data array to set the set the values for the specified kind of data
  89214. * @param data a linear array of floating numbers
  89215. * @param kind the type of data that is being set, eg positions, colors etc
  89216. */
  89217. set(data: FloatArray, kind: string): void;
  89218. /**
  89219. * Associates the vertexData to the passed Mesh.
  89220. * Sets it as updatable or not (default `false`)
  89221. * @param mesh the mesh the vertexData is applied to
  89222. * @param updatable when used and having the value true allows new data to update the vertexData
  89223. * @returns the VertexData
  89224. */
  89225. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  89226. /**
  89227. * Associates the vertexData to the passed Geometry.
  89228. * Sets it as updatable or not (default `false`)
  89229. * @param geometry the geometry the vertexData is applied to
  89230. * @param updatable when used and having the value true allows new data to update the vertexData
  89231. * @returns VertexData
  89232. */
  89233. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  89234. /**
  89235. * Updates the associated mesh
  89236. * @param mesh the mesh to be updated
  89237. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89238. * @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
  89239. * @returns VertexData
  89240. */
  89241. updateMesh(mesh: Mesh): VertexData;
  89242. /**
  89243. * Updates the associated geometry
  89244. * @param geometry the geometry to be updated
  89245. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  89246. * @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
  89247. * @returns VertexData.
  89248. */
  89249. updateGeometry(geometry: Geometry): VertexData;
  89250. private _applyTo;
  89251. private _update;
  89252. /**
  89253. * Transforms each position and each normal of the vertexData according to the passed Matrix
  89254. * @param matrix the transforming matrix
  89255. * @returns the VertexData
  89256. */
  89257. transform(matrix: Matrix): VertexData;
  89258. /**
  89259. * Merges the passed VertexData into the current one
  89260. * @param other the VertexData to be merged into the current one
  89261. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  89262. * @returns the modified VertexData
  89263. */
  89264. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  89265. private _mergeElement;
  89266. private _validate;
  89267. /**
  89268. * Serializes the VertexData
  89269. * @returns a serialized object
  89270. */
  89271. serialize(): any;
  89272. /**
  89273. * Extracts the vertexData from a mesh
  89274. * @param mesh the mesh from which to extract the VertexData
  89275. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  89276. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89277. * @returns the object VertexData associated to the passed mesh
  89278. */
  89279. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89280. /**
  89281. * Extracts the vertexData from the geometry
  89282. * @param geometry the geometry from which to extract the VertexData
  89283. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  89284. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  89285. * @returns the object VertexData associated to the passed mesh
  89286. */
  89287. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  89288. private static _ExtractFrom;
  89289. /**
  89290. * Creates the VertexData for a Ribbon
  89291. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  89292. * * pathArray array of paths, each of which an array of successive Vector3
  89293. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  89294. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  89295. * * 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
  89296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89297. * * 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)
  89298. * * 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)
  89299. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  89300. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  89301. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  89302. * @returns the VertexData of the ribbon
  89303. */
  89304. static CreateRibbon(options: {
  89305. pathArray: Vector3[][];
  89306. closeArray?: boolean;
  89307. closePath?: boolean;
  89308. offset?: number;
  89309. sideOrientation?: number;
  89310. frontUVs?: Vector4;
  89311. backUVs?: Vector4;
  89312. invertUV?: boolean;
  89313. uvs?: Vector2[];
  89314. colors?: Color4[];
  89315. }): VertexData;
  89316. /**
  89317. * Creates the VertexData for a box
  89318. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89319. * * size sets the width, height and depth of the box to the value of size, optional default 1
  89320. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  89321. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  89322. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  89323. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89324. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89326. * * 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)
  89327. * * 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)
  89328. * @returns the VertexData of the box
  89329. */
  89330. static CreateBox(options: {
  89331. size?: number;
  89332. width?: number;
  89333. height?: number;
  89334. depth?: number;
  89335. faceUV?: Vector4[];
  89336. faceColors?: Color4[];
  89337. sideOrientation?: number;
  89338. frontUVs?: Vector4;
  89339. backUVs?: Vector4;
  89340. }): VertexData;
  89341. /**
  89342. * Creates the VertexData for a tiled box
  89343. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89344. * * faceTiles sets the pattern, tile size and number of tiles for a face
  89345. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  89346. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  89347. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89348. * @returns the VertexData of the box
  89349. */
  89350. static CreateTiledBox(options: {
  89351. pattern?: number;
  89352. width?: number;
  89353. height?: number;
  89354. depth?: number;
  89355. tileSize?: number;
  89356. tileWidth?: number;
  89357. tileHeight?: number;
  89358. alignHorizontal?: number;
  89359. alignVertical?: number;
  89360. faceUV?: Vector4[];
  89361. faceColors?: Color4[];
  89362. sideOrientation?: number;
  89363. }): VertexData;
  89364. /**
  89365. * Creates the VertexData for a tiled plane
  89366. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89367. * * pattern a limited pattern arrangement depending on the number
  89368. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  89369. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  89370. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  89371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89372. * * 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)
  89373. * * 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)
  89374. * @returns the VertexData of the tiled plane
  89375. */
  89376. static CreateTiledPlane(options: {
  89377. pattern?: number;
  89378. tileSize?: number;
  89379. tileWidth?: number;
  89380. tileHeight?: number;
  89381. size?: number;
  89382. width?: number;
  89383. height?: number;
  89384. alignHorizontal?: number;
  89385. alignVertical?: number;
  89386. sideOrientation?: number;
  89387. frontUVs?: Vector4;
  89388. backUVs?: Vector4;
  89389. }): VertexData;
  89390. /**
  89391. * Creates the VertexData for an ellipsoid, defaults to a sphere
  89392. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89393. * * segments sets the number of horizontal strips optional, default 32
  89394. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  89395. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  89396. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  89397. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  89398. * * 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
  89399. * * 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
  89400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89401. * * 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)
  89402. * * 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)
  89403. * @returns the VertexData of the ellipsoid
  89404. */
  89405. static CreateSphere(options: {
  89406. segments?: number;
  89407. diameter?: number;
  89408. diameterX?: number;
  89409. diameterY?: number;
  89410. diameterZ?: number;
  89411. arc?: number;
  89412. slice?: number;
  89413. sideOrientation?: number;
  89414. frontUVs?: Vector4;
  89415. backUVs?: Vector4;
  89416. }): VertexData;
  89417. /**
  89418. * Creates the VertexData for a cylinder, cone or prism
  89419. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89420. * * height sets the height (y direction) of the cylinder, optional, default 2
  89421. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  89422. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  89423. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  89424. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89425. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  89426. * * 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
  89427. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89428. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89429. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  89430. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  89431. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89432. * * 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)
  89433. * * 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)
  89434. * @returns the VertexData of the cylinder, cone or prism
  89435. */
  89436. static CreateCylinder(options: {
  89437. height?: number;
  89438. diameterTop?: number;
  89439. diameterBottom?: number;
  89440. diameter?: number;
  89441. tessellation?: number;
  89442. subdivisions?: number;
  89443. arc?: number;
  89444. faceColors?: Color4[];
  89445. faceUV?: Vector4[];
  89446. hasRings?: boolean;
  89447. enclose?: boolean;
  89448. sideOrientation?: number;
  89449. frontUVs?: Vector4;
  89450. backUVs?: Vector4;
  89451. }): VertexData;
  89452. /**
  89453. * Creates the VertexData for a torus
  89454. * @param options an object used to set the following optional parameters for the box, required but can be empty
  89455. * * diameter the diameter of the torus, optional default 1
  89456. * * thickness the diameter of the tube forming the torus, optional default 0.5
  89457. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  89458. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89459. * * 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)
  89460. * * 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)
  89461. * @returns the VertexData of the torus
  89462. */
  89463. static CreateTorus(options: {
  89464. diameter?: number;
  89465. thickness?: number;
  89466. tessellation?: number;
  89467. sideOrientation?: number;
  89468. frontUVs?: Vector4;
  89469. backUVs?: Vector4;
  89470. }): VertexData;
  89471. /**
  89472. * Creates the VertexData of the LineSystem
  89473. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  89474. * - lines an array of lines, each line being an array of successive Vector3
  89475. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  89476. * @returns the VertexData of the LineSystem
  89477. */
  89478. static CreateLineSystem(options: {
  89479. lines: Vector3[][];
  89480. colors?: Nullable<Color4[][]>;
  89481. }): VertexData;
  89482. /**
  89483. * Create the VertexData for a DashedLines
  89484. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  89485. * - points an array successive Vector3
  89486. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  89487. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  89488. * - dashNb the intended total number of dashes, optional, default 200
  89489. * @returns the VertexData for the DashedLines
  89490. */
  89491. static CreateDashedLines(options: {
  89492. points: Vector3[];
  89493. dashSize?: number;
  89494. gapSize?: number;
  89495. dashNb?: number;
  89496. }): VertexData;
  89497. /**
  89498. * Creates the VertexData for a Ground
  89499. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89500. * - width the width (x direction) of the ground, optional, default 1
  89501. * - height the height (z direction) of the ground, optional, default 1
  89502. * - subdivisions the number of subdivisions per side, optional, default 1
  89503. * @returns the VertexData of the Ground
  89504. */
  89505. static CreateGround(options: {
  89506. width?: number;
  89507. height?: number;
  89508. subdivisions?: number;
  89509. subdivisionsX?: number;
  89510. subdivisionsY?: number;
  89511. }): VertexData;
  89512. /**
  89513. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  89514. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  89515. * * xmin the ground minimum X coordinate, optional, default -1
  89516. * * zmin the ground minimum Z coordinate, optional, default -1
  89517. * * xmax the ground maximum X coordinate, optional, default 1
  89518. * * zmax the ground maximum Z coordinate, optional, default 1
  89519. * * 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}
  89520. * * 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}
  89521. * @returns the VertexData of the TiledGround
  89522. */
  89523. static CreateTiledGround(options: {
  89524. xmin: number;
  89525. zmin: number;
  89526. xmax: number;
  89527. zmax: number;
  89528. subdivisions?: {
  89529. w: number;
  89530. h: number;
  89531. };
  89532. precision?: {
  89533. w: number;
  89534. h: number;
  89535. };
  89536. }): VertexData;
  89537. /**
  89538. * Creates the VertexData of the Ground designed from a heightmap
  89539. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  89540. * * width the width (x direction) of the ground
  89541. * * height the height (z direction) of the ground
  89542. * * subdivisions the number of subdivisions per side
  89543. * * minHeight the minimum altitude on the ground, optional, default 0
  89544. * * maxHeight the maximum altitude on the ground, optional default 1
  89545. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  89546. * * buffer the array holding the image color data
  89547. * * bufferWidth the width of image
  89548. * * bufferHeight the height of image
  89549. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  89550. * @returns the VertexData of the Ground designed from a heightmap
  89551. */
  89552. static CreateGroundFromHeightMap(options: {
  89553. width: number;
  89554. height: number;
  89555. subdivisions: number;
  89556. minHeight: number;
  89557. maxHeight: number;
  89558. colorFilter: Color3;
  89559. buffer: Uint8Array;
  89560. bufferWidth: number;
  89561. bufferHeight: number;
  89562. alphaFilter: number;
  89563. }): VertexData;
  89564. /**
  89565. * Creates the VertexData for a Plane
  89566. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  89567. * * size sets the width and height of the plane to the value of size, optional default 1
  89568. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  89569. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  89570. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89571. * * 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)
  89572. * * 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)
  89573. * @returns the VertexData of the box
  89574. */
  89575. static CreatePlane(options: {
  89576. size?: number;
  89577. width?: number;
  89578. height?: number;
  89579. sideOrientation?: number;
  89580. frontUVs?: Vector4;
  89581. backUVs?: Vector4;
  89582. }): VertexData;
  89583. /**
  89584. * Creates the VertexData of the Disc or regular Polygon
  89585. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  89586. * * radius the radius of the disc, optional default 0.5
  89587. * * tessellation the number of polygon sides, optional, default 64
  89588. * * 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
  89589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89590. * * 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)
  89591. * * 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)
  89592. * @returns the VertexData of the box
  89593. */
  89594. static CreateDisc(options: {
  89595. radius?: number;
  89596. tessellation?: number;
  89597. arc?: number;
  89598. sideOrientation?: number;
  89599. frontUVs?: Vector4;
  89600. backUVs?: Vector4;
  89601. }): VertexData;
  89602. /**
  89603. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  89604. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  89605. * @param polygon a mesh built from polygonTriangulation.build()
  89606. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89607. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89608. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89609. * @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)
  89610. * @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)
  89611. * @returns the VertexData of the Polygon
  89612. */
  89613. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  89614. /**
  89615. * Creates the VertexData of the IcoSphere
  89616. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  89617. * * radius the radius of the IcoSphere, optional default 1
  89618. * * radiusX allows stretching in the x direction, optional, default radius
  89619. * * radiusY allows stretching in the y direction, optional, default radius
  89620. * * radiusZ allows stretching in the z direction, optional, default radius
  89621. * * flat when true creates a flat shaded mesh, optional, default true
  89622. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89623. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89624. * * 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)
  89625. * * 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)
  89626. * @returns the VertexData of the IcoSphere
  89627. */
  89628. static CreateIcoSphere(options: {
  89629. radius?: number;
  89630. radiusX?: number;
  89631. radiusY?: number;
  89632. radiusZ?: number;
  89633. flat?: boolean;
  89634. subdivisions?: number;
  89635. sideOrientation?: number;
  89636. frontUVs?: Vector4;
  89637. backUVs?: Vector4;
  89638. }): VertexData;
  89639. /**
  89640. * Creates the VertexData for a Polyhedron
  89641. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  89642. * * type provided types are:
  89643. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  89644. * * 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)
  89645. * * size the size of the IcoSphere, optional default 1
  89646. * * sizeX allows stretching in the x direction, optional, default size
  89647. * * sizeY allows stretching in the y direction, optional, default size
  89648. * * sizeZ allows stretching in the z direction, optional, default size
  89649. * * 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
  89650. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  89651. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  89652. * * flat when true creates a flat shaded mesh, optional, default true
  89653. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  89654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89655. * * 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)
  89656. * * 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)
  89657. * @returns the VertexData of the Polyhedron
  89658. */
  89659. static CreatePolyhedron(options: {
  89660. type?: number;
  89661. size?: number;
  89662. sizeX?: number;
  89663. sizeY?: number;
  89664. sizeZ?: number;
  89665. custom?: any;
  89666. faceUV?: Vector4[];
  89667. faceColors?: Color4[];
  89668. flat?: boolean;
  89669. sideOrientation?: number;
  89670. frontUVs?: Vector4;
  89671. backUVs?: Vector4;
  89672. }): VertexData;
  89673. /**
  89674. * Creates the VertexData for a TorusKnot
  89675. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  89676. * * radius the radius of the torus knot, optional, default 2
  89677. * * tube the thickness of the tube, optional, default 0.5
  89678. * * radialSegments the number of sides on each tube segments, optional, default 32
  89679. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  89680. * * p the number of windings around the z axis, optional, default 2
  89681. * * q the number of windings around the x axis, optional, default 3
  89682. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89683. * * 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)
  89684. * * 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)
  89685. * @returns the VertexData of the Torus Knot
  89686. */
  89687. static CreateTorusKnot(options: {
  89688. radius?: number;
  89689. tube?: number;
  89690. radialSegments?: number;
  89691. tubularSegments?: number;
  89692. p?: number;
  89693. q?: number;
  89694. sideOrientation?: number;
  89695. frontUVs?: Vector4;
  89696. backUVs?: Vector4;
  89697. }): VertexData;
  89698. /**
  89699. * Compute normals for given positions and indices
  89700. * @param positions an array of vertex positions, [...., x, y, z, ......]
  89701. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  89702. * @param normals an array of vertex normals, [...., x, y, z, ......]
  89703. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  89704. * * facetNormals : optional array of facet normals (vector3)
  89705. * * facetPositions : optional array of facet positions (vector3)
  89706. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  89707. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  89708. * * bInfo : optional bounding info, required for facetPartitioning computation
  89709. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  89710. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  89711. * * useRightHandedSystem: optional boolean to for right handed system computation
  89712. * * depthSort : optional boolean to enable the facet depth sort computation
  89713. * * distanceTo : optional Vector3 to compute the facet depth from this location
  89714. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  89715. */
  89716. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  89717. facetNormals?: any;
  89718. facetPositions?: any;
  89719. facetPartitioning?: any;
  89720. ratio?: number;
  89721. bInfo?: any;
  89722. bbSize?: Vector3;
  89723. subDiv?: any;
  89724. useRightHandedSystem?: boolean;
  89725. depthSort?: boolean;
  89726. distanceTo?: Vector3;
  89727. depthSortedFacets?: any;
  89728. }): void;
  89729. /** @hidden */
  89730. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  89731. /**
  89732. * Applies VertexData created from the imported parameters to the geometry
  89733. * @param parsedVertexData the parsed data from an imported file
  89734. * @param geometry the geometry to apply the VertexData to
  89735. */
  89736. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  89737. }
  89738. }
  89739. declare module BABYLON {
  89740. /**
  89741. * Defines a target to use with MorphTargetManager
  89742. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89743. */
  89744. export class MorphTarget implements IAnimatable {
  89745. /** defines the name of the target */
  89746. name: string;
  89747. /**
  89748. * Gets or sets the list of animations
  89749. */
  89750. animations: Animation[];
  89751. private _scene;
  89752. private _positions;
  89753. private _normals;
  89754. private _tangents;
  89755. private _uvs;
  89756. private _influence;
  89757. private _uniqueId;
  89758. /**
  89759. * Observable raised when the influence changes
  89760. */
  89761. onInfluenceChanged: Observable<boolean>;
  89762. /** @hidden */
  89763. _onDataLayoutChanged: Observable<void>;
  89764. /**
  89765. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  89766. */
  89767. influence: number;
  89768. /**
  89769. * Gets or sets the id of the morph Target
  89770. */
  89771. id: string;
  89772. private _animationPropertiesOverride;
  89773. /**
  89774. * Gets or sets the animation properties override
  89775. */
  89776. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89777. /**
  89778. * Creates a new MorphTarget
  89779. * @param name defines the name of the target
  89780. * @param influence defines the influence to use
  89781. * @param scene defines the scene the morphtarget belongs to
  89782. */
  89783. constructor(
  89784. /** defines the name of the target */
  89785. name: string, influence?: number, scene?: Nullable<Scene>);
  89786. /**
  89787. * Gets the unique ID of this manager
  89788. */
  89789. readonly uniqueId: number;
  89790. /**
  89791. * Gets a boolean defining if the target contains position data
  89792. */
  89793. readonly hasPositions: boolean;
  89794. /**
  89795. * Gets a boolean defining if the target contains normal data
  89796. */
  89797. readonly hasNormals: boolean;
  89798. /**
  89799. * Gets a boolean defining if the target contains tangent data
  89800. */
  89801. readonly hasTangents: boolean;
  89802. /**
  89803. * Gets a boolean defining if the target contains texture coordinates data
  89804. */
  89805. readonly hasUVs: boolean;
  89806. /**
  89807. * Affects position data to this target
  89808. * @param data defines the position data to use
  89809. */
  89810. setPositions(data: Nullable<FloatArray>): void;
  89811. /**
  89812. * Gets the position data stored in this target
  89813. * @returns a FloatArray containing the position data (or null if not present)
  89814. */
  89815. getPositions(): Nullable<FloatArray>;
  89816. /**
  89817. * Affects normal data to this target
  89818. * @param data defines the normal data to use
  89819. */
  89820. setNormals(data: Nullable<FloatArray>): void;
  89821. /**
  89822. * Gets the normal data stored in this target
  89823. * @returns a FloatArray containing the normal data (or null if not present)
  89824. */
  89825. getNormals(): Nullable<FloatArray>;
  89826. /**
  89827. * Affects tangent data to this target
  89828. * @param data defines the tangent data to use
  89829. */
  89830. setTangents(data: Nullable<FloatArray>): void;
  89831. /**
  89832. * Gets the tangent data stored in this target
  89833. * @returns a FloatArray containing the tangent data (or null if not present)
  89834. */
  89835. getTangents(): Nullable<FloatArray>;
  89836. /**
  89837. * Affects texture coordinates data to this target
  89838. * @param data defines the texture coordinates data to use
  89839. */
  89840. setUVs(data: Nullable<FloatArray>): void;
  89841. /**
  89842. * Gets the texture coordinates data stored in this target
  89843. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  89844. */
  89845. getUVs(): Nullable<FloatArray>;
  89846. /**
  89847. * Clone the current target
  89848. * @returns a new MorphTarget
  89849. */
  89850. clone(): MorphTarget;
  89851. /**
  89852. * Serializes the current target into a Serialization object
  89853. * @returns the serialized object
  89854. */
  89855. serialize(): any;
  89856. /**
  89857. * Returns the string "MorphTarget"
  89858. * @returns "MorphTarget"
  89859. */
  89860. getClassName(): string;
  89861. /**
  89862. * Creates a new target from serialized data
  89863. * @param serializationObject defines the serialized data to use
  89864. * @returns a new MorphTarget
  89865. */
  89866. static Parse(serializationObject: any): MorphTarget;
  89867. /**
  89868. * Creates a MorphTarget from mesh data
  89869. * @param mesh defines the source mesh
  89870. * @param name defines the name to use for the new target
  89871. * @param influence defines the influence to attach to the target
  89872. * @returns a new MorphTarget
  89873. */
  89874. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  89875. }
  89876. }
  89877. declare module BABYLON {
  89878. /**
  89879. * This class is used to deform meshes using morphing between different targets
  89880. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89881. */
  89882. export class MorphTargetManager {
  89883. private _targets;
  89884. private _targetInfluenceChangedObservers;
  89885. private _targetDataLayoutChangedObservers;
  89886. private _activeTargets;
  89887. private _scene;
  89888. private _influences;
  89889. private _supportsNormals;
  89890. private _supportsTangents;
  89891. private _supportsUVs;
  89892. private _vertexCount;
  89893. private _uniqueId;
  89894. private _tempInfluences;
  89895. /**
  89896. * Gets or sets a boolean indicating if normals must be morphed
  89897. */
  89898. enableNormalMorphing: boolean;
  89899. /**
  89900. * Gets or sets a boolean indicating if tangents must be morphed
  89901. */
  89902. enableTangentMorphing: boolean;
  89903. /**
  89904. * Gets or sets a boolean indicating if UV must be morphed
  89905. */
  89906. enableUVMorphing: boolean;
  89907. /**
  89908. * Creates a new MorphTargetManager
  89909. * @param scene defines the current scene
  89910. */
  89911. constructor(scene?: Nullable<Scene>);
  89912. /**
  89913. * Gets the unique ID of this manager
  89914. */
  89915. readonly uniqueId: number;
  89916. /**
  89917. * Gets the number of vertices handled by this manager
  89918. */
  89919. readonly vertexCount: number;
  89920. /**
  89921. * Gets a boolean indicating if this manager supports morphing of normals
  89922. */
  89923. readonly supportsNormals: boolean;
  89924. /**
  89925. * Gets a boolean indicating if this manager supports morphing of tangents
  89926. */
  89927. readonly supportsTangents: boolean;
  89928. /**
  89929. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89930. */
  89931. readonly supportsUVs: boolean;
  89932. /**
  89933. * Gets the number of targets stored in this manager
  89934. */
  89935. readonly numTargets: number;
  89936. /**
  89937. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89938. */
  89939. readonly numInfluencers: number;
  89940. /**
  89941. * Gets the list of influences (one per target)
  89942. */
  89943. readonly influences: Float32Array;
  89944. /**
  89945. * Gets the active target at specified index. An active target is a target with an influence > 0
  89946. * @param index defines the index to check
  89947. * @returns the requested target
  89948. */
  89949. getActiveTarget(index: number): MorphTarget;
  89950. /**
  89951. * Gets the target at specified index
  89952. * @param index defines the index to check
  89953. * @returns the requested target
  89954. */
  89955. getTarget(index: number): MorphTarget;
  89956. /**
  89957. * Add a new target to this manager
  89958. * @param target defines the target to add
  89959. */
  89960. addTarget(target: MorphTarget): void;
  89961. /**
  89962. * Removes a target from the manager
  89963. * @param target defines the target to remove
  89964. */
  89965. removeTarget(target: MorphTarget): void;
  89966. /**
  89967. * Clone the current manager
  89968. * @returns a new MorphTargetManager
  89969. */
  89970. clone(): MorphTargetManager;
  89971. /**
  89972. * Serializes the current manager into a Serialization object
  89973. * @returns the serialized object
  89974. */
  89975. serialize(): any;
  89976. private _syncActiveTargets;
  89977. /**
  89978. * Syncrhonize the targets with all the meshes using this morph target manager
  89979. */
  89980. synchronize(): void;
  89981. /**
  89982. * Creates a new MorphTargetManager from serialized data
  89983. * @param serializationObject defines the serialized data
  89984. * @param scene defines the hosting scene
  89985. * @returns the new MorphTargetManager
  89986. */
  89987. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89988. }
  89989. }
  89990. declare module BABYLON {
  89991. /**
  89992. * Class used to represent a specific level of detail of a mesh
  89993. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89994. */
  89995. export class MeshLODLevel {
  89996. /** Defines the distance where this level should start being displayed */
  89997. distance: number;
  89998. /** Defines the mesh to use to render this level */
  89999. mesh: Nullable<Mesh>;
  90000. /**
  90001. * Creates a new LOD level
  90002. * @param distance defines the distance where this level should star being displayed
  90003. * @param mesh defines the mesh to use to render this level
  90004. */
  90005. constructor(
  90006. /** Defines the distance where this level should start being displayed */
  90007. distance: number,
  90008. /** Defines the mesh to use to render this level */
  90009. mesh: Nullable<Mesh>);
  90010. }
  90011. }
  90012. declare module BABYLON {
  90013. /**
  90014. * Mesh representing the gorund
  90015. */
  90016. export class GroundMesh extends Mesh {
  90017. /** If octree should be generated */
  90018. generateOctree: boolean;
  90019. private _heightQuads;
  90020. /** @hidden */
  90021. _subdivisionsX: number;
  90022. /** @hidden */
  90023. _subdivisionsY: number;
  90024. /** @hidden */
  90025. _width: number;
  90026. /** @hidden */
  90027. _height: number;
  90028. /** @hidden */
  90029. _minX: number;
  90030. /** @hidden */
  90031. _maxX: number;
  90032. /** @hidden */
  90033. _minZ: number;
  90034. /** @hidden */
  90035. _maxZ: number;
  90036. constructor(name: string, scene: Scene);
  90037. /**
  90038. * "GroundMesh"
  90039. * @returns "GroundMesh"
  90040. */
  90041. getClassName(): string;
  90042. /**
  90043. * The minimum of x and y subdivisions
  90044. */
  90045. readonly subdivisions: number;
  90046. /**
  90047. * X subdivisions
  90048. */
  90049. readonly subdivisionsX: number;
  90050. /**
  90051. * Y subdivisions
  90052. */
  90053. readonly subdivisionsY: number;
  90054. /**
  90055. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90056. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90057. * @param chunksCount the number of subdivisions for x and y
  90058. * @param octreeBlocksSize (Default: 32)
  90059. */
  90060. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90061. /**
  90062. * Returns a height (y) value in the Worl system :
  90063. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90064. * @param x x coordinate
  90065. * @param z z coordinate
  90066. * @returns the ground y position if (x, z) are outside the ground surface.
  90067. */
  90068. getHeightAtCoordinates(x: number, z: number): number;
  90069. /**
  90070. * Returns a normalized vector (Vector3) orthogonal to the ground
  90071. * at the ground coordinates (x, z) expressed in the World system.
  90072. * @param x x coordinate
  90073. * @param z z coordinate
  90074. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90075. */
  90076. getNormalAtCoordinates(x: number, z: number): Vector3;
  90077. /**
  90078. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90079. * at the ground coordinates (x, z) expressed in the World system.
  90080. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90081. * @param x x coordinate
  90082. * @param z z coordinate
  90083. * @param ref vector to store the result
  90084. * @returns the GroundMesh.
  90085. */
  90086. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90087. /**
  90088. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90089. * if the ground has been updated.
  90090. * This can be used in the render loop.
  90091. * @returns the GroundMesh.
  90092. */
  90093. updateCoordinateHeights(): GroundMesh;
  90094. private _getFacetAt;
  90095. private _initHeightQuads;
  90096. private _computeHeightQuads;
  90097. /**
  90098. * Serializes this ground mesh
  90099. * @param serializationObject object to write serialization to
  90100. */
  90101. serialize(serializationObject: any): void;
  90102. /**
  90103. * Parses a serialized ground mesh
  90104. * @param parsedMesh the serialized mesh
  90105. * @param scene the scene to create the ground mesh in
  90106. * @returns the created ground mesh
  90107. */
  90108. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  90109. }
  90110. }
  90111. declare module BABYLON {
  90112. /**
  90113. * Interface for Physics-Joint data
  90114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90115. */
  90116. export interface PhysicsJointData {
  90117. /**
  90118. * The main pivot of the joint
  90119. */
  90120. mainPivot?: Vector3;
  90121. /**
  90122. * The connected pivot of the joint
  90123. */
  90124. connectedPivot?: Vector3;
  90125. /**
  90126. * The main axis of the joint
  90127. */
  90128. mainAxis?: Vector3;
  90129. /**
  90130. * The connected axis of the joint
  90131. */
  90132. connectedAxis?: Vector3;
  90133. /**
  90134. * The collision of the joint
  90135. */
  90136. collision?: boolean;
  90137. /**
  90138. * Native Oimo/Cannon/Energy data
  90139. */
  90140. nativeParams?: any;
  90141. }
  90142. /**
  90143. * This is a holder class for the physics joint created by the physics plugin
  90144. * It holds a set of functions to control the underlying joint
  90145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90146. */
  90147. export class PhysicsJoint {
  90148. /**
  90149. * The type of the physics joint
  90150. */
  90151. type: number;
  90152. /**
  90153. * The data for the physics joint
  90154. */
  90155. jointData: PhysicsJointData;
  90156. private _physicsJoint;
  90157. protected _physicsPlugin: IPhysicsEnginePlugin;
  90158. /**
  90159. * Initializes the physics joint
  90160. * @param type The type of the physics joint
  90161. * @param jointData The data for the physics joint
  90162. */
  90163. constructor(
  90164. /**
  90165. * The type of the physics joint
  90166. */
  90167. type: number,
  90168. /**
  90169. * The data for the physics joint
  90170. */
  90171. jointData: PhysicsJointData);
  90172. /**
  90173. * Gets the physics joint
  90174. */
  90175. /**
  90176. * Sets the physics joint
  90177. */
  90178. physicsJoint: any;
  90179. /**
  90180. * Sets the physics plugin
  90181. */
  90182. physicsPlugin: IPhysicsEnginePlugin;
  90183. /**
  90184. * Execute a function that is physics-plugin specific.
  90185. * @param {Function} func the function that will be executed.
  90186. * It accepts two parameters: the physics world and the physics joint
  90187. */
  90188. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  90189. /**
  90190. * Distance-Joint type
  90191. */
  90192. static DistanceJoint: number;
  90193. /**
  90194. * Hinge-Joint type
  90195. */
  90196. static HingeJoint: number;
  90197. /**
  90198. * Ball-and-Socket joint type
  90199. */
  90200. static BallAndSocketJoint: number;
  90201. /**
  90202. * Wheel-Joint type
  90203. */
  90204. static WheelJoint: number;
  90205. /**
  90206. * Slider-Joint type
  90207. */
  90208. static SliderJoint: number;
  90209. /**
  90210. * Prismatic-Joint type
  90211. */
  90212. static PrismaticJoint: number;
  90213. /**
  90214. * Universal-Joint type
  90215. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  90216. */
  90217. static UniversalJoint: number;
  90218. /**
  90219. * Hinge-Joint 2 type
  90220. */
  90221. static Hinge2Joint: number;
  90222. /**
  90223. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  90224. */
  90225. static PointToPointJoint: number;
  90226. /**
  90227. * Spring-Joint type
  90228. */
  90229. static SpringJoint: number;
  90230. /**
  90231. * Lock-Joint type
  90232. */
  90233. static LockJoint: number;
  90234. }
  90235. /**
  90236. * A class representing a physics distance joint
  90237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90238. */
  90239. export class DistanceJoint extends PhysicsJoint {
  90240. /**
  90241. *
  90242. * @param jointData The data for the Distance-Joint
  90243. */
  90244. constructor(jointData: DistanceJointData);
  90245. /**
  90246. * Update the predefined distance.
  90247. * @param maxDistance The maximum preferred distance
  90248. * @param minDistance The minimum preferred distance
  90249. */
  90250. updateDistance(maxDistance: number, minDistance?: number): void;
  90251. }
  90252. /**
  90253. * Represents a Motor-Enabled Joint
  90254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90255. */
  90256. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  90257. /**
  90258. * Initializes the Motor-Enabled Joint
  90259. * @param type The type of the joint
  90260. * @param jointData The physica joint data for the joint
  90261. */
  90262. constructor(type: number, jointData: PhysicsJointData);
  90263. /**
  90264. * Set the motor values.
  90265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90266. * @param force the force to apply
  90267. * @param maxForce max force for this motor.
  90268. */
  90269. setMotor(force?: number, maxForce?: number): void;
  90270. /**
  90271. * Set the motor's limits.
  90272. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90273. * @param upperLimit The upper limit of the motor
  90274. * @param lowerLimit The lower limit of the motor
  90275. */
  90276. setLimit(upperLimit: number, lowerLimit?: number): void;
  90277. }
  90278. /**
  90279. * This class represents a single physics Hinge-Joint
  90280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90281. */
  90282. export class HingeJoint extends MotorEnabledJoint {
  90283. /**
  90284. * Initializes the Hinge-Joint
  90285. * @param jointData The joint data for the Hinge-Joint
  90286. */
  90287. constructor(jointData: PhysicsJointData);
  90288. /**
  90289. * Set the motor values.
  90290. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90291. * @param {number} force the force to apply
  90292. * @param {number} maxForce max force for this motor.
  90293. */
  90294. setMotor(force?: number, maxForce?: number): void;
  90295. /**
  90296. * Set the motor's limits.
  90297. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90298. * @param upperLimit The upper limit of the motor
  90299. * @param lowerLimit The lower limit of the motor
  90300. */
  90301. setLimit(upperLimit: number, lowerLimit?: number): void;
  90302. }
  90303. /**
  90304. * This class represents a dual hinge physics joint (same as wheel joint)
  90305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90306. */
  90307. export class Hinge2Joint extends MotorEnabledJoint {
  90308. /**
  90309. * Initializes the Hinge2-Joint
  90310. * @param jointData The joint data for the Hinge2-Joint
  90311. */
  90312. constructor(jointData: PhysicsJointData);
  90313. /**
  90314. * Set the motor values.
  90315. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90316. * @param {number} targetSpeed the speed the motor is to reach
  90317. * @param {number} maxForce max force for this motor.
  90318. * @param {motorIndex} the motor's index, 0 or 1.
  90319. */
  90320. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  90321. /**
  90322. * Set the motor limits.
  90323. * Attention, this function is plugin specific. Engines won't react 100% the same.
  90324. * @param {number} upperLimit the upper limit
  90325. * @param {number} lowerLimit lower limit
  90326. * @param {motorIndex} the motor's index, 0 or 1.
  90327. */
  90328. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90329. }
  90330. /**
  90331. * Interface for a motor enabled joint
  90332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90333. */
  90334. export interface IMotorEnabledJoint {
  90335. /**
  90336. * Physics joint
  90337. */
  90338. physicsJoint: any;
  90339. /**
  90340. * Sets the motor of the motor-enabled joint
  90341. * @param force The force of the motor
  90342. * @param maxForce The maximum force of the motor
  90343. * @param motorIndex The index of the motor
  90344. */
  90345. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  90346. /**
  90347. * Sets the limit of the motor
  90348. * @param upperLimit The upper limit of the motor
  90349. * @param lowerLimit The lower limit of the motor
  90350. * @param motorIndex The index of the motor
  90351. */
  90352. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90353. }
  90354. /**
  90355. * Joint data for a Distance-Joint
  90356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90357. */
  90358. export interface DistanceJointData extends PhysicsJointData {
  90359. /**
  90360. * Max distance the 2 joint objects can be apart
  90361. */
  90362. maxDistance: number;
  90363. }
  90364. /**
  90365. * Joint data from a spring joint
  90366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90367. */
  90368. export interface SpringJointData extends PhysicsJointData {
  90369. /**
  90370. * Length of the spring
  90371. */
  90372. length: number;
  90373. /**
  90374. * Stiffness of the spring
  90375. */
  90376. stiffness: number;
  90377. /**
  90378. * Damping of the spring
  90379. */
  90380. damping: number;
  90381. /** this callback will be called when applying the force to the impostors. */
  90382. forceApplicationCallback: () => void;
  90383. }
  90384. }
  90385. declare module BABYLON {
  90386. /**
  90387. * Holds the data for the raycast result
  90388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90389. */
  90390. export class PhysicsRaycastResult {
  90391. private _hasHit;
  90392. private _hitDistance;
  90393. private _hitNormalWorld;
  90394. private _hitPointWorld;
  90395. private _rayFromWorld;
  90396. private _rayToWorld;
  90397. /**
  90398. * Gets if there was a hit
  90399. */
  90400. readonly hasHit: boolean;
  90401. /**
  90402. * Gets the distance from the hit
  90403. */
  90404. readonly hitDistance: number;
  90405. /**
  90406. * Gets the hit normal/direction in the world
  90407. */
  90408. readonly hitNormalWorld: Vector3;
  90409. /**
  90410. * Gets the hit point in the world
  90411. */
  90412. readonly hitPointWorld: Vector3;
  90413. /**
  90414. * Gets the ray "start point" of the ray in the world
  90415. */
  90416. readonly rayFromWorld: Vector3;
  90417. /**
  90418. * Gets the ray "end point" of the ray in the world
  90419. */
  90420. readonly rayToWorld: Vector3;
  90421. /**
  90422. * Sets the hit data (normal & point in world space)
  90423. * @param hitNormalWorld defines the normal in world space
  90424. * @param hitPointWorld defines the point in world space
  90425. */
  90426. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  90427. /**
  90428. * Sets the distance from the start point to the hit point
  90429. * @param distance
  90430. */
  90431. setHitDistance(distance: number): void;
  90432. /**
  90433. * Calculates the distance manually
  90434. */
  90435. calculateHitDistance(): void;
  90436. /**
  90437. * Resets all the values to default
  90438. * @param from The from point on world space
  90439. * @param to The to point on world space
  90440. */
  90441. reset(from?: Vector3, to?: Vector3): void;
  90442. }
  90443. /**
  90444. * Interface for the size containing width and height
  90445. */
  90446. interface IXYZ {
  90447. /**
  90448. * X
  90449. */
  90450. x: number;
  90451. /**
  90452. * Y
  90453. */
  90454. y: number;
  90455. /**
  90456. * Z
  90457. */
  90458. z: number;
  90459. }
  90460. }
  90461. declare module BABYLON {
  90462. /**
  90463. * Interface used to describe a physics joint
  90464. */
  90465. export interface PhysicsImpostorJoint {
  90466. /** Defines the main impostor to which the joint is linked */
  90467. mainImpostor: PhysicsImpostor;
  90468. /** Defines the impostor that is connected to the main impostor using this joint */
  90469. connectedImpostor: PhysicsImpostor;
  90470. /** Defines the joint itself */
  90471. joint: PhysicsJoint;
  90472. }
  90473. /** @hidden */
  90474. export interface IPhysicsEnginePlugin {
  90475. world: any;
  90476. name: string;
  90477. setGravity(gravity: Vector3): void;
  90478. setTimeStep(timeStep: number): void;
  90479. getTimeStep(): number;
  90480. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  90481. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90482. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  90483. generatePhysicsBody(impostor: PhysicsImpostor): void;
  90484. removePhysicsBody(impostor: PhysicsImpostor): void;
  90485. generateJoint(joint: PhysicsImpostorJoint): void;
  90486. removeJoint(joint: PhysicsImpostorJoint): void;
  90487. isSupported(): boolean;
  90488. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  90489. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  90490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90491. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  90492. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90493. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  90494. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  90495. getBodyMass(impostor: PhysicsImpostor): number;
  90496. getBodyFriction(impostor: PhysicsImpostor): number;
  90497. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  90498. getBodyRestitution(impostor: PhysicsImpostor): number;
  90499. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  90500. getBodyPressure?(impostor: PhysicsImpostor): number;
  90501. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  90502. getBodyStiffness?(impostor: PhysicsImpostor): number;
  90503. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  90504. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  90505. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  90506. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  90507. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  90508. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90509. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  90510. sleepBody(impostor: PhysicsImpostor): void;
  90511. wakeUpBody(impostor: PhysicsImpostor): void;
  90512. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90513. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  90514. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  90515. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  90516. getRadius(impostor: PhysicsImpostor): number;
  90517. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  90518. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  90519. dispose(): void;
  90520. }
  90521. /**
  90522. * Interface used to define a physics engine
  90523. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  90524. */
  90525. export interface IPhysicsEngine {
  90526. /**
  90527. * Gets the gravity vector used by the simulation
  90528. */
  90529. gravity: Vector3;
  90530. /**
  90531. * Sets the gravity vector used by the simulation
  90532. * @param gravity defines the gravity vector to use
  90533. */
  90534. setGravity(gravity: Vector3): void;
  90535. /**
  90536. * Set the time step of the physics engine.
  90537. * Default is 1/60.
  90538. * To slow it down, enter 1/600 for example.
  90539. * To speed it up, 1/30
  90540. * @param newTimeStep the new timestep to apply to this world.
  90541. */
  90542. setTimeStep(newTimeStep: number): void;
  90543. /**
  90544. * Get the time step of the physics engine.
  90545. * @returns the current time step
  90546. */
  90547. getTimeStep(): number;
  90548. /**
  90549. * Release all resources
  90550. */
  90551. dispose(): void;
  90552. /**
  90553. * Gets the name of the current physics plugin
  90554. * @returns the name of the plugin
  90555. */
  90556. getPhysicsPluginName(): string;
  90557. /**
  90558. * Adding a new impostor for the impostor tracking.
  90559. * This will be done by the impostor itself.
  90560. * @param impostor the impostor to add
  90561. */
  90562. addImpostor(impostor: PhysicsImpostor): void;
  90563. /**
  90564. * Remove an impostor from the engine.
  90565. * This impostor and its mesh will not longer be updated by the physics engine.
  90566. * @param impostor the impostor to remove
  90567. */
  90568. removeImpostor(impostor: PhysicsImpostor): void;
  90569. /**
  90570. * Add a joint to the physics engine
  90571. * @param mainImpostor defines the main impostor to which the joint is added.
  90572. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  90573. * @param joint defines the joint that will connect both impostors.
  90574. */
  90575. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90576. /**
  90577. * Removes a joint from the simulation
  90578. * @param mainImpostor defines the impostor used with the joint
  90579. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  90580. * @param joint defines the joint to remove
  90581. */
  90582. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  90583. /**
  90584. * Gets the current plugin used to run the simulation
  90585. * @returns current plugin
  90586. */
  90587. getPhysicsPlugin(): IPhysicsEnginePlugin;
  90588. /**
  90589. * Gets the list of physic impostors
  90590. * @returns an array of PhysicsImpostor
  90591. */
  90592. getImpostors(): Array<PhysicsImpostor>;
  90593. /**
  90594. * Gets the impostor for a physics enabled object
  90595. * @param object defines the object impersonated by the impostor
  90596. * @returns the PhysicsImpostor or null if not found
  90597. */
  90598. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90599. /**
  90600. * Gets the impostor for a physics body object
  90601. * @param body defines physics body used by the impostor
  90602. * @returns the PhysicsImpostor or null if not found
  90603. */
  90604. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  90605. /**
  90606. * Does a raycast in the physics world
  90607. * @param from when should the ray start?
  90608. * @param to when should the ray end?
  90609. * @returns PhysicsRaycastResult
  90610. */
  90611. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  90612. /**
  90613. * Called by the scene. No need to call it.
  90614. * @param delta defines the timespam between frames
  90615. */
  90616. _step(delta: number): void;
  90617. }
  90618. }
  90619. declare module BABYLON {
  90620. /**
  90621. * The interface for the physics imposter parameters
  90622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90623. */
  90624. export interface PhysicsImpostorParameters {
  90625. /**
  90626. * The mass of the physics imposter
  90627. */
  90628. mass: number;
  90629. /**
  90630. * The friction of the physics imposter
  90631. */
  90632. friction?: number;
  90633. /**
  90634. * The coefficient of restitution of the physics imposter
  90635. */
  90636. restitution?: number;
  90637. /**
  90638. * The native options of the physics imposter
  90639. */
  90640. nativeOptions?: any;
  90641. /**
  90642. * Specifies if the parent should be ignored
  90643. */
  90644. ignoreParent?: boolean;
  90645. /**
  90646. * Specifies if bi-directional transformations should be disabled
  90647. */
  90648. disableBidirectionalTransformation?: boolean;
  90649. /**
  90650. * The pressure inside the physics imposter, soft object only
  90651. */
  90652. pressure?: number;
  90653. /**
  90654. * The stiffness the physics imposter, soft object only
  90655. */
  90656. stiffness?: number;
  90657. /**
  90658. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  90659. */
  90660. velocityIterations?: number;
  90661. /**
  90662. * The number of iterations used in maintaining consistent vertex positions, soft object only
  90663. */
  90664. positionIterations?: number;
  90665. /**
  90666. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  90667. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  90668. * Add to fix multiple points
  90669. */
  90670. fixedPoints?: number;
  90671. /**
  90672. * The collision margin around a soft object
  90673. */
  90674. margin?: number;
  90675. /**
  90676. * The collision margin around a soft object
  90677. */
  90678. damping?: number;
  90679. /**
  90680. * The path for a rope based on an extrusion
  90681. */
  90682. path?: any;
  90683. /**
  90684. * The shape of an extrusion used for a rope based on an extrusion
  90685. */
  90686. shape?: any;
  90687. }
  90688. /**
  90689. * Interface for a physics-enabled object
  90690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90691. */
  90692. export interface IPhysicsEnabledObject {
  90693. /**
  90694. * The position of the physics-enabled object
  90695. */
  90696. position: Vector3;
  90697. /**
  90698. * The rotation of the physics-enabled object
  90699. */
  90700. rotationQuaternion: Nullable<Quaternion>;
  90701. /**
  90702. * The scale of the physics-enabled object
  90703. */
  90704. scaling: Vector3;
  90705. /**
  90706. * The rotation of the physics-enabled object
  90707. */
  90708. rotation?: Vector3;
  90709. /**
  90710. * The parent of the physics-enabled object
  90711. */
  90712. parent?: any;
  90713. /**
  90714. * The bounding info of the physics-enabled object
  90715. * @returns The bounding info of the physics-enabled object
  90716. */
  90717. getBoundingInfo(): BoundingInfo;
  90718. /**
  90719. * Computes the world matrix
  90720. * @param force Specifies if the world matrix should be computed by force
  90721. * @returns A world matrix
  90722. */
  90723. computeWorldMatrix(force: boolean): Matrix;
  90724. /**
  90725. * Gets the world matrix
  90726. * @returns A world matrix
  90727. */
  90728. getWorldMatrix?(): Matrix;
  90729. /**
  90730. * Gets the child meshes
  90731. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  90732. * @returns An array of abstract meshes
  90733. */
  90734. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  90735. /**
  90736. * Gets the vertex data
  90737. * @param kind The type of vertex data
  90738. * @returns A nullable array of numbers, or a float32 array
  90739. */
  90740. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  90741. /**
  90742. * Gets the indices from the mesh
  90743. * @returns A nullable array of index arrays
  90744. */
  90745. getIndices?(): Nullable<IndicesArray>;
  90746. /**
  90747. * Gets the scene from the mesh
  90748. * @returns the indices array or null
  90749. */
  90750. getScene?(): Scene;
  90751. /**
  90752. * Gets the absolute position from the mesh
  90753. * @returns the absolute position
  90754. */
  90755. getAbsolutePosition(): Vector3;
  90756. /**
  90757. * Gets the absolute pivot point from the mesh
  90758. * @returns the absolute pivot point
  90759. */
  90760. getAbsolutePivotPoint(): Vector3;
  90761. /**
  90762. * Rotates the mesh
  90763. * @param axis The axis of rotation
  90764. * @param amount The amount of rotation
  90765. * @param space The space of the rotation
  90766. * @returns The rotation transform node
  90767. */
  90768. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  90769. /**
  90770. * Translates the mesh
  90771. * @param axis The axis of translation
  90772. * @param distance The distance of translation
  90773. * @param space The space of the translation
  90774. * @returns The transform node
  90775. */
  90776. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  90777. /**
  90778. * Sets the absolute position of the mesh
  90779. * @param absolutePosition The absolute position of the mesh
  90780. * @returns The transform node
  90781. */
  90782. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  90783. /**
  90784. * Gets the class name of the mesh
  90785. * @returns The class name
  90786. */
  90787. getClassName(): string;
  90788. }
  90789. /**
  90790. * Represents a physics imposter
  90791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  90792. */
  90793. export class PhysicsImpostor {
  90794. /**
  90795. * The physics-enabled object used as the physics imposter
  90796. */
  90797. object: IPhysicsEnabledObject;
  90798. /**
  90799. * The type of the physics imposter
  90800. */
  90801. type: number;
  90802. private _options;
  90803. private _scene?;
  90804. /**
  90805. * The default object size of the imposter
  90806. */
  90807. static DEFAULT_OBJECT_SIZE: Vector3;
  90808. /**
  90809. * The identity quaternion of the imposter
  90810. */
  90811. static IDENTITY_QUATERNION: Quaternion;
  90812. /** @hidden */
  90813. _pluginData: any;
  90814. private _physicsEngine;
  90815. private _physicsBody;
  90816. private _bodyUpdateRequired;
  90817. private _onBeforePhysicsStepCallbacks;
  90818. private _onAfterPhysicsStepCallbacks;
  90819. /** @hidden */
  90820. _onPhysicsCollideCallbacks: Array<{
  90821. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  90822. otherImpostors: Array<PhysicsImpostor>;
  90823. }>;
  90824. private _deltaPosition;
  90825. private _deltaRotation;
  90826. private _deltaRotationConjugated;
  90827. /** @hidden */
  90828. _isFromLine: boolean;
  90829. private _parent;
  90830. private _isDisposed;
  90831. private static _tmpVecs;
  90832. private static _tmpQuat;
  90833. /**
  90834. * Specifies if the physics imposter is disposed
  90835. */
  90836. readonly isDisposed: boolean;
  90837. /**
  90838. * Gets the mass of the physics imposter
  90839. */
  90840. mass: number;
  90841. /**
  90842. * Gets the coefficient of friction
  90843. */
  90844. /**
  90845. * Sets the coefficient of friction
  90846. */
  90847. friction: number;
  90848. /**
  90849. * Gets the coefficient of restitution
  90850. */
  90851. /**
  90852. * Sets the coefficient of restitution
  90853. */
  90854. restitution: number;
  90855. /**
  90856. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  90857. */
  90858. /**
  90859. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  90860. */
  90861. pressure: number;
  90862. /**
  90863. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90864. */
  90865. /**
  90866. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  90867. */
  90868. stiffness: number;
  90869. /**
  90870. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90871. */
  90872. /**
  90873. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  90874. */
  90875. velocityIterations: number;
  90876. /**
  90877. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90878. */
  90879. /**
  90880. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  90881. */
  90882. positionIterations: number;
  90883. /**
  90884. * The unique id of the physics imposter
  90885. * set by the physics engine when adding this impostor to the array
  90886. */
  90887. uniqueId: number;
  90888. /**
  90889. * @hidden
  90890. */
  90891. soft: boolean;
  90892. /**
  90893. * @hidden
  90894. */
  90895. segments: number;
  90896. private _joints;
  90897. /**
  90898. * Initializes the physics imposter
  90899. * @param object The physics-enabled object used as the physics imposter
  90900. * @param type The type of the physics imposter
  90901. * @param _options The options for the physics imposter
  90902. * @param _scene The Babylon scene
  90903. */
  90904. constructor(
  90905. /**
  90906. * The physics-enabled object used as the physics imposter
  90907. */
  90908. object: IPhysicsEnabledObject,
  90909. /**
  90910. * The type of the physics imposter
  90911. */
  90912. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90913. /**
  90914. * This function will completly initialize this impostor.
  90915. * It will create a new body - but only if this mesh has no parent.
  90916. * If it has, this impostor will not be used other than to define the impostor
  90917. * of the child mesh.
  90918. * @hidden
  90919. */
  90920. _init(): void;
  90921. private _getPhysicsParent;
  90922. /**
  90923. * Should a new body be generated.
  90924. * @returns boolean specifying if body initialization is required
  90925. */
  90926. isBodyInitRequired(): boolean;
  90927. /**
  90928. * Sets the updated scaling
  90929. * @param updated Specifies if the scaling is updated
  90930. */
  90931. setScalingUpdated(): void;
  90932. /**
  90933. * Force a regeneration of this or the parent's impostor's body.
  90934. * Use under cautious - This will remove all joints already implemented.
  90935. */
  90936. forceUpdate(): void;
  90937. /**
  90938. * Gets the body that holds this impostor. Either its own, or its parent.
  90939. */
  90940. /**
  90941. * Set the physics body. Used mainly by the physics engine/plugin
  90942. */
  90943. physicsBody: any;
  90944. /**
  90945. * Get the parent of the physics imposter
  90946. * @returns Physics imposter or null
  90947. */
  90948. /**
  90949. * Sets the parent of the physics imposter
  90950. */
  90951. parent: Nullable<PhysicsImpostor>;
  90952. /**
  90953. * Resets the update flags
  90954. */
  90955. resetUpdateFlags(): void;
  90956. /**
  90957. * Gets the object extend size
  90958. * @returns the object extend size
  90959. */
  90960. getObjectExtendSize(): Vector3;
  90961. /**
  90962. * Gets the object center
  90963. * @returns The object center
  90964. */
  90965. getObjectCenter(): Vector3;
  90966. /**
  90967. * Get a specific parametes from the options parameter
  90968. * @param paramName The object parameter name
  90969. * @returns The object parameter
  90970. */
  90971. getParam(paramName: string): any;
  90972. /**
  90973. * Sets a specific parameter in the options given to the physics plugin
  90974. * @param paramName The parameter name
  90975. * @param value The value of the parameter
  90976. */
  90977. setParam(paramName: string, value: number): void;
  90978. /**
  90979. * Specifically change the body's mass option. Won't recreate the physics body object
  90980. * @param mass The mass of the physics imposter
  90981. */
  90982. setMass(mass: number): void;
  90983. /**
  90984. * Gets the linear velocity
  90985. * @returns linear velocity or null
  90986. */
  90987. getLinearVelocity(): Nullable<Vector3>;
  90988. /**
  90989. * Sets the linear velocity
  90990. * @param velocity linear velocity or null
  90991. */
  90992. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90993. /**
  90994. * Gets the angular velocity
  90995. * @returns angular velocity or null
  90996. */
  90997. getAngularVelocity(): Nullable<Vector3>;
  90998. /**
  90999. * Sets the angular velocity
  91000. * @param velocity The velocity or null
  91001. */
  91002. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91003. /**
  91004. * Execute a function with the physics plugin native code
  91005. * Provide a function the will have two variables - the world object and the physics body object
  91006. * @param func The function to execute with the physics plugin native code
  91007. */
  91008. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91009. /**
  91010. * Register a function that will be executed before the physics world is stepping forward
  91011. * @param func The function to execute before the physics world is stepped forward
  91012. */
  91013. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91014. /**
  91015. * Unregister a function that will be executed before the physics world is stepping forward
  91016. * @param func The function to execute before the physics world is stepped forward
  91017. */
  91018. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91019. /**
  91020. * Register a function that will be executed after the physics step
  91021. * @param func The function to execute after physics step
  91022. */
  91023. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91024. /**
  91025. * Unregisters a function that will be executed after the physics step
  91026. * @param func The function to execute after physics step
  91027. */
  91028. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91029. /**
  91030. * register a function that will be executed when this impostor collides against a different body
  91031. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91032. * @param func Callback that is executed on collision
  91033. */
  91034. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91035. /**
  91036. * Unregisters the physics imposter on contact
  91037. * @param collideAgainst The physics object to collide against
  91038. * @param func Callback to execute on collision
  91039. */
  91040. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91041. private _tmpQuat;
  91042. private _tmpQuat2;
  91043. /**
  91044. * Get the parent rotation
  91045. * @returns The parent rotation
  91046. */
  91047. getParentsRotation(): Quaternion;
  91048. /**
  91049. * this function is executed by the physics engine.
  91050. */
  91051. beforeStep: () => void;
  91052. /**
  91053. * this function is executed by the physics engine
  91054. */
  91055. afterStep: () => void;
  91056. /**
  91057. * Legacy collision detection event support
  91058. */
  91059. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91060. /**
  91061. * event and body object due to cannon's event-based architecture.
  91062. */
  91063. onCollide: (e: {
  91064. body: any;
  91065. }) => void;
  91066. /**
  91067. * Apply a force
  91068. * @param force The force to apply
  91069. * @param contactPoint The contact point for the force
  91070. * @returns The physics imposter
  91071. */
  91072. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91073. /**
  91074. * Apply an impulse
  91075. * @param force The impulse force
  91076. * @param contactPoint The contact point for the impulse force
  91077. * @returns The physics imposter
  91078. */
  91079. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91080. /**
  91081. * A help function to create a joint
  91082. * @param otherImpostor A physics imposter used to create a joint
  91083. * @param jointType The type of joint
  91084. * @param jointData The data for the joint
  91085. * @returns The physics imposter
  91086. */
  91087. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91088. /**
  91089. * Add a joint to this impostor with a different impostor
  91090. * @param otherImpostor A physics imposter used to add a joint
  91091. * @param joint The joint to add
  91092. * @returns The physics imposter
  91093. */
  91094. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  91095. /**
  91096. * Add an anchor to a cloth impostor
  91097. * @param otherImpostor rigid impostor to anchor to
  91098. * @param width ratio across width from 0 to 1
  91099. * @param height ratio up height from 0 to 1
  91100. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  91101. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  91102. * @returns impostor the soft imposter
  91103. */
  91104. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91105. /**
  91106. * Add a hook to a rope impostor
  91107. * @param otherImpostor rigid impostor to anchor to
  91108. * @param length ratio across rope from 0 to 1
  91109. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  91110. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  91111. * @returns impostor the rope imposter
  91112. */
  91113. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  91114. /**
  91115. * Will keep this body still, in a sleep mode.
  91116. * @returns the physics imposter
  91117. */
  91118. sleep(): PhysicsImpostor;
  91119. /**
  91120. * Wake the body up.
  91121. * @returns The physics imposter
  91122. */
  91123. wakeUp(): PhysicsImpostor;
  91124. /**
  91125. * Clones the physics imposter
  91126. * @param newObject The physics imposter clones to this physics-enabled object
  91127. * @returns A nullable physics imposter
  91128. */
  91129. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91130. /**
  91131. * Disposes the physics imposter
  91132. */
  91133. dispose(): void;
  91134. /**
  91135. * Sets the delta position
  91136. * @param position The delta position amount
  91137. */
  91138. setDeltaPosition(position: Vector3): void;
  91139. /**
  91140. * Sets the delta rotation
  91141. * @param rotation The delta rotation amount
  91142. */
  91143. setDeltaRotation(rotation: Quaternion): void;
  91144. /**
  91145. * Gets the box size of the physics imposter and stores the result in the input parameter
  91146. * @param result Stores the box size
  91147. * @returns The physics imposter
  91148. */
  91149. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  91150. /**
  91151. * Gets the radius of the physics imposter
  91152. * @returns Radius of the physics imposter
  91153. */
  91154. getRadius(): number;
  91155. /**
  91156. * Sync a bone with this impostor
  91157. * @param bone The bone to sync to the impostor.
  91158. * @param boneMesh The mesh that the bone is influencing.
  91159. * @param jointPivot The pivot of the joint / bone in local space.
  91160. * @param distToJoint Optional distance from the impostor to the joint.
  91161. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91162. */
  91163. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  91164. /**
  91165. * Sync impostor to a bone
  91166. * @param bone The bone that the impostor will be synced to.
  91167. * @param boneMesh The mesh that the bone is influencing.
  91168. * @param jointPivot The pivot of the joint / bone in local space.
  91169. * @param distToJoint Optional distance from the impostor to the joint.
  91170. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  91171. * @param boneAxis Optional vector3 axis the bone is aligned with
  91172. */
  91173. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  91174. /**
  91175. * No-Imposter type
  91176. */
  91177. static NoImpostor: number;
  91178. /**
  91179. * Sphere-Imposter type
  91180. */
  91181. static SphereImpostor: number;
  91182. /**
  91183. * Box-Imposter type
  91184. */
  91185. static BoxImpostor: number;
  91186. /**
  91187. * Plane-Imposter type
  91188. */
  91189. static PlaneImpostor: number;
  91190. /**
  91191. * Mesh-imposter type
  91192. */
  91193. static MeshImpostor: number;
  91194. /**
  91195. * Capsule-Impostor type (Ammo.js plugin only)
  91196. */
  91197. static CapsuleImpostor: number;
  91198. /**
  91199. * Cylinder-Imposter type
  91200. */
  91201. static CylinderImpostor: number;
  91202. /**
  91203. * Particle-Imposter type
  91204. */
  91205. static ParticleImpostor: number;
  91206. /**
  91207. * Heightmap-Imposter type
  91208. */
  91209. static HeightmapImpostor: number;
  91210. /**
  91211. * ConvexHull-Impostor type (Ammo.js plugin only)
  91212. */
  91213. static ConvexHullImpostor: number;
  91214. /**
  91215. * Rope-Imposter type
  91216. */
  91217. static RopeImpostor: number;
  91218. /**
  91219. * Cloth-Imposter type
  91220. */
  91221. static ClothImpostor: number;
  91222. /**
  91223. * Softbody-Imposter type
  91224. */
  91225. static SoftbodyImpostor: number;
  91226. }
  91227. }
  91228. declare module BABYLON {
  91229. /**
  91230. * @hidden
  91231. **/
  91232. export class _CreationDataStorage {
  91233. closePath?: boolean;
  91234. closeArray?: boolean;
  91235. idx: number[];
  91236. dashSize: number;
  91237. gapSize: number;
  91238. path3D: Path3D;
  91239. pathArray: Vector3[][];
  91240. arc: number;
  91241. radius: number;
  91242. cap: number;
  91243. tessellation: number;
  91244. }
  91245. /**
  91246. * @hidden
  91247. **/
  91248. class _InstanceDataStorage {
  91249. visibleInstances: any;
  91250. batchCache: _InstancesBatch;
  91251. instancesBufferSize: number;
  91252. instancesBuffer: Nullable<Buffer>;
  91253. instancesData: Float32Array;
  91254. overridenInstanceCount: number;
  91255. isFrozen: boolean;
  91256. previousBatch: Nullable<_InstancesBatch>;
  91257. hardwareInstancedRendering: boolean;
  91258. sideOrientation: number;
  91259. }
  91260. /**
  91261. * @hidden
  91262. **/
  91263. export class _InstancesBatch {
  91264. mustReturn: boolean;
  91265. visibleInstances: Nullable<InstancedMesh[]>[];
  91266. renderSelf: boolean[];
  91267. hardwareInstancedRendering: boolean[];
  91268. }
  91269. /**
  91270. * Class used to represent renderable models
  91271. */
  91272. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  91273. /**
  91274. * Mesh side orientation : usually the external or front surface
  91275. */
  91276. static readonly FRONTSIDE: number;
  91277. /**
  91278. * Mesh side orientation : usually the internal or back surface
  91279. */
  91280. static readonly BACKSIDE: number;
  91281. /**
  91282. * Mesh side orientation : both internal and external or front and back surfaces
  91283. */
  91284. static readonly DOUBLESIDE: number;
  91285. /**
  91286. * Mesh side orientation : by default, `FRONTSIDE`
  91287. */
  91288. static readonly DEFAULTSIDE: number;
  91289. /**
  91290. * Mesh cap setting : no cap
  91291. */
  91292. static readonly NO_CAP: number;
  91293. /**
  91294. * Mesh cap setting : one cap at the beginning of the mesh
  91295. */
  91296. static readonly CAP_START: number;
  91297. /**
  91298. * Mesh cap setting : one cap at the end of the mesh
  91299. */
  91300. static readonly CAP_END: number;
  91301. /**
  91302. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91303. */
  91304. static readonly CAP_ALL: number;
  91305. /**
  91306. * Mesh pattern setting : no flip or rotate
  91307. */
  91308. static readonly NO_FLIP: number;
  91309. /**
  91310. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  91311. */
  91312. static readonly FLIP_TILE: number;
  91313. /**
  91314. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  91315. */
  91316. static readonly ROTATE_TILE: number;
  91317. /**
  91318. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  91319. */
  91320. static readonly FLIP_ROW: number;
  91321. /**
  91322. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  91323. */
  91324. static readonly ROTATE_ROW: number;
  91325. /**
  91326. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  91327. */
  91328. static readonly FLIP_N_ROTATE_TILE: number;
  91329. /**
  91330. * Mesh pattern setting : rotate pattern and rotate
  91331. */
  91332. static readonly FLIP_N_ROTATE_ROW: number;
  91333. /**
  91334. * Mesh tile positioning : part tiles same on left/right or top/bottom
  91335. */
  91336. static readonly CENTER: number;
  91337. /**
  91338. * Mesh tile positioning : part tiles on left
  91339. */
  91340. static readonly LEFT: number;
  91341. /**
  91342. * Mesh tile positioning : part tiles on right
  91343. */
  91344. static readonly RIGHT: number;
  91345. /**
  91346. * Mesh tile positioning : part tiles on top
  91347. */
  91348. static readonly TOP: number;
  91349. /**
  91350. * Mesh tile positioning : part tiles on bottom
  91351. */
  91352. static readonly BOTTOM: number;
  91353. /**
  91354. * Gets the default side orientation.
  91355. * @param orientation the orientation to value to attempt to get
  91356. * @returns the default orientation
  91357. * @hidden
  91358. */
  91359. static _GetDefaultSideOrientation(orientation?: number): number;
  91360. private _internalMeshDataInfo;
  91361. /**
  91362. * An event triggered before rendering the mesh
  91363. */
  91364. readonly onBeforeRenderObservable: Observable<Mesh>;
  91365. /**
  91366. * An event triggered before binding the mesh
  91367. */
  91368. readonly onBeforeBindObservable: Observable<Mesh>;
  91369. /**
  91370. * An event triggered after rendering the mesh
  91371. */
  91372. readonly onAfterRenderObservable: Observable<Mesh>;
  91373. /**
  91374. * An event triggered before drawing the mesh
  91375. */
  91376. readonly onBeforeDrawObservable: Observable<Mesh>;
  91377. private _onBeforeDrawObserver;
  91378. /**
  91379. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  91380. */
  91381. onBeforeDraw: () => void;
  91382. readonly hasInstances: boolean;
  91383. /**
  91384. * Gets the delay loading state of the mesh (when delay loading is turned on)
  91385. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  91386. */
  91387. delayLoadState: number;
  91388. /**
  91389. * Gets the list of instances created from this mesh
  91390. * it is not supposed to be modified manually.
  91391. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  91392. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91393. */
  91394. instances: InstancedMesh[];
  91395. /**
  91396. * Gets the file containing delay loading data for this mesh
  91397. */
  91398. delayLoadingFile: string;
  91399. /** @hidden */
  91400. _binaryInfo: any;
  91401. /**
  91402. * User defined function used to change how LOD level selection is done
  91403. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91404. */
  91405. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  91406. /**
  91407. * Gets or sets the morph target manager
  91408. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91409. */
  91410. morphTargetManager: Nullable<MorphTargetManager>;
  91411. /** @hidden */
  91412. _creationDataStorage: Nullable<_CreationDataStorage>;
  91413. /** @hidden */
  91414. _geometry: Nullable<Geometry>;
  91415. /** @hidden */
  91416. _delayInfo: Array<string>;
  91417. /** @hidden */
  91418. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  91419. /** @hidden */
  91420. _instanceDataStorage: _InstanceDataStorage;
  91421. private _effectiveMaterial;
  91422. /** @hidden */
  91423. _shouldGenerateFlatShading: boolean;
  91424. /** @hidden */
  91425. _originalBuilderSideOrientation: number;
  91426. /**
  91427. * Use this property to change the original side orientation defined at construction time
  91428. */
  91429. overrideMaterialSideOrientation: Nullable<number>;
  91430. /**
  91431. * Gets the source mesh (the one used to clone this one from)
  91432. */
  91433. readonly source: Nullable<Mesh>;
  91434. /**
  91435. * Gets or sets a boolean indicating that this mesh does not use index buffer
  91436. */
  91437. isUnIndexed: boolean;
  91438. /**
  91439. * @constructor
  91440. * @param name The value used by scene.getMeshByName() to do a lookup.
  91441. * @param scene The scene to add this mesh to.
  91442. * @param parent The parent of this mesh, if it has one
  91443. * @param source An optional Mesh from which geometry is shared, cloned.
  91444. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91445. * When false, achieved by calling a clone(), also passing False.
  91446. * This will make creation of children, recursive.
  91447. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  91448. */
  91449. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  91450. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  91451. doNotInstantiate: boolean;
  91452. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  91453. /**
  91454. * Gets the class name
  91455. * @returns the string "Mesh".
  91456. */
  91457. getClassName(): string;
  91458. /** @hidden */
  91459. readonly _isMesh: boolean;
  91460. /**
  91461. * Returns a description of this mesh
  91462. * @param fullDetails define if full details about this mesh must be used
  91463. * @returns a descriptive string representing this mesh
  91464. */
  91465. toString(fullDetails?: boolean): string;
  91466. /** @hidden */
  91467. _unBindEffect(): void;
  91468. /**
  91469. * Gets a boolean indicating if this mesh has LOD
  91470. */
  91471. readonly hasLODLevels: boolean;
  91472. /**
  91473. * Gets the list of MeshLODLevel associated with the current mesh
  91474. * @returns an array of MeshLODLevel
  91475. */
  91476. getLODLevels(): MeshLODLevel[];
  91477. private _sortLODLevels;
  91478. /**
  91479. * Add a mesh as LOD level triggered at the given distance.
  91480. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91481. * @param distance The distance from the center of the object to show this level
  91482. * @param mesh The mesh to be added as LOD level (can be null)
  91483. * @return This mesh (for chaining)
  91484. */
  91485. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  91486. /**
  91487. * Returns the LOD level mesh at the passed distance or null if not found.
  91488. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91489. * @param distance The distance from the center of the object to show this level
  91490. * @returns a Mesh or `null`
  91491. */
  91492. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  91493. /**
  91494. * Remove a mesh from the LOD array
  91495. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91496. * @param mesh defines the mesh to be removed
  91497. * @return This mesh (for chaining)
  91498. */
  91499. removeLODLevel(mesh: Mesh): Mesh;
  91500. /**
  91501. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  91502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  91503. * @param camera defines the camera to use to compute distance
  91504. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  91505. * @return This mesh (for chaining)
  91506. */
  91507. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  91508. /**
  91509. * Gets the mesh internal Geometry object
  91510. */
  91511. readonly geometry: Nullable<Geometry>;
  91512. /**
  91513. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  91514. * @returns the total number of vertices
  91515. */
  91516. getTotalVertices(): number;
  91517. /**
  91518. * Returns the content of an associated vertex buffer
  91519. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91520. * - VertexBuffer.PositionKind
  91521. * - VertexBuffer.UVKind
  91522. * - VertexBuffer.UV2Kind
  91523. * - VertexBuffer.UV3Kind
  91524. * - VertexBuffer.UV4Kind
  91525. * - VertexBuffer.UV5Kind
  91526. * - VertexBuffer.UV6Kind
  91527. * - VertexBuffer.ColorKind
  91528. * - VertexBuffer.MatricesIndicesKind
  91529. * - VertexBuffer.MatricesIndicesExtraKind
  91530. * - VertexBuffer.MatricesWeightsKind
  91531. * - VertexBuffer.MatricesWeightsExtraKind
  91532. * @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
  91533. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  91534. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  91535. */
  91536. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91537. /**
  91538. * Returns the mesh VertexBuffer object from the requested `kind`
  91539. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91540. * - VertexBuffer.PositionKind
  91541. * - VertexBuffer.NormalKind
  91542. * - VertexBuffer.UVKind
  91543. * - VertexBuffer.UV2Kind
  91544. * - VertexBuffer.UV3Kind
  91545. * - VertexBuffer.UV4Kind
  91546. * - VertexBuffer.UV5Kind
  91547. * - VertexBuffer.UV6Kind
  91548. * - VertexBuffer.ColorKind
  91549. * - VertexBuffer.MatricesIndicesKind
  91550. * - VertexBuffer.MatricesIndicesExtraKind
  91551. * - VertexBuffer.MatricesWeightsKind
  91552. * - VertexBuffer.MatricesWeightsExtraKind
  91553. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  91554. */
  91555. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  91556. /**
  91557. * Tests if a specific vertex buffer is associated with this mesh
  91558. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91559. * - VertexBuffer.PositionKind
  91560. * - VertexBuffer.NormalKind
  91561. * - VertexBuffer.UVKind
  91562. * - VertexBuffer.UV2Kind
  91563. * - VertexBuffer.UV3Kind
  91564. * - VertexBuffer.UV4Kind
  91565. * - VertexBuffer.UV5Kind
  91566. * - VertexBuffer.UV6Kind
  91567. * - VertexBuffer.ColorKind
  91568. * - VertexBuffer.MatricesIndicesKind
  91569. * - VertexBuffer.MatricesIndicesExtraKind
  91570. * - VertexBuffer.MatricesWeightsKind
  91571. * - VertexBuffer.MatricesWeightsExtraKind
  91572. * @returns a boolean
  91573. */
  91574. isVerticesDataPresent(kind: string): boolean;
  91575. /**
  91576. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  91577. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  91578. * - VertexBuffer.PositionKind
  91579. * - VertexBuffer.UVKind
  91580. * - VertexBuffer.UV2Kind
  91581. * - VertexBuffer.UV3Kind
  91582. * - VertexBuffer.UV4Kind
  91583. * - VertexBuffer.UV5Kind
  91584. * - VertexBuffer.UV6Kind
  91585. * - VertexBuffer.ColorKind
  91586. * - VertexBuffer.MatricesIndicesKind
  91587. * - VertexBuffer.MatricesIndicesExtraKind
  91588. * - VertexBuffer.MatricesWeightsKind
  91589. * - VertexBuffer.MatricesWeightsExtraKind
  91590. * @returns a boolean
  91591. */
  91592. isVertexBufferUpdatable(kind: string): boolean;
  91593. /**
  91594. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  91595. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  91596. * - VertexBuffer.PositionKind
  91597. * - VertexBuffer.NormalKind
  91598. * - VertexBuffer.UVKind
  91599. * - VertexBuffer.UV2Kind
  91600. * - VertexBuffer.UV3Kind
  91601. * - VertexBuffer.UV4Kind
  91602. * - VertexBuffer.UV5Kind
  91603. * - VertexBuffer.UV6Kind
  91604. * - VertexBuffer.ColorKind
  91605. * - VertexBuffer.MatricesIndicesKind
  91606. * - VertexBuffer.MatricesIndicesExtraKind
  91607. * - VertexBuffer.MatricesWeightsKind
  91608. * - VertexBuffer.MatricesWeightsExtraKind
  91609. * @returns an array of strings
  91610. */
  91611. getVerticesDataKinds(): string[];
  91612. /**
  91613. * Returns a positive integer : the total number of indices in this mesh geometry.
  91614. * @returns the numner of indices or zero if the mesh has no geometry.
  91615. */
  91616. getTotalIndices(): number;
  91617. /**
  91618. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91619. * @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.
  91620. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91621. * @returns the indices array or an empty array if the mesh has no geometry
  91622. */
  91623. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91624. readonly isBlocked: boolean;
  91625. /**
  91626. * Determine if the current mesh is ready to be rendered
  91627. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  91628. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  91629. * @returns true if all associated assets are ready (material, textures, shaders)
  91630. */
  91631. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  91632. /**
  91633. * 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.
  91634. */
  91635. readonly areNormalsFrozen: boolean;
  91636. /**
  91637. * 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.
  91638. * @returns the current mesh
  91639. */
  91640. freezeNormals(): Mesh;
  91641. /**
  91642. * 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
  91643. * @returns the current mesh
  91644. */
  91645. unfreezeNormals(): Mesh;
  91646. /**
  91647. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  91648. */
  91649. overridenInstanceCount: number;
  91650. /** @hidden */
  91651. _preActivate(): Mesh;
  91652. /** @hidden */
  91653. _preActivateForIntermediateRendering(renderId: number): Mesh;
  91654. /** @hidden */
  91655. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  91656. /**
  91657. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91658. * This means the mesh underlying bounding box and sphere are recomputed.
  91659. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91660. * @returns the current mesh
  91661. */
  91662. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  91663. /** @hidden */
  91664. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  91665. /**
  91666. * This function will subdivide the mesh into multiple submeshes
  91667. * @param count defines the expected number of submeshes
  91668. */
  91669. subdivide(count: number): void;
  91670. /**
  91671. * Copy a FloatArray into a specific associated vertex buffer
  91672. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91673. * - VertexBuffer.PositionKind
  91674. * - VertexBuffer.UVKind
  91675. * - VertexBuffer.UV2Kind
  91676. * - VertexBuffer.UV3Kind
  91677. * - VertexBuffer.UV4Kind
  91678. * - VertexBuffer.UV5Kind
  91679. * - VertexBuffer.UV6Kind
  91680. * - VertexBuffer.ColorKind
  91681. * - VertexBuffer.MatricesIndicesKind
  91682. * - VertexBuffer.MatricesIndicesExtraKind
  91683. * - VertexBuffer.MatricesWeightsKind
  91684. * - VertexBuffer.MatricesWeightsExtraKind
  91685. * @param data defines the data source
  91686. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91687. * @param stride defines the data stride size (can be null)
  91688. * @returns the current mesh
  91689. */
  91690. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91691. /**
  91692. * Delete a vertex buffer associated with this mesh
  91693. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  91694. * - VertexBuffer.PositionKind
  91695. * - VertexBuffer.UVKind
  91696. * - VertexBuffer.UV2Kind
  91697. * - VertexBuffer.UV3Kind
  91698. * - VertexBuffer.UV4Kind
  91699. * - VertexBuffer.UV5Kind
  91700. * - VertexBuffer.UV6Kind
  91701. * - VertexBuffer.ColorKind
  91702. * - VertexBuffer.MatricesIndicesKind
  91703. * - VertexBuffer.MatricesIndicesExtraKind
  91704. * - VertexBuffer.MatricesWeightsKind
  91705. * - VertexBuffer.MatricesWeightsExtraKind
  91706. */
  91707. removeVerticesData(kind: string): void;
  91708. /**
  91709. * Flags an associated vertex buffer as updatable
  91710. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  91711. * - VertexBuffer.PositionKind
  91712. * - VertexBuffer.UVKind
  91713. * - VertexBuffer.UV2Kind
  91714. * - VertexBuffer.UV3Kind
  91715. * - VertexBuffer.UV4Kind
  91716. * - VertexBuffer.UV5Kind
  91717. * - VertexBuffer.UV6Kind
  91718. * - VertexBuffer.ColorKind
  91719. * - VertexBuffer.MatricesIndicesKind
  91720. * - VertexBuffer.MatricesIndicesExtraKind
  91721. * - VertexBuffer.MatricesWeightsKind
  91722. * - VertexBuffer.MatricesWeightsExtraKind
  91723. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  91724. */
  91725. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  91726. /**
  91727. * Sets the mesh global Vertex Buffer
  91728. * @param buffer defines the buffer to use
  91729. * @returns the current mesh
  91730. */
  91731. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  91732. /**
  91733. * Update a specific associated vertex buffer
  91734. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91735. * - VertexBuffer.PositionKind
  91736. * - VertexBuffer.UVKind
  91737. * - VertexBuffer.UV2Kind
  91738. * - VertexBuffer.UV3Kind
  91739. * - VertexBuffer.UV4Kind
  91740. * - VertexBuffer.UV5Kind
  91741. * - VertexBuffer.UV6Kind
  91742. * - VertexBuffer.ColorKind
  91743. * - VertexBuffer.MatricesIndicesKind
  91744. * - VertexBuffer.MatricesIndicesExtraKind
  91745. * - VertexBuffer.MatricesWeightsKind
  91746. * - VertexBuffer.MatricesWeightsExtraKind
  91747. * @param data defines the data source
  91748. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91749. * @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)
  91750. * @returns the current mesh
  91751. */
  91752. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91753. /**
  91754. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  91755. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  91756. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  91757. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  91758. * @returns the current mesh
  91759. */
  91760. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  91761. /**
  91762. * Creates a un-shared specific occurence of the geometry for the mesh.
  91763. * @returns the current mesh
  91764. */
  91765. makeGeometryUnique(): Mesh;
  91766. /**
  91767. * Set the index buffer of this mesh
  91768. * @param indices defines the source data
  91769. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  91770. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  91771. * @returns the current mesh
  91772. */
  91773. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  91774. /**
  91775. * Update the current index buffer
  91776. * @param indices defines the source data
  91777. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  91778. * @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)
  91779. * @returns the current mesh
  91780. */
  91781. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  91782. /**
  91783. * Invert the geometry to move from a right handed system to a left handed one.
  91784. * @returns the current mesh
  91785. */
  91786. toLeftHanded(): Mesh;
  91787. /** @hidden */
  91788. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91789. /** @hidden */
  91790. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91791. /**
  91792. * Registers for this mesh a javascript function called just before the rendering process
  91793. * @param func defines the function to call before rendering this mesh
  91794. * @returns the current mesh
  91795. */
  91796. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91797. /**
  91798. * Disposes a previously registered javascript function called before the rendering
  91799. * @param func defines the function to remove
  91800. * @returns the current mesh
  91801. */
  91802. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  91803. /**
  91804. * Registers for this mesh a javascript function called just after the rendering is complete
  91805. * @param func defines the function to call after rendering this mesh
  91806. * @returns the current mesh
  91807. */
  91808. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91809. /**
  91810. * Disposes a previously registered javascript function called after the rendering.
  91811. * @param func defines the function to remove
  91812. * @returns the current mesh
  91813. */
  91814. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  91815. /** @hidden */
  91816. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  91817. /** @hidden */
  91818. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  91819. /** @hidden */
  91820. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  91821. /** @hidden */
  91822. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  91823. /** @hidden */
  91824. _rebuild(): void;
  91825. /** @hidden */
  91826. _freeze(): void;
  91827. /** @hidden */
  91828. _unFreeze(): void;
  91829. /**
  91830. * 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
  91831. * @param subMesh defines the subMesh to render
  91832. * @param enableAlphaMode defines if alpha mode can be changed
  91833. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  91834. * @returns the current mesh
  91835. */
  91836. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  91837. private _onBeforeDraw;
  91838. /**
  91839. * Renormalize the mesh and patch it up if there are no weights
  91840. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  91841. * However in the case of zero weights then we set just a single influence to 1.
  91842. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  91843. */
  91844. cleanMatrixWeights(): void;
  91845. private normalizeSkinFourWeights;
  91846. private normalizeSkinWeightsAndExtra;
  91847. /**
  91848. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  91849. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  91850. * the user know there was an issue with importing the mesh
  91851. * @returns a validation object with skinned, valid and report string
  91852. */
  91853. validateSkinning(): {
  91854. skinned: boolean;
  91855. valid: boolean;
  91856. report: string;
  91857. };
  91858. /** @hidden */
  91859. _checkDelayState(): Mesh;
  91860. private _queueLoad;
  91861. /**
  91862. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91863. * A mesh is in the frustum if its bounding box intersects the frustum
  91864. * @param frustumPlanes defines the frustum to test
  91865. * @returns true if the mesh is in the frustum planes
  91866. */
  91867. isInFrustum(frustumPlanes: Plane[]): boolean;
  91868. /**
  91869. * Sets the mesh material by the material or multiMaterial `id` property
  91870. * @param id is a string identifying the material or the multiMaterial
  91871. * @returns the current mesh
  91872. */
  91873. setMaterialByID(id: string): Mesh;
  91874. /**
  91875. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  91876. * @returns an array of IAnimatable
  91877. */
  91878. getAnimatables(): IAnimatable[];
  91879. /**
  91880. * Modifies the mesh geometry according to the passed transformation matrix.
  91881. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  91882. * The mesh normals are modified using the same transformation.
  91883. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91884. * @param transform defines the transform matrix to use
  91885. * @see http://doc.babylonjs.com/resources/baking_transformations
  91886. * @returns the current mesh
  91887. */
  91888. bakeTransformIntoVertices(transform: Matrix): Mesh;
  91889. /**
  91890. * Modifies the mesh geometry according to its own current World Matrix.
  91891. * The mesh World Matrix is then reset.
  91892. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  91893. * Note that, under the hood, this method sets a new VertexBuffer each call.
  91894. * @see http://doc.babylonjs.com/resources/baking_transformations
  91895. * @returns the current mesh
  91896. */
  91897. bakeCurrentTransformIntoVertices(): Mesh;
  91898. /** @hidden */
  91899. readonly _positions: Nullable<Vector3[]>;
  91900. /** @hidden */
  91901. _resetPointsArrayCache(): Mesh;
  91902. /** @hidden */
  91903. _generatePointsArray(): boolean;
  91904. /**
  91905. * Returns a new Mesh object generated from the current mesh properties.
  91906. * This method must not get confused with createInstance()
  91907. * @param name is a string, the name given to the new mesh
  91908. * @param newParent can be any Node object (default `null`)
  91909. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  91910. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  91911. * @returns a new mesh
  91912. */
  91913. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  91914. /**
  91915. * Releases resources associated with this mesh.
  91916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91918. */
  91919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91920. /** @hidden */
  91921. _disposeInstanceSpecificData(): void;
  91922. /**
  91923. * Modifies the mesh geometry according to a displacement map.
  91924. * 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.
  91925. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91926. * @param url is a string, the URL from the image file is to be downloaded.
  91927. * @param minHeight is the lower limit of the displacement.
  91928. * @param maxHeight is the upper limit of the displacement.
  91929. * @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.
  91930. * @param uvOffset is an optional vector2 used to offset UV.
  91931. * @param uvScale is an optional vector2 used to scale UV.
  91932. * @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.
  91933. * @returns the Mesh.
  91934. */
  91935. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91936. /**
  91937. * Modifies the mesh geometry according to a displacementMap buffer.
  91938. * 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.
  91939. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91940. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91941. * @param heightMapWidth is the width of the buffer image.
  91942. * @param heightMapHeight is the height of the buffer image.
  91943. * @param minHeight is the lower limit of the displacement.
  91944. * @param maxHeight is the upper limit of the displacement.
  91945. * @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.
  91946. * @param uvOffset is an optional vector2 used to offset UV.
  91947. * @param uvScale is an optional vector2 used to scale UV.
  91948. * @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.
  91949. * @returns the Mesh.
  91950. */
  91951. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91952. /**
  91953. * Modify the mesh to get a flat shading rendering.
  91954. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91955. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91956. * @returns current mesh
  91957. */
  91958. convertToFlatShadedMesh(): Mesh;
  91959. /**
  91960. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91961. * In other words, more vertices, no more indices and a single bigger VBO.
  91962. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91963. * @returns current mesh
  91964. */
  91965. convertToUnIndexedMesh(): Mesh;
  91966. /**
  91967. * Inverses facet orientations.
  91968. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91969. * @param flipNormals will also inverts the normals
  91970. * @returns current mesh
  91971. */
  91972. flipFaces(flipNormals?: boolean): Mesh;
  91973. /**
  91974. * Increase the number of facets and hence vertices in a mesh
  91975. * Vertex normals are interpolated from existing vertex normals
  91976. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91977. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91978. */
  91979. increaseVertices(numberPerEdge: number): void;
  91980. /**
  91981. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91982. * This will undo any application of covertToFlatShadedMesh
  91983. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91984. */
  91985. forceSharedVertices(): void;
  91986. /** @hidden */
  91987. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91988. /** @hidden */
  91989. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91990. /**
  91991. * Creates a new InstancedMesh object from the mesh model.
  91992. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91993. * @param name defines the name of the new instance
  91994. * @returns a new InstancedMesh
  91995. */
  91996. createInstance(name: string): InstancedMesh;
  91997. /**
  91998. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91999. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92000. * @returns the current mesh
  92001. */
  92002. synchronizeInstances(): Mesh;
  92003. /**
  92004. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92005. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92006. * This should be used together with the simplification to avoid disappearing triangles.
  92007. * @param successCallback an optional success callback to be called after the optimization finished.
  92008. * @returns the current mesh
  92009. */
  92010. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92011. /**
  92012. * Serialize current mesh
  92013. * @param serializationObject defines the object which will receive the serialization data
  92014. */
  92015. serialize(serializationObject: any): void;
  92016. /** @hidden */
  92017. _syncGeometryWithMorphTargetManager(): void;
  92018. /** @hidden */
  92019. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92020. /**
  92021. * Returns a new Mesh object parsed from the source provided.
  92022. * @param parsedMesh is the source
  92023. * @param scene defines the hosting scene
  92024. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92025. * @returns a new Mesh
  92026. */
  92027. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92028. /**
  92029. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92030. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92031. * @param name defines the name of the mesh to create
  92032. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92033. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92034. * @param closePath creates a seam between the first and the last points of each path of the path array
  92035. * @param offset is taken in account only if the `pathArray` is containing a single path
  92036. * @param scene defines the hosting scene
  92037. * @param updatable defines if the mesh must be flagged as updatable
  92038. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92039. * @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)
  92040. * @returns a new Mesh
  92041. */
  92042. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92043. /**
  92044. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92045. * @param name defines the name of the mesh to create
  92046. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92047. * @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
  92048. * @param scene defines the hosting scene
  92049. * @param updatable defines if the mesh must be flagged as updatable
  92050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92051. * @returns a new Mesh
  92052. */
  92053. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92054. /**
  92055. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92056. * @param name defines the name of the mesh to create
  92057. * @param size sets the size (float) of each box side (default 1)
  92058. * @param scene defines the hosting scene
  92059. * @param updatable defines if the mesh must be flagged as updatable
  92060. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92061. * @returns a new Mesh
  92062. */
  92063. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92064. /**
  92065. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92066. * @param name defines the name of the mesh to create
  92067. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92068. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92069. * @param scene defines the hosting scene
  92070. * @param updatable defines if the mesh must be flagged as updatable
  92071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92072. * @returns a new Mesh
  92073. */
  92074. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92075. /**
  92076. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92077. * @param name defines the name of the mesh to create
  92078. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92079. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92080. * @param scene defines the hosting scene
  92081. * @returns a new Mesh
  92082. */
  92083. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92084. /**
  92085. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  92086. * @param name defines the name of the mesh to create
  92087. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  92088. * @param diameterTop set the top cap diameter (floats, default 1)
  92089. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  92090. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  92091. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  92092. * @param scene defines the hosting scene
  92093. * @param updatable defines if the mesh must be flagged as updatable
  92094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92095. * @returns a new Mesh
  92096. */
  92097. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  92098. /**
  92099. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  92100. * @param name defines the name of the mesh to create
  92101. * @param diameter sets the diameter size (float) of the torus (default 1)
  92102. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  92103. * @param tessellation sets the number of torus sides (postive integer, default 16)
  92104. * @param scene defines the hosting scene
  92105. * @param updatable defines if the mesh must be flagged as updatable
  92106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92107. * @returns a new Mesh
  92108. */
  92109. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92110. /**
  92111. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  92112. * @param name defines the name of the mesh to create
  92113. * @param radius sets the global radius size (float) of the torus knot (default 2)
  92114. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  92115. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  92116. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  92117. * @param p the number of windings on X axis (positive integers, default 2)
  92118. * @param q the number of windings on Y axis (positive integers, default 3)
  92119. * @param scene defines the hosting scene
  92120. * @param updatable defines if the mesh must be flagged as updatable
  92121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92122. * @returns a new Mesh
  92123. */
  92124. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92125. /**
  92126. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  92127. * @param name defines the name of the mesh to create
  92128. * @param points is an array successive Vector3
  92129. * @param scene defines the hosting scene
  92130. * @param updatable defines if the mesh must be flagged as updatable
  92131. * @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).
  92132. * @returns a new Mesh
  92133. */
  92134. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  92135. /**
  92136. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  92137. * @param name defines the name of the mesh to create
  92138. * @param points is an array successive Vector3
  92139. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  92140. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92141. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  92142. * @param scene defines the hosting scene
  92143. * @param updatable defines if the mesh must be flagged as updatable
  92144. * @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)
  92145. * @returns a new Mesh
  92146. */
  92147. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  92148. /**
  92149. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  92150. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  92151. * 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.
  92152. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92153. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92154. * Remember you can only change the shape positions, not their number when updating a polygon.
  92155. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  92156. * @param name defines the name of the mesh to create
  92157. * @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
  92158. * @param scene defines the hosting scene
  92159. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92160. * @param updatable defines if the mesh must be flagged as updatable
  92161. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92162. * @param earcutInjection can be used to inject your own earcut reference
  92163. * @returns a new Mesh
  92164. */
  92165. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92166. /**
  92167. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  92168. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  92169. * @param name defines the name of the mesh to create
  92170. * @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
  92171. * @param depth defines the height of extrusion
  92172. * @param scene defines the hosting scene
  92173. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  92174. * @param updatable defines if the mesh must be flagged as updatable
  92175. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92176. * @param earcutInjection can be used to inject your own earcut reference
  92177. * @returns a new Mesh
  92178. */
  92179. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  92180. /**
  92181. * Creates an extruded shape mesh.
  92182. * 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
  92183. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92184. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92185. * @param name defines the name of the mesh to create
  92186. * @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
  92187. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92188. * @param scale is the value to scale the shape
  92189. * @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
  92190. * @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
  92191. * @param scene defines the hosting scene
  92192. * @param updatable defines if the mesh must be flagged as updatable
  92193. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92194. * @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)
  92195. * @returns a new Mesh
  92196. */
  92197. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92198. /**
  92199. * Creates an custom extruded shape mesh.
  92200. * The custom extrusion is a parametric shape.
  92201. * It has no predefined shape. Its final shape will depend on the input parameters.
  92202. * Please consider using the same method from the MeshBuilder class instead
  92203. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92204. * @param name defines the name of the mesh to create
  92205. * @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
  92206. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  92207. * @param scaleFunction is a custom Javascript function called on each path point
  92208. * @param rotationFunction is a custom Javascript function called on each path point
  92209. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92210. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  92211. * @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
  92212. * @param scene defines the hosting scene
  92213. * @param updatable defines if the mesh must be flagged as updatable
  92214. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92215. * @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)
  92216. * @returns a new Mesh
  92217. */
  92218. 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;
  92219. /**
  92220. * Creates lathe mesh.
  92221. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  92222. * Please consider using the same method from the MeshBuilder class instead
  92223. * @param name defines the name of the mesh to create
  92224. * @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
  92225. * @param radius is the radius value of the lathe
  92226. * @param tessellation is the side number of the lathe.
  92227. * @param scene defines the hosting scene
  92228. * @param updatable defines if the mesh must be flagged as updatable
  92229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92230. * @returns a new Mesh
  92231. */
  92232. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92233. /**
  92234. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  92235. * @param name defines the name of the mesh to create
  92236. * @param size sets the size (float) of both sides of the plane at once (default 1)
  92237. * @param scene defines the hosting scene
  92238. * @param updatable defines if the mesh must be flagged as updatable
  92239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92240. * @returns a new Mesh
  92241. */
  92242. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92243. /**
  92244. * Creates a ground mesh.
  92245. * Please consider using the same method from the MeshBuilder class instead
  92246. * @param name defines the name of the mesh to create
  92247. * @param width set the width of the ground
  92248. * @param height set the height of the ground
  92249. * @param subdivisions sets the number of subdivisions per side
  92250. * @param scene defines the hosting scene
  92251. * @param updatable defines if the mesh must be flagged as updatable
  92252. * @returns a new Mesh
  92253. */
  92254. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  92255. /**
  92256. * Creates a tiled ground mesh.
  92257. * Please consider using the same method from the MeshBuilder class instead
  92258. * @param name defines the name of the mesh to create
  92259. * @param xmin set the ground minimum X coordinate
  92260. * @param zmin set the ground minimum Y coordinate
  92261. * @param xmax set the ground maximum X coordinate
  92262. * @param zmax set the ground maximum Z coordinate
  92263. * @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
  92264. * @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
  92265. * @param scene defines the hosting scene
  92266. * @param updatable defines if the mesh must be flagged as updatable
  92267. * @returns a new Mesh
  92268. */
  92269. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  92270. w: number;
  92271. h: number;
  92272. }, precision: {
  92273. w: number;
  92274. h: number;
  92275. }, scene: Scene, updatable?: boolean): Mesh;
  92276. /**
  92277. * Creates a ground mesh from a height map.
  92278. * Please consider using the same method from the MeshBuilder class instead
  92279. * @see http://doc.babylonjs.com/babylon101/height_map
  92280. * @param name defines the name of the mesh to create
  92281. * @param url sets the URL of the height map image resource
  92282. * @param width set the ground width size
  92283. * @param height set the ground height size
  92284. * @param subdivisions sets the number of subdivision per side
  92285. * @param minHeight is the minimum altitude on the ground
  92286. * @param maxHeight is the maximum altitude on the ground
  92287. * @param scene defines the hosting scene
  92288. * @param updatable defines if the mesh must be flagged as updatable
  92289. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  92290. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92291. * @returns a new Mesh
  92292. */
  92293. 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;
  92294. /**
  92295. * Creates a tube mesh.
  92296. * The tube is a parametric shape.
  92297. * It has no predefined shape. Its final shape will depend on the input parameters.
  92298. * Please consider using the same method from the MeshBuilder class instead
  92299. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92300. * @param name defines the name of the mesh to create
  92301. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  92302. * @param radius sets the tube radius size
  92303. * @param tessellation is the number of sides on the tubular surface
  92304. * @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
  92305. * @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
  92306. * @param scene defines the hosting scene
  92307. * @param updatable defines if the mesh must be flagged as updatable
  92308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92309. * @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)
  92310. * @returns a new Mesh
  92311. */
  92312. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  92313. (i: number, distance: number): number;
  92314. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92315. /**
  92316. * Creates a polyhedron mesh.
  92317. * Please consider using the same method from the MeshBuilder class instead.
  92318. * * 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
  92319. * * The parameter `size` (positive float, default 1) sets the polygon size
  92320. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92321. * * 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`
  92322. * * 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
  92323. * * 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)`)
  92324. * * 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
  92325. * * 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
  92326. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92327. * * If you create a double-sided mesh, you can choose what parts of 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
  92328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92329. * @param name defines the name of the mesh to create
  92330. * @param options defines the options used to create the mesh
  92331. * @param scene defines the hosting scene
  92332. * @returns a new Mesh
  92333. */
  92334. static CreatePolyhedron(name: string, options: {
  92335. type?: number;
  92336. size?: number;
  92337. sizeX?: number;
  92338. sizeY?: number;
  92339. sizeZ?: number;
  92340. custom?: any;
  92341. faceUV?: Vector4[];
  92342. faceColors?: Color4[];
  92343. updatable?: boolean;
  92344. sideOrientation?: number;
  92345. }, scene: Scene): Mesh;
  92346. /**
  92347. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92348. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92349. * * 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`)
  92350. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92351. * * 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
  92352. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92353. * * If you create a double-sided mesh, you can choose what parts of 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
  92354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92355. * @param name defines the name of the mesh
  92356. * @param options defines the options used to create the mesh
  92357. * @param scene defines the hosting scene
  92358. * @returns a new Mesh
  92359. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92360. */
  92361. static CreateIcoSphere(name: string, options: {
  92362. radius?: number;
  92363. flat?: boolean;
  92364. subdivisions?: number;
  92365. sideOrientation?: number;
  92366. updatable?: boolean;
  92367. }, scene: Scene): Mesh;
  92368. /**
  92369. * Creates a decal mesh.
  92370. * Please consider using the same method from the MeshBuilder class instead.
  92371. * A decal is a mesh usually applied as a model onto the surface of another mesh
  92372. * @param name defines the name of the mesh
  92373. * @param sourceMesh defines the mesh receiving the decal
  92374. * @param position sets the position of the decal in world coordinates
  92375. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  92376. * @param size sets the decal scaling
  92377. * @param angle sets the angle to rotate the decal
  92378. * @returns a new Mesh
  92379. */
  92380. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  92381. /**
  92382. * Prepare internal position array for software CPU skinning
  92383. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  92384. */
  92385. setPositionsForCPUSkinning(): Float32Array;
  92386. /**
  92387. * Prepare internal normal array for software CPU skinning
  92388. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  92389. */
  92390. setNormalsForCPUSkinning(): Float32Array;
  92391. /**
  92392. * Updates the vertex buffer by applying transformation from the bones
  92393. * @param skeleton defines the skeleton to apply to current mesh
  92394. * @returns the current mesh
  92395. */
  92396. applySkeleton(skeleton: Skeleton): Mesh;
  92397. /**
  92398. * 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
  92399. * @param meshes defines the list of meshes to scan
  92400. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  92401. */
  92402. static MinMax(meshes: AbstractMesh[]): {
  92403. min: Vector3;
  92404. max: Vector3;
  92405. };
  92406. /**
  92407. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  92408. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  92409. * @returns a vector3
  92410. */
  92411. static Center(meshesOrMinMaxVector: {
  92412. min: Vector3;
  92413. max: Vector3;
  92414. } | AbstractMesh[]): Vector3;
  92415. /**
  92416. * Merge the array of meshes into a single mesh for performance reasons.
  92417. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  92418. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  92419. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  92420. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  92421. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  92422. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  92423. * @returns a new mesh
  92424. */
  92425. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  92426. /** @hidden */
  92427. addInstance(instance: InstancedMesh): void;
  92428. /** @hidden */
  92429. removeInstance(instance: InstancedMesh): void;
  92430. }
  92431. }
  92432. declare module BABYLON {
  92433. /**
  92434. * This is the base class of all the camera used in the application.
  92435. * @see http://doc.babylonjs.com/features/cameras
  92436. */
  92437. export class Camera extends Node {
  92438. /** @hidden */
  92439. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92440. /**
  92441. * This is the default projection mode used by the cameras.
  92442. * It helps recreating a feeling of perspective and better appreciate depth.
  92443. * This is the best way to simulate real life cameras.
  92444. */
  92445. static readonly PERSPECTIVE_CAMERA: number;
  92446. /**
  92447. * This helps creating camera with an orthographic mode.
  92448. * 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.
  92449. */
  92450. static readonly ORTHOGRAPHIC_CAMERA: number;
  92451. /**
  92452. * This is the default FOV mode for perspective cameras.
  92453. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92454. */
  92455. static readonly FOVMODE_VERTICAL_FIXED: number;
  92456. /**
  92457. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92458. */
  92459. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92460. /**
  92461. * This specifies ther is no need for a camera rig.
  92462. * Basically only one eye is rendered corresponding to the camera.
  92463. */
  92464. static readonly RIG_MODE_NONE: number;
  92465. /**
  92466. * Simulates a camera Rig with one blue eye and one red eye.
  92467. * This can be use with 3d blue and red glasses.
  92468. */
  92469. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92470. /**
  92471. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92472. */
  92473. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92474. /**
  92475. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92476. */
  92477. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92478. /**
  92479. * Defines that both eyes of the camera will be rendered over under each other.
  92480. */
  92481. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92482. /**
  92483. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92484. */
  92485. static readonly RIG_MODE_VR: number;
  92486. /**
  92487. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92488. */
  92489. static readonly RIG_MODE_WEBVR: number;
  92490. /**
  92491. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92492. */
  92493. static readonly RIG_MODE_CUSTOM: number;
  92494. /**
  92495. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92496. */
  92497. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92498. /**
  92499. * Define the input manager associated with the camera.
  92500. */
  92501. inputs: CameraInputsManager<Camera>;
  92502. /** @hidden */
  92503. _position: Vector3;
  92504. /**
  92505. * Define the current local position of the camera in the scene
  92506. */
  92507. position: Vector3;
  92508. /**
  92509. * The vector the camera should consider as up.
  92510. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92511. */
  92512. upVector: Vector3;
  92513. /**
  92514. * Define the current limit on the left side for an orthographic camera
  92515. * In scene unit
  92516. */
  92517. orthoLeft: Nullable<number>;
  92518. /**
  92519. * Define the current limit on the right side for an orthographic camera
  92520. * In scene unit
  92521. */
  92522. orthoRight: Nullable<number>;
  92523. /**
  92524. * Define the current limit on the bottom side for an orthographic camera
  92525. * In scene unit
  92526. */
  92527. orthoBottom: Nullable<number>;
  92528. /**
  92529. * Define the current limit on the top side for an orthographic camera
  92530. * In scene unit
  92531. */
  92532. orthoTop: Nullable<number>;
  92533. /**
  92534. * Field Of View is set in Radians. (default is 0.8)
  92535. */
  92536. fov: number;
  92537. /**
  92538. * Define the minimum distance the camera can see from.
  92539. * This is important to note that the depth buffer are not infinite and the closer it starts
  92540. * the more your scene might encounter depth fighting issue.
  92541. */
  92542. minZ: number;
  92543. /**
  92544. * Define the maximum distance the camera can see to.
  92545. * This is important to note that the depth buffer are not infinite and the further it end
  92546. * the more your scene might encounter depth fighting issue.
  92547. */
  92548. maxZ: number;
  92549. /**
  92550. * Define the default inertia of the camera.
  92551. * This helps giving a smooth feeling to the camera movement.
  92552. */
  92553. inertia: number;
  92554. /**
  92555. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  92556. */
  92557. mode: number;
  92558. /**
  92559. * Define wether the camera is intermediate.
  92560. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92561. */
  92562. isIntermediate: boolean;
  92563. /**
  92564. * Define the viewport of the camera.
  92565. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92566. */
  92567. viewport: Viewport;
  92568. /**
  92569. * Restricts the camera to viewing objects with the same layerMask.
  92570. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92571. */
  92572. layerMask: number;
  92573. /**
  92574. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92575. */
  92576. fovMode: number;
  92577. /**
  92578. * Rig mode of the camera.
  92579. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92580. * This is normally controlled byt the camera themselves as internal use.
  92581. */
  92582. cameraRigMode: number;
  92583. /**
  92584. * Defines the distance between both "eyes" in case of a RIG
  92585. */
  92586. interaxialDistance: number;
  92587. /**
  92588. * Defines if stereoscopic rendering is done side by side or over under.
  92589. */
  92590. isStereoscopicSideBySide: boolean;
  92591. /**
  92592. * 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
  92593. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92594. * else in the scene. (Eg. security camera)
  92595. *
  92596. * 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)
  92597. */
  92598. customRenderTargets: RenderTargetTexture[];
  92599. /**
  92600. * When set, the camera will render to this render target instead of the default canvas
  92601. *
  92602. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  92603. */
  92604. outputRenderTarget: Nullable<RenderTargetTexture>;
  92605. /**
  92606. * Observable triggered when the camera view matrix has changed.
  92607. */
  92608. onViewMatrixChangedObservable: Observable<Camera>;
  92609. /**
  92610. * Observable triggered when the camera Projection matrix has changed.
  92611. */
  92612. onProjectionMatrixChangedObservable: Observable<Camera>;
  92613. /**
  92614. * Observable triggered when the inputs have been processed.
  92615. */
  92616. onAfterCheckInputsObservable: Observable<Camera>;
  92617. /**
  92618. * Observable triggered when reset has been called and applied to the camera.
  92619. */
  92620. onRestoreStateObservable: Observable<Camera>;
  92621. /** @hidden */
  92622. _cameraRigParams: any;
  92623. /** @hidden */
  92624. _rigCameras: Camera[];
  92625. /** @hidden */
  92626. _rigPostProcess: Nullable<PostProcess>;
  92627. protected _webvrViewMatrix: Matrix;
  92628. /** @hidden */
  92629. _skipRendering: boolean;
  92630. /** @hidden */
  92631. _projectionMatrix: Matrix;
  92632. /** @hidden */
  92633. _postProcesses: Nullable<PostProcess>[];
  92634. /** @hidden */
  92635. _activeMeshes: SmartArray<AbstractMesh>;
  92636. protected _globalPosition: Vector3;
  92637. /** @hidden */
  92638. _computedViewMatrix: Matrix;
  92639. private _doNotComputeProjectionMatrix;
  92640. private _transformMatrix;
  92641. private _frustumPlanes;
  92642. private _refreshFrustumPlanes;
  92643. private _storedFov;
  92644. private _stateStored;
  92645. /**
  92646. * Instantiates a new camera object.
  92647. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92648. * @see http://doc.babylonjs.com/features/cameras
  92649. * @param name Defines the name of the camera in the scene
  92650. * @param position Defines the position of the camera
  92651. * @param scene Defines the scene the camera belongs too
  92652. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92653. */
  92654. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92655. /**
  92656. * Store current camera state (fov, position, etc..)
  92657. * @returns the camera
  92658. */
  92659. storeState(): Camera;
  92660. /**
  92661. * Restores the camera state values if it has been stored. You must call storeState() first
  92662. */
  92663. protected _restoreStateValues(): boolean;
  92664. /**
  92665. * Restored camera state. You must call storeState() first.
  92666. * @returns true if restored and false otherwise
  92667. */
  92668. restoreState(): boolean;
  92669. /**
  92670. * Gets the class name of the camera.
  92671. * @returns the class name
  92672. */
  92673. getClassName(): string;
  92674. /** @hidden */
  92675. readonly _isCamera: boolean;
  92676. /**
  92677. * Gets a string representation of the camera useful for debug purpose.
  92678. * @param fullDetails Defines that a more verboe level of logging is required
  92679. * @returns the string representation
  92680. */
  92681. toString(fullDetails?: boolean): string;
  92682. /**
  92683. * Gets the current world space position of the camera.
  92684. */
  92685. readonly globalPosition: Vector3;
  92686. /**
  92687. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92688. * @returns the active meshe list
  92689. */
  92690. getActiveMeshes(): SmartArray<AbstractMesh>;
  92691. /**
  92692. * Check wether a mesh is part of the current active mesh list of the camera
  92693. * @param mesh Defines the mesh to check
  92694. * @returns true if active, false otherwise
  92695. */
  92696. isActiveMesh(mesh: Mesh): boolean;
  92697. /**
  92698. * Is this camera ready to be used/rendered
  92699. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92700. * @return true if the camera is ready
  92701. */
  92702. isReady(completeCheck?: boolean): boolean;
  92703. /** @hidden */
  92704. _initCache(): void;
  92705. /** @hidden */
  92706. _updateCache(ignoreParentClass?: boolean): void;
  92707. /** @hidden */
  92708. _isSynchronized(): boolean;
  92709. /** @hidden */
  92710. _isSynchronizedViewMatrix(): boolean;
  92711. /** @hidden */
  92712. _isSynchronizedProjectionMatrix(): boolean;
  92713. /**
  92714. * Attach the input controls to a specific dom element to get the input from.
  92715. * @param element Defines the element the controls should be listened from
  92716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92717. */
  92718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92719. /**
  92720. * Detach the current controls from the specified dom element.
  92721. * @param element Defines the element to stop listening the inputs from
  92722. */
  92723. detachControl(element: HTMLElement): void;
  92724. /**
  92725. * Update the camera state according to the different inputs gathered during the frame.
  92726. */
  92727. update(): void;
  92728. /** @hidden */
  92729. _checkInputs(): void;
  92730. /** @hidden */
  92731. readonly rigCameras: Camera[];
  92732. /**
  92733. * Gets the post process used by the rig cameras
  92734. */
  92735. readonly rigPostProcess: Nullable<PostProcess>;
  92736. /**
  92737. * Internal, gets the first post proces.
  92738. * @returns the first post process to be run on this camera.
  92739. */
  92740. _getFirstPostProcess(): Nullable<PostProcess>;
  92741. private _cascadePostProcessesToRigCams;
  92742. /**
  92743. * Attach a post process to the camera.
  92744. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92745. * @param postProcess The post process to attach to the camera
  92746. * @param insertAt The position of the post process in case several of them are in use in the scene
  92747. * @returns the position the post process has been inserted at
  92748. */
  92749. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92750. /**
  92751. * Detach a post process to the camera.
  92752. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92753. * @param postProcess The post process to detach from the camera
  92754. */
  92755. detachPostProcess(postProcess: PostProcess): void;
  92756. /**
  92757. * Gets the current world matrix of the camera
  92758. */
  92759. getWorldMatrix(): Matrix;
  92760. /** @hidden */
  92761. _getViewMatrix(): Matrix;
  92762. /**
  92763. * Gets the current view matrix of the camera.
  92764. * @param force forces the camera to recompute the matrix without looking at the cached state
  92765. * @returns the view matrix
  92766. */
  92767. getViewMatrix(force?: boolean): Matrix;
  92768. /**
  92769. * Freeze the projection matrix.
  92770. * It will prevent the cache check of the camera projection compute and can speed up perf
  92771. * if no parameter of the camera are meant to change
  92772. * @param projection Defines manually a projection if necessary
  92773. */
  92774. freezeProjectionMatrix(projection?: Matrix): void;
  92775. /**
  92776. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92777. */
  92778. unfreezeProjectionMatrix(): void;
  92779. /**
  92780. * Gets the current projection matrix of the camera.
  92781. * @param force forces the camera to recompute the matrix without looking at the cached state
  92782. * @returns the projection matrix
  92783. */
  92784. getProjectionMatrix(force?: boolean): Matrix;
  92785. /**
  92786. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92787. * @returns a Matrix
  92788. */
  92789. getTransformationMatrix(): Matrix;
  92790. private _updateFrustumPlanes;
  92791. /**
  92792. * Checks if a cullable object (mesh...) is in the camera frustum
  92793. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92794. * @param target The object to check
  92795. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92796. * @returns true if the object is in frustum otherwise false
  92797. */
  92798. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92799. /**
  92800. * Checks if a cullable object (mesh...) is in the camera frustum
  92801. * Unlike isInFrustum this cheks the full bounding box
  92802. * @param target The object to check
  92803. * @returns true if the object is in frustum otherwise false
  92804. */
  92805. isCompletelyInFrustum(target: ICullable): boolean;
  92806. /**
  92807. * Gets a ray in the forward direction from the camera.
  92808. * @param length Defines the length of the ray to create
  92809. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92810. * @param origin Defines the start point of the ray which defaults to the camera position
  92811. * @returns the forward ray
  92812. */
  92813. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92814. /**
  92815. * Releases resources associated with this node.
  92816. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92817. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92818. */
  92819. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92820. /** @hidden */
  92821. _isLeftCamera: boolean;
  92822. /**
  92823. * Gets the left camera of a rig setup in case of Rigged Camera
  92824. */
  92825. readonly isLeftCamera: boolean;
  92826. /** @hidden */
  92827. _isRightCamera: boolean;
  92828. /**
  92829. * Gets the right camera of a rig setup in case of Rigged Camera
  92830. */
  92831. readonly isRightCamera: boolean;
  92832. /**
  92833. * Gets the left camera of a rig setup in case of Rigged Camera
  92834. */
  92835. readonly leftCamera: Nullable<FreeCamera>;
  92836. /**
  92837. * Gets the right camera of a rig setup in case of Rigged Camera
  92838. */
  92839. readonly rightCamera: Nullable<FreeCamera>;
  92840. /**
  92841. * Gets the left camera target of a rig setup in case of Rigged Camera
  92842. * @returns the target position
  92843. */
  92844. getLeftTarget(): Nullable<Vector3>;
  92845. /**
  92846. * Gets the right camera target of a rig setup in case of Rigged Camera
  92847. * @returns the target position
  92848. */
  92849. getRightTarget(): Nullable<Vector3>;
  92850. /**
  92851. * @hidden
  92852. */
  92853. setCameraRigMode(mode: number, rigParams: any): void;
  92854. /** @hidden */
  92855. static _setStereoscopicRigMode(camera: Camera): void;
  92856. /** @hidden */
  92857. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92858. /** @hidden */
  92859. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92860. /** @hidden */
  92861. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92862. /** @hidden */
  92863. _getVRProjectionMatrix(): Matrix;
  92864. protected _updateCameraRotationMatrix(): void;
  92865. protected _updateWebVRCameraRotationMatrix(): void;
  92866. /**
  92867. * This function MUST be overwritten by the different WebVR cameras available.
  92868. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92869. * @hidden
  92870. */
  92871. _getWebVRProjectionMatrix(): Matrix;
  92872. /**
  92873. * This function MUST be overwritten by the different WebVR cameras available.
  92874. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92875. * @hidden
  92876. */
  92877. _getWebVRViewMatrix(): Matrix;
  92878. /** @hidden */
  92879. setCameraRigParameter(name: string, value: any): void;
  92880. /**
  92881. * needs to be overridden by children so sub has required properties to be copied
  92882. * @hidden
  92883. */
  92884. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92885. /**
  92886. * May need to be overridden by children
  92887. * @hidden
  92888. */
  92889. _updateRigCameras(): void;
  92890. /** @hidden */
  92891. _setupInputs(): void;
  92892. /**
  92893. * Serialiaze the camera setup to a json represention
  92894. * @returns the JSON representation
  92895. */
  92896. serialize(): any;
  92897. /**
  92898. * Clones the current camera.
  92899. * @param name The cloned camera name
  92900. * @returns the cloned camera
  92901. */
  92902. clone(name: string): Camera;
  92903. /**
  92904. * Gets the direction of the camera relative to a given local axis.
  92905. * @param localAxis Defines the reference axis to provide a relative direction.
  92906. * @return the direction
  92907. */
  92908. getDirection(localAxis: Vector3): Vector3;
  92909. /**
  92910. * Returns the current camera absolute rotation
  92911. */
  92912. readonly absoluteRotation: Quaternion;
  92913. /**
  92914. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92915. * @param localAxis Defines the reference axis to provide a relative direction.
  92916. * @param result Defines the vector to store the result in
  92917. */
  92918. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92919. /**
  92920. * Gets a camera constructor for a given camera type
  92921. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92922. * @param name The name of the camera the result will be able to instantiate
  92923. * @param scene The scene the result will construct the camera in
  92924. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92925. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92926. * @returns a factory method to construc the camera
  92927. */
  92928. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92929. /**
  92930. * Compute the world matrix of the camera.
  92931. * @returns the camera world matrix
  92932. */
  92933. computeWorldMatrix(): Matrix;
  92934. /**
  92935. * Parse a JSON and creates the camera from the parsed information
  92936. * @param parsedCamera The JSON to parse
  92937. * @param scene The scene to instantiate the camera in
  92938. * @returns the newly constructed camera
  92939. */
  92940. static Parse(parsedCamera: any, scene: Scene): Camera;
  92941. }
  92942. }
  92943. declare module BABYLON {
  92944. /**
  92945. * Class containing static functions to help procedurally build meshes
  92946. */
  92947. export class DiscBuilder {
  92948. /**
  92949. * Creates a plane polygonal mesh. By default, this is a disc
  92950. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92951. * * 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
  92952. * * 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
  92953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92956. * @param name defines the name of the mesh
  92957. * @param options defines the options used to create the mesh
  92958. * @param scene defines the hosting scene
  92959. * @returns the plane polygonal mesh
  92960. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92961. */
  92962. static CreateDisc(name: string, options: {
  92963. radius?: number;
  92964. tessellation?: number;
  92965. arc?: number;
  92966. updatable?: boolean;
  92967. sideOrientation?: number;
  92968. frontUVs?: Vector4;
  92969. backUVs?: Vector4;
  92970. }, scene?: Nullable<Scene>): Mesh;
  92971. }
  92972. }
  92973. declare module BABYLON {
  92974. /**
  92975. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92976. *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.
  92977. * The SPS is also a particle system. It provides some methods to manage the particles.
  92978. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92979. *
  92980. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92981. */
  92982. export class SolidParticleSystem implements IDisposable {
  92983. /**
  92984. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92985. * Example : var p = SPS.particles[i];
  92986. */
  92987. particles: SolidParticle[];
  92988. /**
  92989. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92990. */
  92991. nbParticles: number;
  92992. /**
  92993. * If the particles must ever face the camera (default false). Useful for planar particles.
  92994. */
  92995. billboard: boolean;
  92996. /**
  92997. * Recompute normals when adding a shape
  92998. */
  92999. recomputeNormals: boolean;
  93000. /**
  93001. * This a counter ofr your own usage. It's not set by any SPS functions.
  93002. */
  93003. counter: number;
  93004. /**
  93005. * The SPS name. This name is also given to the underlying mesh.
  93006. */
  93007. name: string;
  93008. /**
  93009. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93010. */
  93011. mesh: Mesh;
  93012. /**
  93013. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93014. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93015. */
  93016. vars: any;
  93017. /**
  93018. * This array is populated when the SPS is set as 'pickable'.
  93019. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93020. * Each element of this array is an object `{idx: int, faceId: int}`.
  93021. * `idx` is the picked particle index in the `SPS.particles` array
  93022. * `faceId` is the picked face index counted within this particle.
  93023. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93024. */
  93025. pickedParticles: {
  93026. idx: number;
  93027. faceId: number;
  93028. }[];
  93029. /**
  93030. * This array is populated when `enableDepthSort` is set to true.
  93031. * Each element of this array is an instance of the class DepthSortedParticle.
  93032. */
  93033. depthSortedParticles: DepthSortedParticle[];
  93034. /**
  93035. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93036. * @hidden
  93037. */
  93038. _bSphereOnly: boolean;
  93039. /**
  93040. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93041. * @hidden
  93042. */
  93043. _bSphereRadiusFactor: number;
  93044. private _scene;
  93045. private _positions;
  93046. private _indices;
  93047. private _normals;
  93048. private _colors;
  93049. private _uvs;
  93050. private _indices32;
  93051. private _positions32;
  93052. private _normals32;
  93053. private _fixedNormal32;
  93054. private _colors32;
  93055. private _uvs32;
  93056. private _index;
  93057. private _updatable;
  93058. private _pickable;
  93059. private _isVisibilityBoxLocked;
  93060. private _alwaysVisible;
  93061. private _depthSort;
  93062. private _expandable;
  93063. private _shapeCounter;
  93064. private _copy;
  93065. private _color;
  93066. private _computeParticleColor;
  93067. private _computeParticleTexture;
  93068. private _computeParticleRotation;
  93069. private _computeParticleVertex;
  93070. private _computeBoundingBox;
  93071. private _depthSortParticles;
  93072. private _camera;
  93073. private _mustUnrotateFixedNormals;
  93074. private _particlesIntersect;
  93075. private _needs32Bits;
  93076. private _isNotBuilt;
  93077. /**
  93078. * Creates a SPS (Solid Particle System) object.
  93079. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93080. * @param scene (Scene) is the scene in which the SPS is added.
  93081. * @param options defines the options of the sps e.g.
  93082. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  93083. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  93084. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  93085. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  93086. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  93087. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  93088. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  93089. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  93090. */
  93091. constructor(name: string, scene: Scene, options?: {
  93092. updatable?: boolean;
  93093. isPickable?: boolean;
  93094. enableDepthSort?: boolean;
  93095. particleIntersection?: boolean;
  93096. boundingSphereOnly?: boolean;
  93097. bSphereRadiusFactor?: number;
  93098. expandable?: boolean;
  93099. });
  93100. /**
  93101. * Builds the SPS underlying mesh. Returns a standard Mesh.
  93102. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  93103. * @returns the created mesh
  93104. */
  93105. buildMesh(): Mesh;
  93106. /**
  93107. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  93108. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  93109. * Thus the particles generated from `digest()` have their property `position` set yet.
  93110. * @param mesh ( Mesh ) is the mesh to be digested
  93111. * @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
  93112. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  93113. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  93114. * @returns the current SPS
  93115. */
  93116. digest(mesh: Mesh, options?: {
  93117. facetNb?: number;
  93118. number?: number;
  93119. delta?: number;
  93120. }): SolidParticleSystem;
  93121. private _unrotateFixedNormals;
  93122. private _resetCopy;
  93123. private _meshBuilder;
  93124. private _posToShape;
  93125. private _uvsToShapeUV;
  93126. private _addParticle;
  93127. /**
  93128. * Adds some particles to the SPS from the model shape. Returns the shape id.
  93129. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  93130. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  93131. * @param nb (positive integer) the number of particles to be created from this model
  93132. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  93133. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  93134. * @returns the number of shapes in the system
  93135. */
  93136. addShape(mesh: Mesh, nb: number, options?: {
  93137. positionFunction?: any;
  93138. vertexFunction?: any;
  93139. }): number;
  93140. private _rebuildParticle;
  93141. /**
  93142. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  93143. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  93144. * @returns the SPS.
  93145. */
  93146. rebuildMesh(reset?: boolean): SolidParticleSystem;
  93147. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  93148. * Returns an array with the removed particles.
  93149. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  93150. * The SPS can't be empty so at least one particle needs to remain in place.
  93151. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  93152. * @param start index of the first particle to remove
  93153. * @param end index of the last particle to remove (included)
  93154. * @returns an array populated with the removed particles
  93155. */
  93156. removeParticles(start: number, end: number): SolidParticle[];
  93157. /**
  93158. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  93159. * This method calls `updateParticle()` for each particle of the SPS.
  93160. * For an animated SPS, it is usually called within the render loop.
  93161. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  93162. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  93163. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  93164. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  93165. * @returns the SPS.
  93166. */
  93167. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  93168. /**
  93169. * Disposes the SPS.
  93170. */
  93171. dispose(): void;
  93172. /**
  93173. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  93174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93175. * @returns the SPS.
  93176. */
  93177. refreshVisibleSize(): SolidParticleSystem;
  93178. /**
  93179. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  93180. * @param size the size (float) of the visibility box
  93181. * note : this doesn't lock the SPS mesh bounding box.
  93182. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93183. */
  93184. setVisibilityBox(size: number): void;
  93185. /**
  93186. * Gets whether the SPS as always visible or not
  93187. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93188. */
  93189. /**
  93190. * Sets the SPS as always visible or not
  93191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93192. */
  93193. isAlwaysVisible: boolean;
  93194. /**
  93195. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93196. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93197. */
  93198. /**
  93199. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  93200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  93201. */
  93202. isVisibilityBoxLocked: boolean;
  93203. /**
  93204. * Tells to `setParticles()` to compute the particle rotations or not.
  93205. * Default value : true. The SPS is faster when it's set to false.
  93206. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93207. */
  93208. /**
  93209. * Gets if `setParticles()` computes the particle rotations or not.
  93210. * Default value : true. The SPS is faster when it's set to false.
  93211. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  93212. */
  93213. computeParticleRotation: boolean;
  93214. /**
  93215. * Tells to `setParticles()` to compute the particle colors or not.
  93216. * Default value : true. The SPS is faster when it's set to false.
  93217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93218. */
  93219. /**
  93220. * Gets if `setParticles()` computes the particle colors or not.
  93221. * Default value : true. The SPS is faster when it's set to false.
  93222. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  93223. */
  93224. computeParticleColor: boolean;
  93225. /**
  93226. * Gets if `setParticles()` computes the particle textures or not.
  93227. * Default value : true. The SPS is faster when it's set to false.
  93228. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  93229. */
  93230. computeParticleTexture: boolean;
  93231. /**
  93232. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  93233. * Default value : false. The SPS is faster when it's set to false.
  93234. * Note : the particle custom vertex positions aren't stored values.
  93235. */
  93236. /**
  93237. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  93238. * Default value : false. The SPS is faster when it's set to false.
  93239. * Note : the particle custom vertex positions aren't stored values.
  93240. */
  93241. computeParticleVertex: boolean;
  93242. /**
  93243. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  93244. */
  93245. /**
  93246. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  93247. */
  93248. computeBoundingBox: boolean;
  93249. /**
  93250. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  93251. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93252. * Default : `true`
  93253. */
  93254. /**
  93255. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  93256. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  93257. * Default : `true`
  93258. */
  93259. depthSortParticles: boolean;
  93260. /**
  93261. * Gets if the SPS is created as expandable at construction time.
  93262. * Default : `false`
  93263. */
  93264. readonly expandable: boolean;
  93265. /**
  93266. * This function does nothing. It may be overwritten to set all the particle first values.
  93267. * The SPS doesn't call this function, you may have to call it by your own.
  93268. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93269. */
  93270. initParticles(): void;
  93271. /**
  93272. * This function does nothing. It may be overwritten to recycle a particle.
  93273. * The SPS doesn't call this function, you may have to call it by your own.
  93274. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93275. * @param particle The particle to recycle
  93276. * @returns the recycled particle
  93277. */
  93278. recycleParticle(particle: SolidParticle): SolidParticle;
  93279. /**
  93280. * Updates a particle : this function should be overwritten by the user.
  93281. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  93282. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  93283. * @example : just set a particle position or velocity and recycle conditions
  93284. * @param particle The particle to update
  93285. * @returns the updated particle
  93286. */
  93287. updateParticle(particle: SolidParticle): SolidParticle;
  93288. /**
  93289. * Updates a vertex of a particle : it can be overwritten by the user.
  93290. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  93291. * @param particle the current particle
  93292. * @param vertex the current index of the current particle
  93293. * @param pt the index of the current vertex in the particle shape
  93294. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  93295. * @example : just set a vertex particle position
  93296. * @returns the updated vertex
  93297. */
  93298. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  93299. /**
  93300. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  93301. * This does nothing and may be overwritten by the user.
  93302. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93303. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93304. * @param update the boolean update value actually passed to setParticles()
  93305. */
  93306. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93307. /**
  93308. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  93309. * This will be passed three parameters.
  93310. * This does nothing and may be overwritten by the user.
  93311. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93312. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  93313. * @param update the boolean update value actually passed to setParticles()
  93314. */
  93315. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  93316. }
  93317. }
  93318. declare module BABYLON {
  93319. /**
  93320. * Represents one particle of a solid particle system.
  93321. */
  93322. export class SolidParticle {
  93323. /**
  93324. * particle global index
  93325. */
  93326. idx: number;
  93327. /**
  93328. * The color of the particle
  93329. */
  93330. color: Nullable<Color4>;
  93331. /**
  93332. * The world space position of the particle.
  93333. */
  93334. position: Vector3;
  93335. /**
  93336. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  93337. */
  93338. rotation: Vector3;
  93339. /**
  93340. * The world space rotation quaternion of the particle.
  93341. */
  93342. rotationQuaternion: Nullable<Quaternion>;
  93343. /**
  93344. * The scaling of the particle.
  93345. */
  93346. scaling: Vector3;
  93347. /**
  93348. * The uvs of the particle.
  93349. */
  93350. uvs: Vector4;
  93351. /**
  93352. * The current speed of the particle.
  93353. */
  93354. velocity: Vector3;
  93355. /**
  93356. * The pivot point in the particle local space.
  93357. */
  93358. pivot: Vector3;
  93359. /**
  93360. * Must the particle be translated from its pivot point in its local space ?
  93361. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  93362. * Default : false
  93363. */
  93364. translateFromPivot: boolean;
  93365. /**
  93366. * Is the particle active or not ?
  93367. */
  93368. alive: boolean;
  93369. /**
  93370. * Is the particle visible or not ?
  93371. */
  93372. isVisible: boolean;
  93373. /**
  93374. * Index of this particle in the global "positions" array (Internal use)
  93375. * @hidden
  93376. */
  93377. _pos: number;
  93378. /**
  93379. * @hidden Index of this particle in the global "indices" array (Internal use)
  93380. */
  93381. _ind: number;
  93382. /**
  93383. * @hidden ModelShape of this particle (Internal use)
  93384. */
  93385. _model: ModelShape;
  93386. /**
  93387. * ModelShape id of this particle
  93388. */
  93389. shapeId: number;
  93390. /**
  93391. * Index of the particle in its shape id
  93392. */
  93393. idxInShape: number;
  93394. /**
  93395. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  93396. */
  93397. _modelBoundingInfo: BoundingInfo;
  93398. /**
  93399. * @hidden Particle BoundingInfo object (Internal use)
  93400. */
  93401. _boundingInfo: BoundingInfo;
  93402. /**
  93403. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  93404. */
  93405. _sps: SolidParticleSystem;
  93406. /**
  93407. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  93408. */
  93409. _stillInvisible: boolean;
  93410. /**
  93411. * @hidden Last computed particle rotation matrix
  93412. */
  93413. _rotationMatrix: number[];
  93414. /**
  93415. * Parent particle Id, if any.
  93416. * Default null.
  93417. */
  93418. parentId: Nullable<number>;
  93419. /**
  93420. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  93421. * The possible values are :
  93422. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93423. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93424. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93425. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93426. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93427. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  93428. * */
  93429. cullingStrategy: number;
  93430. /**
  93431. * @hidden Internal global position in the SPS.
  93432. */
  93433. _globalPosition: Vector3;
  93434. /**
  93435. * Creates a Solid Particle object.
  93436. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  93437. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  93438. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  93439. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  93440. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  93441. * @param shapeId (integer) is the model shape identifier in the SPS.
  93442. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  93443. * @param sps defines the sps it is associated to
  93444. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  93445. */
  93446. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  93447. /**
  93448. * Legacy support, changed scale to scaling
  93449. */
  93450. /**
  93451. * Legacy support, changed scale to scaling
  93452. */
  93453. scale: Vector3;
  93454. /**
  93455. * Legacy support, changed quaternion to rotationQuaternion
  93456. */
  93457. /**
  93458. * Legacy support, changed quaternion to rotationQuaternion
  93459. */
  93460. quaternion: Nullable<Quaternion>;
  93461. /**
  93462. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  93463. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  93464. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  93465. * @returns true if it intersects
  93466. */
  93467. intersectsMesh(target: Mesh | SolidParticle): boolean;
  93468. /**
  93469. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  93470. * A particle is in the frustum if its bounding box intersects the frustum
  93471. * @param frustumPlanes defines the frustum to test
  93472. * @returns true if the particle is in the frustum planes
  93473. */
  93474. isInFrustum(frustumPlanes: Plane[]): boolean;
  93475. /**
  93476. * get the rotation matrix of the particle
  93477. * @hidden
  93478. */
  93479. getRotationMatrix(m: Matrix): void;
  93480. }
  93481. /**
  93482. * Represents the shape of the model used by one particle of a solid particle system.
  93483. * SPS internal tool, don't use it manually.
  93484. */
  93485. export class ModelShape {
  93486. /**
  93487. * The shape id
  93488. * @hidden
  93489. */
  93490. shapeID: number;
  93491. /**
  93492. * flat array of model positions (internal use)
  93493. * @hidden
  93494. */
  93495. _shape: Vector3[];
  93496. /**
  93497. * flat array of model UVs (internal use)
  93498. * @hidden
  93499. */
  93500. _shapeUV: number[];
  93501. /**
  93502. * color array of the model
  93503. * @hidden
  93504. */
  93505. _shapeColors: number[];
  93506. /**
  93507. * indices array of the model
  93508. * @hidden
  93509. */
  93510. _indices: number[];
  93511. /**
  93512. * normals array of the model
  93513. * @hidden
  93514. */
  93515. _normals: number[];
  93516. /**
  93517. * length of the shape in the model indices array (internal use)
  93518. * @hidden
  93519. */
  93520. _indicesLength: number;
  93521. /**
  93522. * Custom position function (internal use)
  93523. * @hidden
  93524. */
  93525. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  93526. /**
  93527. * Custom vertex function (internal use)
  93528. * @hidden
  93529. */
  93530. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  93531. /**
  93532. * 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.
  93533. * SPS internal tool, don't use it manually.
  93534. * @hidden
  93535. */
  93536. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  93537. }
  93538. /**
  93539. * Represents a Depth Sorted Particle in the solid particle system.
  93540. */
  93541. export class DepthSortedParticle {
  93542. /**
  93543. * Index of the particle in the "indices" array
  93544. */
  93545. ind: number;
  93546. /**
  93547. * Length of the particle shape in the "indices" array
  93548. */
  93549. indicesLength: number;
  93550. /**
  93551. * Squared distance from the particle to the camera
  93552. */
  93553. sqDistance: number;
  93554. }
  93555. }
  93556. declare module BABYLON {
  93557. /**
  93558. * @hidden
  93559. */
  93560. export class _MeshCollisionData {
  93561. _checkCollisions: boolean;
  93562. _collisionMask: number;
  93563. _collisionGroup: number;
  93564. _collider: Nullable<Collider>;
  93565. _oldPositionForCollisions: Vector3;
  93566. _diffPositionForCollisions: Vector3;
  93567. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  93568. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  93569. }
  93570. }
  93571. declare module BABYLON {
  93572. /** @hidden */
  93573. class _FacetDataStorage {
  93574. facetPositions: Vector3[];
  93575. facetNormals: Vector3[];
  93576. facetPartitioning: number[][];
  93577. facetNb: number;
  93578. partitioningSubdivisions: number;
  93579. partitioningBBoxRatio: number;
  93580. facetDataEnabled: boolean;
  93581. facetParameters: any;
  93582. bbSize: Vector3;
  93583. subDiv: {
  93584. max: number;
  93585. X: number;
  93586. Y: number;
  93587. Z: number;
  93588. };
  93589. facetDepthSort: boolean;
  93590. facetDepthSortEnabled: boolean;
  93591. depthSortedIndices: IndicesArray;
  93592. depthSortedFacets: {
  93593. ind: number;
  93594. sqDistance: number;
  93595. }[];
  93596. facetDepthSortFunction: (f1: {
  93597. ind: number;
  93598. sqDistance: number;
  93599. }, f2: {
  93600. ind: number;
  93601. sqDistance: number;
  93602. }) => number;
  93603. facetDepthSortFrom: Vector3;
  93604. facetDepthSortOrigin: Vector3;
  93605. invertedMatrix: Matrix;
  93606. }
  93607. /**
  93608. * @hidden
  93609. **/
  93610. class _InternalAbstractMeshDataInfo {
  93611. _hasVertexAlpha: boolean;
  93612. _useVertexColors: boolean;
  93613. _numBoneInfluencers: number;
  93614. _applyFog: boolean;
  93615. _receiveShadows: boolean;
  93616. _facetData: _FacetDataStorage;
  93617. _visibility: number;
  93618. _skeleton: Nullable<Skeleton>;
  93619. _layerMask: number;
  93620. _computeBonesUsingShaders: boolean;
  93621. _isActive: boolean;
  93622. _onlyForInstances: boolean;
  93623. _isActiveIntermediate: boolean;
  93624. _onlyForInstancesIntermediate: boolean;
  93625. _actAsRegularMesh: boolean;
  93626. }
  93627. /**
  93628. * Class used to store all common mesh properties
  93629. */
  93630. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  93631. /** No occlusion */
  93632. static OCCLUSION_TYPE_NONE: number;
  93633. /** Occlusion set to optimisitic */
  93634. static OCCLUSION_TYPE_OPTIMISTIC: number;
  93635. /** Occlusion set to strict */
  93636. static OCCLUSION_TYPE_STRICT: number;
  93637. /** Use an accurante occlusion algorithm */
  93638. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  93639. /** Use a conservative occlusion algorithm */
  93640. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  93641. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  93642. * Test order :
  93643. * Is the bounding sphere outside the frustum ?
  93644. * If not, are the bounding box vertices outside the frustum ?
  93645. * It not, then the cullable object is in the frustum.
  93646. */
  93647. static readonly CULLINGSTRATEGY_STANDARD: number;
  93648. /** Culling strategy : Bounding Sphere Only.
  93649. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  93650. * It's also less accurate than the standard because some not visible objects can still be selected.
  93651. * Test : is the bounding sphere outside the frustum ?
  93652. * If not, then the cullable object is in the frustum.
  93653. */
  93654. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  93655. /** Culling strategy : Optimistic Inclusion.
  93656. * This in an inclusion test first, then the standard exclusion test.
  93657. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  93658. * 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.
  93659. * Anyway, it's as accurate as the standard strategy.
  93660. * Test :
  93661. * Is the cullable object bounding sphere center in the frustum ?
  93662. * If not, apply the default culling strategy.
  93663. */
  93664. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  93665. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  93666. * This in an inclusion test first, then the bounding sphere only exclusion test.
  93667. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  93668. * 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.
  93669. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  93670. * Test :
  93671. * Is the cullable object bounding sphere center in the frustum ?
  93672. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  93673. */
  93674. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  93675. /**
  93676. * No billboard
  93677. */
  93678. static readonly BILLBOARDMODE_NONE: number;
  93679. /** Billboard on X axis */
  93680. static readonly BILLBOARDMODE_X: number;
  93681. /** Billboard on Y axis */
  93682. static readonly BILLBOARDMODE_Y: number;
  93683. /** Billboard on Z axis */
  93684. static readonly BILLBOARDMODE_Z: number;
  93685. /** Billboard on all axes */
  93686. static readonly BILLBOARDMODE_ALL: number;
  93687. /** Billboard on using position instead of orientation */
  93688. static readonly BILLBOARDMODE_USE_POSITION: number;
  93689. /** @hidden */
  93690. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  93691. /**
  93692. * The culling strategy to use to check whether the mesh must be rendered or not.
  93693. * This value can be changed at any time and will be used on the next render mesh selection.
  93694. * The possible values are :
  93695. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  93696. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  93697. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  93698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  93699. * Please read each static variable documentation to get details about the culling process.
  93700. * */
  93701. cullingStrategy: number;
  93702. /**
  93703. * Gets the number of facets in the mesh
  93704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93705. */
  93706. readonly facetNb: number;
  93707. /**
  93708. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  93709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93710. */
  93711. partitioningSubdivisions: number;
  93712. /**
  93713. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  93714. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  93715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  93716. */
  93717. partitioningBBoxRatio: number;
  93718. /**
  93719. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  93720. * Works only for updatable meshes.
  93721. * Doesn't work with multi-materials
  93722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93723. */
  93724. mustDepthSortFacets: boolean;
  93725. /**
  93726. * The location (Vector3) where the facet depth sort must be computed from.
  93727. * By default, the active camera position.
  93728. * Used only when facet depth sort is enabled
  93729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  93730. */
  93731. facetDepthSortFrom: Vector3;
  93732. /**
  93733. * gets a boolean indicating if facetData is enabled
  93734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  93735. */
  93736. readonly isFacetDataEnabled: boolean;
  93737. /** @hidden */
  93738. _updateNonUniformScalingState(value: boolean): boolean;
  93739. /**
  93740. * An event triggered when this mesh collides with another one
  93741. */
  93742. onCollideObservable: Observable<AbstractMesh>;
  93743. /** Set a function to call when this mesh collides with another one */
  93744. onCollide: () => void;
  93745. /**
  93746. * An event triggered when the collision's position changes
  93747. */
  93748. onCollisionPositionChangeObservable: Observable<Vector3>;
  93749. /** Set a function to call when the collision's position changes */
  93750. onCollisionPositionChange: () => void;
  93751. /**
  93752. * An event triggered when material is changed
  93753. */
  93754. onMaterialChangedObservable: Observable<AbstractMesh>;
  93755. /**
  93756. * Gets or sets the orientation for POV movement & rotation
  93757. */
  93758. definedFacingForward: boolean;
  93759. /** @hidden */
  93760. _occlusionQuery: Nullable<WebGLQuery>;
  93761. /** @hidden */
  93762. _renderingGroup: Nullable<RenderingGroup>;
  93763. /**
  93764. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93765. */
  93766. /**
  93767. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  93768. */
  93769. visibility: number;
  93770. /** Gets or sets the alpha index used to sort transparent meshes
  93771. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  93772. */
  93773. alphaIndex: number;
  93774. /**
  93775. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  93776. */
  93777. isVisible: boolean;
  93778. /**
  93779. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  93780. */
  93781. isPickable: boolean;
  93782. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  93783. showSubMeshesBoundingBox: boolean;
  93784. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  93785. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  93786. */
  93787. isBlocker: boolean;
  93788. /**
  93789. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  93790. */
  93791. enablePointerMoveEvents: boolean;
  93792. /**
  93793. * Specifies the rendering group id for this mesh (0 by default)
  93794. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  93795. */
  93796. renderingGroupId: number;
  93797. private _material;
  93798. /** Gets or sets current material */
  93799. material: Nullable<Material>;
  93800. /**
  93801. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  93802. * @see http://doc.babylonjs.com/babylon101/shadows
  93803. */
  93804. receiveShadows: boolean;
  93805. /** Defines color to use when rendering outline */
  93806. outlineColor: Color3;
  93807. /** Define width to use when rendering outline */
  93808. outlineWidth: number;
  93809. /** Defines color to use when rendering overlay */
  93810. overlayColor: Color3;
  93811. /** Defines alpha to use when rendering overlay */
  93812. overlayAlpha: number;
  93813. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  93814. hasVertexAlpha: boolean;
  93815. /** 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) */
  93816. useVertexColors: boolean;
  93817. /**
  93818. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  93819. */
  93820. computeBonesUsingShaders: boolean;
  93821. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  93822. numBoneInfluencers: number;
  93823. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  93824. applyFog: boolean;
  93825. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  93826. useOctreeForRenderingSelection: boolean;
  93827. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  93828. useOctreeForPicking: boolean;
  93829. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  93830. useOctreeForCollisions: boolean;
  93831. /**
  93832. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  93833. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  93834. */
  93835. layerMask: number;
  93836. /**
  93837. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  93838. */
  93839. alwaysSelectAsActiveMesh: boolean;
  93840. /**
  93841. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  93842. */
  93843. doNotSyncBoundingInfo: boolean;
  93844. /**
  93845. * Gets or sets the current action manager
  93846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93847. */
  93848. actionManager: Nullable<AbstractActionManager>;
  93849. private _meshCollisionData;
  93850. /**
  93851. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  93852. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93853. */
  93854. ellipsoid: Vector3;
  93855. /**
  93856. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  93857. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93858. */
  93859. ellipsoidOffset: Vector3;
  93860. /**
  93861. * Gets or sets a collision mask used to mask collisions (default is -1).
  93862. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93863. */
  93864. collisionMask: number;
  93865. /**
  93866. * Gets or sets the current collision group mask (-1 by default).
  93867. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  93868. */
  93869. collisionGroup: number;
  93870. /**
  93871. * Defines edge width used when edgesRenderer is enabled
  93872. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93873. */
  93874. edgesWidth: number;
  93875. /**
  93876. * Defines edge color used when edgesRenderer is enabled
  93877. * @see https://www.babylonjs-playground.com/#10OJSG#13
  93878. */
  93879. edgesColor: Color4;
  93880. /** @hidden */
  93881. _edgesRenderer: Nullable<IEdgesRenderer>;
  93882. /** @hidden */
  93883. _masterMesh: Nullable<AbstractMesh>;
  93884. /** @hidden */
  93885. _boundingInfo: Nullable<BoundingInfo>;
  93886. /** @hidden */
  93887. _renderId: number;
  93888. /**
  93889. * Gets or sets the list of subMeshes
  93890. * @see http://doc.babylonjs.com/how_to/multi_materials
  93891. */
  93892. subMeshes: SubMesh[];
  93893. /** @hidden */
  93894. _intersectionsInProgress: AbstractMesh[];
  93895. /** @hidden */
  93896. _unIndexed: boolean;
  93897. /** @hidden */
  93898. _lightSources: Light[];
  93899. /** Gets the list of lights affecting that mesh */
  93900. readonly lightSources: Light[];
  93901. /** @hidden */
  93902. readonly _positions: Nullable<Vector3[]>;
  93903. /** @hidden */
  93904. _waitingData: {
  93905. lods: Nullable<any>;
  93906. actions: Nullable<any>;
  93907. freezeWorldMatrix: Nullable<boolean>;
  93908. };
  93909. /** @hidden */
  93910. _bonesTransformMatrices: Nullable<Float32Array>;
  93911. /** @hidden */
  93912. _transformMatrixTexture: Nullable<RawTexture>;
  93913. /**
  93914. * Gets or sets a skeleton to apply skining transformations
  93915. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93916. */
  93917. skeleton: Nullable<Skeleton>;
  93918. /**
  93919. * An event triggered when the mesh is rebuilt.
  93920. */
  93921. onRebuildObservable: Observable<AbstractMesh>;
  93922. /**
  93923. * Creates a new AbstractMesh
  93924. * @param name defines the name of the mesh
  93925. * @param scene defines the hosting scene
  93926. */
  93927. constructor(name: string, scene?: Nullable<Scene>);
  93928. /**
  93929. * Returns the string "AbstractMesh"
  93930. * @returns "AbstractMesh"
  93931. */
  93932. getClassName(): string;
  93933. /**
  93934. * Gets a string representation of the current mesh
  93935. * @param fullDetails defines a boolean indicating if full details must be included
  93936. * @returns a string representation of the current mesh
  93937. */
  93938. toString(fullDetails?: boolean): string;
  93939. /**
  93940. * @hidden
  93941. */
  93942. protected _getEffectiveParent(): Nullable<Node>;
  93943. /** @hidden */
  93944. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93945. /** @hidden */
  93946. _rebuild(): void;
  93947. /** @hidden */
  93948. _resyncLightSources(): void;
  93949. /** @hidden */
  93950. _resyncLighSource(light: Light): void;
  93951. /** @hidden */
  93952. _unBindEffect(): void;
  93953. /** @hidden */
  93954. _removeLightSource(light: Light, dispose: boolean): void;
  93955. private _markSubMeshesAsDirty;
  93956. /** @hidden */
  93957. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  93958. /** @hidden */
  93959. _markSubMeshesAsAttributesDirty(): void;
  93960. /** @hidden */
  93961. _markSubMeshesAsMiscDirty(): void;
  93962. /**
  93963. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93964. */
  93965. scaling: Vector3;
  93966. /**
  93967. * Returns true if the mesh is blocked. Implemented by child classes
  93968. */
  93969. readonly isBlocked: boolean;
  93970. /**
  93971. * Returns the mesh itself by default. Implemented by child classes
  93972. * @param camera defines the camera to use to pick the right LOD level
  93973. * @returns the currentAbstractMesh
  93974. */
  93975. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93976. /**
  93977. * Returns 0 by default. Implemented by child classes
  93978. * @returns an integer
  93979. */
  93980. getTotalVertices(): number;
  93981. /**
  93982. * Returns a positive integer : the total number of indices in this mesh geometry.
  93983. * @returns the numner of indices or zero if the mesh has no geometry.
  93984. */
  93985. getTotalIndices(): number;
  93986. /**
  93987. * Returns null by default. Implemented by child classes
  93988. * @returns null
  93989. */
  93990. getIndices(): Nullable<IndicesArray>;
  93991. /**
  93992. * Returns the array of the requested vertex data kind. Implemented by child classes
  93993. * @param kind defines the vertex data kind to use
  93994. * @returns null
  93995. */
  93996. getVerticesData(kind: string): Nullable<FloatArray>;
  93997. /**
  93998. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93999. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94000. * Note that a new underlying VertexBuffer object is created each call.
  94001. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94002. * @param kind defines vertex data kind:
  94003. * * VertexBuffer.PositionKind
  94004. * * VertexBuffer.UVKind
  94005. * * VertexBuffer.UV2Kind
  94006. * * VertexBuffer.UV3Kind
  94007. * * VertexBuffer.UV4Kind
  94008. * * VertexBuffer.UV5Kind
  94009. * * VertexBuffer.UV6Kind
  94010. * * VertexBuffer.ColorKind
  94011. * * VertexBuffer.MatricesIndicesKind
  94012. * * VertexBuffer.MatricesIndicesExtraKind
  94013. * * VertexBuffer.MatricesWeightsKind
  94014. * * VertexBuffer.MatricesWeightsExtraKind
  94015. * @param data defines the data source
  94016. * @param updatable defines if the data must be flagged as updatable (or static)
  94017. * @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
  94018. * @returns the current mesh
  94019. */
  94020. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94021. /**
  94022. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94023. * If the mesh has no geometry, it is simply returned as it is.
  94024. * @param kind defines vertex data kind:
  94025. * * VertexBuffer.PositionKind
  94026. * * VertexBuffer.UVKind
  94027. * * VertexBuffer.UV2Kind
  94028. * * VertexBuffer.UV3Kind
  94029. * * VertexBuffer.UV4Kind
  94030. * * VertexBuffer.UV5Kind
  94031. * * VertexBuffer.UV6Kind
  94032. * * VertexBuffer.ColorKind
  94033. * * VertexBuffer.MatricesIndicesKind
  94034. * * VertexBuffer.MatricesIndicesExtraKind
  94035. * * VertexBuffer.MatricesWeightsKind
  94036. * * VertexBuffer.MatricesWeightsExtraKind
  94037. * @param data defines the data source
  94038. * @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
  94039. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  94040. * @returns the current mesh
  94041. */
  94042. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  94043. /**
  94044. * Sets the mesh indices,
  94045. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94046. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  94047. * @param totalVertices Defines the total number of vertices
  94048. * @returns the current mesh
  94049. */
  94050. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  94051. /**
  94052. * Gets a boolean indicating if specific vertex data is present
  94053. * @param kind defines the vertex data kind to use
  94054. * @returns true is data kind is present
  94055. */
  94056. isVerticesDataPresent(kind: string): boolean;
  94057. /**
  94058. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  94059. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  94060. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  94061. * @returns a BoundingInfo
  94062. */
  94063. getBoundingInfo(): BoundingInfo;
  94064. /**
  94065. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94066. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94067. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94068. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94069. * @returns the current mesh
  94070. */
  94071. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  94072. /**
  94073. * Overwrite the current bounding info
  94074. * @param boundingInfo defines the new bounding info
  94075. * @returns the current mesh
  94076. */
  94077. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  94078. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  94079. readonly useBones: boolean;
  94080. /** @hidden */
  94081. _preActivate(): void;
  94082. /** @hidden */
  94083. _preActivateForIntermediateRendering(renderId: number): void;
  94084. /** @hidden */
  94085. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94086. /** @hidden */
  94087. _postActivate(): void;
  94088. /** @hidden */
  94089. _freeze(): void;
  94090. /** @hidden */
  94091. _unFreeze(): void;
  94092. /**
  94093. * Gets the current world matrix
  94094. * @returns a Matrix
  94095. */
  94096. getWorldMatrix(): Matrix;
  94097. /** @hidden */
  94098. _getWorldMatrixDeterminant(): number;
  94099. /**
  94100. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  94101. */
  94102. readonly isAnInstance: boolean;
  94103. /**
  94104. * Gets a boolean indicating if this mesh has instances
  94105. */
  94106. readonly hasInstances: boolean;
  94107. /**
  94108. * Perform relative position change from the point of view of behind the front of the mesh.
  94109. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94110. * Supports definition of mesh facing forward or backward
  94111. * @param amountRight defines the distance on the right axis
  94112. * @param amountUp defines the distance on the up axis
  94113. * @param amountForward defines the distance on the forward axis
  94114. * @returns the current mesh
  94115. */
  94116. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  94117. /**
  94118. * Calculate relative position change from the point of view of behind the front of the mesh.
  94119. * This is performed taking into account the meshes current rotation, so you do not have to care.
  94120. * Supports definition of mesh facing forward or backward
  94121. * @param amountRight defines the distance on the right axis
  94122. * @param amountUp defines the distance on the up axis
  94123. * @param amountForward defines the distance on the forward axis
  94124. * @returns the new displacement vector
  94125. */
  94126. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  94127. /**
  94128. * Perform relative rotation change from the point of view of behind the front of the mesh.
  94129. * Supports definition of mesh facing forward or backward
  94130. * @param flipBack defines the flip
  94131. * @param twirlClockwise defines the twirl
  94132. * @param tiltRight defines the tilt
  94133. * @returns the current mesh
  94134. */
  94135. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  94136. /**
  94137. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  94138. * Supports definition of mesh facing forward or backward.
  94139. * @param flipBack defines the flip
  94140. * @param twirlClockwise defines the twirl
  94141. * @param tiltRight defines the tilt
  94142. * @returns the new rotation vector
  94143. */
  94144. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  94145. /**
  94146. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94147. * This means the mesh underlying bounding box and sphere are recomputed.
  94148. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94149. * @returns the current mesh
  94150. */
  94151. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  94152. /** @hidden */
  94153. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  94154. /** @hidden */
  94155. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  94156. /** @hidden */
  94157. _updateBoundingInfo(): AbstractMesh;
  94158. /** @hidden */
  94159. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  94160. /** @hidden */
  94161. protected _afterComputeWorldMatrix(): void;
  94162. /** @hidden */
  94163. readonly _effectiveMesh: AbstractMesh;
  94164. /**
  94165. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  94166. * A mesh is in the frustum if its bounding box intersects the frustum
  94167. * @param frustumPlanes defines the frustum to test
  94168. * @returns true if the mesh is in the frustum planes
  94169. */
  94170. isInFrustum(frustumPlanes: Plane[]): boolean;
  94171. /**
  94172. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  94173. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  94174. * @param frustumPlanes defines the frustum to test
  94175. * @returns true if the mesh is completely in the frustum planes
  94176. */
  94177. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94178. /**
  94179. * True if the mesh intersects another mesh or a SolidParticle object
  94180. * @param mesh defines a target mesh or SolidParticle to test
  94181. * @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)
  94182. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  94183. * @returns true if there is an intersection
  94184. */
  94185. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  94186. /**
  94187. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  94188. * @param point defines the point to test
  94189. * @returns true if there is an intersection
  94190. */
  94191. intersectsPoint(point: Vector3): boolean;
  94192. /**
  94193. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  94194. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94195. */
  94196. checkCollisions: boolean;
  94197. /**
  94198. * Gets Collider object used to compute collisions (not physics)
  94199. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94200. */
  94201. readonly collider: Nullable<Collider>;
  94202. /**
  94203. * Move the mesh using collision engine
  94204. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94205. * @param displacement defines the requested displacement vector
  94206. * @returns the current mesh
  94207. */
  94208. moveWithCollisions(displacement: Vector3): AbstractMesh;
  94209. private _onCollisionPositionChange;
  94210. /** @hidden */
  94211. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  94212. /** @hidden */
  94213. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  94214. /** @hidden */
  94215. _checkCollision(collider: Collider): AbstractMesh;
  94216. /** @hidden */
  94217. _generatePointsArray(): boolean;
  94218. /**
  94219. * Checks if the passed Ray intersects with the mesh
  94220. * @param ray defines the ray to use
  94221. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  94222. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94223. * @returns the picking info
  94224. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  94225. */
  94226. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  94227. /**
  94228. * Clones the current mesh
  94229. * @param name defines the mesh name
  94230. * @param newParent defines the new mesh parent
  94231. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  94232. * @returns the new mesh
  94233. */
  94234. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  94235. /**
  94236. * Disposes all the submeshes of the current meshnp
  94237. * @returns the current mesh
  94238. */
  94239. releaseSubMeshes(): AbstractMesh;
  94240. /**
  94241. * Releases resources associated with this abstract mesh.
  94242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94244. */
  94245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94246. /**
  94247. * Adds the passed mesh as a child to the current mesh
  94248. * @param mesh defines the child mesh
  94249. * @returns the current mesh
  94250. */
  94251. addChild(mesh: AbstractMesh): AbstractMesh;
  94252. /**
  94253. * Removes the passed mesh from the current mesh children list
  94254. * @param mesh defines the child mesh
  94255. * @returns the current mesh
  94256. */
  94257. removeChild(mesh: AbstractMesh): AbstractMesh;
  94258. /** @hidden */
  94259. private _initFacetData;
  94260. /**
  94261. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  94262. * This method can be called within the render loop.
  94263. * 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
  94264. * @returns the current mesh
  94265. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94266. */
  94267. updateFacetData(): AbstractMesh;
  94268. /**
  94269. * Returns the facetLocalNormals array.
  94270. * The normals are expressed in the mesh local spac
  94271. * @returns an array of Vector3
  94272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94273. */
  94274. getFacetLocalNormals(): Vector3[];
  94275. /**
  94276. * Returns the facetLocalPositions array.
  94277. * The facet positions are expressed in the mesh local space
  94278. * @returns an array of Vector3
  94279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94280. */
  94281. getFacetLocalPositions(): Vector3[];
  94282. /**
  94283. * Returns the facetLocalPartioning array
  94284. * @returns an array of array of numbers
  94285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94286. */
  94287. getFacetLocalPartitioning(): number[][];
  94288. /**
  94289. * Returns the i-th facet position in the world system.
  94290. * This method allocates a new Vector3 per call
  94291. * @param i defines the facet index
  94292. * @returns a new Vector3
  94293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94294. */
  94295. getFacetPosition(i: number): Vector3;
  94296. /**
  94297. * Sets the reference Vector3 with the i-th facet position in the world system
  94298. * @param i defines the facet index
  94299. * @param ref defines the target vector
  94300. * @returns the current mesh
  94301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94302. */
  94303. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  94304. /**
  94305. * Returns the i-th facet normal in the world system.
  94306. * This method allocates a new Vector3 per call
  94307. * @param i defines the facet index
  94308. * @returns a new Vector3
  94309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94310. */
  94311. getFacetNormal(i: number): Vector3;
  94312. /**
  94313. * Sets the reference Vector3 with the i-th facet normal in the world system
  94314. * @param i defines the facet index
  94315. * @param ref defines the target vector
  94316. * @returns the current mesh
  94317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94318. */
  94319. getFacetNormalToRef(i: number, ref: Vector3): this;
  94320. /**
  94321. * 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)
  94322. * @param x defines x coordinate
  94323. * @param y defines y coordinate
  94324. * @param z defines z coordinate
  94325. * @returns the array of facet indexes
  94326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94327. */
  94328. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  94329. /**
  94330. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  94331. * @param projected sets as the (x,y,z) world projection on the facet
  94332. * @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
  94333. * @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
  94334. * @param x defines x coordinate
  94335. * @param y defines y coordinate
  94336. * @param z defines z coordinate
  94337. * @returns the face index if found (or null instead)
  94338. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94339. */
  94340. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94341. /**
  94342. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  94343. * @param projected sets as the (x,y,z) local projection on the facet
  94344. * @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
  94345. * @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
  94346. * @param x defines x coordinate
  94347. * @param y defines y coordinate
  94348. * @param z defines z coordinate
  94349. * @returns the face index if found (or null instead)
  94350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94351. */
  94352. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  94353. /**
  94354. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  94355. * @returns the parameters
  94356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94357. */
  94358. getFacetDataParameters(): any;
  94359. /**
  94360. * Disables the feature FacetData and frees the related memory
  94361. * @returns the current mesh
  94362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  94363. */
  94364. disableFacetData(): AbstractMesh;
  94365. /**
  94366. * Updates the AbstractMesh indices array
  94367. * @param indices defines the data source
  94368. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  94369. * @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)
  94370. * @returns the current mesh
  94371. */
  94372. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  94373. /**
  94374. * Creates new normals data for the mesh
  94375. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  94376. * @returns the current mesh
  94377. */
  94378. createNormals(updatable: boolean): AbstractMesh;
  94379. /**
  94380. * Align the mesh with a normal
  94381. * @param normal defines the normal to use
  94382. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  94383. * @returns the current mesh
  94384. */
  94385. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  94386. /** @hidden */
  94387. _checkOcclusionQuery(): boolean;
  94388. /**
  94389. * Disables the mesh edge rendering mode
  94390. * @returns the currentAbstractMesh
  94391. */
  94392. disableEdgesRendering(): AbstractMesh;
  94393. /**
  94394. * Enables the edge rendering mode on the mesh.
  94395. * This mode makes the mesh edges visible
  94396. * @param epsilon defines the maximal distance between two angles to detect a face
  94397. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94398. * @returns the currentAbstractMesh
  94399. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94400. */
  94401. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94402. }
  94403. }
  94404. declare module BABYLON {
  94405. /**
  94406. * Interface used to define ActionEvent
  94407. */
  94408. export interface IActionEvent {
  94409. /** The mesh or sprite that triggered the action */
  94410. source: any;
  94411. /** The X mouse cursor position at the time of the event */
  94412. pointerX: number;
  94413. /** The Y mouse cursor position at the time of the event */
  94414. pointerY: number;
  94415. /** The mesh that is currently pointed at (can be null) */
  94416. meshUnderPointer: Nullable<AbstractMesh>;
  94417. /** the original (browser) event that triggered the ActionEvent */
  94418. sourceEvent?: any;
  94419. /** additional data for the event */
  94420. additionalData?: any;
  94421. }
  94422. /**
  94423. * ActionEvent is the event being sent when an action is triggered.
  94424. */
  94425. export class ActionEvent implements IActionEvent {
  94426. /** The mesh or sprite that triggered the action */
  94427. source: any;
  94428. /** The X mouse cursor position at the time of the event */
  94429. pointerX: number;
  94430. /** The Y mouse cursor position at the time of the event */
  94431. pointerY: number;
  94432. /** The mesh that is currently pointed at (can be null) */
  94433. meshUnderPointer: Nullable<AbstractMesh>;
  94434. /** the original (browser) event that triggered the ActionEvent */
  94435. sourceEvent?: any;
  94436. /** additional data for the event */
  94437. additionalData?: any;
  94438. /**
  94439. * Creates a new ActionEvent
  94440. * @param source The mesh or sprite that triggered the action
  94441. * @param pointerX The X mouse cursor position at the time of the event
  94442. * @param pointerY The Y mouse cursor position at the time of the event
  94443. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  94444. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  94445. * @param additionalData additional data for the event
  94446. */
  94447. constructor(
  94448. /** The mesh or sprite that triggered the action */
  94449. source: any,
  94450. /** The X mouse cursor position at the time of the event */
  94451. pointerX: number,
  94452. /** The Y mouse cursor position at the time of the event */
  94453. pointerY: number,
  94454. /** The mesh that is currently pointed at (can be null) */
  94455. meshUnderPointer: Nullable<AbstractMesh>,
  94456. /** the original (browser) event that triggered the ActionEvent */
  94457. sourceEvent?: any,
  94458. /** additional data for the event */
  94459. additionalData?: any);
  94460. /**
  94461. * Helper function to auto-create an ActionEvent from a source mesh.
  94462. * @param source The source mesh that triggered the event
  94463. * @param evt The original (browser) event
  94464. * @param additionalData additional data for the event
  94465. * @returns the new ActionEvent
  94466. */
  94467. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  94468. /**
  94469. * Helper function to auto-create an ActionEvent from a source sprite
  94470. * @param source The source sprite that triggered the event
  94471. * @param scene Scene associated with the sprite
  94472. * @param evt The original (browser) event
  94473. * @param additionalData additional data for the event
  94474. * @returns the new ActionEvent
  94475. */
  94476. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  94477. /**
  94478. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  94479. * @param scene the scene where the event occurred
  94480. * @param evt The original (browser) event
  94481. * @returns the new ActionEvent
  94482. */
  94483. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  94484. /**
  94485. * Helper function to auto-create an ActionEvent from a primitive
  94486. * @param prim defines the target primitive
  94487. * @param pointerPos defines the pointer position
  94488. * @param evt The original (browser) event
  94489. * @param additionalData additional data for the event
  94490. * @returns the new ActionEvent
  94491. */
  94492. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  94493. }
  94494. }
  94495. declare module BABYLON {
  94496. /**
  94497. * Abstract class used to decouple action Manager from scene and meshes.
  94498. * Do not instantiate.
  94499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94500. */
  94501. export abstract class AbstractActionManager implements IDisposable {
  94502. /** Gets the list of active triggers */
  94503. static Triggers: {
  94504. [key: string]: number;
  94505. };
  94506. /** Gets the cursor to use when hovering items */
  94507. hoverCursor: string;
  94508. /** Gets the list of actions */
  94509. actions: IAction[];
  94510. /**
  94511. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  94512. */
  94513. isRecursive: boolean;
  94514. /**
  94515. * Releases all associated resources
  94516. */
  94517. abstract dispose(): void;
  94518. /**
  94519. * Does this action manager has pointer triggers
  94520. */
  94521. abstract readonly hasPointerTriggers: boolean;
  94522. /**
  94523. * Does this action manager has pick triggers
  94524. */
  94525. abstract readonly hasPickTriggers: boolean;
  94526. /**
  94527. * Process a specific trigger
  94528. * @param trigger defines the trigger to process
  94529. * @param evt defines the event details to be processed
  94530. */
  94531. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  94532. /**
  94533. * Does this action manager handles actions of any of the given triggers
  94534. * @param triggers defines the triggers to be tested
  94535. * @return a boolean indicating whether one (or more) of the triggers is handled
  94536. */
  94537. abstract hasSpecificTriggers(triggers: number[]): boolean;
  94538. /**
  94539. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  94540. * speed.
  94541. * @param triggerA defines the trigger to be tested
  94542. * @param triggerB defines the trigger to be tested
  94543. * @return a boolean indicating whether one (or more) of the triggers is handled
  94544. */
  94545. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  94546. /**
  94547. * Does this action manager handles actions of a given trigger
  94548. * @param trigger defines the trigger to be tested
  94549. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  94550. * @return whether the trigger is handled
  94551. */
  94552. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  94553. /**
  94554. * Serialize this manager to a JSON object
  94555. * @param name defines the property name to store this manager
  94556. * @returns a JSON representation of this manager
  94557. */
  94558. abstract serialize(name: string): any;
  94559. /**
  94560. * Registers an action to this action manager
  94561. * @param action defines the action to be registered
  94562. * @return the action amended (prepared) after registration
  94563. */
  94564. abstract registerAction(action: IAction): Nullable<IAction>;
  94565. /**
  94566. * Unregisters an action to this action manager
  94567. * @param action defines the action to be unregistered
  94568. * @return a boolean indicating whether the action has been unregistered
  94569. */
  94570. abstract unregisterAction(action: IAction): Boolean;
  94571. /**
  94572. * Does exist one action manager with at least one trigger
  94573. **/
  94574. static readonly HasTriggers: boolean;
  94575. /**
  94576. * Does exist one action manager with at least one pick trigger
  94577. **/
  94578. static readonly HasPickTriggers: boolean;
  94579. /**
  94580. * Does exist one action manager that handles actions of a given trigger
  94581. * @param trigger defines the trigger to be tested
  94582. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  94583. **/
  94584. static HasSpecificTrigger(trigger: number): boolean;
  94585. }
  94586. }
  94587. declare module BABYLON {
  94588. /**
  94589. * Defines how a node can be built from a string name.
  94590. */
  94591. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  94592. /**
  94593. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  94594. */
  94595. export class Node implements IBehaviorAware<Node> {
  94596. /** @hidden */
  94597. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  94598. private static _NodeConstructors;
  94599. /**
  94600. * Add a new node constructor
  94601. * @param type defines the type name of the node to construct
  94602. * @param constructorFunc defines the constructor function
  94603. */
  94604. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  94605. /**
  94606. * Returns a node constructor based on type name
  94607. * @param type defines the type name
  94608. * @param name defines the new node name
  94609. * @param scene defines the hosting scene
  94610. * @param options defines optional options to transmit to constructors
  94611. * @returns the new constructor or null
  94612. */
  94613. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  94614. /**
  94615. * Gets or sets the name of the node
  94616. */
  94617. name: string;
  94618. /**
  94619. * Gets or sets the id of the node
  94620. */
  94621. id: string;
  94622. /**
  94623. * Gets or sets the unique id of the node
  94624. */
  94625. uniqueId: number;
  94626. /**
  94627. * Gets or sets a string used to store user defined state for the node
  94628. */
  94629. state: string;
  94630. /**
  94631. * Gets or sets an object used to store user defined information for the node
  94632. */
  94633. metadata: any;
  94634. /**
  94635. * For internal use only. Please do not use.
  94636. */
  94637. reservedDataStore: any;
  94638. /**
  94639. * List of inspectable custom properties (used by the Inspector)
  94640. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94641. */
  94642. inspectableCustomProperties: IInspectable[];
  94643. private _doNotSerialize;
  94644. /**
  94645. * Gets or sets a boolean used to define if the node must be serialized
  94646. */
  94647. doNotSerialize: boolean;
  94648. /** @hidden */
  94649. _isDisposed: boolean;
  94650. /**
  94651. * Gets a list of Animations associated with the node
  94652. */
  94653. animations: Animation[];
  94654. protected _ranges: {
  94655. [name: string]: Nullable<AnimationRange>;
  94656. };
  94657. /**
  94658. * Callback raised when the node is ready to be used
  94659. */
  94660. onReady: Nullable<(node: Node) => void>;
  94661. private _isEnabled;
  94662. private _isParentEnabled;
  94663. private _isReady;
  94664. /** @hidden */
  94665. _currentRenderId: number;
  94666. private _parentUpdateId;
  94667. /** @hidden */
  94668. _childUpdateId: number;
  94669. /** @hidden */
  94670. _waitingParentId: Nullable<string>;
  94671. /** @hidden */
  94672. _scene: Scene;
  94673. /** @hidden */
  94674. _cache: any;
  94675. private _parentNode;
  94676. private _children;
  94677. /** @hidden */
  94678. _worldMatrix: Matrix;
  94679. /** @hidden */
  94680. _worldMatrixDeterminant: number;
  94681. /** @hidden */
  94682. _worldMatrixDeterminantIsDirty: boolean;
  94683. /** @hidden */
  94684. private _sceneRootNodesIndex;
  94685. /**
  94686. * Gets a boolean indicating if the node has been disposed
  94687. * @returns true if the node was disposed
  94688. */
  94689. isDisposed(): boolean;
  94690. /**
  94691. * Gets or sets the parent of the node (without keeping the current position in the scene)
  94692. * @see https://doc.babylonjs.com/how_to/parenting
  94693. */
  94694. parent: Nullable<Node>;
  94695. private addToSceneRootNodes;
  94696. private removeFromSceneRootNodes;
  94697. private _animationPropertiesOverride;
  94698. /**
  94699. * Gets or sets the animation properties override
  94700. */
  94701. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94702. /**
  94703. * Gets a string idenfifying the name of the class
  94704. * @returns "Node" string
  94705. */
  94706. getClassName(): string;
  94707. /** @hidden */
  94708. readonly _isNode: boolean;
  94709. /**
  94710. * An event triggered when the mesh is disposed
  94711. */
  94712. onDisposeObservable: Observable<Node>;
  94713. private _onDisposeObserver;
  94714. /**
  94715. * Sets a callback that will be raised when the node will be disposed
  94716. */
  94717. onDispose: () => void;
  94718. /**
  94719. * Creates a new Node
  94720. * @param name the name and id to be given to this node
  94721. * @param scene the scene this node will be added to
  94722. * @param addToRootNodes the node will be added to scene.rootNodes
  94723. */
  94724. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  94725. /**
  94726. * Gets the scene of the node
  94727. * @returns a scene
  94728. */
  94729. getScene(): Scene;
  94730. /**
  94731. * Gets the engine of the node
  94732. * @returns a Engine
  94733. */
  94734. getEngine(): Engine;
  94735. private _behaviors;
  94736. /**
  94737. * Attach a behavior to the node
  94738. * @see http://doc.babylonjs.com/features/behaviour
  94739. * @param behavior defines the behavior to attach
  94740. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  94741. * @returns the current Node
  94742. */
  94743. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  94744. /**
  94745. * Remove an attached behavior
  94746. * @see http://doc.babylonjs.com/features/behaviour
  94747. * @param behavior defines the behavior to attach
  94748. * @returns the current Node
  94749. */
  94750. removeBehavior(behavior: Behavior<Node>): Node;
  94751. /**
  94752. * Gets the list of attached behaviors
  94753. * @see http://doc.babylonjs.com/features/behaviour
  94754. */
  94755. readonly behaviors: Behavior<Node>[];
  94756. /**
  94757. * Gets an attached behavior by name
  94758. * @param name defines the name of the behavior to look for
  94759. * @see http://doc.babylonjs.com/features/behaviour
  94760. * @returns null if behavior was not found else the requested behavior
  94761. */
  94762. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  94763. /**
  94764. * Returns the latest update of the World matrix
  94765. * @returns a Matrix
  94766. */
  94767. getWorldMatrix(): Matrix;
  94768. /** @hidden */
  94769. _getWorldMatrixDeterminant(): number;
  94770. /**
  94771. * Returns directly the latest state of the mesh World matrix.
  94772. * A Matrix is returned.
  94773. */
  94774. readonly worldMatrixFromCache: Matrix;
  94775. /** @hidden */
  94776. _initCache(): void;
  94777. /** @hidden */
  94778. updateCache(force?: boolean): void;
  94779. /** @hidden */
  94780. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94781. /** @hidden */
  94782. _updateCache(ignoreParentClass?: boolean): void;
  94783. /** @hidden */
  94784. _isSynchronized(): boolean;
  94785. /** @hidden */
  94786. _markSyncedWithParent(): void;
  94787. /** @hidden */
  94788. isSynchronizedWithParent(): boolean;
  94789. /** @hidden */
  94790. isSynchronized(): boolean;
  94791. /**
  94792. * Is this node ready to be used/rendered
  94793. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94794. * @return true if the node is ready
  94795. */
  94796. isReady(completeCheck?: boolean): boolean;
  94797. /**
  94798. * Is this node enabled?
  94799. * 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
  94800. * @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
  94801. * @return whether this node (and its parent) is enabled
  94802. */
  94803. isEnabled(checkAncestors?: boolean): boolean;
  94804. /** @hidden */
  94805. protected _syncParentEnabledState(): void;
  94806. /**
  94807. * Set the enabled state of this node
  94808. * @param value defines the new enabled state
  94809. */
  94810. setEnabled(value: boolean): void;
  94811. /**
  94812. * Is this node a descendant of the given node?
  94813. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  94814. * @param ancestor defines the parent node to inspect
  94815. * @returns a boolean indicating if this node is a descendant of the given node
  94816. */
  94817. isDescendantOf(ancestor: Node): boolean;
  94818. /** @hidden */
  94819. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  94820. /**
  94821. * Will return all nodes that have this node as ascendant
  94822. * @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
  94823. * @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
  94824. * @return all children nodes of all types
  94825. */
  94826. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  94827. /**
  94828. * Get all child-meshes of this node
  94829. * @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)
  94830. * @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
  94831. * @returns an array of AbstractMesh
  94832. */
  94833. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  94834. /**
  94835. * Get all direct children of this node
  94836. * @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
  94837. * @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)
  94838. * @returns an array of Node
  94839. */
  94840. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  94841. /** @hidden */
  94842. _setReady(state: boolean): void;
  94843. /**
  94844. * Get an animation by name
  94845. * @param name defines the name of the animation to look for
  94846. * @returns null if not found else the requested animation
  94847. */
  94848. getAnimationByName(name: string): Nullable<Animation>;
  94849. /**
  94850. * Creates an animation range for this node
  94851. * @param name defines the name of the range
  94852. * @param from defines the starting key
  94853. * @param to defines the end key
  94854. */
  94855. createAnimationRange(name: string, from: number, to: number): void;
  94856. /**
  94857. * Delete a specific animation range
  94858. * @param name defines the name of the range to delete
  94859. * @param deleteFrames defines if animation frames from the range must be deleted as well
  94860. */
  94861. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94862. /**
  94863. * Get an animation range by name
  94864. * @param name defines the name of the animation range to look for
  94865. * @returns null if not found else the requested animation range
  94866. */
  94867. getAnimationRange(name: string): Nullable<AnimationRange>;
  94868. /**
  94869. * Gets the list of all animation ranges defined on this node
  94870. * @returns an array
  94871. */
  94872. getAnimationRanges(): Nullable<AnimationRange>[];
  94873. /**
  94874. * Will start the animation sequence
  94875. * @param name defines the range frames for animation sequence
  94876. * @param loop defines if the animation should loop (false by default)
  94877. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  94878. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  94879. * @returns the object created for this animation. If range does not exist, it will return null
  94880. */
  94881. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94882. /**
  94883. * Serialize animation ranges into a JSON compatible object
  94884. * @returns serialization object
  94885. */
  94886. serializeAnimationRanges(): any;
  94887. /**
  94888. * Computes the world matrix of the node
  94889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94890. * @returns the world matrix
  94891. */
  94892. computeWorldMatrix(force?: boolean): Matrix;
  94893. /**
  94894. * Releases resources associated with this node.
  94895. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94896. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94897. */
  94898. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94899. /**
  94900. * Parse animation range data from a serialization object and store them into a given node
  94901. * @param node defines where to store the animation ranges
  94902. * @param parsedNode defines the serialization object to read data from
  94903. * @param scene defines the hosting scene
  94904. */
  94905. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  94906. /**
  94907. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  94908. * @param includeDescendants Include bounding info from descendants as well (true by default)
  94909. * @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
  94910. * @returns the new bounding vectors
  94911. */
  94912. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  94913. min: Vector3;
  94914. max: Vector3;
  94915. };
  94916. }
  94917. }
  94918. declare module BABYLON {
  94919. /**
  94920. * @hidden
  94921. */
  94922. export class _IAnimationState {
  94923. key: number;
  94924. repeatCount: number;
  94925. workValue?: any;
  94926. loopMode?: number;
  94927. offsetValue?: any;
  94928. highLimitValue?: any;
  94929. }
  94930. /**
  94931. * Class used to store any kind of animation
  94932. */
  94933. export class Animation {
  94934. /**Name of the animation */
  94935. name: string;
  94936. /**Property to animate */
  94937. targetProperty: string;
  94938. /**The frames per second of the animation */
  94939. framePerSecond: number;
  94940. /**The data type of the animation */
  94941. dataType: number;
  94942. /**The loop mode of the animation */
  94943. loopMode?: number | undefined;
  94944. /**Specifies if blending should be enabled */
  94945. enableBlending?: boolean | undefined;
  94946. /**
  94947. * Use matrix interpolation instead of using direct key value when animating matrices
  94948. */
  94949. static AllowMatricesInterpolation: boolean;
  94950. /**
  94951. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  94952. */
  94953. static AllowMatrixDecomposeForInterpolation: boolean;
  94954. /**
  94955. * Stores the key frames of the animation
  94956. */
  94957. private _keys;
  94958. /**
  94959. * Stores the easing function of the animation
  94960. */
  94961. private _easingFunction;
  94962. /**
  94963. * @hidden Internal use only
  94964. */
  94965. _runtimeAnimations: RuntimeAnimation[];
  94966. /**
  94967. * The set of event that will be linked to this animation
  94968. */
  94969. private _events;
  94970. /**
  94971. * Stores an array of target property paths
  94972. */
  94973. targetPropertyPath: string[];
  94974. /**
  94975. * Stores the blending speed of the animation
  94976. */
  94977. blendingSpeed: number;
  94978. /**
  94979. * Stores the animation ranges for the animation
  94980. */
  94981. private _ranges;
  94982. /**
  94983. * @hidden Internal use
  94984. */
  94985. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94986. /**
  94987. * Sets up an animation
  94988. * @param property The property to animate
  94989. * @param animationType The animation type to apply
  94990. * @param framePerSecond The frames per second of the animation
  94991. * @param easingFunction The easing function used in the animation
  94992. * @returns The created animation
  94993. */
  94994. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94995. /**
  94996. * Create and start an animation on a node
  94997. * @param name defines the name of the global animation that will be run on all nodes
  94998. * @param node defines the root node where the animation will take place
  94999. * @param targetProperty defines property to animate
  95000. * @param framePerSecond defines the number of frame per second yo use
  95001. * @param totalFrame defines the number of frames in total
  95002. * @param from defines the initial value
  95003. * @param to defines the final value
  95004. * @param loopMode defines which loop mode you want to use (off by default)
  95005. * @param easingFunction defines the easing function to use (linear by default)
  95006. * @param onAnimationEnd defines the callback to call when animation end
  95007. * @returns the animatable created for this animation
  95008. */
  95009. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95010. /**
  95011. * Create and start an animation on a node and its descendants
  95012. * @param name defines the name of the global animation that will be run on all nodes
  95013. * @param node defines the root node where the animation will take place
  95014. * @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
  95015. * @param targetProperty defines property to animate
  95016. * @param framePerSecond defines the number of frame per second to use
  95017. * @param totalFrame defines the number of frames in total
  95018. * @param from defines the initial value
  95019. * @param to defines the final value
  95020. * @param loopMode defines which loop mode you want to use (off by default)
  95021. * @param easingFunction defines the easing function to use (linear by default)
  95022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95023. * @returns the list of animatables created for all nodes
  95024. * @example https://www.babylonjs-playground.com/#MH0VLI
  95025. */
  95026. 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[]>;
  95027. /**
  95028. * Creates a new animation, merges it with the existing animations and starts it
  95029. * @param name Name of the animation
  95030. * @param node Node which contains the scene that begins the animations
  95031. * @param targetProperty Specifies which property to animate
  95032. * @param framePerSecond The frames per second of the animation
  95033. * @param totalFrame The total number of frames
  95034. * @param from The frame at the beginning of the animation
  95035. * @param to The frame at the end of the animation
  95036. * @param loopMode Specifies the loop mode of the animation
  95037. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  95038. * @param onAnimationEnd Callback to run once the animation is complete
  95039. * @returns Nullable animation
  95040. */
  95041. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  95042. /**
  95043. * Transition property of an host to the target Value
  95044. * @param property The property to transition
  95045. * @param targetValue The target Value of the property
  95046. * @param host The object where the property to animate belongs
  95047. * @param scene Scene used to run the animation
  95048. * @param frameRate Framerate (in frame/s) to use
  95049. * @param transition The transition type we want to use
  95050. * @param duration The duration of the animation, in milliseconds
  95051. * @param onAnimationEnd Callback trigger at the end of the animation
  95052. * @returns Nullable animation
  95053. */
  95054. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  95055. /**
  95056. * Return the array of runtime animations currently using this animation
  95057. */
  95058. readonly runtimeAnimations: RuntimeAnimation[];
  95059. /**
  95060. * Specifies if any of the runtime animations are currently running
  95061. */
  95062. readonly hasRunningRuntimeAnimations: boolean;
  95063. /**
  95064. * Initializes the animation
  95065. * @param name Name of the animation
  95066. * @param targetProperty Property to animate
  95067. * @param framePerSecond The frames per second of the animation
  95068. * @param dataType The data type of the animation
  95069. * @param loopMode The loop mode of the animation
  95070. * @param enableBlending Specifies if blending should be enabled
  95071. */
  95072. constructor(
  95073. /**Name of the animation */
  95074. name: string,
  95075. /**Property to animate */
  95076. targetProperty: string,
  95077. /**The frames per second of the animation */
  95078. framePerSecond: number,
  95079. /**The data type of the animation */
  95080. dataType: number,
  95081. /**The loop mode of the animation */
  95082. loopMode?: number | undefined,
  95083. /**Specifies if blending should be enabled */
  95084. enableBlending?: boolean | undefined);
  95085. /**
  95086. * Converts the animation to a string
  95087. * @param fullDetails support for multiple levels of logging within scene loading
  95088. * @returns String form of the animation
  95089. */
  95090. toString(fullDetails?: boolean): string;
  95091. /**
  95092. * Add an event to this animation
  95093. * @param event Event to add
  95094. */
  95095. addEvent(event: AnimationEvent): void;
  95096. /**
  95097. * Remove all events found at the given frame
  95098. * @param frame The frame to remove events from
  95099. */
  95100. removeEvents(frame: number): void;
  95101. /**
  95102. * Retrieves all the events from the animation
  95103. * @returns Events from the animation
  95104. */
  95105. getEvents(): AnimationEvent[];
  95106. /**
  95107. * Creates an animation range
  95108. * @param name Name of the animation range
  95109. * @param from Starting frame of the animation range
  95110. * @param to Ending frame of the animation
  95111. */
  95112. createRange(name: string, from: number, to: number): void;
  95113. /**
  95114. * Deletes an animation range by name
  95115. * @param name Name of the animation range to delete
  95116. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  95117. */
  95118. deleteRange(name: string, deleteFrames?: boolean): void;
  95119. /**
  95120. * Gets the animation range by name, or null if not defined
  95121. * @param name Name of the animation range
  95122. * @returns Nullable animation range
  95123. */
  95124. getRange(name: string): Nullable<AnimationRange>;
  95125. /**
  95126. * Gets the key frames from the animation
  95127. * @returns The key frames of the animation
  95128. */
  95129. getKeys(): Array<IAnimationKey>;
  95130. /**
  95131. * Gets the highest frame rate of the animation
  95132. * @returns Highest frame rate of the animation
  95133. */
  95134. getHighestFrame(): number;
  95135. /**
  95136. * Gets the easing function of the animation
  95137. * @returns Easing function of the animation
  95138. */
  95139. getEasingFunction(): IEasingFunction;
  95140. /**
  95141. * Sets the easing function of the animation
  95142. * @param easingFunction A custom mathematical formula for animation
  95143. */
  95144. setEasingFunction(easingFunction: EasingFunction): void;
  95145. /**
  95146. * Interpolates a scalar linearly
  95147. * @param startValue Start value of the animation curve
  95148. * @param endValue End value of the animation curve
  95149. * @param gradient Scalar amount to interpolate
  95150. * @returns Interpolated scalar value
  95151. */
  95152. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  95153. /**
  95154. * Interpolates a scalar cubically
  95155. * @param startValue Start value of the animation curve
  95156. * @param outTangent End tangent of the animation
  95157. * @param endValue End value of the animation curve
  95158. * @param inTangent Start tangent of the animation curve
  95159. * @param gradient Scalar amount to interpolate
  95160. * @returns Interpolated scalar value
  95161. */
  95162. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  95163. /**
  95164. * Interpolates a quaternion using a spherical linear interpolation
  95165. * @param startValue Start value of the animation curve
  95166. * @param endValue End value of the animation curve
  95167. * @param gradient Scalar amount to interpolate
  95168. * @returns Interpolated quaternion value
  95169. */
  95170. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  95171. /**
  95172. * Interpolates a quaternion cubically
  95173. * @param startValue Start value of the animation curve
  95174. * @param outTangent End tangent of the animation curve
  95175. * @param endValue End value of the animation curve
  95176. * @param inTangent Start tangent of the animation curve
  95177. * @param gradient Scalar amount to interpolate
  95178. * @returns Interpolated quaternion value
  95179. */
  95180. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  95181. /**
  95182. * Interpolates a Vector3 linearl
  95183. * @param startValue Start value of the animation curve
  95184. * @param endValue End value of the animation curve
  95185. * @param gradient Scalar amount to interpolate
  95186. * @returns Interpolated scalar value
  95187. */
  95188. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  95189. /**
  95190. * Interpolates a Vector3 cubically
  95191. * @param startValue Start value of the animation curve
  95192. * @param outTangent End tangent of the animation
  95193. * @param endValue End value of the animation curve
  95194. * @param inTangent Start tangent of the animation curve
  95195. * @param gradient Scalar amount to interpolate
  95196. * @returns InterpolatedVector3 value
  95197. */
  95198. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  95199. /**
  95200. * Interpolates a Vector2 linearly
  95201. * @param startValue Start value of the animation curve
  95202. * @param endValue End value of the animation curve
  95203. * @param gradient Scalar amount to interpolate
  95204. * @returns Interpolated Vector2 value
  95205. */
  95206. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  95207. /**
  95208. * Interpolates a Vector2 cubically
  95209. * @param startValue Start value of the animation curve
  95210. * @param outTangent End tangent of the animation
  95211. * @param endValue End value of the animation curve
  95212. * @param inTangent Start tangent of the animation curve
  95213. * @param gradient Scalar amount to interpolate
  95214. * @returns Interpolated Vector2 value
  95215. */
  95216. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  95217. /**
  95218. * Interpolates a size linearly
  95219. * @param startValue Start value of the animation curve
  95220. * @param endValue End value of the animation curve
  95221. * @param gradient Scalar amount to interpolate
  95222. * @returns Interpolated Size value
  95223. */
  95224. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  95225. /**
  95226. * Interpolates a Color3 linearly
  95227. * @param startValue Start value of the animation curve
  95228. * @param endValue End value of the animation curve
  95229. * @param gradient Scalar amount to interpolate
  95230. * @returns Interpolated Color3 value
  95231. */
  95232. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  95233. /**
  95234. * Interpolates a Color4 linearly
  95235. * @param startValue Start value of the animation curve
  95236. * @param endValue End value of the animation curve
  95237. * @param gradient Scalar amount to interpolate
  95238. * @returns Interpolated Color3 value
  95239. */
  95240. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  95241. /**
  95242. * @hidden Internal use only
  95243. */
  95244. _getKeyValue(value: any): any;
  95245. /**
  95246. * @hidden Internal use only
  95247. */
  95248. _interpolate(currentFrame: number, state: _IAnimationState): any;
  95249. /**
  95250. * Defines the function to use to interpolate matrices
  95251. * @param startValue defines the start matrix
  95252. * @param endValue defines the end matrix
  95253. * @param gradient defines the gradient between both matrices
  95254. * @param result defines an optional target matrix where to store the interpolation
  95255. * @returns the interpolated matrix
  95256. */
  95257. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  95258. /**
  95259. * Makes a copy of the animation
  95260. * @returns Cloned animation
  95261. */
  95262. clone(): Animation;
  95263. /**
  95264. * Sets the key frames of the animation
  95265. * @param values The animation key frames to set
  95266. */
  95267. setKeys(values: Array<IAnimationKey>): void;
  95268. /**
  95269. * Serializes the animation to an object
  95270. * @returns Serialized object
  95271. */
  95272. serialize(): any;
  95273. /**
  95274. * Float animation type
  95275. */
  95276. static readonly ANIMATIONTYPE_FLOAT: number;
  95277. /**
  95278. * Vector3 animation type
  95279. */
  95280. static readonly ANIMATIONTYPE_VECTOR3: number;
  95281. /**
  95282. * Quaternion animation type
  95283. */
  95284. static readonly ANIMATIONTYPE_QUATERNION: number;
  95285. /**
  95286. * Matrix animation type
  95287. */
  95288. static readonly ANIMATIONTYPE_MATRIX: number;
  95289. /**
  95290. * Color3 animation type
  95291. */
  95292. static readonly ANIMATIONTYPE_COLOR3: number;
  95293. /**
  95294. * Color3 animation type
  95295. */
  95296. static readonly ANIMATIONTYPE_COLOR4: number;
  95297. /**
  95298. * Vector2 animation type
  95299. */
  95300. static readonly ANIMATIONTYPE_VECTOR2: number;
  95301. /**
  95302. * Size animation type
  95303. */
  95304. static readonly ANIMATIONTYPE_SIZE: number;
  95305. /**
  95306. * Relative Loop Mode
  95307. */
  95308. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  95309. /**
  95310. * Cycle Loop Mode
  95311. */
  95312. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  95313. /**
  95314. * Constant Loop Mode
  95315. */
  95316. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  95317. /** @hidden */
  95318. static _UniversalLerp(left: any, right: any, amount: number): any;
  95319. /**
  95320. * Parses an animation object and creates an animation
  95321. * @param parsedAnimation Parsed animation object
  95322. * @returns Animation object
  95323. */
  95324. static Parse(parsedAnimation: any): Animation;
  95325. /**
  95326. * Appends the serialized animations from the source animations
  95327. * @param source Source containing the animations
  95328. * @param destination Target to store the animations
  95329. */
  95330. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95331. }
  95332. }
  95333. declare module BABYLON {
  95334. /**
  95335. * Interface containing an array of animations
  95336. */
  95337. export interface IAnimatable {
  95338. /**
  95339. * Array of animations
  95340. */
  95341. animations: Nullable<Array<Animation>>;
  95342. }
  95343. }
  95344. declare module BABYLON {
  95345. /**
  95346. * This represents all the required information to add a fresnel effect on a material:
  95347. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95348. */
  95349. export class FresnelParameters {
  95350. private _isEnabled;
  95351. /**
  95352. * Define if the fresnel effect is enable or not.
  95353. */
  95354. isEnabled: boolean;
  95355. /**
  95356. * Define the color used on edges (grazing angle)
  95357. */
  95358. leftColor: Color3;
  95359. /**
  95360. * Define the color used on center
  95361. */
  95362. rightColor: Color3;
  95363. /**
  95364. * Define bias applied to computed fresnel term
  95365. */
  95366. bias: number;
  95367. /**
  95368. * Defined the power exponent applied to fresnel term
  95369. */
  95370. power: number;
  95371. /**
  95372. * Clones the current fresnel and its valuues
  95373. * @returns a clone fresnel configuration
  95374. */
  95375. clone(): FresnelParameters;
  95376. /**
  95377. * Serializes the current fresnel parameters to a JSON representation.
  95378. * @return the JSON serialization
  95379. */
  95380. serialize(): any;
  95381. /**
  95382. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  95383. * @param parsedFresnelParameters Define the JSON representation
  95384. * @returns the parsed parameters
  95385. */
  95386. static Parse(parsedFresnelParameters: any): FresnelParameters;
  95387. }
  95388. }
  95389. declare module BABYLON {
  95390. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  95391. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95392. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95393. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95394. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95395. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95396. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95397. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95398. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95399. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95400. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95401. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95402. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95403. /**
  95404. * Decorator used to define property that can be serialized as reference to a camera
  95405. * @param sourceName defines the name of the property to decorate
  95406. */
  95407. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  95408. /**
  95409. * Class used to help serialization objects
  95410. */
  95411. export class SerializationHelper {
  95412. /** @hidden */
  95413. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  95414. /** @hidden */
  95415. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  95416. /** @hidden */
  95417. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  95418. /** @hidden */
  95419. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  95420. /**
  95421. * Appends the serialized animations from the source animations
  95422. * @param source Source containing the animations
  95423. * @param destination Target to store the animations
  95424. */
  95425. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  95426. /**
  95427. * Static function used to serialized a specific entity
  95428. * @param entity defines the entity to serialize
  95429. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  95430. * @returns a JSON compatible object representing the serialization of the entity
  95431. */
  95432. static Serialize<T>(entity: T, serializationObject?: any): any;
  95433. /**
  95434. * Creates a new entity from a serialization data object
  95435. * @param creationFunction defines a function used to instanciated the new entity
  95436. * @param source defines the source serialization data
  95437. * @param scene defines the hosting scene
  95438. * @param rootUrl defines the root url for resources
  95439. * @returns a new entity
  95440. */
  95441. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  95442. /**
  95443. * Clones an object
  95444. * @param creationFunction defines the function used to instanciate the new object
  95445. * @param source defines the source object
  95446. * @returns the cloned object
  95447. */
  95448. static Clone<T>(creationFunction: () => T, source: T): T;
  95449. /**
  95450. * Instanciates a new object based on a source one (some data will be shared between both object)
  95451. * @param creationFunction defines the function used to instanciate the new object
  95452. * @param source defines the source object
  95453. * @returns the new object
  95454. */
  95455. static Instanciate<T>(creationFunction: () => T, source: T): T;
  95456. }
  95457. }
  95458. declare module BABYLON {
  95459. /**
  95460. * Class used to manipulate GUIDs
  95461. */
  95462. export class GUID {
  95463. /**
  95464. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95465. * Be aware Math.random() could cause collisions, but:
  95466. * "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"
  95467. * @returns a pseudo random id
  95468. */
  95469. static RandomId(): string;
  95470. }
  95471. }
  95472. declare module BABYLON {
  95473. /**
  95474. * Base class of all the textures in babylon.
  95475. * It groups all the common properties the materials, post process, lights... might need
  95476. * in order to make a correct use of the texture.
  95477. */
  95478. export class BaseTexture implements IAnimatable {
  95479. /**
  95480. * Default anisotropic filtering level for the application.
  95481. * It is set to 4 as a good tradeoff between perf and quality.
  95482. */
  95483. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  95484. /**
  95485. * Gets or sets the unique id of the texture
  95486. */
  95487. uniqueId: number;
  95488. /**
  95489. * Define the name of the texture.
  95490. */
  95491. name: string;
  95492. /**
  95493. * Gets or sets an object used to store user defined information.
  95494. */
  95495. metadata: any;
  95496. /**
  95497. * For internal use only. Please do not use.
  95498. */
  95499. reservedDataStore: any;
  95500. private _hasAlpha;
  95501. /**
  95502. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  95503. */
  95504. hasAlpha: boolean;
  95505. /**
  95506. * Defines if the alpha value should be determined via the rgb values.
  95507. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  95508. */
  95509. getAlphaFromRGB: boolean;
  95510. /**
  95511. * Intensity or strength of the texture.
  95512. * It is commonly used by materials to fine tune the intensity of the texture
  95513. */
  95514. level: number;
  95515. /**
  95516. * Define the UV chanel to use starting from 0 and defaulting to 0.
  95517. * This is part of the texture as textures usually maps to one uv set.
  95518. */
  95519. coordinatesIndex: number;
  95520. private _coordinatesMode;
  95521. /**
  95522. * How a texture is mapped.
  95523. *
  95524. * | Value | Type | Description |
  95525. * | ----- | ----------------------------------- | ----------- |
  95526. * | 0 | EXPLICIT_MODE | |
  95527. * | 1 | SPHERICAL_MODE | |
  95528. * | 2 | PLANAR_MODE | |
  95529. * | 3 | CUBIC_MODE | |
  95530. * | 4 | PROJECTION_MODE | |
  95531. * | 5 | SKYBOX_MODE | |
  95532. * | 6 | INVCUBIC_MODE | |
  95533. * | 7 | EQUIRECTANGULAR_MODE | |
  95534. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  95535. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  95536. */
  95537. coordinatesMode: number;
  95538. /**
  95539. * | Value | Type | Description |
  95540. * | ----- | ------------------ | ----------- |
  95541. * | 0 | CLAMP_ADDRESSMODE | |
  95542. * | 1 | WRAP_ADDRESSMODE | |
  95543. * | 2 | MIRROR_ADDRESSMODE | |
  95544. */
  95545. wrapU: number;
  95546. /**
  95547. * | Value | Type | Description |
  95548. * | ----- | ------------------ | ----------- |
  95549. * | 0 | CLAMP_ADDRESSMODE | |
  95550. * | 1 | WRAP_ADDRESSMODE | |
  95551. * | 2 | MIRROR_ADDRESSMODE | |
  95552. */
  95553. wrapV: number;
  95554. /**
  95555. * | Value | Type | Description |
  95556. * | ----- | ------------------ | ----------- |
  95557. * | 0 | CLAMP_ADDRESSMODE | |
  95558. * | 1 | WRAP_ADDRESSMODE | |
  95559. * | 2 | MIRROR_ADDRESSMODE | |
  95560. */
  95561. wrapR: number;
  95562. /**
  95563. * With compliant hardware and browser (supporting anisotropic filtering)
  95564. * this defines the level of anisotropic filtering in the texture.
  95565. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  95566. */
  95567. anisotropicFilteringLevel: number;
  95568. /**
  95569. * Define if the texture is a cube texture or if false a 2d texture.
  95570. */
  95571. isCube: boolean;
  95572. /**
  95573. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  95574. */
  95575. is3D: boolean;
  95576. /**
  95577. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  95578. * HDR texture are usually stored in linear space.
  95579. * This only impacts the PBR and Background materials
  95580. */
  95581. gammaSpace: boolean;
  95582. /**
  95583. * Gets or sets whether or not the texture contains RGBD data.
  95584. */
  95585. isRGBD: boolean;
  95586. /**
  95587. * Is Z inverted in the texture (useful in a cube texture).
  95588. */
  95589. invertZ: boolean;
  95590. /**
  95591. * Are mip maps generated for this texture or not.
  95592. */
  95593. readonly noMipmap: boolean;
  95594. /**
  95595. * @hidden
  95596. */
  95597. lodLevelInAlpha: boolean;
  95598. /**
  95599. * With prefiltered texture, defined the offset used during the prefiltering steps.
  95600. */
  95601. lodGenerationOffset: number;
  95602. /**
  95603. * With prefiltered texture, defined the scale used during the prefiltering steps.
  95604. */
  95605. lodGenerationScale: number;
  95606. /**
  95607. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  95608. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  95609. * average roughness values.
  95610. */
  95611. linearSpecularLOD: boolean;
  95612. /**
  95613. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  95614. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  95615. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  95616. */
  95617. irradianceTexture: Nullable<BaseTexture>;
  95618. /**
  95619. * Define if the texture is a render target.
  95620. */
  95621. isRenderTarget: boolean;
  95622. /**
  95623. * Define the unique id of the texture in the scene.
  95624. */
  95625. readonly uid: string;
  95626. /**
  95627. * Return a string representation of the texture.
  95628. * @returns the texture as a string
  95629. */
  95630. toString(): string;
  95631. /**
  95632. * Get the class name of the texture.
  95633. * @returns "BaseTexture"
  95634. */
  95635. getClassName(): string;
  95636. /**
  95637. * Define the list of animation attached to the texture.
  95638. */
  95639. animations: Animation[];
  95640. /**
  95641. * An event triggered when the texture is disposed.
  95642. */
  95643. onDisposeObservable: Observable<BaseTexture>;
  95644. private _onDisposeObserver;
  95645. /**
  95646. * Callback triggered when the texture has been disposed.
  95647. * Kept for back compatibility, you can use the onDisposeObservable instead.
  95648. */
  95649. onDispose: () => void;
  95650. /**
  95651. * Define the current state of the loading sequence when in delayed load mode.
  95652. */
  95653. delayLoadState: number;
  95654. private _scene;
  95655. /** @hidden */
  95656. _texture: Nullable<InternalTexture>;
  95657. private _uid;
  95658. /**
  95659. * Define if the texture is preventinga material to render or not.
  95660. * If not and the texture is not ready, the engine will use a default black texture instead.
  95661. */
  95662. readonly isBlocking: boolean;
  95663. /**
  95664. * Instantiates a new BaseTexture.
  95665. * Base class of all the textures in babylon.
  95666. * It groups all the common properties the materials, post process, lights... might need
  95667. * in order to make a correct use of the texture.
  95668. * @param scene Define the scene the texture blongs to
  95669. */
  95670. constructor(scene: Nullable<Scene>);
  95671. /**
  95672. * Get the scene the texture belongs to.
  95673. * @returns the scene or null if undefined
  95674. */
  95675. getScene(): Nullable<Scene>;
  95676. /**
  95677. * Get the texture transform matrix used to offset tile the texture for istance.
  95678. * @returns the transformation matrix
  95679. */
  95680. getTextureMatrix(): Matrix;
  95681. /**
  95682. * Get the texture reflection matrix used to rotate/transform the reflection.
  95683. * @returns the reflection matrix
  95684. */
  95685. getReflectionTextureMatrix(): Matrix;
  95686. /**
  95687. * Get the underlying lower level texture from Babylon.
  95688. * @returns the insternal texture
  95689. */
  95690. getInternalTexture(): Nullable<InternalTexture>;
  95691. /**
  95692. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  95693. * @returns true if ready or not blocking
  95694. */
  95695. isReadyOrNotBlocking(): boolean;
  95696. /**
  95697. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  95698. * @returns true if fully ready
  95699. */
  95700. isReady(): boolean;
  95701. private _cachedSize;
  95702. /**
  95703. * Get the size of the texture.
  95704. * @returns the texture size.
  95705. */
  95706. getSize(): ISize;
  95707. /**
  95708. * Get the base size of the texture.
  95709. * It can be different from the size if the texture has been resized for POT for instance
  95710. * @returns the base size
  95711. */
  95712. getBaseSize(): ISize;
  95713. /**
  95714. * Update the sampling mode of the texture.
  95715. * Default is Trilinear mode.
  95716. *
  95717. * | Value | Type | Description |
  95718. * | ----- | ------------------ | ----------- |
  95719. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  95720. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  95721. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  95722. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  95723. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  95724. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  95725. * | 7 | NEAREST_LINEAR | |
  95726. * | 8 | NEAREST_NEAREST | |
  95727. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  95728. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  95729. * | 11 | LINEAR_LINEAR | |
  95730. * | 12 | LINEAR_NEAREST | |
  95731. *
  95732. * > _mag_: magnification filter (close to the viewer)
  95733. * > _min_: minification filter (far from the viewer)
  95734. * > _mip_: filter used between mip map levels
  95735. *@param samplingMode Define the new sampling mode of the texture
  95736. */
  95737. updateSamplingMode(samplingMode: number): void;
  95738. /**
  95739. * Scales the texture if is `canRescale()`
  95740. * @param ratio the resize factor we want to use to rescale
  95741. */
  95742. scale(ratio: number): void;
  95743. /**
  95744. * Get if the texture can rescale.
  95745. */
  95746. readonly canRescale: boolean;
  95747. /** @hidden */
  95748. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  95749. /** @hidden */
  95750. _rebuild(): void;
  95751. /**
  95752. * Triggers the load sequence in delayed load mode.
  95753. */
  95754. delayLoad(): void;
  95755. /**
  95756. * Clones the texture.
  95757. * @returns the cloned texture
  95758. */
  95759. clone(): Nullable<BaseTexture>;
  95760. /**
  95761. * Get the texture underlying type (INT, FLOAT...)
  95762. */
  95763. readonly textureType: number;
  95764. /**
  95765. * Get the texture underlying format (RGB, RGBA...)
  95766. */
  95767. readonly textureFormat: number;
  95768. /**
  95769. * Indicates that textures need to be re-calculated for all materials
  95770. */
  95771. protected _markAllSubMeshesAsTexturesDirty(): void;
  95772. /**
  95773. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  95774. * This will returns an RGBA array buffer containing either in values (0-255) or
  95775. * float values (0-1) depending of the underlying buffer type.
  95776. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  95777. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  95778. * @param buffer defines a user defined buffer to fill with data (can be null)
  95779. * @returns The Array buffer containing the pixels data.
  95780. */
  95781. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  95782. /**
  95783. * Release and destroy the underlying lower level texture aka internalTexture.
  95784. */
  95785. releaseInternalTexture(): void;
  95786. /** @hidden */
  95787. readonly _lodTextureHigh: Nullable<BaseTexture>;
  95788. /** @hidden */
  95789. readonly _lodTextureMid: Nullable<BaseTexture>;
  95790. /** @hidden */
  95791. readonly _lodTextureLow: Nullable<BaseTexture>;
  95792. /**
  95793. * Dispose the texture and release its associated resources.
  95794. */
  95795. dispose(): void;
  95796. /**
  95797. * Serialize the texture into a JSON representation that can be parsed later on.
  95798. * @returns the JSON representation of the texture
  95799. */
  95800. serialize(): any;
  95801. /**
  95802. * Helper function to be called back once a list of texture contains only ready textures.
  95803. * @param textures Define the list of textures to wait for
  95804. * @param callback Define the callback triggered once the entire list will be ready
  95805. */
  95806. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  95807. }
  95808. }
  95809. declare module BABYLON {
  95810. /**
  95811. * Options to be used when creating an effect.
  95812. */
  95813. export interface IEffectCreationOptions {
  95814. /**
  95815. * Atrributes that will be used in the shader.
  95816. */
  95817. attributes: string[];
  95818. /**
  95819. * Uniform varible names that will be set in the shader.
  95820. */
  95821. uniformsNames: string[];
  95822. /**
  95823. * Uniform buffer varible names that will be set in the shader.
  95824. */
  95825. uniformBuffersNames: string[];
  95826. /**
  95827. * Sampler texture variable names that will be set in the shader.
  95828. */
  95829. samplers: string[];
  95830. /**
  95831. * Define statements that will be set in the shader.
  95832. */
  95833. defines: any;
  95834. /**
  95835. * Possible fallbacks for this effect to improve performance when needed.
  95836. */
  95837. fallbacks: Nullable<IEffectFallbacks>;
  95838. /**
  95839. * Callback that will be called when the shader is compiled.
  95840. */
  95841. onCompiled: Nullable<(effect: Effect) => void>;
  95842. /**
  95843. * Callback that will be called if an error occurs during shader compilation.
  95844. */
  95845. onError: Nullable<(effect: Effect, errors: string) => void>;
  95846. /**
  95847. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95848. */
  95849. indexParameters?: any;
  95850. /**
  95851. * Max number of lights that can be used in the shader.
  95852. */
  95853. maxSimultaneousLights?: number;
  95854. /**
  95855. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95856. */
  95857. transformFeedbackVaryings?: Nullable<string[]>;
  95858. }
  95859. /**
  95860. * Effect containing vertex and fragment shader that can be executed on an object.
  95861. */
  95862. export class Effect implements IDisposable {
  95863. /**
  95864. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95865. */
  95866. static ShadersRepository: string;
  95867. /**
  95868. * Name of the effect.
  95869. */
  95870. name: any;
  95871. /**
  95872. * String container all the define statements that should be set on the shader.
  95873. */
  95874. defines: string;
  95875. /**
  95876. * Callback that will be called when the shader is compiled.
  95877. */
  95878. onCompiled: Nullable<(effect: Effect) => void>;
  95879. /**
  95880. * Callback that will be called if an error occurs during shader compilation.
  95881. */
  95882. onError: Nullable<(effect: Effect, errors: string) => void>;
  95883. /**
  95884. * Callback that will be called when effect is bound.
  95885. */
  95886. onBind: Nullable<(effect: Effect) => void>;
  95887. /**
  95888. * Unique ID of the effect.
  95889. */
  95890. uniqueId: number;
  95891. /**
  95892. * Observable that will be called when the shader is compiled.
  95893. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95894. */
  95895. onCompileObservable: Observable<Effect>;
  95896. /**
  95897. * Observable that will be called if an error occurs during shader compilation.
  95898. */
  95899. onErrorObservable: Observable<Effect>;
  95900. /** @hidden */
  95901. _onBindObservable: Nullable<Observable<Effect>>;
  95902. /**
  95903. * Observable that will be called when effect is bound.
  95904. */
  95905. readonly onBindObservable: Observable<Effect>;
  95906. /** @hidden */
  95907. _bonesComputationForcedToCPU: boolean;
  95908. private static _uniqueIdSeed;
  95909. private _engine;
  95910. private _uniformBuffersNames;
  95911. private _uniformsNames;
  95912. private _samplerList;
  95913. private _samplers;
  95914. private _isReady;
  95915. private _compilationError;
  95916. private _allFallbacksProcessed;
  95917. private _attributesNames;
  95918. private _attributes;
  95919. private _uniforms;
  95920. /**
  95921. * Key for the effect.
  95922. * @hidden
  95923. */
  95924. _key: string;
  95925. private _indexParameters;
  95926. private _fallbacks;
  95927. private _vertexSourceCode;
  95928. private _fragmentSourceCode;
  95929. private _vertexSourceCodeOverride;
  95930. private _fragmentSourceCodeOverride;
  95931. private _transformFeedbackVaryings;
  95932. /**
  95933. * Compiled shader to webGL program.
  95934. * @hidden
  95935. */
  95936. _pipelineContext: Nullable<IPipelineContext>;
  95937. private _valueCache;
  95938. private static _baseCache;
  95939. /**
  95940. * Instantiates an effect.
  95941. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95942. * @param baseName Name of the effect.
  95943. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95944. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95945. * @param samplers List of sampler variables that will be passed to the shader.
  95946. * @param engine Engine to be used to render the effect
  95947. * @param defines Define statements to be added to the shader.
  95948. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95949. * @param onCompiled Callback that will be called when the shader is compiled.
  95950. * @param onError Callback that will be called if an error occurs during shader compilation.
  95951. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95952. */
  95953. 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);
  95954. private _useFinalCode;
  95955. /**
  95956. * Unique key for this effect
  95957. */
  95958. readonly key: string;
  95959. /**
  95960. * If the effect has been compiled and prepared.
  95961. * @returns if the effect is compiled and prepared.
  95962. */
  95963. isReady(): boolean;
  95964. private _isReadyInternal;
  95965. /**
  95966. * The engine the effect was initialized with.
  95967. * @returns the engine.
  95968. */
  95969. getEngine(): Engine;
  95970. /**
  95971. * The pipeline context for this effect
  95972. * @returns the associated pipeline context
  95973. */
  95974. getPipelineContext(): Nullable<IPipelineContext>;
  95975. /**
  95976. * The set of names of attribute variables for the shader.
  95977. * @returns An array of attribute names.
  95978. */
  95979. getAttributesNames(): string[];
  95980. /**
  95981. * Returns the attribute at the given index.
  95982. * @param index The index of the attribute.
  95983. * @returns The location of the attribute.
  95984. */
  95985. getAttributeLocation(index: number): number;
  95986. /**
  95987. * Returns the attribute based on the name of the variable.
  95988. * @param name of the attribute to look up.
  95989. * @returns the attribute location.
  95990. */
  95991. getAttributeLocationByName(name: string): number;
  95992. /**
  95993. * The number of attributes.
  95994. * @returns the numnber of attributes.
  95995. */
  95996. getAttributesCount(): number;
  95997. /**
  95998. * Gets the index of a uniform variable.
  95999. * @param uniformName of the uniform to look up.
  96000. * @returns the index.
  96001. */
  96002. getUniformIndex(uniformName: string): number;
  96003. /**
  96004. * Returns the attribute based on the name of the variable.
  96005. * @param uniformName of the uniform to look up.
  96006. * @returns the location of the uniform.
  96007. */
  96008. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  96009. /**
  96010. * Returns an array of sampler variable names
  96011. * @returns The array of sampler variable neames.
  96012. */
  96013. getSamplers(): string[];
  96014. /**
  96015. * The error from the last compilation.
  96016. * @returns the error string.
  96017. */
  96018. getCompilationError(): string;
  96019. /**
  96020. * Gets a boolean indicating that all fallbacks were used during compilation
  96021. * @returns true if all fallbacks were used
  96022. */
  96023. allFallbacksProcessed(): boolean;
  96024. /**
  96025. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  96026. * @param func The callback to be used.
  96027. */
  96028. executeWhenCompiled(func: (effect: Effect) => void): void;
  96029. private _checkIsReady;
  96030. private _loadShader;
  96031. /**
  96032. * Recompiles the webGL program
  96033. * @param vertexSourceCode The source code for the vertex shader.
  96034. * @param fragmentSourceCode The source code for the fragment shader.
  96035. * @param onCompiled Callback called when completed.
  96036. * @param onError Callback called on error.
  96037. * @hidden
  96038. */
  96039. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  96040. /**
  96041. * Prepares the effect
  96042. * @hidden
  96043. */
  96044. _prepareEffect(): void;
  96045. private _processCompilationErrors;
  96046. /**
  96047. * Checks if the effect is supported. (Must be called after compilation)
  96048. */
  96049. readonly isSupported: boolean;
  96050. /**
  96051. * Binds a texture to the engine to be used as output of the shader.
  96052. * @param channel Name of the output variable.
  96053. * @param texture Texture to bind.
  96054. * @hidden
  96055. */
  96056. _bindTexture(channel: string, texture: InternalTexture): void;
  96057. /**
  96058. * Sets a texture on the engine to be used in the shader.
  96059. * @param channel Name of the sampler variable.
  96060. * @param texture Texture to set.
  96061. */
  96062. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  96063. /**
  96064. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  96065. * @param channel Name of the sampler variable.
  96066. * @param texture Texture to set.
  96067. */
  96068. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  96069. /**
  96070. * Sets an array of textures on the engine to be used in the shader.
  96071. * @param channel Name of the variable.
  96072. * @param textures Textures to set.
  96073. */
  96074. setTextureArray(channel: string, textures: BaseTexture[]): void;
  96075. /**
  96076. * 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)
  96077. * @param channel Name of the sampler variable.
  96078. * @param postProcess Post process to get the input texture from.
  96079. */
  96080. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  96081. /**
  96082. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  96083. * 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)
  96084. * @param channel Name of the sampler variable.
  96085. * @param postProcess Post process to get the output texture from.
  96086. */
  96087. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  96088. /** @hidden */
  96089. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  96090. /** @hidden */
  96091. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  96092. /** @hidden */
  96093. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  96094. /** @hidden */
  96095. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  96096. /**
  96097. * Binds a buffer to a uniform.
  96098. * @param buffer Buffer to bind.
  96099. * @param name Name of the uniform variable to bind to.
  96100. */
  96101. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  96102. /**
  96103. * Binds block to a uniform.
  96104. * @param blockName Name of the block to bind.
  96105. * @param index Index to bind.
  96106. */
  96107. bindUniformBlock(blockName: string, index: number): void;
  96108. /**
  96109. * Sets an interger value on a uniform variable.
  96110. * @param uniformName Name of the variable.
  96111. * @param value Value to be set.
  96112. * @returns this effect.
  96113. */
  96114. setInt(uniformName: string, value: number): Effect;
  96115. /**
  96116. * Sets an int array on a uniform variable.
  96117. * @param uniformName Name of the variable.
  96118. * @param array array to be set.
  96119. * @returns this effect.
  96120. */
  96121. setIntArray(uniformName: string, array: Int32Array): Effect;
  96122. /**
  96123. * 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)
  96124. * @param uniformName Name of the variable.
  96125. * @param array array to be set.
  96126. * @returns this effect.
  96127. */
  96128. setIntArray2(uniformName: string, array: Int32Array): Effect;
  96129. /**
  96130. * 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)
  96131. * @param uniformName Name of the variable.
  96132. * @param array array to be set.
  96133. * @returns this effect.
  96134. */
  96135. setIntArray3(uniformName: string, array: Int32Array): Effect;
  96136. /**
  96137. * 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)
  96138. * @param uniformName Name of the variable.
  96139. * @param array array to be set.
  96140. * @returns this effect.
  96141. */
  96142. setIntArray4(uniformName: string, array: Int32Array): Effect;
  96143. /**
  96144. * Sets an float array on a uniform variable.
  96145. * @param uniformName Name of the variable.
  96146. * @param array array to be set.
  96147. * @returns this effect.
  96148. */
  96149. setFloatArray(uniformName: string, array: Float32Array): Effect;
  96150. /**
  96151. * 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)
  96152. * @param uniformName Name of the variable.
  96153. * @param array array to be set.
  96154. * @returns this effect.
  96155. */
  96156. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  96157. /**
  96158. * 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)
  96159. * @param uniformName Name of the variable.
  96160. * @param array array to be set.
  96161. * @returns this effect.
  96162. */
  96163. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  96164. /**
  96165. * 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)
  96166. * @param uniformName Name of the variable.
  96167. * @param array array to be set.
  96168. * @returns this effect.
  96169. */
  96170. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  96171. /**
  96172. * Sets an array on a uniform variable.
  96173. * @param uniformName Name of the variable.
  96174. * @param array array to be set.
  96175. * @returns this effect.
  96176. */
  96177. setArray(uniformName: string, array: number[]): Effect;
  96178. /**
  96179. * 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)
  96180. * @param uniformName Name of the variable.
  96181. * @param array array to be set.
  96182. * @returns this effect.
  96183. */
  96184. setArray2(uniformName: string, array: number[]): Effect;
  96185. /**
  96186. * 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)
  96187. * @param uniformName Name of the variable.
  96188. * @param array array to be set.
  96189. * @returns this effect.
  96190. */
  96191. setArray3(uniformName: string, array: number[]): Effect;
  96192. /**
  96193. * 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)
  96194. * @param uniformName Name of the variable.
  96195. * @param array array to be set.
  96196. * @returns this effect.
  96197. */
  96198. setArray4(uniformName: string, array: number[]): Effect;
  96199. /**
  96200. * Sets matrices on a uniform variable.
  96201. * @param uniformName Name of the variable.
  96202. * @param matrices matrices to be set.
  96203. * @returns this effect.
  96204. */
  96205. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  96206. /**
  96207. * Sets matrix on a uniform variable.
  96208. * @param uniformName Name of the variable.
  96209. * @param matrix matrix to be set.
  96210. * @returns this effect.
  96211. */
  96212. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  96213. /**
  96214. * 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)
  96215. * @param uniformName Name of the variable.
  96216. * @param matrix matrix to be set.
  96217. * @returns this effect.
  96218. */
  96219. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  96220. /**
  96221. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  96222. * @param uniformName Name of the variable.
  96223. * @param matrix matrix to be set.
  96224. * @returns this effect.
  96225. */
  96226. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  96227. /**
  96228. * Sets a float on a uniform variable.
  96229. * @param uniformName Name of the variable.
  96230. * @param value value to be set.
  96231. * @returns this effect.
  96232. */
  96233. setFloat(uniformName: string, value: number): Effect;
  96234. /**
  96235. * Sets a boolean on a uniform variable.
  96236. * @param uniformName Name of the variable.
  96237. * @param bool value to be set.
  96238. * @returns this effect.
  96239. */
  96240. setBool(uniformName: string, bool: boolean): Effect;
  96241. /**
  96242. * Sets a Vector2 on a uniform variable.
  96243. * @param uniformName Name of the variable.
  96244. * @param vector2 vector2 to be set.
  96245. * @returns this effect.
  96246. */
  96247. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  96248. /**
  96249. * Sets a float2 on a uniform variable.
  96250. * @param uniformName Name of the variable.
  96251. * @param x First float in float2.
  96252. * @param y Second float in float2.
  96253. * @returns this effect.
  96254. */
  96255. setFloat2(uniformName: string, x: number, y: number): Effect;
  96256. /**
  96257. * Sets a Vector3 on a uniform variable.
  96258. * @param uniformName Name of the variable.
  96259. * @param vector3 Value to be set.
  96260. * @returns this effect.
  96261. */
  96262. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  96263. /**
  96264. * Sets a float3 on a uniform variable.
  96265. * @param uniformName Name of the variable.
  96266. * @param x First float in float3.
  96267. * @param y Second float in float3.
  96268. * @param z Third float in float3.
  96269. * @returns this effect.
  96270. */
  96271. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  96272. /**
  96273. * Sets a Vector4 on a uniform variable.
  96274. * @param uniformName Name of the variable.
  96275. * @param vector4 Value to be set.
  96276. * @returns this effect.
  96277. */
  96278. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  96279. /**
  96280. * Sets a float4 on a uniform variable.
  96281. * @param uniformName Name of the variable.
  96282. * @param x First float in float4.
  96283. * @param y Second float in float4.
  96284. * @param z Third float in float4.
  96285. * @param w Fourth float in float4.
  96286. * @returns this effect.
  96287. */
  96288. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  96289. /**
  96290. * Sets a Color3 on a uniform variable.
  96291. * @param uniformName Name of the variable.
  96292. * @param color3 Value to be set.
  96293. * @returns this effect.
  96294. */
  96295. setColor3(uniformName: string, color3: IColor3Like): Effect;
  96296. /**
  96297. * Sets a Color4 on a uniform variable.
  96298. * @param uniformName Name of the variable.
  96299. * @param color3 Value to be set.
  96300. * @param alpha Alpha value to be set.
  96301. * @returns this effect.
  96302. */
  96303. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  96304. /**
  96305. * Sets a Color4 on a uniform variable
  96306. * @param uniformName defines the name of the variable
  96307. * @param color4 defines the value to be set
  96308. * @returns this effect.
  96309. */
  96310. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  96311. /** Release all associated resources */
  96312. dispose(): void;
  96313. /**
  96314. * This function will add a new shader to the shader store
  96315. * @param name the name of the shader
  96316. * @param pixelShader optional pixel shader content
  96317. * @param vertexShader optional vertex shader content
  96318. */
  96319. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  96320. /**
  96321. * Store of each shader (The can be looked up using effect.key)
  96322. */
  96323. static ShadersStore: {
  96324. [key: string]: string;
  96325. };
  96326. /**
  96327. * Store of each included file for a shader (The can be looked up using effect.key)
  96328. */
  96329. static IncludesShadersStore: {
  96330. [key: string]: string;
  96331. };
  96332. /**
  96333. * Resets the cache of effects.
  96334. */
  96335. static ResetCache(): void;
  96336. }
  96337. }
  96338. declare module BABYLON {
  96339. /**
  96340. * Interface used to describe the capabilities of the engine relatively to the current browser
  96341. */
  96342. export interface EngineCapabilities {
  96343. /** Maximum textures units per fragment shader */
  96344. maxTexturesImageUnits: number;
  96345. /** Maximum texture units per vertex shader */
  96346. maxVertexTextureImageUnits: number;
  96347. /** Maximum textures units in the entire pipeline */
  96348. maxCombinedTexturesImageUnits: number;
  96349. /** Maximum texture size */
  96350. maxTextureSize: number;
  96351. /** Maximum cube texture size */
  96352. maxCubemapTextureSize: number;
  96353. /** Maximum render texture size */
  96354. maxRenderTextureSize: number;
  96355. /** Maximum number of vertex attributes */
  96356. maxVertexAttribs: number;
  96357. /** Maximum number of varyings */
  96358. maxVaryingVectors: number;
  96359. /** Maximum number of uniforms per vertex shader */
  96360. maxVertexUniformVectors: number;
  96361. /** Maximum number of uniforms per fragment shader */
  96362. maxFragmentUniformVectors: number;
  96363. /** Defines if standard derivates (dx/dy) are supported */
  96364. standardDerivatives: boolean;
  96365. /** Defines if s3tc texture compression is supported */
  96366. s3tc?: WEBGL_compressed_texture_s3tc;
  96367. /** Defines if pvrtc texture compression is supported */
  96368. pvrtc: any;
  96369. /** Defines if etc1 texture compression is supported */
  96370. etc1: any;
  96371. /** Defines if etc2 texture compression is supported */
  96372. etc2: any;
  96373. /** Defines if astc texture compression is supported */
  96374. astc: any;
  96375. /** Defines if float textures are supported */
  96376. textureFloat: boolean;
  96377. /** Defines if vertex array objects are supported */
  96378. vertexArrayObject: boolean;
  96379. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  96380. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  96381. /** Gets the maximum level of anisotropy supported */
  96382. maxAnisotropy: number;
  96383. /** Defines if instancing is supported */
  96384. instancedArrays: boolean;
  96385. /** Defines if 32 bits indices are supported */
  96386. uintIndices: boolean;
  96387. /** Defines if high precision shaders are supported */
  96388. highPrecisionShaderSupported: boolean;
  96389. /** Defines if depth reading in the fragment shader is supported */
  96390. fragmentDepthSupported: boolean;
  96391. /** Defines if float texture linear filtering is supported*/
  96392. textureFloatLinearFiltering: boolean;
  96393. /** Defines if rendering to float textures is supported */
  96394. textureFloatRender: boolean;
  96395. /** Defines if half float textures are supported*/
  96396. textureHalfFloat: boolean;
  96397. /** Defines if half float texture linear filtering is supported*/
  96398. textureHalfFloatLinearFiltering: boolean;
  96399. /** Defines if rendering to half float textures is supported */
  96400. textureHalfFloatRender: boolean;
  96401. /** Defines if textureLOD shader command is supported */
  96402. textureLOD: boolean;
  96403. /** Defines if draw buffers extension is supported */
  96404. drawBuffersExtension: boolean;
  96405. /** Defines if depth textures are supported */
  96406. depthTextureExtension: boolean;
  96407. /** Defines if float color buffer are supported */
  96408. colorBufferFloat: boolean;
  96409. /** Gets disjoint timer query extension (null if not supported) */
  96410. timerQuery?: EXT_disjoint_timer_query;
  96411. /** Defines if timestamp can be used with timer query */
  96412. canUseTimestampForTimerQuery: boolean;
  96413. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  96414. multiview?: any;
  96415. /** Function used to let the system compiles shaders in background */
  96416. parallelShaderCompile?: {
  96417. COMPLETION_STATUS_KHR: number;
  96418. };
  96419. /** Max number of texture samples for MSAA */
  96420. maxMSAASamples: number;
  96421. /** Defines if the blend min max extension is supported */
  96422. blendMinMax: boolean;
  96423. }
  96424. }
  96425. declare module BABYLON {
  96426. /**
  96427. * @hidden
  96428. **/
  96429. export class DepthCullingState {
  96430. private _isDepthTestDirty;
  96431. private _isDepthMaskDirty;
  96432. private _isDepthFuncDirty;
  96433. private _isCullFaceDirty;
  96434. private _isCullDirty;
  96435. private _isZOffsetDirty;
  96436. private _isFrontFaceDirty;
  96437. private _depthTest;
  96438. private _depthMask;
  96439. private _depthFunc;
  96440. private _cull;
  96441. private _cullFace;
  96442. private _zOffset;
  96443. private _frontFace;
  96444. /**
  96445. * Initializes the state.
  96446. */
  96447. constructor();
  96448. readonly isDirty: boolean;
  96449. zOffset: number;
  96450. cullFace: Nullable<number>;
  96451. cull: Nullable<boolean>;
  96452. depthFunc: Nullable<number>;
  96453. depthMask: boolean;
  96454. depthTest: boolean;
  96455. frontFace: Nullable<number>;
  96456. reset(): void;
  96457. apply(gl: WebGLRenderingContext): void;
  96458. }
  96459. }
  96460. declare module BABYLON {
  96461. /**
  96462. * @hidden
  96463. **/
  96464. export class StencilState {
  96465. /** 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 */
  96466. static readonly ALWAYS: number;
  96467. /** Passed to stencilOperation to specify that stencil value must be kept */
  96468. static readonly KEEP: number;
  96469. /** Passed to stencilOperation to specify that stencil value must be replaced */
  96470. static readonly REPLACE: number;
  96471. private _isStencilTestDirty;
  96472. private _isStencilMaskDirty;
  96473. private _isStencilFuncDirty;
  96474. private _isStencilOpDirty;
  96475. private _stencilTest;
  96476. private _stencilMask;
  96477. private _stencilFunc;
  96478. private _stencilFuncRef;
  96479. private _stencilFuncMask;
  96480. private _stencilOpStencilFail;
  96481. private _stencilOpDepthFail;
  96482. private _stencilOpStencilDepthPass;
  96483. readonly isDirty: boolean;
  96484. stencilFunc: number;
  96485. stencilFuncRef: number;
  96486. stencilFuncMask: number;
  96487. stencilOpStencilFail: number;
  96488. stencilOpDepthFail: number;
  96489. stencilOpStencilDepthPass: number;
  96490. stencilMask: number;
  96491. stencilTest: boolean;
  96492. constructor();
  96493. reset(): void;
  96494. apply(gl: WebGLRenderingContext): void;
  96495. }
  96496. }
  96497. declare module BABYLON {
  96498. /**
  96499. * @hidden
  96500. **/
  96501. export class AlphaState {
  96502. private _isAlphaBlendDirty;
  96503. private _isBlendFunctionParametersDirty;
  96504. private _isBlendEquationParametersDirty;
  96505. private _isBlendConstantsDirty;
  96506. private _alphaBlend;
  96507. private _blendFunctionParameters;
  96508. private _blendEquationParameters;
  96509. private _blendConstants;
  96510. /**
  96511. * Initializes the state.
  96512. */
  96513. constructor();
  96514. readonly isDirty: boolean;
  96515. alphaBlend: boolean;
  96516. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  96517. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  96518. setAlphaEquationParameters(rgb: number, alpha: number): void;
  96519. reset(): void;
  96520. apply(gl: WebGLRenderingContext): void;
  96521. }
  96522. }
  96523. declare module BABYLON {
  96524. /** @hidden */
  96525. export class WebGL2ShaderProcessor implements IShaderProcessor {
  96526. attributeProcessor(attribute: string): string;
  96527. varyingProcessor(varying: string, isFragment: boolean): string;
  96528. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  96529. }
  96530. }
  96531. declare module BABYLON {
  96532. /**
  96533. * Interface for attribute information associated with buffer instanciation
  96534. */
  96535. export interface InstancingAttributeInfo {
  96536. /**
  96537. * Index/offset of the attribute in the vertex shader
  96538. */
  96539. index: number;
  96540. /**
  96541. * size of the attribute, 1, 2, 3 or 4
  96542. */
  96543. attributeSize: number;
  96544. /**
  96545. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  96546. * default is FLOAT
  96547. */
  96548. attributeType: number;
  96549. /**
  96550. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  96551. */
  96552. normalized: boolean;
  96553. /**
  96554. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  96555. */
  96556. offset: number;
  96557. /**
  96558. * Name of the GLSL attribute, for debugging purpose only
  96559. */
  96560. attributeName: string;
  96561. }
  96562. }
  96563. declare module BABYLON {
  96564. interface ThinEngine {
  96565. /**
  96566. * Update a video texture
  96567. * @param texture defines the texture to update
  96568. * @param video defines the video element to use
  96569. * @param invertY defines if data must be stored with Y axis inverted
  96570. */
  96571. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  96572. }
  96573. }
  96574. declare module BABYLON {
  96575. /**
  96576. * Settings for finer control over video usage
  96577. */
  96578. export interface VideoTextureSettings {
  96579. /**
  96580. * Applies `autoplay` to video, if specified
  96581. */
  96582. autoPlay?: boolean;
  96583. /**
  96584. * Applies `loop` to video, if specified
  96585. */
  96586. loop?: boolean;
  96587. /**
  96588. * Automatically updates internal texture from video at every frame in the render loop
  96589. */
  96590. autoUpdateTexture: boolean;
  96591. /**
  96592. * Image src displayed during the video loading or until the user interacts with the video.
  96593. */
  96594. poster?: string;
  96595. }
  96596. /**
  96597. * If you want to display a video in your scene, this is the special texture for that.
  96598. * This special texture works similar to other textures, with the exception of a few parameters.
  96599. * @see https://doc.babylonjs.com/how_to/video_texture
  96600. */
  96601. export class VideoTexture extends Texture {
  96602. /**
  96603. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  96604. */
  96605. readonly autoUpdateTexture: boolean;
  96606. /**
  96607. * The video instance used by the texture internally
  96608. */
  96609. readonly video: HTMLVideoElement;
  96610. private _onUserActionRequestedObservable;
  96611. /**
  96612. * Event triggerd when a dom action is required by the user to play the video.
  96613. * This happens due to recent changes in browser policies preventing video to auto start.
  96614. */
  96615. readonly onUserActionRequestedObservable: Observable<Texture>;
  96616. private _generateMipMaps;
  96617. private _engine;
  96618. private _stillImageCaptured;
  96619. private _displayingPosterTexture;
  96620. private _settings;
  96621. private _createInternalTextureOnEvent;
  96622. private _frameId;
  96623. /**
  96624. * Creates a video texture.
  96625. * If you want to display a video in your scene, this is the special texture for that.
  96626. * This special texture works similar to other textures, with the exception of a few parameters.
  96627. * @see https://doc.babylonjs.com/how_to/video_texture
  96628. * @param name optional name, will detect from video source, if not defined
  96629. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  96630. * @param scene is obviously the current scene.
  96631. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  96632. * @param invertY is false by default but can be used to invert video on Y axis
  96633. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  96634. * @param settings allows finer control over video usage
  96635. */
  96636. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  96637. private _getName;
  96638. private _getVideo;
  96639. private _createInternalTexture;
  96640. private reset;
  96641. /**
  96642. * @hidden Internal method to initiate `update`.
  96643. */
  96644. _rebuild(): void;
  96645. /**
  96646. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  96647. */
  96648. update(): void;
  96649. /**
  96650. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  96651. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  96652. */
  96653. updateTexture(isVisible: boolean): void;
  96654. protected _updateInternalTexture: () => void;
  96655. /**
  96656. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  96657. * @param url New url.
  96658. */
  96659. updateURL(url: string): void;
  96660. /**
  96661. * Dispose the texture and release its associated resources.
  96662. */
  96663. dispose(): void;
  96664. /**
  96665. * Creates a video texture straight from a stream.
  96666. * @param scene Define the scene the texture should be created in
  96667. * @param stream Define the stream the texture should be created from
  96668. * @returns The created video texture as a promise
  96669. */
  96670. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  96671. /**
  96672. * Creates a video texture straight from your WebCam video feed.
  96673. * @param scene Define the scene the texture should be created in
  96674. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96675. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96676. * @returns The created video texture as a promise
  96677. */
  96678. static CreateFromWebCamAsync(scene: Scene, constraints: {
  96679. minWidth: number;
  96680. maxWidth: number;
  96681. minHeight: number;
  96682. maxHeight: number;
  96683. deviceId: string;
  96684. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  96685. /**
  96686. * Creates a video texture straight from your WebCam video feed.
  96687. * @param scene Define the scene the texture should be created in
  96688. * @param onReady Define a callback to triggered once the texture will be ready
  96689. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  96690. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  96691. */
  96692. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  96693. minWidth: number;
  96694. maxWidth: number;
  96695. minHeight: number;
  96696. maxHeight: number;
  96697. deviceId: string;
  96698. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  96699. }
  96700. }
  96701. declare module BABYLON {
  96702. /**
  96703. * Defines the interface used by objects working like Scene
  96704. * @hidden
  96705. */
  96706. interface ISceneLike {
  96707. _addPendingData(data: any): void;
  96708. _removePendingData(data: any): void;
  96709. offlineProvider: IOfflineProvider;
  96710. }
  96711. /** Interface defining initialization parameters for Engine class */
  96712. export interface EngineOptions extends WebGLContextAttributes {
  96713. /**
  96714. * Defines if the engine should no exceed a specified device ratio
  96715. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  96716. */
  96717. limitDeviceRatio?: number;
  96718. /**
  96719. * Defines if webvr should be enabled automatically
  96720. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96721. */
  96722. autoEnableWebVR?: boolean;
  96723. /**
  96724. * Defines if webgl2 should be turned off even if supported
  96725. * @see http://doc.babylonjs.com/features/webgl2
  96726. */
  96727. disableWebGL2Support?: boolean;
  96728. /**
  96729. * Defines if webaudio should be initialized as well
  96730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96731. */
  96732. audioEngine?: boolean;
  96733. /**
  96734. * Defines if animations should run using a deterministic lock step
  96735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96736. */
  96737. deterministicLockstep?: boolean;
  96738. /** Defines the maximum steps to use with deterministic lock step mode */
  96739. lockstepMaxSteps?: number;
  96740. /**
  96741. * Defines that engine should ignore context lost events
  96742. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  96743. */
  96744. doNotHandleContextLost?: boolean;
  96745. /**
  96746. * Defines that engine should ignore modifying touch action attribute and style
  96747. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  96748. */
  96749. doNotHandleTouchAction?: boolean;
  96750. /**
  96751. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  96752. */
  96753. useHighPrecisionFloats?: boolean;
  96754. }
  96755. /**
  96756. * The base engine class (root of all engines)
  96757. */
  96758. export class ThinEngine {
  96759. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  96760. static ExceptionList: ({
  96761. key: string;
  96762. capture: string;
  96763. captureConstraint: number;
  96764. targets: string[];
  96765. } | {
  96766. key: string;
  96767. capture: null;
  96768. captureConstraint: null;
  96769. targets: string[];
  96770. })[];
  96771. /** @hidden */
  96772. static _TextureLoaders: IInternalTextureLoader[];
  96773. /**
  96774. * Returns the current npm package of the sdk
  96775. */
  96776. static readonly NpmPackage: string;
  96777. /**
  96778. * Returns the current version of the framework
  96779. */
  96780. static readonly Version: string;
  96781. /**
  96782. * Returns a string describing the current engine
  96783. */
  96784. readonly description: string;
  96785. /**
  96786. * Gets or sets the epsilon value used by collision engine
  96787. */
  96788. static CollisionsEpsilon: number;
  96789. /**
  96790. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96791. */
  96792. static ShadersRepository: string;
  96793. /** @hidden */
  96794. _shaderProcessor: IShaderProcessor;
  96795. /**
  96796. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96797. */
  96798. forcePOTTextures: boolean;
  96799. /**
  96800. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96801. */
  96802. isFullscreen: boolean;
  96803. /**
  96804. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96805. */
  96806. cullBackFaces: boolean;
  96807. /**
  96808. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96809. */
  96810. renderEvenInBackground: boolean;
  96811. /**
  96812. * Gets or sets a boolean indicating that cache can be kept between frames
  96813. */
  96814. preventCacheWipeBetweenFrames: boolean;
  96815. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96816. validateShaderPrograms: boolean;
  96817. /**
  96818. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96819. */
  96820. disableUniformBuffers: boolean;
  96821. /** @hidden */
  96822. _uniformBuffers: UniformBuffer[];
  96823. /**
  96824. * Gets a boolean indicating that the engine supports uniform buffers
  96825. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96826. */
  96827. readonly supportsUniformBuffers: boolean;
  96828. /** @hidden */
  96829. _gl: WebGLRenderingContext;
  96830. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96831. protected _windowIsBackground: boolean;
  96832. protected _webGLVersion: number;
  96833. protected _creationOptions: EngineOptions;
  96834. protected _highPrecisionShadersAllowed: boolean;
  96835. /** @hidden */
  96836. readonly _shouldUseHighPrecisionShader: boolean;
  96837. /**
  96838. * Gets a boolean indicating that only power of 2 textures are supported
  96839. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96840. */
  96841. readonly needPOTTextures: boolean;
  96842. /** @hidden */
  96843. _badOS: boolean;
  96844. /** @hidden */
  96845. _badDesktopOS: boolean;
  96846. private _hardwareScalingLevel;
  96847. /** @hidden */
  96848. _caps: EngineCapabilities;
  96849. private _isStencilEnable;
  96850. protected _colorWrite: boolean;
  96851. private _glVersion;
  96852. private _glRenderer;
  96853. private _glVendor;
  96854. /** @hidden */
  96855. _videoTextureSupported: boolean;
  96856. protected _renderingQueueLaunched: boolean;
  96857. protected _activeRenderLoops: (() => void)[];
  96858. /**
  96859. * Observable signaled when a context lost event is raised
  96860. */
  96861. onContextLostObservable: Observable<ThinEngine>;
  96862. /**
  96863. * Observable signaled when a context restored event is raised
  96864. */
  96865. onContextRestoredObservable: Observable<ThinEngine>;
  96866. private _onContextLost;
  96867. private _onContextRestored;
  96868. protected _contextWasLost: boolean;
  96869. /** @hidden */
  96870. _doNotHandleContextLost: boolean;
  96871. /**
  96872. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96873. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96874. */
  96875. doNotHandleContextLost: boolean;
  96876. /**
  96877. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96878. */
  96879. disableVertexArrayObjects: boolean;
  96880. /** @hidden */
  96881. protected _depthCullingState: DepthCullingState;
  96882. /** @hidden */
  96883. protected _stencilState: StencilState;
  96884. /** @hidden */
  96885. protected _alphaState: AlphaState;
  96886. /** @hidden */
  96887. _internalTexturesCache: InternalTexture[];
  96888. /** @hidden */
  96889. protected _activeChannel: number;
  96890. private _currentTextureChannel;
  96891. /** @hidden */
  96892. protected _boundTexturesCache: {
  96893. [key: string]: Nullable<InternalTexture>;
  96894. };
  96895. /** @hidden */
  96896. protected _currentEffect: Nullable<Effect>;
  96897. /** @hidden */
  96898. protected _currentProgram: Nullable<WebGLProgram>;
  96899. private _compiledEffects;
  96900. private _vertexAttribArraysEnabled;
  96901. /** @hidden */
  96902. protected _cachedViewport: Nullable<IViewportLike>;
  96903. private _cachedVertexArrayObject;
  96904. /** @hidden */
  96905. protected _cachedVertexBuffers: any;
  96906. /** @hidden */
  96907. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96908. /** @hidden */
  96909. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96910. /** @hidden */
  96911. _currentRenderTarget: Nullable<InternalTexture>;
  96912. private _uintIndicesCurrentlySet;
  96913. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96914. /** @hidden */
  96915. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96916. private _currentBufferPointers;
  96917. private _currentInstanceLocations;
  96918. private _currentInstanceBuffers;
  96919. private _textureUnits;
  96920. /** @hidden */
  96921. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  96922. /** @hidden */
  96923. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  96924. /** @hidden */
  96925. _bindedRenderFunction: any;
  96926. private _vaoRecordInProgress;
  96927. private _mustWipeVertexAttributes;
  96928. private _emptyTexture;
  96929. private _emptyCubeTexture;
  96930. private _emptyTexture3D;
  96931. /** @hidden */
  96932. _frameHandler: number;
  96933. private _nextFreeTextureSlots;
  96934. private _maxSimultaneousTextures;
  96935. private _activeRequests;
  96936. protected _texturesSupported: string[];
  96937. /** @hidden */
  96938. _textureFormatInUse: Nullable<string>;
  96939. protected readonly _supportsHardwareTextureRescaling: boolean;
  96940. /**
  96941. * Gets the list of texture formats supported
  96942. */
  96943. readonly texturesSupported: Array<string>;
  96944. /**
  96945. * Gets the list of texture formats in use
  96946. */
  96947. readonly textureFormatInUse: Nullable<string>;
  96948. /**
  96949. * Gets the current viewport
  96950. */
  96951. readonly currentViewport: Nullable<IViewportLike>;
  96952. /**
  96953. * Gets the default empty texture
  96954. */
  96955. readonly emptyTexture: InternalTexture;
  96956. /**
  96957. * Gets the default empty 3D texture
  96958. */
  96959. readonly emptyTexture3D: InternalTexture;
  96960. /**
  96961. * Gets the default empty cube texture
  96962. */
  96963. readonly emptyCubeTexture: InternalTexture;
  96964. /**
  96965. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96966. */
  96967. readonly premultipliedAlpha: boolean;
  96968. /**
  96969. * Observable event triggered before each texture is initialized
  96970. */
  96971. onBeforeTextureInitObservable: Observable<Texture>;
  96972. /**
  96973. * Creates a new engine
  96974. * @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
  96975. * @param antialias defines enable antialiasing (default: false)
  96976. * @param options defines further options to be sent to the getContext() function
  96977. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96978. */
  96979. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96980. private _rebuildInternalTextures;
  96981. private _rebuildEffects;
  96982. /**
  96983. * Gets a boolean indicating if all created effects are ready
  96984. * @returns true if all effects are ready
  96985. */
  96986. areAllEffectsReady(): boolean;
  96987. protected _rebuildBuffers(): void;
  96988. private _initGLContext;
  96989. /**
  96990. * Gets version of the current webGL context
  96991. */
  96992. readonly webGLVersion: number;
  96993. /**
  96994. * Gets a string idenfifying the name of the class
  96995. * @returns "Engine" string
  96996. */
  96997. getClassName(): string;
  96998. /**
  96999. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  97000. */
  97001. readonly isStencilEnable: boolean;
  97002. /** @hidden */
  97003. _prepareWorkingCanvas(): void;
  97004. /**
  97005. * Reset the texture cache to empty state
  97006. */
  97007. resetTextureCache(): void;
  97008. /**
  97009. * Gets an object containing information about the current webGL context
  97010. * @returns an object containing the vender, the renderer and the version of the current webGL context
  97011. */
  97012. getGlInfo(): {
  97013. vendor: string;
  97014. renderer: string;
  97015. version: string;
  97016. };
  97017. /**
  97018. * Defines the hardware scaling level.
  97019. * By default the hardware scaling level is computed from the window device ratio.
  97020. * 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.
  97021. * @param level defines the level to use
  97022. */
  97023. setHardwareScalingLevel(level: number): void;
  97024. /**
  97025. * Gets the current hardware scaling level.
  97026. * By default the hardware scaling level is computed from the window device ratio.
  97027. * 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.
  97028. * @returns a number indicating the current hardware scaling level
  97029. */
  97030. getHardwareScalingLevel(): number;
  97031. /**
  97032. * Gets the list of loaded textures
  97033. * @returns an array containing all loaded textures
  97034. */
  97035. getLoadedTexturesCache(): InternalTexture[];
  97036. /**
  97037. * Gets the object containing all engine capabilities
  97038. * @returns the EngineCapabilities object
  97039. */
  97040. getCaps(): EngineCapabilities;
  97041. /**
  97042. * stop executing a render loop function and remove it from the execution array
  97043. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  97044. */
  97045. stopRenderLoop(renderFunction?: () => void): void;
  97046. /** @hidden */
  97047. _renderLoop(): void;
  97048. /**
  97049. * Gets the HTML canvas attached with the current webGL context
  97050. * @returns a HTML canvas
  97051. */
  97052. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  97053. /**
  97054. * Gets host window
  97055. * @returns the host window object
  97056. */
  97057. getHostWindow(): Nullable<Window>;
  97058. /**
  97059. * Gets the current render width
  97060. * @param useScreen defines if screen size must be used (or the current render target if any)
  97061. * @returns a number defining the current render width
  97062. */
  97063. getRenderWidth(useScreen?: boolean): number;
  97064. /**
  97065. * Gets the current render height
  97066. * @param useScreen defines if screen size must be used (or the current render target if any)
  97067. * @returns a number defining the current render height
  97068. */
  97069. getRenderHeight(useScreen?: boolean): number;
  97070. /**
  97071. * Can be used to override the current requestAnimationFrame requester.
  97072. * @hidden
  97073. */
  97074. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  97075. /**
  97076. * Register and execute a render loop. The engine can have more than one render function
  97077. * @param renderFunction defines the function to continuously execute
  97078. */
  97079. runRenderLoop(renderFunction: () => void): void;
  97080. /**
  97081. * Clear the current render buffer or the current render target (if any is set up)
  97082. * @param color defines the color to use
  97083. * @param backBuffer defines if the back buffer must be cleared
  97084. * @param depth defines if the depth buffer must be cleared
  97085. * @param stencil defines if the stencil buffer must be cleared
  97086. */
  97087. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  97088. private _viewportCached;
  97089. /** @hidden */
  97090. _viewport(x: number, y: number, width: number, height: number): void;
  97091. /**
  97092. * Set the WebGL's viewport
  97093. * @param viewport defines the viewport element to be used
  97094. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  97095. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  97096. */
  97097. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  97098. /**
  97099. * Begin a new frame
  97100. */
  97101. beginFrame(): void;
  97102. /**
  97103. * Enf the current frame
  97104. */
  97105. endFrame(): void;
  97106. /**
  97107. * Resize the view according to the canvas' size
  97108. */
  97109. resize(): void;
  97110. /**
  97111. * Force a specific size of the canvas
  97112. * @param width defines the new canvas' width
  97113. * @param height defines the new canvas' height
  97114. */
  97115. setSize(width: number, height: number): void;
  97116. /**
  97117. * Binds the frame buffer to the specified texture.
  97118. * @param texture The texture to render to or null for the default canvas
  97119. * @param faceIndex The face of the texture to render to in case of cube texture
  97120. * @param requiredWidth The width of the target to render to
  97121. * @param requiredHeight The height of the target to render to
  97122. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  97123. * @param depthStencilTexture The depth stencil texture to use to render
  97124. * @param lodLevel defines le lod level to bind to the frame buffer
  97125. */
  97126. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  97127. /** @hidden */
  97128. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  97129. /**
  97130. * Unbind the current render target texture from the webGL context
  97131. * @param texture defines the render target texture to unbind
  97132. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  97133. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  97134. */
  97135. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  97136. /**
  97137. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  97138. */
  97139. flushFramebuffer(): void;
  97140. /**
  97141. * Unbind the current render target and bind the default framebuffer
  97142. */
  97143. restoreDefaultFramebuffer(): void;
  97144. /** @hidden */
  97145. protected _resetVertexBufferBinding(): void;
  97146. /**
  97147. * Creates a vertex buffer
  97148. * @param data the data for the vertex buffer
  97149. * @returns the new WebGL static buffer
  97150. */
  97151. createVertexBuffer(data: DataArray): DataBuffer;
  97152. private _createVertexBuffer;
  97153. /**
  97154. * Creates a dynamic vertex buffer
  97155. * @param data the data for the dynamic vertex buffer
  97156. * @returns the new WebGL dynamic buffer
  97157. */
  97158. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  97159. protected _resetIndexBufferBinding(): void;
  97160. /**
  97161. * Creates a new index buffer
  97162. * @param indices defines the content of the index buffer
  97163. * @param updatable defines if the index buffer must be updatable
  97164. * @returns a new webGL buffer
  97165. */
  97166. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  97167. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  97168. /**
  97169. * Bind a webGL buffer to the webGL context
  97170. * @param buffer defines the buffer to bind
  97171. */
  97172. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  97173. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  97174. private bindBuffer;
  97175. /**
  97176. * update the bound buffer with the given data
  97177. * @param data defines the data to update
  97178. */
  97179. updateArrayBuffer(data: Float32Array): void;
  97180. private _vertexAttribPointer;
  97181. private _bindIndexBufferWithCache;
  97182. private _bindVertexBuffersAttributes;
  97183. /**
  97184. * Records a vertex array object
  97185. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97186. * @param vertexBuffers defines the list of vertex buffers to store
  97187. * @param indexBuffer defines the index buffer to store
  97188. * @param effect defines the effect to store
  97189. * @returns the new vertex array object
  97190. */
  97191. recordVertexArrayObject(vertexBuffers: {
  97192. [key: string]: VertexBuffer;
  97193. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  97194. /**
  97195. * Bind a specific vertex array object
  97196. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  97197. * @param vertexArrayObject defines the vertex array object to bind
  97198. * @param indexBuffer defines the index buffer to bind
  97199. */
  97200. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  97201. /**
  97202. * Bind webGl buffers directly to the webGL context
  97203. * @param vertexBuffer defines the vertex buffer to bind
  97204. * @param indexBuffer defines the index buffer to bind
  97205. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  97206. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  97207. * @param effect defines the effect associated with the vertex buffer
  97208. */
  97209. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  97210. private _unbindVertexArrayObject;
  97211. /**
  97212. * Bind a list of vertex buffers to the webGL context
  97213. * @param vertexBuffers defines the list of vertex buffers to bind
  97214. * @param indexBuffer defines the index buffer to bind
  97215. * @param effect defines the effect associated with the vertex buffers
  97216. */
  97217. bindBuffers(vertexBuffers: {
  97218. [key: string]: Nullable<VertexBuffer>;
  97219. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  97220. /**
  97221. * Unbind all instance attributes
  97222. */
  97223. unbindInstanceAttributes(): void;
  97224. /**
  97225. * Release and free the memory of a vertex array object
  97226. * @param vao defines the vertex array object to delete
  97227. */
  97228. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  97229. /** @hidden */
  97230. _releaseBuffer(buffer: DataBuffer): boolean;
  97231. protected _deleteBuffer(buffer: DataBuffer): void;
  97232. /**
  97233. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  97234. * @param instancesBuffer defines the webGL buffer to update and bind
  97235. * @param data defines the data to store in the buffer
  97236. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  97237. */
  97238. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  97239. /**
  97240. * Apply all cached states (depth, culling, stencil and alpha)
  97241. */
  97242. applyStates(): void;
  97243. /**
  97244. * Send a draw order
  97245. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97246. * @param indexStart defines the starting index
  97247. * @param indexCount defines the number of index to draw
  97248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97249. */
  97250. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  97251. /**
  97252. * Draw a list of points
  97253. * @param verticesStart defines the index of first vertex to draw
  97254. * @param verticesCount defines the count of vertices to draw
  97255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97256. */
  97257. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97258. /**
  97259. * Draw a list of unindexed primitives
  97260. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  97261. * @param verticesStart defines the index of first vertex to draw
  97262. * @param verticesCount defines the count of vertices to draw
  97263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97264. */
  97265. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97266. /**
  97267. * Draw a list of indexed primitives
  97268. * @param fillMode defines the primitive to use
  97269. * @param indexStart defines the starting index
  97270. * @param indexCount defines the number of index to draw
  97271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97272. */
  97273. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  97274. /**
  97275. * Draw a list of unindexed primitives
  97276. * @param fillMode defines the primitive to use
  97277. * @param verticesStart defines the index of first vertex to draw
  97278. * @param verticesCount defines the count of vertices to draw
  97279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  97280. */
  97281. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  97282. private _drawMode;
  97283. /** @hidden */
  97284. protected _reportDrawCall(): void;
  97285. /** @hidden */
  97286. _releaseEffect(effect: Effect): void;
  97287. /** @hidden */
  97288. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  97289. /**
  97290. * Create a new effect (used to store vertex/fragment shaders)
  97291. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  97292. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  97293. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  97294. * @param samplers defines an array of string used to represent textures
  97295. * @param defines defines the string containing the defines to use to compile the shaders
  97296. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  97297. * @param onCompiled defines a function to call when the effect creation is successful
  97298. * @param onError defines a function to call when the effect creation has failed
  97299. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  97300. * @returns the new Effect
  97301. */
  97302. 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;
  97303. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  97304. private _compileShader;
  97305. private _compileRawShader;
  97306. /**
  97307. * Directly creates a webGL program
  97308. * @param pipelineContext defines the pipeline context to attach to
  97309. * @param vertexCode defines the vertex shader code to use
  97310. * @param fragmentCode defines the fragment shader code to use
  97311. * @param context defines the webGL context to use (if not set, the current one will be used)
  97312. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97313. * @returns the new webGL program
  97314. */
  97315. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97316. /**
  97317. * Creates a webGL program
  97318. * @param pipelineContext defines the pipeline context to attach to
  97319. * @param vertexCode defines the vertex shader code to use
  97320. * @param fragmentCode defines the fragment shader code to use
  97321. * @param defines defines the string containing the defines to use to compile the shaders
  97322. * @param context defines the webGL context to use (if not set, the current one will be used)
  97323. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  97324. * @returns the new webGL program
  97325. */
  97326. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97327. /**
  97328. * Creates a new pipeline context
  97329. * @returns the new pipeline
  97330. */
  97331. createPipelineContext(): IPipelineContext;
  97332. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  97333. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  97334. /** @hidden */
  97335. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  97336. /** @hidden */
  97337. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  97338. /** @hidden */
  97339. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  97340. /**
  97341. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  97342. * @param pipelineContext defines the pipeline context to use
  97343. * @param uniformsNames defines the list of uniform names
  97344. * @returns an array of webGL uniform locations
  97345. */
  97346. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  97347. /**
  97348. * Gets the lsit of active attributes for a given webGL program
  97349. * @param pipelineContext defines the pipeline context to use
  97350. * @param attributesNames defines the list of attribute names to get
  97351. * @returns an array of indices indicating the offset of each attribute
  97352. */
  97353. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  97354. /**
  97355. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  97356. * @param effect defines the effect to activate
  97357. */
  97358. enableEffect(effect: Nullable<Effect>): void;
  97359. /**
  97360. * Set the value of an uniform to a number (int)
  97361. * @param uniform defines the webGL uniform location where to store the value
  97362. * @param value defines the int number to store
  97363. */
  97364. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97365. /**
  97366. * Set the value of an uniform to an array of int32
  97367. * @param uniform defines the webGL uniform location where to store the value
  97368. * @param array defines the array of int32 to store
  97369. */
  97370. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97371. /**
  97372. * Set the value of an uniform to an array of int32 (stored as vec2)
  97373. * @param uniform defines the webGL uniform location where to store the value
  97374. * @param array defines the array of int32 to store
  97375. */
  97376. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97377. /**
  97378. * Set the value of an uniform to an array of int32 (stored as vec3)
  97379. * @param uniform defines the webGL uniform location where to store the value
  97380. * @param array defines the array of int32 to store
  97381. */
  97382. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97383. /**
  97384. * Set the value of an uniform to an array of int32 (stored as vec4)
  97385. * @param uniform defines the webGL uniform location where to store the value
  97386. * @param array defines the array of int32 to store
  97387. */
  97388. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97389. /**
  97390. * Set the value of an uniform to an array of number
  97391. * @param uniform defines the webGL uniform location where to store the value
  97392. * @param array defines the array of number to store
  97393. */
  97394. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97395. /**
  97396. * Set the value of an uniform to an array of number (stored as vec2)
  97397. * @param uniform defines the webGL uniform location where to store the value
  97398. * @param array defines the array of number to store
  97399. */
  97400. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97401. /**
  97402. * Set the value of an uniform to an array of number (stored as vec3)
  97403. * @param uniform defines the webGL uniform location where to store the value
  97404. * @param array defines the array of number to store
  97405. */
  97406. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97407. /**
  97408. * Set the value of an uniform to an array of number (stored as vec4)
  97409. * @param uniform defines the webGL uniform location where to store the value
  97410. * @param array defines the array of number to store
  97411. */
  97412. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  97413. /**
  97414. * Set the value of an uniform to an array of float32 (stored as matrices)
  97415. * @param uniform defines the webGL uniform location where to store the value
  97416. * @param matrices defines the array of float32 to store
  97417. */
  97418. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97419. /**
  97420. * Set the value of an uniform to a matrix (3x3)
  97421. * @param uniform defines the webGL uniform location where to store the value
  97422. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97423. */
  97424. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97425. /**
  97426. * Set the value of an uniform to a matrix (2x2)
  97427. * @param uniform defines the webGL uniform location where to store the value
  97428. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97429. */
  97430. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97431. /**
  97432. * Set the value of an uniform to a number (float)
  97433. * @param uniform defines the webGL uniform location where to store the value
  97434. * @param value defines the float number to store
  97435. */
  97436. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97437. /**
  97438. * Set the value of an uniform to a vec2
  97439. * @param uniform defines the webGL uniform location where to store the value
  97440. * @param x defines the 1st component of the value
  97441. * @param y defines the 2nd component of the value
  97442. */
  97443. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97444. /**
  97445. * Set the value of an uniform to a vec3
  97446. * @param uniform defines the webGL uniform location where to store the value
  97447. * @param x defines the 1st component of the value
  97448. * @param y defines the 2nd component of the value
  97449. * @param z defines the 3rd component of the value
  97450. */
  97451. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97452. /**
  97453. * Set the value of an uniform to a vec4
  97454. * @param uniform defines the webGL uniform location where to store the value
  97455. * @param x defines the 1st component of the value
  97456. * @param y defines the 2nd component of the value
  97457. * @param z defines the 3rd component of the value
  97458. * @param w defines the 4th component of the value
  97459. */
  97460. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97461. /**
  97462. * Gets the depth culling state manager
  97463. */
  97464. readonly depthCullingState: DepthCullingState;
  97465. /**
  97466. * Gets the alpha state manager
  97467. */
  97468. readonly alphaState: AlphaState;
  97469. /**
  97470. * Gets the stencil state manager
  97471. */
  97472. readonly stencilState: StencilState;
  97473. /**
  97474. * Clears the list of texture accessible through engine.
  97475. * This can help preventing texture load conflict due to name collision.
  97476. */
  97477. clearInternalTexturesCache(): void;
  97478. /**
  97479. * Force the entire cache to be cleared
  97480. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97481. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97482. */
  97483. wipeCaches(bruteForce?: boolean): void;
  97484. /** @hidden */
  97485. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97486. min: number;
  97487. mag: number;
  97488. };
  97489. /** @hidden */
  97490. _createTexture(): WebGLTexture;
  97491. /**
  97492. * Usually called from Texture.ts.
  97493. * Passed information to create a WebGLTexture
  97494. * @param urlArg defines a value which contains one of the following:
  97495. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97496. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97497. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97498. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97499. * @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)
  97500. * @param scene needed for loading to the correct scene
  97501. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97502. * @param onLoad optional callback to be called upon successful completion
  97503. * @param onError optional callback to be called upon failure
  97504. * @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
  97505. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97506. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97507. * @param forcedExtension defines the extension to use to pick the right loader
  97508. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97509. * @param mimeType defines an optional mime type
  97510. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97511. */
  97512. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  97513. /**
  97514. * @hidden
  97515. */
  97516. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  97517. /**
  97518. * Creates a raw texture
  97519. * @param data defines the data to store in the texture
  97520. * @param width defines the width of the texture
  97521. * @param height defines the height of the texture
  97522. * @param format defines the format of the data
  97523. * @param generateMipMaps defines if the engine should generate the mip levels
  97524. * @param invertY defines if data must be stored with Y axis inverted
  97525. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97526. * @param compression defines the compression used (null by default)
  97527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  97528. * @returns the raw texture inside an InternalTexture
  97529. */
  97530. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  97531. /**
  97532. * Creates a new raw cube texture
  97533. * @param data defines the array of data to use to create each face
  97534. * @param size defines the size of the textures
  97535. * @param format defines the format of the data
  97536. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  97537. * @param generateMipMaps defines if the engine should generate the mip levels
  97538. * @param invertY defines if data must be stored with Y axis inverted
  97539. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97540. * @param compression defines the compression used (null by default)
  97541. * @returns the cube texture as an InternalTexture
  97542. */
  97543. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  97544. /**
  97545. * Creates a new raw 3D texture
  97546. * @param data defines the data used to create the texture
  97547. * @param width defines the width of the texture
  97548. * @param height defines the height of the texture
  97549. * @param depth defines the depth of the texture
  97550. * @param format defines the format of the texture
  97551. * @param generateMipMaps defines if the engine must generate mip levels
  97552. * @param invertY defines if data must be stored with Y axis inverted
  97553. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  97554. * @param compression defines the compressed used (can be null)
  97555. * @param textureType defines the compressed used (can be null)
  97556. * @returns a new raw 3D texture (stored in an InternalTexture)
  97557. */
  97558. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  97559. private _unpackFlipYCached;
  97560. /**
  97561. * In case you are sharing the context with other applications, it might
  97562. * be interested to not cache the unpack flip y state to ensure a consistent
  97563. * value would be set.
  97564. */
  97565. enableUnpackFlipYCached: boolean;
  97566. /** @hidden */
  97567. _unpackFlipY(value: boolean): void;
  97568. /** @hidden */
  97569. _getUnpackAlignement(): number;
  97570. /**
  97571. * Update the sampling mode of a given texture
  97572. * @param samplingMode defines the required sampling mode
  97573. * @param texture defines the texture to update
  97574. */
  97575. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97576. /** @hidden */
  97577. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97578. width: number;
  97579. height: number;
  97580. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97581. /** @hidden */
  97582. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97583. /** @hidden */
  97584. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97585. /** @hidden */
  97586. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97587. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97588. private _prepareWebGLTexture;
  97589. /** @hidden */
  97590. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97591. /** @hidden */
  97592. _releaseFramebufferObjects(texture: InternalTexture): void;
  97593. /** @hidden */
  97594. _releaseTexture(texture: InternalTexture): void;
  97595. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97596. protected _setProgram(program: WebGLProgram): void;
  97597. protected _boundUniforms: {
  97598. [key: number]: WebGLUniformLocation;
  97599. };
  97600. /**
  97601. * Binds an effect to the webGL context
  97602. * @param effect defines the effect to bind
  97603. */
  97604. bindSamplers(effect: Effect): void;
  97605. private _activateCurrentTexture;
  97606. /** @hidden */
  97607. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97608. /** @hidden */
  97609. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97610. /**
  97611. * Unbind all textures from the webGL context
  97612. */
  97613. unbindAllTextures(): void;
  97614. /**
  97615. * Sets a texture to the according uniform.
  97616. * @param channel The texture channel
  97617. * @param uniform The uniform to set
  97618. * @param texture The texture to apply
  97619. */
  97620. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97621. private _bindSamplerUniformToChannel;
  97622. private _getTextureWrapMode;
  97623. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97624. /**
  97625. * Sets an array of texture to the webGL context
  97626. * @param channel defines the channel where the texture array must be set
  97627. * @param uniform defines the associated uniform location
  97628. * @param textures defines the array of textures to bind
  97629. */
  97630. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97631. /** @hidden */
  97632. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97633. private _setTextureParameterFloat;
  97634. private _setTextureParameterInteger;
  97635. /**
  97636. * Unbind all vertex attributes from the webGL context
  97637. */
  97638. unbindAllAttributes(): void;
  97639. /**
  97640. * 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
  97641. */
  97642. releaseEffects(): void;
  97643. /**
  97644. * Dispose and release all associated resources
  97645. */
  97646. dispose(): void;
  97647. /**
  97648. * Attach a new callback raised when context lost event is fired
  97649. * @param callback defines the callback to call
  97650. */
  97651. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97652. /**
  97653. * Attach a new callback raised when context restored event is fired
  97654. * @param callback defines the callback to call
  97655. */
  97656. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97657. /**
  97658. * Get the current error code of the webGL context
  97659. * @returns the error code
  97660. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97661. */
  97662. getError(): number;
  97663. private _canRenderToFloatFramebuffer;
  97664. private _canRenderToHalfFloatFramebuffer;
  97665. private _canRenderToFramebuffer;
  97666. /** @hidden */
  97667. _getWebGLTextureType(type: number): number;
  97668. /** @hidden */
  97669. _getInternalFormat(format: number): number;
  97670. /** @hidden */
  97671. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97672. /** @hidden */
  97673. _getRGBAMultiSampleBufferFormat(type: number): number;
  97674. /** @hidden */
  97675. _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;
  97676. /**
  97677. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97678. * @returns true if the engine can be created
  97679. * @ignorenaming
  97680. */
  97681. static isSupported(): boolean;
  97682. /**
  97683. * Find the next highest power of two.
  97684. * @param x Number to start search from.
  97685. * @return Next highest power of two.
  97686. */
  97687. static CeilingPOT(x: number): number;
  97688. /**
  97689. * Find the next lowest power of two.
  97690. * @param x Number to start search from.
  97691. * @return Next lowest power of two.
  97692. */
  97693. static FloorPOT(x: number): number;
  97694. /**
  97695. * Find the nearest power of two.
  97696. * @param x Number to start search from.
  97697. * @return Next nearest power of two.
  97698. */
  97699. static NearestPOT(x: number): number;
  97700. /**
  97701. * Get the closest exponent of two
  97702. * @param value defines the value to approximate
  97703. * @param max defines the maximum value to return
  97704. * @param mode defines how to define the closest value
  97705. * @returns closest exponent of two of the given value
  97706. */
  97707. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97708. /**
  97709. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97710. * @param func - the function to be called
  97711. * @param requester - the object that will request the next frame. Falls back to window.
  97712. * @returns frame number
  97713. */
  97714. static QueueNewFrame(func: () => void, requester?: any): number;
  97715. }
  97716. }
  97717. declare module BABYLON {
  97718. /**
  97719. * Class representing spherical harmonics coefficients to the 3rd degree
  97720. */
  97721. export class SphericalHarmonics {
  97722. /**
  97723. * Defines whether or not the harmonics have been prescaled for rendering.
  97724. */
  97725. preScaled: boolean;
  97726. /**
  97727. * The l0,0 coefficients of the spherical harmonics
  97728. */
  97729. l00: Vector3;
  97730. /**
  97731. * The l1,-1 coefficients of the spherical harmonics
  97732. */
  97733. l1_1: Vector3;
  97734. /**
  97735. * The l1,0 coefficients of the spherical harmonics
  97736. */
  97737. l10: Vector3;
  97738. /**
  97739. * The l1,1 coefficients of the spherical harmonics
  97740. */
  97741. l11: Vector3;
  97742. /**
  97743. * The l2,-2 coefficients of the spherical harmonics
  97744. */
  97745. l2_2: Vector3;
  97746. /**
  97747. * The l2,-1 coefficients of the spherical harmonics
  97748. */
  97749. l2_1: Vector3;
  97750. /**
  97751. * The l2,0 coefficients of the spherical harmonics
  97752. */
  97753. l20: Vector3;
  97754. /**
  97755. * The l2,1 coefficients of the spherical harmonics
  97756. */
  97757. l21: Vector3;
  97758. /**
  97759. * The l2,2 coefficients of the spherical harmonics
  97760. */
  97761. l22: Vector3;
  97762. /**
  97763. * Adds a light to the spherical harmonics
  97764. * @param direction the direction of the light
  97765. * @param color the color of the light
  97766. * @param deltaSolidAngle the delta solid angle of the light
  97767. */
  97768. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  97769. /**
  97770. * Scales the spherical harmonics by the given amount
  97771. * @param scale the amount to scale
  97772. */
  97773. scaleInPlace(scale: number): void;
  97774. /**
  97775. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  97776. *
  97777. * ```
  97778. * E_lm = A_l * L_lm
  97779. * ```
  97780. *
  97781. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  97782. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  97783. * the scaling factors are given in equation 9.
  97784. */
  97785. convertIncidentRadianceToIrradiance(): void;
  97786. /**
  97787. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  97788. *
  97789. * ```
  97790. * L = (1/pi) * E * rho
  97791. * ```
  97792. *
  97793. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  97794. */
  97795. convertIrradianceToLambertianRadiance(): void;
  97796. /**
  97797. * Integrates the reconstruction coefficients directly in to the SH preventing further
  97798. * required operations at run time.
  97799. *
  97800. * This is simply done by scaling back the SH with Ylm constants parameter.
  97801. * The trigonometric part being applied by the shader at run time.
  97802. */
  97803. preScaleForRendering(): void;
  97804. /**
  97805. * Constructs a spherical harmonics from an array.
  97806. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  97807. * @returns the spherical harmonics
  97808. */
  97809. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  97810. /**
  97811. * Gets the spherical harmonics from polynomial
  97812. * @param polynomial the spherical polynomial
  97813. * @returns the spherical harmonics
  97814. */
  97815. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  97816. }
  97817. /**
  97818. * Class representing spherical polynomial coefficients to the 3rd degree
  97819. */
  97820. export class SphericalPolynomial {
  97821. private _harmonics;
  97822. /**
  97823. * The spherical harmonics used to create the polynomials.
  97824. */
  97825. readonly preScaledHarmonics: SphericalHarmonics;
  97826. /**
  97827. * The x coefficients of the spherical polynomial
  97828. */
  97829. x: Vector3;
  97830. /**
  97831. * The y coefficients of the spherical polynomial
  97832. */
  97833. y: Vector3;
  97834. /**
  97835. * The z coefficients of the spherical polynomial
  97836. */
  97837. z: Vector3;
  97838. /**
  97839. * The xx coefficients of the spherical polynomial
  97840. */
  97841. xx: Vector3;
  97842. /**
  97843. * The yy coefficients of the spherical polynomial
  97844. */
  97845. yy: Vector3;
  97846. /**
  97847. * The zz coefficients of the spherical polynomial
  97848. */
  97849. zz: Vector3;
  97850. /**
  97851. * The xy coefficients of the spherical polynomial
  97852. */
  97853. xy: Vector3;
  97854. /**
  97855. * The yz coefficients of the spherical polynomial
  97856. */
  97857. yz: Vector3;
  97858. /**
  97859. * The zx coefficients of the spherical polynomial
  97860. */
  97861. zx: Vector3;
  97862. /**
  97863. * Adds an ambient color to the spherical polynomial
  97864. * @param color the color to add
  97865. */
  97866. addAmbient(color: Color3): void;
  97867. /**
  97868. * Scales the spherical polynomial by the given amount
  97869. * @param scale the amount to scale
  97870. */
  97871. scaleInPlace(scale: number): void;
  97872. /**
  97873. * Gets the spherical polynomial from harmonics
  97874. * @param harmonics the spherical harmonics
  97875. * @returns the spherical polynomial
  97876. */
  97877. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  97878. /**
  97879. * Constructs a spherical polynomial from an array.
  97880. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  97881. * @returns the spherical polynomial
  97882. */
  97883. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  97884. }
  97885. }
  97886. declare module BABYLON {
  97887. /**
  97888. * Defines the source of the internal texture
  97889. */
  97890. export enum InternalTextureSource {
  97891. /**
  97892. * The source of the texture data is unknown
  97893. */
  97894. Unknown = 0,
  97895. /**
  97896. * Texture data comes from an URL
  97897. */
  97898. Url = 1,
  97899. /**
  97900. * Texture data is only used for temporary storage
  97901. */
  97902. Temp = 2,
  97903. /**
  97904. * Texture data comes from raw data (ArrayBuffer)
  97905. */
  97906. Raw = 3,
  97907. /**
  97908. * Texture content is dynamic (video or dynamic texture)
  97909. */
  97910. Dynamic = 4,
  97911. /**
  97912. * Texture content is generated by rendering to it
  97913. */
  97914. RenderTarget = 5,
  97915. /**
  97916. * Texture content is part of a multi render target process
  97917. */
  97918. MultiRenderTarget = 6,
  97919. /**
  97920. * Texture data comes from a cube data file
  97921. */
  97922. Cube = 7,
  97923. /**
  97924. * Texture data comes from a raw cube data
  97925. */
  97926. CubeRaw = 8,
  97927. /**
  97928. * Texture data come from a prefiltered cube data file
  97929. */
  97930. CubePrefiltered = 9,
  97931. /**
  97932. * Texture content is raw 3D data
  97933. */
  97934. Raw3D = 10,
  97935. /**
  97936. * Texture content is a depth texture
  97937. */
  97938. Depth = 11,
  97939. /**
  97940. * Texture data comes from a raw cube data encoded with RGBD
  97941. */
  97942. CubeRawRGBD = 12
  97943. }
  97944. /**
  97945. * Class used to store data associated with WebGL texture data for the engine
  97946. * This class should not be used directly
  97947. */
  97948. export class InternalTexture {
  97949. /** @hidden */
  97950. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97951. /**
  97952. * Defines if the texture is ready
  97953. */
  97954. isReady: boolean;
  97955. /**
  97956. * Defines if the texture is a cube texture
  97957. */
  97958. isCube: boolean;
  97959. /**
  97960. * Defines if the texture contains 3D data
  97961. */
  97962. is3D: boolean;
  97963. /**
  97964. * Defines if the texture contains multiview data
  97965. */
  97966. isMultiview: boolean;
  97967. /**
  97968. * Gets the URL used to load this texture
  97969. */
  97970. url: string;
  97971. /**
  97972. * Gets the sampling mode of the texture
  97973. */
  97974. samplingMode: number;
  97975. /**
  97976. * Gets a boolean indicating if the texture needs mipmaps generation
  97977. */
  97978. generateMipMaps: boolean;
  97979. /**
  97980. * Gets the number of samples used by the texture (WebGL2+ only)
  97981. */
  97982. samples: number;
  97983. /**
  97984. * Gets the type of the texture (int, float...)
  97985. */
  97986. type: number;
  97987. /**
  97988. * Gets the format of the texture (RGB, RGBA...)
  97989. */
  97990. format: number;
  97991. /**
  97992. * Observable called when the texture is loaded
  97993. */
  97994. onLoadedObservable: Observable<InternalTexture>;
  97995. /**
  97996. * Gets the width of the texture
  97997. */
  97998. width: number;
  97999. /**
  98000. * Gets the height of the texture
  98001. */
  98002. height: number;
  98003. /**
  98004. * Gets the depth of the texture
  98005. */
  98006. depth: number;
  98007. /**
  98008. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  98009. */
  98010. baseWidth: number;
  98011. /**
  98012. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  98013. */
  98014. baseHeight: number;
  98015. /**
  98016. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  98017. */
  98018. baseDepth: number;
  98019. /**
  98020. * Gets a boolean indicating if the texture is inverted on Y axis
  98021. */
  98022. invertY: boolean;
  98023. /** @hidden */
  98024. _invertVScale: boolean;
  98025. /** @hidden */
  98026. _associatedChannel: number;
  98027. /** @hidden */
  98028. _source: InternalTextureSource;
  98029. /** @hidden */
  98030. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  98031. /** @hidden */
  98032. _bufferView: Nullable<ArrayBufferView>;
  98033. /** @hidden */
  98034. _bufferViewArray: Nullable<ArrayBufferView[]>;
  98035. /** @hidden */
  98036. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  98037. /** @hidden */
  98038. _size: number;
  98039. /** @hidden */
  98040. _extension: string;
  98041. /** @hidden */
  98042. _files: Nullable<string[]>;
  98043. /** @hidden */
  98044. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  98045. /** @hidden */
  98046. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  98047. /** @hidden */
  98048. _framebuffer: Nullable<WebGLFramebuffer>;
  98049. /** @hidden */
  98050. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  98051. /** @hidden */
  98052. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  98053. /** @hidden */
  98054. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  98055. /** @hidden */
  98056. _attachments: Nullable<number[]>;
  98057. /** @hidden */
  98058. _cachedCoordinatesMode: Nullable<number>;
  98059. /** @hidden */
  98060. _cachedWrapU: Nullable<number>;
  98061. /** @hidden */
  98062. _cachedWrapV: Nullable<number>;
  98063. /** @hidden */
  98064. _cachedWrapR: Nullable<number>;
  98065. /** @hidden */
  98066. _cachedAnisotropicFilteringLevel: Nullable<number>;
  98067. /** @hidden */
  98068. _isDisabled: boolean;
  98069. /** @hidden */
  98070. _compression: Nullable<string>;
  98071. /** @hidden */
  98072. _generateStencilBuffer: boolean;
  98073. /** @hidden */
  98074. _generateDepthBuffer: boolean;
  98075. /** @hidden */
  98076. _comparisonFunction: number;
  98077. /** @hidden */
  98078. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  98079. /** @hidden */
  98080. _lodGenerationScale: number;
  98081. /** @hidden */
  98082. _lodGenerationOffset: number;
  98083. /** @hidden */
  98084. _colorTextureArray: Nullable<WebGLTexture>;
  98085. /** @hidden */
  98086. _depthStencilTextureArray: Nullable<WebGLTexture>;
  98087. /** @hidden */
  98088. _lodTextureHigh: Nullable<BaseTexture>;
  98089. /** @hidden */
  98090. _lodTextureMid: Nullable<BaseTexture>;
  98091. /** @hidden */
  98092. _lodTextureLow: Nullable<BaseTexture>;
  98093. /** @hidden */
  98094. _isRGBD: boolean;
  98095. /** @hidden */
  98096. _linearSpecularLOD: boolean;
  98097. /** @hidden */
  98098. _irradianceTexture: Nullable<BaseTexture>;
  98099. /** @hidden */
  98100. _webGLTexture: Nullable<WebGLTexture>;
  98101. /** @hidden */
  98102. _references: number;
  98103. private _engine;
  98104. /**
  98105. * Gets the Engine the texture belongs to.
  98106. * @returns The babylon engine
  98107. */
  98108. getEngine(): ThinEngine;
  98109. /**
  98110. * Gets the data source type of the texture
  98111. */
  98112. readonly source: InternalTextureSource;
  98113. /**
  98114. * Creates a new InternalTexture
  98115. * @param engine defines the engine to use
  98116. * @param source defines the type of data that will be used
  98117. * @param delayAllocation if the texture allocation should be delayed (default: false)
  98118. */
  98119. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  98120. /**
  98121. * Increments the number of references (ie. the number of Texture that point to it)
  98122. */
  98123. incrementReferences(): void;
  98124. /**
  98125. * Change the size of the texture (not the size of the content)
  98126. * @param width defines the new width
  98127. * @param height defines the new height
  98128. * @param depth defines the new depth (1 by default)
  98129. */
  98130. updateSize(width: int, height: int, depth?: int): void;
  98131. /** @hidden */
  98132. _rebuild(): void;
  98133. /** @hidden */
  98134. _swapAndDie(target: InternalTexture): void;
  98135. /**
  98136. * Dispose the current allocated resources
  98137. */
  98138. dispose(): void;
  98139. }
  98140. }
  98141. declare module BABYLON {
  98142. /**
  98143. * Class used to work with sound analyzer using fast fourier transform (FFT)
  98144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98145. */
  98146. export class Analyser {
  98147. /**
  98148. * Gets or sets the smoothing
  98149. * @ignorenaming
  98150. */
  98151. SMOOTHING: number;
  98152. /**
  98153. * Gets or sets the FFT table size
  98154. * @ignorenaming
  98155. */
  98156. FFT_SIZE: number;
  98157. /**
  98158. * Gets or sets the bar graph amplitude
  98159. * @ignorenaming
  98160. */
  98161. BARGRAPHAMPLITUDE: number;
  98162. /**
  98163. * Gets or sets the position of the debug canvas
  98164. * @ignorenaming
  98165. */
  98166. DEBUGCANVASPOS: {
  98167. x: number;
  98168. y: number;
  98169. };
  98170. /**
  98171. * Gets or sets the debug canvas size
  98172. * @ignorenaming
  98173. */
  98174. DEBUGCANVASSIZE: {
  98175. width: number;
  98176. height: number;
  98177. };
  98178. private _byteFreqs;
  98179. private _byteTime;
  98180. private _floatFreqs;
  98181. private _webAudioAnalyser;
  98182. private _debugCanvas;
  98183. private _debugCanvasContext;
  98184. private _scene;
  98185. private _registerFunc;
  98186. private _audioEngine;
  98187. /**
  98188. * Creates a new analyser
  98189. * @param scene defines hosting scene
  98190. */
  98191. constructor(scene: Scene);
  98192. /**
  98193. * Get the number of data values you will have to play with for the visualization
  98194. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  98195. * @returns a number
  98196. */
  98197. getFrequencyBinCount(): number;
  98198. /**
  98199. * Gets the current frequency data as a byte array
  98200. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98201. * @returns a Uint8Array
  98202. */
  98203. getByteFrequencyData(): Uint8Array;
  98204. /**
  98205. * Gets the current waveform as a byte array
  98206. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  98207. * @returns a Uint8Array
  98208. */
  98209. getByteTimeDomainData(): Uint8Array;
  98210. /**
  98211. * Gets the current frequency data as a float array
  98212. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  98213. * @returns a Float32Array
  98214. */
  98215. getFloatFrequencyData(): Float32Array;
  98216. /**
  98217. * Renders the debug canvas
  98218. */
  98219. drawDebugCanvas(): void;
  98220. /**
  98221. * Stops rendering the debug canvas and removes it
  98222. */
  98223. stopDebugCanvas(): void;
  98224. /**
  98225. * Connects two audio nodes
  98226. * @param inputAudioNode defines first node to connect
  98227. * @param outputAudioNode defines second node to connect
  98228. */
  98229. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  98230. /**
  98231. * Releases all associated resources
  98232. */
  98233. dispose(): void;
  98234. }
  98235. }
  98236. declare module BABYLON {
  98237. /**
  98238. * This represents an audio engine and it is responsible
  98239. * to play, synchronize and analyse sounds throughout the application.
  98240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98241. */
  98242. export interface IAudioEngine extends IDisposable {
  98243. /**
  98244. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98245. */
  98246. readonly canUseWebAudio: boolean;
  98247. /**
  98248. * Gets the current AudioContext if available.
  98249. */
  98250. readonly audioContext: Nullable<AudioContext>;
  98251. /**
  98252. * The master gain node defines the global audio volume of your audio engine.
  98253. */
  98254. readonly masterGain: GainNode;
  98255. /**
  98256. * Gets whether or not mp3 are supported by your browser.
  98257. */
  98258. readonly isMP3supported: boolean;
  98259. /**
  98260. * Gets whether or not ogg are supported by your browser.
  98261. */
  98262. readonly isOGGsupported: boolean;
  98263. /**
  98264. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98265. * @ignoreNaming
  98266. */
  98267. WarnedWebAudioUnsupported: boolean;
  98268. /**
  98269. * Defines if the audio engine relies on a custom unlocked button.
  98270. * In this case, the embedded button will not be displayed.
  98271. */
  98272. useCustomUnlockedButton: boolean;
  98273. /**
  98274. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  98275. */
  98276. readonly unlocked: boolean;
  98277. /**
  98278. * Event raised when audio has been unlocked on the browser.
  98279. */
  98280. onAudioUnlockedObservable: Observable<AudioEngine>;
  98281. /**
  98282. * Event raised when audio has been locked on the browser.
  98283. */
  98284. onAudioLockedObservable: Observable<AudioEngine>;
  98285. /**
  98286. * Flags the audio engine in Locked state.
  98287. * This happens due to new browser policies preventing audio to autoplay.
  98288. */
  98289. lock(): void;
  98290. /**
  98291. * Unlocks the audio engine once a user action has been done on the dom.
  98292. * This is helpful to resume play once browser policies have been satisfied.
  98293. */
  98294. unlock(): void;
  98295. }
  98296. /**
  98297. * This represents the default audio engine used in babylon.
  98298. * It is responsible to play, synchronize and analyse sounds throughout the application.
  98299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98300. */
  98301. export class AudioEngine implements IAudioEngine {
  98302. private _audioContext;
  98303. private _audioContextInitialized;
  98304. private _muteButton;
  98305. private _hostElement;
  98306. /**
  98307. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  98308. */
  98309. canUseWebAudio: boolean;
  98310. /**
  98311. * The master gain node defines the global audio volume of your audio engine.
  98312. */
  98313. masterGain: GainNode;
  98314. /**
  98315. * Defines if Babylon should emit a warning if WebAudio is not supported.
  98316. * @ignoreNaming
  98317. */
  98318. WarnedWebAudioUnsupported: boolean;
  98319. /**
  98320. * Gets whether or not mp3 are supported by your browser.
  98321. */
  98322. isMP3supported: boolean;
  98323. /**
  98324. * Gets whether or not ogg are supported by your browser.
  98325. */
  98326. isOGGsupported: boolean;
  98327. /**
  98328. * Gets whether audio has been unlocked on the device.
  98329. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  98330. * a user interaction has happened.
  98331. */
  98332. unlocked: boolean;
  98333. /**
  98334. * Defines if the audio engine relies on a custom unlocked button.
  98335. * In this case, the embedded button will not be displayed.
  98336. */
  98337. useCustomUnlockedButton: boolean;
  98338. /**
  98339. * Event raised when audio has been unlocked on the browser.
  98340. */
  98341. onAudioUnlockedObservable: Observable<AudioEngine>;
  98342. /**
  98343. * Event raised when audio has been locked on the browser.
  98344. */
  98345. onAudioLockedObservable: Observable<AudioEngine>;
  98346. /**
  98347. * Gets the current AudioContext if available.
  98348. */
  98349. readonly audioContext: Nullable<AudioContext>;
  98350. private _connectedAnalyser;
  98351. /**
  98352. * Instantiates a new audio engine.
  98353. *
  98354. * There should be only one per page as some browsers restrict the number
  98355. * of audio contexts you can create.
  98356. * @param hostElement defines the host element where to display the mute icon if necessary
  98357. */
  98358. constructor(hostElement?: Nullable<HTMLElement>);
  98359. /**
  98360. * Flags the audio engine in Locked state.
  98361. * This happens due to new browser policies preventing audio to autoplay.
  98362. */
  98363. lock(): void;
  98364. /**
  98365. * Unlocks the audio engine once a user action has been done on the dom.
  98366. * This is helpful to resume play once browser policies have been satisfied.
  98367. */
  98368. unlock(): void;
  98369. private _resumeAudioContext;
  98370. private _initializeAudioContext;
  98371. private _tryToRun;
  98372. private _triggerRunningState;
  98373. private _triggerSuspendedState;
  98374. private _displayMuteButton;
  98375. private _moveButtonToTopLeft;
  98376. private _onResize;
  98377. private _hideMuteButton;
  98378. /**
  98379. * Destroy and release the resources associated with the audio ccontext.
  98380. */
  98381. dispose(): void;
  98382. /**
  98383. * Gets the global volume sets on the master gain.
  98384. * @returns the global volume if set or -1 otherwise
  98385. */
  98386. getGlobalVolume(): number;
  98387. /**
  98388. * Sets the global volume of your experience (sets on the master gain).
  98389. * @param newVolume Defines the new global volume of the application
  98390. */
  98391. setGlobalVolume(newVolume: number): void;
  98392. /**
  98393. * Connect the audio engine to an audio analyser allowing some amazing
  98394. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98396. * @param analyser The analyser to connect to the engine
  98397. */
  98398. connectToAnalyser(analyser: Analyser): void;
  98399. }
  98400. }
  98401. declare module BABYLON {
  98402. /**
  98403. * Interface used to present a loading screen while loading a scene
  98404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98405. */
  98406. export interface ILoadingScreen {
  98407. /**
  98408. * Function called to display the loading screen
  98409. */
  98410. displayLoadingUI: () => void;
  98411. /**
  98412. * Function called to hide the loading screen
  98413. */
  98414. hideLoadingUI: () => void;
  98415. /**
  98416. * Gets or sets the color to use for the background
  98417. */
  98418. loadingUIBackgroundColor: string;
  98419. /**
  98420. * Gets or sets the text to display while loading
  98421. */
  98422. loadingUIText: string;
  98423. }
  98424. /**
  98425. * Class used for the default loading screen
  98426. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98427. */
  98428. export class DefaultLoadingScreen implements ILoadingScreen {
  98429. private _renderingCanvas;
  98430. private _loadingText;
  98431. private _loadingDivBackgroundColor;
  98432. private _loadingDiv;
  98433. private _loadingTextDiv;
  98434. /** Gets or sets the logo url to use for the default loading screen */
  98435. static DefaultLogoUrl: string;
  98436. /** Gets or sets the spinner url to use for the default loading screen */
  98437. static DefaultSpinnerUrl: string;
  98438. /**
  98439. * Creates a new default loading screen
  98440. * @param _renderingCanvas defines the canvas used to render the scene
  98441. * @param _loadingText defines the default text to display
  98442. * @param _loadingDivBackgroundColor defines the default background color
  98443. */
  98444. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  98445. /**
  98446. * Function called to display the loading screen
  98447. */
  98448. displayLoadingUI(): void;
  98449. /**
  98450. * Function called to hide the loading screen
  98451. */
  98452. hideLoadingUI(): void;
  98453. /**
  98454. * Gets or sets the text to display while loading
  98455. */
  98456. loadingUIText: string;
  98457. /**
  98458. * Gets or sets the color to use for the background
  98459. */
  98460. loadingUIBackgroundColor: string;
  98461. private _resizeLoadingUI;
  98462. }
  98463. }
  98464. declare module BABYLON {
  98465. /**
  98466. * Interface for any object that can request an animation frame
  98467. */
  98468. export interface ICustomAnimationFrameRequester {
  98469. /**
  98470. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  98471. */
  98472. renderFunction?: Function;
  98473. /**
  98474. * Called to request the next frame to render to
  98475. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  98476. */
  98477. requestAnimationFrame: Function;
  98478. /**
  98479. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  98480. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  98481. */
  98482. requestID?: number;
  98483. }
  98484. }
  98485. declare module BABYLON {
  98486. /**
  98487. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  98488. */
  98489. export class PerformanceMonitor {
  98490. private _enabled;
  98491. private _rollingFrameTime;
  98492. private _lastFrameTimeMs;
  98493. /**
  98494. * constructor
  98495. * @param frameSampleSize The number of samples required to saturate the sliding window
  98496. */
  98497. constructor(frameSampleSize?: number);
  98498. /**
  98499. * Samples current frame
  98500. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  98501. */
  98502. sampleFrame(timeMs?: number): void;
  98503. /**
  98504. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98505. */
  98506. readonly averageFrameTime: number;
  98507. /**
  98508. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  98509. */
  98510. readonly averageFrameTimeVariance: number;
  98511. /**
  98512. * Returns the frame time of the most recent frame
  98513. */
  98514. readonly instantaneousFrameTime: number;
  98515. /**
  98516. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  98517. */
  98518. readonly averageFPS: number;
  98519. /**
  98520. * Returns the average framerate in frames per second using the most recent frame time
  98521. */
  98522. readonly instantaneousFPS: number;
  98523. /**
  98524. * Returns true if enough samples have been taken to completely fill the sliding window
  98525. */
  98526. readonly isSaturated: boolean;
  98527. /**
  98528. * Enables contributions to the sliding window sample set
  98529. */
  98530. enable(): void;
  98531. /**
  98532. * Disables contributions to the sliding window sample set
  98533. * Samples will not be interpolated over the disabled period
  98534. */
  98535. disable(): void;
  98536. /**
  98537. * Returns true if sampling is enabled
  98538. */
  98539. readonly isEnabled: boolean;
  98540. /**
  98541. * Resets performance monitor
  98542. */
  98543. reset(): void;
  98544. }
  98545. /**
  98546. * RollingAverage
  98547. *
  98548. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  98549. */
  98550. export class RollingAverage {
  98551. /**
  98552. * Current average
  98553. */
  98554. average: number;
  98555. /**
  98556. * Current variance
  98557. */
  98558. variance: number;
  98559. protected _samples: Array<number>;
  98560. protected _sampleCount: number;
  98561. protected _pos: number;
  98562. protected _m2: number;
  98563. /**
  98564. * constructor
  98565. * @param length The number of samples required to saturate the sliding window
  98566. */
  98567. constructor(length: number);
  98568. /**
  98569. * Adds a sample to the sample set
  98570. * @param v The sample value
  98571. */
  98572. add(v: number): void;
  98573. /**
  98574. * Returns previously added values or null if outside of history or outside the sliding window domain
  98575. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  98576. * @return Value previously recorded with add() or null if outside of range
  98577. */
  98578. history(i: number): number;
  98579. /**
  98580. * Returns true if enough samples have been taken to completely fill the sliding window
  98581. * @return true if sample-set saturated
  98582. */
  98583. isSaturated(): boolean;
  98584. /**
  98585. * Resets the rolling average (equivalent to 0 samples taken so far)
  98586. */
  98587. reset(): void;
  98588. /**
  98589. * Wraps a value around the sample range boundaries
  98590. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  98591. * @return Wrapped position in sample range
  98592. */
  98593. protected _wrapPosition(i: number): number;
  98594. }
  98595. }
  98596. declare module BABYLON {
  98597. /**
  98598. * This class is used to track a performance counter which is number based.
  98599. * The user has access to many properties which give statistics of different nature.
  98600. *
  98601. * The implementer can track two kinds of Performance Counter: time and count.
  98602. * 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.
  98603. * 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.
  98604. */
  98605. export class PerfCounter {
  98606. /**
  98607. * Gets or sets a global boolean to turn on and off all the counters
  98608. */
  98609. static Enabled: boolean;
  98610. /**
  98611. * Returns the smallest value ever
  98612. */
  98613. readonly min: number;
  98614. /**
  98615. * Returns the biggest value ever
  98616. */
  98617. readonly max: number;
  98618. /**
  98619. * Returns the average value since the performance counter is running
  98620. */
  98621. readonly average: number;
  98622. /**
  98623. * Returns the average value of the last second the counter was monitored
  98624. */
  98625. readonly lastSecAverage: number;
  98626. /**
  98627. * Returns the current value
  98628. */
  98629. readonly current: number;
  98630. /**
  98631. * Gets the accumulated total
  98632. */
  98633. readonly total: number;
  98634. /**
  98635. * Gets the total value count
  98636. */
  98637. readonly count: number;
  98638. /**
  98639. * Creates a new counter
  98640. */
  98641. constructor();
  98642. /**
  98643. * Call this method to start monitoring a new frame.
  98644. * 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.
  98645. */
  98646. fetchNewFrame(): void;
  98647. /**
  98648. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  98649. * @param newCount the count value to add to the monitored count
  98650. * @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.
  98651. */
  98652. addCount(newCount: number, fetchResult: boolean): void;
  98653. /**
  98654. * Start monitoring this performance counter
  98655. */
  98656. beginMonitoring(): void;
  98657. /**
  98658. * Compute the time lapsed since the previous beginMonitoring() call.
  98659. * @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
  98660. */
  98661. endMonitoring(newFrame?: boolean): void;
  98662. private _fetchResult;
  98663. private _startMonitoringTime;
  98664. private _min;
  98665. private _max;
  98666. private _average;
  98667. private _current;
  98668. private _totalValueCount;
  98669. private _totalAccumulated;
  98670. private _lastSecAverage;
  98671. private _lastSecAccumulated;
  98672. private _lastSecTime;
  98673. private _lastSecValueCount;
  98674. }
  98675. }
  98676. declare module BABYLON {
  98677. /**
  98678. * Defines the interface used by display changed events
  98679. */
  98680. export interface IDisplayChangedEventArgs {
  98681. /** Gets the vrDisplay object (if any) */
  98682. vrDisplay: Nullable<any>;
  98683. /** Gets a boolean indicating if webVR is supported */
  98684. vrSupported: boolean;
  98685. }
  98686. /**
  98687. * Defines the interface used by objects containing a viewport (like a camera)
  98688. */
  98689. interface IViewportOwnerLike {
  98690. /**
  98691. * Gets or sets the viewport
  98692. */
  98693. viewport: IViewportLike;
  98694. }
  98695. /**
  98696. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  98697. */
  98698. export class Engine extends ThinEngine {
  98699. /** Defines that alpha blending is disabled */
  98700. static readonly ALPHA_DISABLE: number;
  98701. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  98702. static readonly ALPHA_ADD: number;
  98703. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  98704. static readonly ALPHA_COMBINE: number;
  98705. /** Defines that alpha blending to DEST - SRC * DEST */
  98706. static readonly ALPHA_SUBTRACT: number;
  98707. /** Defines that alpha blending to SRC * DEST */
  98708. static readonly ALPHA_MULTIPLY: number;
  98709. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  98710. static readonly ALPHA_MAXIMIZED: number;
  98711. /** Defines that alpha blending to SRC + DEST */
  98712. static readonly ALPHA_ONEONE: number;
  98713. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  98714. static readonly ALPHA_PREMULTIPLIED: number;
  98715. /**
  98716. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  98717. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  98718. */
  98719. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  98720. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  98721. static readonly ALPHA_INTERPOLATE: number;
  98722. /**
  98723. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  98724. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  98725. */
  98726. static readonly ALPHA_SCREENMODE: number;
  98727. /** Defines that the ressource is not delayed*/
  98728. static readonly DELAYLOADSTATE_NONE: number;
  98729. /** Defines that the ressource was successfully delay loaded */
  98730. static readonly DELAYLOADSTATE_LOADED: number;
  98731. /** Defines that the ressource is currently delay loading */
  98732. static readonly DELAYLOADSTATE_LOADING: number;
  98733. /** Defines that the ressource is delayed and has not started loading */
  98734. static readonly DELAYLOADSTATE_NOTLOADED: number;
  98735. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  98736. static readonly NEVER: number;
  98737. /** 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 */
  98738. static readonly ALWAYS: number;
  98739. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  98740. static readonly LESS: number;
  98741. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  98742. static readonly EQUAL: number;
  98743. /** 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 */
  98744. static readonly LEQUAL: number;
  98745. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  98746. static readonly GREATER: number;
  98747. /** 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 */
  98748. static readonly GEQUAL: number;
  98749. /** 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 */
  98750. static readonly NOTEQUAL: number;
  98751. /** Passed to stencilOperation to specify that stencil value must be kept */
  98752. static readonly KEEP: number;
  98753. /** Passed to stencilOperation to specify that stencil value must be replaced */
  98754. static readonly REPLACE: number;
  98755. /** Passed to stencilOperation to specify that stencil value must be incremented */
  98756. static readonly INCR: number;
  98757. /** Passed to stencilOperation to specify that stencil value must be decremented */
  98758. static readonly DECR: number;
  98759. /** Passed to stencilOperation to specify that stencil value must be inverted */
  98760. static readonly INVERT: number;
  98761. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  98762. static readonly INCR_WRAP: number;
  98763. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  98764. static readonly DECR_WRAP: number;
  98765. /** Texture is not repeating outside of 0..1 UVs */
  98766. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  98767. /** Texture is repeating outside of 0..1 UVs */
  98768. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  98769. /** Texture is repeating and mirrored */
  98770. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  98771. /** ALPHA */
  98772. static readonly TEXTUREFORMAT_ALPHA: number;
  98773. /** LUMINANCE */
  98774. static readonly TEXTUREFORMAT_LUMINANCE: number;
  98775. /** LUMINANCE_ALPHA */
  98776. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  98777. /** RGB */
  98778. static readonly TEXTUREFORMAT_RGB: number;
  98779. /** RGBA */
  98780. static readonly TEXTUREFORMAT_RGBA: number;
  98781. /** RED */
  98782. static readonly TEXTUREFORMAT_RED: number;
  98783. /** RED (2nd reference) */
  98784. static readonly TEXTUREFORMAT_R: number;
  98785. /** RG */
  98786. static readonly TEXTUREFORMAT_RG: number;
  98787. /** RED_INTEGER */
  98788. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  98789. /** RED_INTEGER (2nd reference) */
  98790. static readonly TEXTUREFORMAT_R_INTEGER: number;
  98791. /** RG_INTEGER */
  98792. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  98793. /** RGB_INTEGER */
  98794. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  98795. /** RGBA_INTEGER */
  98796. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  98797. /** UNSIGNED_BYTE */
  98798. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  98799. /** UNSIGNED_BYTE (2nd reference) */
  98800. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  98801. /** FLOAT */
  98802. static readonly TEXTURETYPE_FLOAT: number;
  98803. /** HALF_FLOAT */
  98804. static readonly TEXTURETYPE_HALF_FLOAT: number;
  98805. /** BYTE */
  98806. static readonly TEXTURETYPE_BYTE: number;
  98807. /** SHORT */
  98808. static readonly TEXTURETYPE_SHORT: number;
  98809. /** UNSIGNED_SHORT */
  98810. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  98811. /** INT */
  98812. static readonly TEXTURETYPE_INT: number;
  98813. /** UNSIGNED_INT */
  98814. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  98815. /** UNSIGNED_SHORT_4_4_4_4 */
  98816. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  98817. /** UNSIGNED_SHORT_5_5_5_1 */
  98818. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  98819. /** UNSIGNED_SHORT_5_6_5 */
  98820. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  98821. /** UNSIGNED_INT_2_10_10_10_REV */
  98822. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  98823. /** UNSIGNED_INT_24_8 */
  98824. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  98825. /** UNSIGNED_INT_10F_11F_11F_REV */
  98826. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  98827. /** UNSIGNED_INT_5_9_9_9_REV */
  98828. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  98829. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  98830. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  98831. /** nearest is mag = nearest and min = nearest and mip = linear */
  98832. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  98833. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98834. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  98835. /** Trilinear is mag = linear and min = linear and mip = linear */
  98836. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  98837. /** nearest is mag = nearest and min = nearest and mip = linear */
  98838. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  98839. /** Bilinear is mag = linear and min = linear and mip = nearest */
  98840. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  98841. /** Trilinear is mag = linear and min = linear and mip = linear */
  98842. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  98843. /** mag = nearest and min = nearest and mip = nearest */
  98844. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  98845. /** mag = nearest and min = linear and mip = nearest */
  98846. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  98847. /** mag = nearest and min = linear and mip = linear */
  98848. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  98849. /** mag = nearest and min = linear and mip = none */
  98850. static readonly TEXTURE_NEAREST_LINEAR: number;
  98851. /** mag = nearest and min = nearest and mip = none */
  98852. static readonly TEXTURE_NEAREST_NEAREST: number;
  98853. /** mag = linear and min = nearest and mip = nearest */
  98854. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  98855. /** mag = linear and min = nearest and mip = linear */
  98856. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  98857. /** mag = linear and min = linear and mip = none */
  98858. static readonly TEXTURE_LINEAR_LINEAR: number;
  98859. /** mag = linear and min = nearest and mip = none */
  98860. static readonly TEXTURE_LINEAR_NEAREST: number;
  98861. /** Explicit coordinates mode */
  98862. static readonly TEXTURE_EXPLICIT_MODE: number;
  98863. /** Spherical coordinates mode */
  98864. static readonly TEXTURE_SPHERICAL_MODE: number;
  98865. /** Planar coordinates mode */
  98866. static readonly TEXTURE_PLANAR_MODE: number;
  98867. /** Cubic coordinates mode */
  98868. static readonly TEXTURE_CUBIC_MODE: number;
  98869. /** Projection coordinates mode */
  98870. static readonly TEXTURE_PROJECTION_MODE: number;
  98871. /** Skybox coordinates mode */
  98872. static readonly TEXTURE_SKYBOX_MODE: number;
  98873. /** Inverse Cubic coordinates mode */
  98874. static readonly TEXTURE_INVCUBIC_MODE: number;
  98875. /** Equirectangular coordinates mode */
  98876. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  98877. /** Equirectangular Fixed coordinates mode */
  98878. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  98879. /** Equirectangular Fixed Mirrored coordinates mode */
  98880. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  98881. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  98882. static readonly SCALEMODE_FLOOR: number;
  98883. /** Defines that texture rescaling will look for the nearest power of 2 size */
  98884. static readonly SCALEMODE_NEAREST: number;
  98885. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  98886. static readonly SCALEMODE_CEILING: number;
  98887. /**
  98888. * Returns the current npm package of the sdk
  98889. */
  98890. static readonly NpmPackage: string;
  98891. /**
  98892. * Returns the current version of the framework
  98893. */
  98894. static readonly Version: string;
  98895. /** Gets the list of created engines */
  98896. static readonly Instances: Engine[];
  98897. /**
  98898. * Gets the latest created engine
  98899. */
  98900. static readonly LastCreatedEngine: Nullable<Engine>;
  98901. /**
  98902. * Gets the latest created scene
  98903. */
  98904. static readonly LastCreatedScene: Nullable<Scene>;
  98905. /**
  98906. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98907. * @param flag defines which part of the materials must be marked as dirty
  98908. * @param predicate defines a predicate used to filter which materials should be affected
  98909. */
  98910. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98911. /**
  98912. * Method called to create the default loading screen.
  98913. * This can be overriden in your own app.
  98914. * @param canvas The rendering canvas element
  98915. * @returns The loading screen
  98916. */
  98917. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98918. /**
  98919. * Method called to create the default rescale post process on each engine.
  98920. */
  98921. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98922. /**
  98923. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98924. **/
  98925. enableOfflineSupport: boolean;
  98926. /**
  98927. * 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)
  98928. **/
  98929. disableManifestCheck: boolean;
  98930. /**
  98931. * Gets the list of created scenes
  98932. */
  98933. scenes: Scene[];
  98934. /**
  98935. * Event raised when a new scene is created
  98936. */
  98937. onNewSceneAddedObservable: Observable<Scene>;
  98938. /**
  98939. * Gets the list of created postprocesses
  98940. */
  98941. postProcesses: PostProcess[];
  98942. /**
  98943. * Gets a boolean indicating if the pointer is currently locked
  98944. */
  98945. isPointerLock: boolean;
  98946. /**
  98947. * Observable event triggered each time the rendering canvas is resized
  98948. */
  98949. onResizeObservable: Observable<Engine>;
  98950. /**
  98951. * Observable event triggered each time the canvas loses focus
  98952. */
  98953. onCanvasBlurObservable: Observable<Engine>;
  98954. /**
  98955. * Observable event triggered each time the canvas gains focus
  98956. */
  98957. onCanvasFocusObservable: Observable<Engine>;
  98958. /**
  98959. * Observable event triggered each time the canvas receives pointerout event
  98960. */
  98961. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98962. /**
  98963. * Observable raised when the engine begins a new frame
  98964. */
  98965. onBeginFrameObservable: Observable<Engine>;
  98966. /**
  98967. * If set, will be used to request the next animation frame for the render loop
  98968. */
  98969. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98970. /**
  98971. * Observable raised when the engine ends the current frame
  98972. */
  98973. onEndFrameObservable: Observable<Engine>;
  98974. /**
  98975. * Observable raised when the engine is about to compile a shader
  98976. */
  98977. onBeforeShaderCompilationObservable: Observable<Engine>;
  98978. /**
  98979. * Observable raised when the engine has jsut compiled a shader
  98980. */
  98981. onAfterShaderCompilationObservable: Observable<Engine>;
  98982. /**
  98983. * Gets the audio engine
  98984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98985. * @ignorenaming
  98986. */
  98987. static audioEngine: IAudioEngine;
  98988. /**
  98989. * Default AudioEngine factory responsible of creating the Audio Engine.
  98990. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98991. */
  98992. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98993. /**
  98994. * Default offline support factory responsible of creating a tool used to store data locally.
  98995. * By default, this will create a Database object if the workload has been embedded.
  98996. */
  98997. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98998. private _loadingScreen;
  98999. private _pointerLockRequested;
  99000. private _dummyFramebuffer;
  99001. private _rescalePostProcess;
  99002. /** @hidden */
  99003. protected _alphaMode: number;
  99004. /** @hidden */
  99005. protected _alphaEquation: number;
  99006. private _deterministicLockstep;
  99007. private _lockstepMaxSteps;
  99008. protected readonly _supportsHardwareTextureRescaling: boolean;
  99009. private _fps;
  99010. private _deltaTime;
  99011. /** @hidden */
  99012. _drawCalls: PerfCounter;
  99013. /**
  99014. * Turn this value on if you want to pause FPS computation when in background
  99015. */
  99016. disablePerformanceMonitorInBackground: boolean;
  99017. private _performanceMonitor;
  99018. /**
  99019. * Gets the performance monitor attached to this engine
  99020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99021. */
  99022. readonly performanceMonitor: PerformanceMonitor;
  99023. private _onFocus;
  99024. private _onBlur;
  99025. private _onCanvasPointerOut;
  99026. private _onCanvasBlur;
  99027. private _onCanvasFocus;
  99028. private _onFullscreenChange;
  99029. private _onPointerLockChange;
  99030. /**
  99031. * Creates a new engine
  99032. * @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
  99033. * @param antialias defines enable antialiasing (default: false)
  99034. * @param options defines further options to be sent to the getContext() function
  99035. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99036. */
  99037. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99038. /**
  99039. * Gets current aspect ratio
  99040. * @param viewportOwner defines the camera to use to get the aspect ratio
  99041. * @param useScreen defines if screen size must be used (or the current render target if any)
  99042. * @returns a number defining the aspect ratio
  99043. */
  99044. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  99045. /**
  99046. * Gets current screen aspect ratio
  99047. * @returns a number defining the aspect ratio
  99048. */
  99049. getScreenAspectRatio(): number;
  99050. /**
  99051. * Gets host document
  99052. * @returns the host document object
  99053. */
  99054. getHostDocument(): Document;
  99055. /**
  99056. * Gets the client rect of the HTML canvas attached with the current webGL context
  99057. * @returns a client rectanglee
  99058. */
  99059. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  99060. /**
  99061. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  99062. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99063. * @returns true if engine is in deterministic lock step mode
  99064. */
  99065. isDeterministicLockStep(): boolean;
  99066. /**
  99067. * Gets the max steps when engine is running in deterministic lock step
  99068. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99069. * @returns the max steps
  99070. */
  99071. getLockstepMaxSteps(): number;
  99072. /**
  99073. * Force the mipmap generation for the given render target texture
  99074. * @param texture defines the render target texture to use
  99075. */
  99076. generateMipMapsForCubemap(texture: InternalTexture): void;
  99077. /** States */
  99078. /**
  99079. * Set various states to the webGL context
  99080. * @param culling defines backface culling state
  99081. * @param zOffset defines the value to apply to zOffset (0 by default)
  99082. * @param force defines if states must be applied even if cache is up to date
  99083. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  99084. */
  99085. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99086. /**
  99087. * Set the z offset to apply to current rendering
  99088. * @param value defines the offset to apply
  99089. */
  99090. setZOffset(value: number): void;
  99091. /**
  99092. * Gets the current value of the zOffset
  99093. * @returns the current zOffset state
  99094. */
  99095. getZOffset(): number;
  99096. /**
  99097. * Enable or disable depth buffering
  99098. * @param enable defines the state to set
  99099. */
  99100. setDepthBuffer(enable: boolean): void;
  99101. /**
  99102. * Gets a boolean indicating if depth writing is enabled
  99103. * @returns the current depth writing state
  99104. */
  99105. getDepthWrite(): boolean;
  99106. /**
  99107. * Enable or disable depth writing
  99108. * @param enable defines the state to set
  99109. */
  99110. setDepthWrite(enable: boolean): void;
  99111. /**
  99112. * Enable or disable color writing
  99113. * @param enable defines the state to set
  99114. */
  99115. setColorWrite(enable: boolean): void;
  99116. /**
  99117. * Gets a boolean indicating if color writing is enabled
  99118. * @returns the current color writing state
  99119. */
  99120. getColorWrite(): boolean;
  99121. /**
  99122. * Sets alpha constants used by some alpha blending modes
  99123. * @param r defines the red component
  99124. * @param g defines the green component
  99125. * @param b defines the blue component
  99126. * @param a defines the alpha component
  99127. */
  99128. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  99129. /**
  99130. * Sets the current alpha mode
  99131. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  99132. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  99133. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99134. */
  99135. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99136. /**
  99137. * Gets the current alpha mode
  99138. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  99139. * @returns the current alpha mode
  99140. */
  99141. getAlphaMode(): number;
  99142. /**
  99143. * Sets the current alpha equation
  99144. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  99145. */
  99146. setAlphaEquation(equation: number): void;
  99147. /**
  99148. * Gets the current alpha equation.
  99149. * @returns the current alpha equation
  99150. */
  99151. getAlphaEquation(): number;
  99152. /**
  99153. * Gets a boolean indicating if stencil buffer is enabled
  99154. * @returns the current stencil buffer state
  99155. */
  99156. getStencilBuffer(): boolean;
  99157. /**
  99158. * Enable or disable the stencil buffer
  99159. * @param enable defines if the stencil buffer must be enabled or disabled
  99160. */
  99161. setStencilBuffer(enable: boolean): void;
  99162. /**
  99163. * Gets the current stencil mask
  99164. * @returns a number defining the new stencil mask to use
  99165. */
  99166. getStencilMask(): number;
  99167. /**
  99168. * Sets the current stencil mask
  99169. * @param mask defines the new stencil mask to use
  99170. */
  99171. setStencilMask(mask: number): void;
  99172. /**
  99173. * Gets the current stencil function
  99174. * @returns a number defining the stencil function to use
  99175. */
  99176. getStencilFunction(): number;
  99177. /**
  99178. * Gets the current stencil reference value
  99179. * @returns a number defining the stencil reference value to use
  99180. */
  99181. getStencilFunctionReference(): number;
  99182. /**
  99183. * Gets the current stencil mask
  99184. * @returns a number defining the stencil mask to use
  99185. */
  99186. getStencilFunctionMask(): number;
  99187. /**
  99188. * Sets the current stencil function
  99189. * @param stencilFunc defines the new stencil function to use
  99190. */
  99191. setStencilFunction(stencilFunc: number): void;
  99192. /**
  99193. * Sets the current stencil reference
  99194. * @param reference defines the new stencil reference to use
  99195. */
  99196. setStencilFunctionReference(reference: number): void;
  99197. /**
  99198. * Sets the current stencil mask
  99199. * @param mask defines the new stencil mask to use
  99200. */
  99201. setStencilFunctionMask(mask: number): void;
  99202. /**
  99203. * Gets the current stencil operation when stencil fails
  99204. * @returns a number defining stencil operation to use when stencil fails
  99205. */
  99206. getStencilOperationFail(): number;
  99207. /**
  99208. * Gets the current stencil operation when depth fails
  99209. * @returns a number defining stencil operation to use when depth fails
  99210. */
  99211. getStencilOperationDepthFail(): number;
  99212. /**
  99213. * Gets the current stencil operation when stencil passes
  99214. * @returns a number defining stencil operation to use when stencil passes
  99215. */
  99216. getStencilOperationPass(): number;
  99217. /**
  99218. * Sets the stencil operation to use when stencil fails
  99219. * @param operation defines the stencil operation to use when stencil fails
  99220. */
  99221. setStencilOperationFail(operation: number): void;
  99222. /**
  99223. * Sets the stencil operation to use when depth fails
  99224. * @param operation defines the stencil operation to use when depth fails
  99225. */
  99226. setStencilOperationDepthFail(operation: number): void;
  99227. /**
  99228. * Sets the stencil operation to use when stencil passes
  99229. * @param operation defines the stencil operation to use when stencil passes
  99230. */
  99231. setStencilOperationPass(operation: number): void;
  99232. /**
  99233. * Sets a boolean indicating if the dithering state is enabled or disabled
  99234. * @param value defines the dithering state
  99235. */
  99236. setDitheringState(value: boolean): void;
  99237. /**
  99238. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  99239. * @param value defines the rasterizer state
  99240. */
  99241. setRasterizerState(value: boolean): void;
  99242. /**
  99243. * Gets the current depth function
  99244. * @returns a number defining the depth function
  99245. */
  99246. getDepthFunction(): Nullable<number>;
  99247. /**
  99248. * Sets the current depth function
  99249. * @param depthFunc defines the function to use
  99250. */
  99251. setDepthFunction(depthFunc: number): void;
  99252. /**
  99253. * Sets the current depth function to GREATER
  99254. */
  99255. setDepthFunctionToGreater(): void;
  99256. /**
  99257. * Sets the current depth function to GEQUAL
  99258. */
  99259. setDepthFunctionToGreaterOrEqual(): void;
  99260. /**
  99261. * Sets the current depth function to LESS
  99262. */
  99263. setDepthFunctionToLess(): void;
  99264. /**
  99265. * Sets the current depth function to LEQUAL
  99266. */
  99267. setDepthFunctionToLessOrEqual(): void;
  99268. private _cachedStencilBuffer;
  99269. private _cachedStencilFunction;
  99270. private _cachedStencilMask;
  99271. private _cachedStencilOperationPass;
  99272. private _cachedStencilOperationFail;
  99273. private _cachedStencilOperationDepthFail;
  99274. private _cachedStencilReference;
  99275. /**
  99276. * Caches the the state of the stencil buffer
  99277. */
  99278. cacheStencilState(): void;
  99279. /**
  99280. * Restores the state of the stencil buffer
  99281. */
  99282. restoreStencilState(): void;
  99283. /**
  99284. * Directly set the WebGL Viewport
  99285. * @param x defines the x coordinate of the viewport (in screen space)
  99286. * @param y defines the y coordinate of the viewport (in screen space)
  99287. * @param width defines the width of the viewport (in screen space)
  99288. * @param height defines the height of the viewport (in screen space)
  99289. * @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
  99290. */
  99291. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  99292. /**
  99293. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  99294. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99295. * @param y defines the y-coordinate of the corner of the clear rectangle
  99296. * @param width defines the width of the clear rectangle
  99297. * @param height defines the height of the clear rectangle
  99298. * @param clearColor defines the clear color
  99299. */
  99300. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  99301. /**
  99302. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  99303. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  99304. * @param y defines the y-coordinate of the corner of the clear rectangle
  99305. * @param width defines the width of the clear rectangle
  99306. * @param height defines the height of the clear rectangle
  99307. */
  99308. enableScissor(x: number, y: number, width: number, height: number): void;
  99309. /**
  99310. * Disable previously set scissor test rectangle
  99311. */
  99312. disableScissor(): void;
  99313. protected _reportDrawCall(): void;
  99314. /**
  99315. * Initializes a webVR display and starts listening to display change events
  99316. * The onVRDisplayChangedObservable will be notified upon these changes
  99317. * @returns The onVRDisplayChangedObservable
  99318. */
  99319. initWebVR(): Observable<IDisplayChangedEventArgs>;
  99320. /** @hidden */
  99321. _prepareVRComponent(): void;
  99322. /** @hidden */
  99323. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  99324. /** @hidden */
  99325. _submitVRFrame(): void;
  99326. /**
  99327. * Call this function to leave webVR mode
  99328. * Will do nothing if webVR is not supported or if there is no webVR device
  99329. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99330. */
  99331. disableVR(): void;
  99332. /**
  99333. * Gets a boolean indicating that the system is in VR mode and is presenting
  99334. * @returns true if VR mode is engaged
  99335. */
  99336. isVRPresenting(): boolean;
  99337. /** @hidden */
  99338. _requestVRFrame(): void;
  99339. /** @hidden */
  99340. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  99341. /**
  99342. * Gets the source code of the vertex shader associated with a specific webGL program
  99343. * @param program defines the program to use
  99344. * @returns a string containing the source code of the vertex shader associated with the program
  99345. */
  99346. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  99347. /**
  99348. * Gets the source code of the fragment shader associated with a specific webGL program
  99349. * @param program defines the program to use
  99350. * @returns a string containing the source code of the fragment shader associated with the program
  99351. */
  99352. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  99353. /**
  99354. * Reads pixels from the current frame buffer. Please note that this function can be slow
  99355. * @param x defines the x coordinate of the rectangle where pixels must be read
  99356. * @param y defines the y coordinate of the rectangle where pixels must be read
  99357. * @param width defines the width of the rectangle where pixels must be read
  99358. * @param height defines the height of the rectangle where pixels must be read
  99359. * @returns a Uint8Array containing RGBA colors
  99360. */
  99361. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  99362. /**
  99363. * Sets a depth stencil texture from a render target to the according uniform.
  99364. * @param channel The texture channel
  99365. * @param uniform The uniform to set
  99366. * @param texture The render target texture containing the depth stencil texture to apply
  99367. */
  99368. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  99369. /**
  99370. * Sets a texture to the webGL context from a postprocess
  99371. * @param channel defines the channel to use
  99372. * @param postProcess defines the source postprocess
  99373. */
  99374. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  99375. /**
  99376. * Binds the output of the passed in post process to the texture channel specified
  99377. * @param channel The channel the texture should be bound to
  99378. * @param postProcess The post process which's output should be bound
  99379. */
  99380. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  99381. /** @hidden */
  99382. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  99383. protected _rebuildBuffers(): void;
  99384. _renderLoop(): void;
  99385. /**
  99386. * Toggle full screen mode
  99387. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99388. */
  99389. switchFullscreen(requestPointerLock: boolean): void;
  99390. /**
  99391. * Enters full screen mode
  99392. * @param requestPointerLock defines if a pointer lock should be requested from the user
  99393. */
  99394. enterFullscreen(requestPointerLock: boolean): void;
  99395. /**
  99396. * Exits full screen mode
  99397. */
  99398. exitFullscreen(): void;
  99399. /**
  99400. * Enters Pointerlock mode
  99401. */
  99402. enterPointerlock(): void;
  99403. /**
  99404. * Exits Pointerlock mode
  99405. */
  99406. exitPointerlock(): void;
  99407. /**
  99408. * Begin a new frame
  99409. */
  99410. beginFrame(): void;
  99411. /**
  99412. * Enf the current frame
  99413. */
  99414. endFrame(): void;
  99415. resize(): void;
  99416. /**
  99417. * Set the compressed texture format to use, based on the formats you have, and the formats
  99418. * supported by the hardware / browser.
  99419. *
  99420. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  99421. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  99422. * to API arguments needed to compressed textures. This puts the burden on the container
  99423. * generator to house the arcane code for determining these for current & future formats.
  99424. *
  99425. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99426. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99427. *
  99428. * Note: The result of this call is not taken into account when a texture is base64.
  99429. *
  99430. * @param formatsAvailable defines the list of those format families you have created
  99431. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  99432. *
  99433. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  99434. * @returns The extension selected.
  99435. */
  99436. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  99437. /**
  99438. * Force a specific size of the canvas
  99439. * @param width defines the new canvas' width
  99440. * @param height defines the new canvas' height
  99441. */
  99442. setSize(width: number, height: number): void;
  99443. /**
  99444. * Updates a dynamic vertex buffer.
  99445. * @param vertexBuffer the vertex buffer to update
  99446. * @param data the data used to update the vertex buffer
  99447. * @param byteOffset the byte offset of the data
  99448. * @param byteLength the byte length of the data
  99449. */
  99450. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  99451. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99452. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99453. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99454. _releaseTexture(texture: InternalTexture): void;
  99455. /**
  99456. * @hidden
  99457. * Rescales a texture
  99458. * @param source input texutre
  99459. * @param destination destination texture
  99460. * @param scene scene to use to render the resize
  99461. * @param internalFormat format to use when resizing
  99462. * @param onComplete callback to be called when resize has completed
  99463. */
  99464. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  99465. /**
  99466. * Gets the current framerate
  99467. * @returns a number representing the framerate
  99468. */
  99469. getFps(): number;
  99470. /**
  99471. * Gets the time spent between current and previous frame
  99472. * @returns a number representing the delta time in ms
  99473. */
  99474. getDeltaTime(): number;
  99475. private _measureFps;
  99476. /** @hidden */
  99477. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  99478. /**
  99479. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  99480. * @param renderTarget The render target to set the frame buffer for
  99481. */
  99482. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  99483. /**
  99484. * Update a dynamic index buffer
  99485. * @param indexBuffer defines the target index buffer
  99486. * @param indices defines the data to update
  99487. * @param offset defines the offset in the target index buffer where update should start
  99488. */
  99489. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  99490. /**
  99491. * Updates the sample count of a render target texture
  99492. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99493. * @param texture defines the texture to update
  99494. * @param samples defines the sample count to set
  99495. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99496. */
  99497. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  99498. /**
  99499. * Updates a depth texture Comparison Mode and Function.
  99500. * If the comparison Function is equal to 0, the mode will be set to none.
  99501. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  99502. * @param texture The texture to set the comparison function for
  99503. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  99504. */
  99505. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  99506. /**
  99507. * Creates a webGL buffer to use with instanciation
  99508. * @param capacity defines the size of the buffer
  99509. * @returns the webGL buffer
  99510. */
  99511. createInstancesBuffer(capacity: number): DataBuffer;
  99512. /**
  99513. * Delete a webGL buffer used with instanciation
  99514. * @param buffer defines the webGL buffer to delete
  99515. */
  99516. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  99517. /** @hidden */
  99518. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  99519. dispose(): void;
  99520. private _disableTouchAction;
  99521. /**
  99522. * Display the loading screen
  99523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99524. */
  99525. displayLoadingUI(): void;
  99526. /**
  99527. * Hide the loading screen
  99528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99529. */
  99530. hideLoadingUI(): void;
  99531. /**
  99532. * Gets the current loading screen object
  99533. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99534. */
  99535. /**
  99536. * Sets the current loading screen object
  99537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99538. */
  99539. loadingScreen: ILoadingScreen;
  99540. /**
  99541. * Sets the current loading screen text
  99542. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99543. */
  99544. loadingUIText: string;
  99545. /**
  99546. * Sets the current loading screen background color
  99547. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99548. */
  99549. loadingUIBackgroundColor: string;
  99550. /** Pointerlock and fullscreen */
  99551. /**
  99552. * Ask the browser to promote the current element to pointerlock mode
  99553. * @param element defines the DOM element to promote
  99554. */
  99555. static _RequestPointerlock(element: HTMLElement): void;
  99556. /**
  99557. * Asks the browser to exit pointerlock mode
  99558. */
  99559. static _ExitPointerlock(): void;
  99560. /**
  99561. * Ask the browser to promote the current element to fullscreen rendering mode
  99562. * @param element defines the DOM element to promote
  99563. */
  99564. static _RequestFullscreen(element: HTMLElement): void;
  99565. /**
  99566. * Asks the browser to exit fullscreen mode
  99567. */
  99568. static _ExitFullscreen(): void;
  99569. }
  99570. }
  99571. declare module BABYLON {
  99572. /**
  99573. * The engine store class is responsible to hold all the instances of Engine and Scene created
  99574. * during the life time of the application.
  99575. */
  99576. export class EngineStore {
  99577. /** Gets the list of created engines */
  99578. static Instances: Engine[];
  99579. /** @hidden */
  99580. static _LastCreatedScene: Nullable<Scene>;
  99581. /**
  99582. * Gets the latest created engine
  99583. */
  99584. static readonly LastCreatedEngine: Nullable<Engine>;
  99585. /**
  99586. * Gets the latest created scene
  99587. */
  99588. static readonly LastCreatedScene: Nullable<Scene>;
  99589. /**
  99590. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99591. * @ignorenaming
  99592. */
  99593. static UseFallbackTexture: boolean;
  99594. /**
  99595. * Texture content used if a texture cannot loaded
  99596. * @ignorenaming
  99597. */
  99598. static FallbackTexture: string;
  99599. }
  99600. }
  99601. declare module BABYLON {
  99602. /**
  99603. * Helper class that provides a small promise polyfill
  99604. */
  99605. export class PromisePolyfill {
  99606. /**
  99607. * Static function used to check if the polyfill is required
  99608. * If this is the case then the function will inject the polyfill to window.Promise
  99609. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  99610. */
  99611. static Apply(force?: boolean): void;
  99612. }
  99613. }
  99614. declare module BABYLON {
  99615. /**
  99616. * Interface for screenshot methods with describe argument called `size` as object with options
  99617. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  99618. */
  99619. export interface IScreenshotSize {
  99620. /**
  99621. * number in pixels for canvas height
  99622. */
  99623. height?: number;
  99624. /**
  99625. * multiplier allowing render at a higher or lower resolution
  99626. * If value is defined then height and width will be ignored and taken from camera
  99627. */
  99628. precision?: number;
  99629. /**
  99630. * number in pixels for canvas width
  99631. */
  99632. width?: number;
  99633. }
  99634. }
  99635. declare module BABYLON {
  99636. interface IColor4Like {
  99637. r: float;
  99638. g: float;
  99639. b: float;
  99640. a: float;
  99641. }
  99642. /**
  99643. * Class containing a set of static utilities functions
  99644. */
  99645. export class Tools {
  99646. /**
  99647. * Gets or sets the base URL to use to load assets
  99648. */
  99649. static BaseUrl: string;
  99650. /**
  99651. * Enable/Disable Custom HTTP Request Headers globally.
  99652. * default = false
  99653. * @see CustomRequestHeaders
  99654. */
  99655. static UseCustomRequestHeaders: boolean;
  99656. /**
  99657. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  99658. * i.e. when loading files, where the server/service expects an Authorization header
  99659. */
  99660. static CustomRequestHeaders: {
  99661. [key: string]: string;
  99662. };
  99663. /**
  99664. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  99665. */
  99666. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  99667. /**
  99668. * Default behaviour for cors in the application.
  99669. * It can be a string if the expected behavior is identical in the entire app.
  99670. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  99671. */
  99672. static CorsBehavior: string | ((url: string | string[]) => string);
  99673. /**
  99674. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  99675. * @ignorenaming
  99676. */
  99677. static UseFallbackTexture: boolean;
  99678. /**
  99679. * Use this object to register external classes like custom textures or material
  99680. * to allow the laoders to instantiate them
  99681. */
  99682. static RegisteredExternalClasses: {
  99683. [key: string]: Object;
  99684. };
  99685. /**
  99686. * Texture content used if a texture cannot loaded
  99687. * @ignorenaming
  99688. */
  99689. static fallbackTexture: string;
  99690. /**
  99691. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99692. * @param u defines the coordinate on X axis
  99693. * @param v defines the coordinate on Y axis
  99694. * @param width defines the width of the source data
  99695. * @param height defines the height of the source data
  99696. * @param pixels defines the source byte array
  99697. * @param color defines the output color
  99698. */
  99699. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  99700. /**
  99701. * Interpolates between a and b via alpha
  99702. * @param a The lower value (returned when alpha = 0)
  99703. * @param b The upper value (returned when alpha = 1)
  99704. * @param alpha The interpolation-factor
  99705. * @return The mixed value
  99706. */
  99707. static Mix(a: number, b: number, alpha: number): number;
  99708. /**
  99709. * Tries to instantiate a new object from a given class name
  99710. * @param className defines the class name to instantiate
  99711. * @returns the new object or null if the system was not able to do the instantiation
  99712. */
  99713. static Instantiate(className: string): any;
  99714. /**
  99715. * Provides a slice function that will work even on IE
  99716. * @param data defines the array to slice
  99717. * @param start defines the start of the data (optional)
  99718. * @param end defines the end of the data (optional)
  99719. * @returns the new sliced array
  99720. */
  99721. static Slice<T>(data: T, start?: number, end?: number): T;
  99722. /**
  99723. * Polyfill for setImmediate
  99724. * @param action defines the action to execute after the current execution block
  99725. */
  99726. static SetImmediate(action: () => void): void;
  99727. /**
  99728. * Function indicating if a number is an exponent of 2
  99729. * @param value defines the value to test
  99730. * @returns true if the value is an exponent of 2
  99731. */
  99732. static IsExponentOfTwo(value: number): boolean;
  99733. private static _tmpFloatArray;
  99734. /**
  99735. * Returns the nearest 32-bit single precision float representation of a Number
  99736. * @param value A Number. If the parameter is of a different type, it will get converted
  99737. * to a number or to NaN if it cannot be converted
  99738. * @returns number
  99739. */
  99740. static FloatRound(value: number): number;
  99741. /**
  99742. * Extracts the filename from a path
  99743. * @param path defines the path to use
  99744. * @returns the filename
  99745. */
  99746. static GetFilename(path: string): string;
  99747. /**
  99748. * Extracts the "folder" part of a path (everything before the filename).
  99749. * @param uri The URI to extract the info from
  99750. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99751. * @returns The "folder" part of the path
  99752. */
  99753. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  99754. /**
  99755. * Extracts text content from a DOM element hierarchy
  99756. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  99757. */
  99758. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  99759. /**
  99760. * Convert an angle in radians to degrees
  99761. * @param angle defines the angle to convert
  99762. * @returns the angle in degrees
  99763. */
  99764. static ToDegrees(angle: number): number;
  99765. /**
  99766. * Convert an angle in degrees to radians
  99767. * @param angle defines the angle to convert
  99768. * @returns the angle in radians
  99769. */
  99770. static ToRadians(angle: number): number;
  99771. /**
  99772. * Returns an array if obj is not an array
  99773. * @param obj defines the object to evaluate as an array
  99774. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99775. * @returns either obj directly if obj is an array or a new array containing obj
  99776. */
  99777. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  99778. /**
  99779. * Gets the pointer prefix to use
  99780. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99781. */
  99782. static GetPointerPrefix(): string;
  99783. /**
  99784. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99785. * @param url define the url we are trying
  99786. * @param element define the dom element where to configure the cors policy
  99787. */
  99788. static SetCorsBehavior(url: string | string[], element: {
  99789. crossOrigin: string | null;
  99790. }): void;
  99791. /**
  99792. * Removes unwanted characters from an url
  99793. * @param url defines the url to clean
  99794. * @returns the cleaned url
  99795. */
  99796. static CleanUrl(url: string): string;
  99797. /**
  99798. * Gets or sets a function used to pre-process url before using them to load assets
  99799. */
  99800. static PreprocessUrl: (url: string) => string;
  99801. /**
  99802. * Loads an image as an HTMLImageElement.
  99803. * @param input url string, ArrayBuffer, or Blob to load
  99804. * @param onLoad callback called when the image successfully loads
  99805. * @param onError callback called when the image fails to load
  99806. * @param offlineProvider offline provider for caching
  99807. * @param mimeType optional mime type
  99808. * @returns the HTMLImageElement of the loaded image
  99809. */
  99810. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  99811. /**
  99812. * Loads a file from a url
  99813. * @param url url string, ArrayBuffer, or Blob to load
  99814. * @param onSuccess callback called when the file successfully loads
  99815. * @param onProgress callback called while file is loading (if the server supports this mode)
  99816. * @param offlineProvider defines the offline provider for caching
  99817. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99818. * @param onError callback called when the file fails to load
  99819. * @returns a file request object
  99820. */
  99821. 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;
  99822. /**
  99823. * Loads a file from a url
  99824. * @param url the file url to load
  99825. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  99826. */
  99827. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  99828. /**
  99829. * Load a script (identified by an url). When the url returns, the
  99830. * content of this file is added into a new script element, attached to the DOM (body element)
  99831. * @param scriptUrl defines the url of the script to laod
  99832. * @param onSuccess defines the callback called when the script is loaded
  99833. * @param onError defines the callback to call if an error occurs
  99834. * @param scriptId defines the id of the script element
  99835. */
  99836. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  99837. /**
  99838. * Load an asynchronous script (identified by an url). When the url returns, the
  99839. * content of this file is added into a new script element, attached to the DOM (body element)
  99840. * @param scriptUrl defines the url of the script to laod
  99841. * @param scriptId defines the id of the script element
  99842. * @returns a promise request object
  99843. */
  99844. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  99845. /**
  99846. * Loads a file from a blob
  99847. * @param fileToLoad defines the blob to use
  99848. * @param callback defines the callback to call when data is loaded
  99849. * @param progressCallback defines the callback to call during loading process
  99850. * @returns a file request object
  99851. */
  99852. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  99853. /**
  99854. * Reads a file from a File object
  99855. * @param file defines the file to load
  99856. * @param onSuccess defines the callback to call when data is loaded
  99857. * @param onProgress defines the callback to call during loading process
  99858. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99859. * @param onError defines the callback to call when an error occurs
  99860. * @returns a file request object
  99861. */
  99862. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  99863. /**
  99864. * Creates a data url from a given string content
  99865. * @param content defines the content to convert
  99866. * @returns the new data url link
  99867. */
  99868. static FileAsURL(content: string): string;
  99869. /**
  99870. * Format the given number to a specific decimal format
  99871. * @param value defines the number to format
  99872. * @param decimals defines the number of decimals to use
  99873. * @returns the formatted string
  99874. */
  99875. static Format(value: number, decimals?: number): string;
  99876. /**
  99877. * Tries to copy an object by duplicating every property
  99878. * @param source defines the source object
  99879. * @param destination defines the target object
  99880. * @param doNotCopyList defines a list of properties to avoid
  99881. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99882. */
  99883. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  99884. /**
  99885. * Gets a boolean indicating if the given object has no own property
  99886. * @param obj defines the object to test
  99887. * @returns true if object has no own property
  99888. */
  99889. static IsEmpty(obj: any): boolean;
  99890. /**
  99891. * Function used to register events at window level
  99892. * @param windowElement defines the Window object to use
  99893. * @param events defines the events to register
  99894. */
  99895. static RegisterTopRootEvents(windowElement: Window, events: {
  99896. name: string;
  99897. handler: Nullable<(e: FocusEvent) => any>;
  99898. }[]): void;
  99899. /**
  99900. * Function used to unregister events from window level
  99901. * @param windowElement defines the Window object to use
  99902. * @param events defines the events to unregister
  99903. */
  99904. static UnregisterTopRootEvents(windowElement: Window, events: {
  99905. name: string;
  99906. handler: Nullable<(e: FocusEvent) => any>;
  99907. }[]): void;
  99908. /**
  99909. * @ignore
  99910. */
  99911. static _ScreenshotCanvas: HTMLCanvasElement;
  99912. /**
  99913. * Dumps the current bound framebuffer
  99914. * @param width defines the rendering width
  99915. * @param height defines the rendering height
  99916. * @param engine defines the hosting engine
  99917. * @param successCallback defines the callback triggered once the data are available
  99918. * @param mimeType defines the mime type of the result
  99919. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99920. */
  99921. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99922. /**
  99923. * Converts the canvas data to blob.
  99924. * This acts as a polyfill for browsers not supporting the to blob function.
  99925. * @param canvas Defines the canvas to extract the data from
  99926. * @param successCallback Defines the callback triggered once the data are available
  99927. * @param mimeType Defines the mime type of the result
  99928. */
  99929. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99930. /**
  99931. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99932. * @param successCallback defines the callback triggered once the data are available
  99933. * @param mimeType defines the mime type of the result
  99934. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99935. */
  99936. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99937. /**
  99938. * Downloads a blob in the browser
  99939. * @param blob defines the blob to download
  99940. * @param fileName defines the name of the downloaded file
  99941. */
  99942. static Download(blob: Blob, fileName: string): void;
  99943. /**
  99944. * Captures a screenshot of the current rendering
  99945. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99946. * @param engine defines the rendering engine
  99947. * @param camera defines the source camera
  99948. * @param size This parameter can be set to a single number or to an object with the
  99949. * following (optional) properties: precision, width, height. If a single number is passed,
  99950. * it will be used for both width and height. If an object is passed, the screenshot size
  99951. * will be derived from the parameters. The precision property is a multiplier allowing
  99952. * rendering at a higher or lower resolution
  99953. * @param successCallback defines the callback receives a single parameter which contains the
  99954. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99955. * src parameter of an <img> to display it
  99956. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99957. * Check your browser for supported MIME types
  99958. */
  99959. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99960. /**
  99961. * Captures a screenshot of the current rendering
  99962. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99963. * @param engine defines the rendering engine
  99964. * @param camera defines the source camera
  99965. * @param size This parameter can be set to a single number or to an object with the
  99966. * following (optional) properties: precision, width, height. If a single number is passed,
  99967. * it will be used for both width and height. If an object is passed, the screenshot size
  99968. * will be derived from the parameters. The precision property is a multiplier allowing
  99969. * rendering at a higher or lower resolution
  99970. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99971. * Check your browser for supported MIME types
  99972. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99973. * to the src parameter of an <img> to display it
  99974. */
  99975. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99976. /**
  99977. * Generates an image screenshot from the specified camera.
  99978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99979. * @param engine The engine to use for rendering
  99980. * @param camera The camera to use for rendering
  99981. * @param size This parameter can be set to a single number or to an object with the
  99982. * following (optional) properties: precision, width, height. If a single number is passed,
  99983. * it will be used for both width and height. If an object is passed, the screenshot size
  99984. * will be derived from the parameters. The precision property is a multiplier allowing
  99985. * rendering at a higher or lower resolution
  99986. * @param successCallback The callback receives a single parameter which contains the
  99987. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99988. * src parameter of an <img> to display it
  99989. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99990. * Check your browser for supported MIME types
  99991. * @param samples Texture samples (default: 1)
  99992. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99993. * @param fileName A name for for the downloaded file.
  99994. */
  99995. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99996. /**
  99997. * Generates an image screenshot from the specified camera.
  99998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99999. * @param engine The engine to use for rendering
  100000. * @param camera The camera to use for rendering
  100001. * @param size This parameter can be set to a single number or to an object with the
  100002. * following (optional) properties: precision, width, height. If a single number is passed,
  100003. * it will be used for both width and height. If an object is passed, the screenshot size
  100004. * will be derived from the parameters. The precision property is a multiplier allowing
  100005. * rendering at a higher or lower resolution
  100006. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100007. * Check your browser for supported MIME types
  100008. * @param samples Texture samples (default: 1)
  100009. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100010. * @param fileName A name for for the downloaded file.
  100011. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  100012. * to the src parameter of an <img> to display it
  100013. */
  100014. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  100015. /**
  100016. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100017. * Be aware Math.random() could cause collisions, but:
  100018. * "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"
  100019. * @returns a pseudo random id
  100020. */
  100021. static RandomId(): string;
  100022. /**
  100023. * Test if the given uri is a base64 string
  100024. * @param uri The uri to test
  100025. * @return True if the uri is a base64 string or false otherwise
  100026. */
  100027. static IsBase64(uri: string): boolean;
  100028. /**
  100029. * Decode the given base64 uri.
  100030. * @param uri The uri to decode
  100031. * @return The decoded base64 data.
  100032. */
  100033. static DecodeBase64(uri: string): ArrayBuffer;
  100034. /**
  100035. * Gets the absolute url.
  100036. * @param url the input url
  100037. * @return the absolute url
  100038. */
  100039. static GetAbsoluteUrl(url: string): string;
  100040. /**
  100041. * No log
  100042. */
  100043. static readonly NoneLogLevel: number;
  100044. /**
  100045. * Only message logs
  100046. */
  100047. static readonly MessageLogLevel: number;
  100048. /**
  100049. * Only warning logs
  100050. */
  100051. static readonly WarningLogLevel: number;
  100052. /**
  100053. * Only error logs
  100054. */
  100055. static readonly ErrorLogLevel: number;
  100056. /**
  100057. * All logs
  100058. */
  100059. static readonly AllLogLevel: number;
  100060. /**
  100061. * Gets a value indicating the number of loading errors
  100062. * @ignorenaming
  100063. */
  100064. static readonly errorsCount: number;
  100065. /**
  100066. * Callback called when a new log is added
  100067. */
  100068. static OnNewCacheEntry: (entry: string) => void;
  100069. /**
  100070. * Log a message to the console
  100071. * @param message defines the message to log
  100072. */
  100073. static Log(message: string): void;
  100074. /**
  100075. * Write a warning message to the console
  100076. * @param message defines the message to log
  100077. */
  100078. static Warn(message: string): void;
  100079. /**
  100080. * Write an error message to the console
  100081. * @param message defines the message to log
  100082. */
  100083. static Error(message: string): void;
  100084. /**
  100085. * Gets current log cache (list of logs)
  100086. */
  100087. static readonly LogCache: string;
  100088. /**
  100089. * Clears the log cache
  100090. */
  100091. static ClearLogCache(): void;
  100092. /**
  100093. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100094. */
  100095. static LogLevels: number;
  100096. /**
  100097. * Checks if the window object exists
  100098. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100099. */
  100100. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  100101. /**
  100102. * No performance log
  100103. */
  100104. static readonly PerformanceNoneLogLevel: number;
  100105. /**
  100106. * Use user marks to log performance
  100107. */
  100108. static readonly PerformanceUserMarkLogLevel: number;
  100109. /**
  100110. * Log performance to the console
  100111. */
  100112. static readonly PerformanceConsoleLogLevel: number;
  100113. private static _performance;
  100114. /**
  100115. * Sets the current performance log level
  100116. */
  100117. static PerformanceLogLevel: number;
  100118. private static _StartPerformanceCounterDisabled;
  100119. private static _EndPerformanceCounterDisabled;
  100120. private static _StartUserMark;
  100121. private static _EndUserMark;
  100122. private static _StartPerformanceConsole;
  100123. private static _EndPerformanceConsole;
  100124. /**
  100125. * Starts a performance counter
  100126. */
  100127. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100128. /**
  100129. * Ends a specific performance coutner
  100130. */
  100131. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  100132. /**
  100133. * Gets either window.performance.now() if supported or Date.now() else
  100134. */
  100135. static readonly Now: number;
  100136. /**
  100137. * This method will return the name of the class used to create the instance of the given object.
  100138. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100139. * @param object the object to get the class name from
  100140. * @param isType defines if the object is actually a type
  100141. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100142. */
  100143. static GetClassName(object: any, isType?: boolean): string;
  100144. /**
  100145. * Gets the first element of an array satisfying a given predicate
  100146. * @param array defines the array to browse
  100147. * @param predicate defines the predicate to use
  100148. * @returns null if not found or the element
  100149. */
  100150. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  100151. /**
  100152. * This method will return the name of the full name of the class, including its owning module (if any).
  100153. * 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).
  100154. * @param object the object to get the class name from
  100155. * @param isType defines if the object is actually a type
  100156. * @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.
  100157. * @ignorenaming
  100158. */
  100159. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  100160. /**
  100161. * Returns a promise that resolves after the given amount of time.
  100162. * @param delay Number of milliseconds to delay
  100163. * @returns Promise that resolves after the given amount of time
  100164. */
  100165. static DelayAsync(delay: number): Promise<void>;
  100166. }
  100167. /**
  100168. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100169. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100170. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100171. * @param name The name of the class, case should be preserved
  100172. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100173. */
  100174. export function className(name: string, module?: string): (target: Object) => void;
  100175. /**
  100176. * An implementation of a loop for asynchronous functions.
  100177. */
  100178. export class AsyncLoop {
  100179. /**
  100180. * Defines the number of iterations for the loop
  100181. */
  100182. iterations: number;
  100183. /**
  100184. * Defines the current index of the loop.
  100185. */
  100186. index: number;
  100187. private _done;
  100188. private _fn;
  100189. private _successCallback;
  100190. /**
  100191. * Constructor.
  100192. * @param iterations the number of iterations.
  100193. * @param func the function to run each iteration
  100194. * @param successCallback the callback that will be called upon succesful execution
  100195. * @param offset starting offset.
  100196. */
  100197. constructor(
  100198. /**
  100199. * Defines the number of iterations for the loop
  100200. */
  100201. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  100202. /**
  100203. * Execute the next iteration. Must be called after the last iteration was finished.
  100204. */
  100205. executeNext(): void;
  100206. /**
  100207. * Break the loop and run the success callback.
  100208. */
  100209. breakLoop(): void;
  100210. /**
  100211. * Create and run an async loop.
  100212. * @param iterations the number of iterations.
  100213. * @param fn the function to run each iteration
  100214. * @param successCallback the callback that will be called upon succesful execution
  100215. * @param offset starting offset.
  100216. * @returns the created async loop object
  100217. */
  100218. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  100219. /**
  100220. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100221. * @param iterations total number of iterations
  100222. * @param syncedIterations number of synchronous iterations in each async iteration.
  100223. * @param fn the function to call each iteration.
  100224. * @param callback a success call back that will be called when iterating stops.
  100225. * @param breakFunction a break condition (optional)
  100226. * @param timeout timeout settings for the setTimeout function. default - 0.
  100227. * @returns the created async loop object
  100228. */
  100229. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  100230. }
  100231. }
  100232. declare module BABYLON {
  100233. /**
  100234. * This class implement a typical dictionary using a string as key and the generic type T as value.
  100235. * The underlying implementation relies on an associative array to ensure the best performances.
  100236. * The value can be anything including 'null' but except 'undefined'
  100237. */
  100238. export class StringDictionary<T> {
  100239. /**
  100240. * This will clear this dictionary and copy the content from the 'source' one.
  100241. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  100242. * @param source the dictionary to take the content from and copy to this dictionary
  100243. */
  100244. copyFrom(source: StringDictionary<T>): void;
  100245. /**
  100246. * Get a value based from its key
  100247. * @param key the given key to get the matching value from
  100248. * @return the value if found, otherwise undefined is returned
  100249. */
  100250. get(key: string): T | undefined;
  100251. /**
  100252. * Get a value from its key or add it if it doesn't exist.
  100253. * This method will ensure you that a given key/data will be present in the dictionary.
  100254. * @param key the given key to get the matching value from
  100255. * @param factory the factory that will create the value if the key is not present in the dictionary.
  100256. * The factory will only be invoked if there's no data for the given key.
  100257. * @return the value corresponding to the key.
  100258. */
  100259. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  100260. /**
  100261. * Get a value from its key if present in the dictionary otherwise add it
  100262. * @param key the key to get the value from
  100263. * @param val if there's no such key/value pair in the dictionary add it with this value
  100264. * @return the value corresponding to the key
  100265. */
  100266. getOrAdd(key: string, val: T): T;
  100267. /**
  100268. * Check if there's a given key in the dictionary
  100269. * @param key the key to check for
  100270. * @return true if the key is present, false otherwise
  100271. */
  100272. contains(key: string): boolean;
  100273. /**
  100274. * Add a new key and its corresponding value
  100275. * @param key the key to add
  100276. * @param value the value corresponding to the key
  100277. * @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
  100278. */
  100279. add(key: string, value: T): boolean;
  100280. /**
  100281. * Update a specific value associated to a key
  100282. * @param key defines the key to use
  100283. * @param value defines the value to store
  100284. * @returns true if the value was updated (or false if the key was not found)
  100285. */
  100286. set(key: string, value: T): boolean;
  100287. /**
  100288. * Get the element of the given key and remove it from the dictionary
  100289. * @param key defines the key to search
  100290. * @returns the value associated with the key or null if not found
  100291. */
  100292. getAndRemove(key: string): Nullable<T>;
  100293. /**
  100294. * Remove a key/value from the dictionary.
  100295. * @param key the key to remove
  100296. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  100297. */
  100298. remove(key: string): boolean;
  100299. /**
  100300. * Clear the whole content of the dictionary
  100301. */
  100302. clear(): void;
  100303. /**
  100304. * Gets the current count
  100305. */
  100306. readonly count: number;
  100307. /**
  100308. * Execute a callback on each key/val of the dictionary.
  100309. * Note that you can remove any element in this dictionary in the callback implementation
  100310. * @param callback the callback to execute on a given key/value pair
  100311. */
  100312. forEach(callback: (key: string, val: T) => void): void;
  100313. /**
  100314. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  100315. * If the callback returns null or undefined the method will iterate to the next key/value pair
  100316. * Note that you can remove any element in this dictionary in the callback implementation
  100317. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  100318. * @returns the first item
  100319. */
  100320. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  100321. private _count;
  100322. private _data;
  100323. }
  100324. }
  100325. declare module BABYLON {
  100326. /** @hidden */
  100327. export interface ICollisionCoordinator {
  100328. createCollider(): Collider;
  100329. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100330. init(scene: Scene): void;
  100331. }
  100332. /** @hidden */
  100333. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  100334. private _scene;
  100335. private _scaledPosition;
  100336. private _scaledVelocity;
  100337. private _finalPosition;
  100338. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  100339. createCollider(): Collider;
  100340. init(scene: Scene): void;
  100341. private _collideWithWorld;
  100342. }
  100343. }
  100344. declare module BABYLON {
  100345. /**
  100346. * Class used to manage all inputs for the scene.
  100347. */
  100348. export class InputManager {
  100349. /** The distance in pixel that you have to move to prevent some events */
  100350. static DragMovementThreshold: number;
  100351. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  100352. static LongPressDelay: number;
  100353. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  100354. static DoubleClickDelay: number;
  100355. /** If you need to check double click without raising a single click at first click, enable this flag */
  100356. static ExclusiveDoubleClickMode: boolean;
  100357. private _wheelEventName;
  100358. private _onPointerMove;
  100359. private _onPointerDown;
  100360. private _onPointerUp;
  100361. private _initClickEvent;
  100362. private _initActionManager;
  100363. private _delayedSimpleClick;
  100364. private _delayedSimpleClickTimeout;
  100365. private _previousDelayedSimpleClickTimeout;
  100366. private _meshPickProceed;
  100367. private _previousButtonPressed;
  100368. private _currentPickResult;
  100369. private _previousPickResult;
  100370. private _totalPointersPressed;
  100371. private _doubleClickOccured;
  100372. private _pointerOverMesh;
  100373. private _pickedDownMesh;
  100374. private _pickedUpMesh;
  100375. private _pointerX;
  100376. private _pointerY;
  100377. private _unTranslatedPointerX;
  100378. private _unTranslatedPointerY;
  100379. private _startingPointerPosition;
  100380. private _previousStartingPointerPosition;
  100381. private _startingPointerTime;
  100382. private _previousStartingPointerTime;
  100383. private _pointerCaptures;
  100384. private _onKeyDown;
  100385. private _onKeyUp;
  100386. private _onCanvasFocusObserver;
  100387. private _onCanvasBlurObserver;
  100388. private _scene;
  100389. /**
  100390. * Creates a new InputManager
  100391. * @param scene defines the hosting scene
  100392. */
  100393. constructor(scene: Scene);
  100394. /**
  100395. * Gets the mesh that is currently under the pointer
  100396. */
  100397. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100398. /**
  100399. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  100400. */
  100401. readonly unTranslatedPointer: Vector2;
  100402. /**
  100403. * Gets or sets the current on-screen X position of the pointer
  100404. */
  100405. pointerX: number;
  100406. /**
  100407. * Gets or sets the current on-screen Y position of the pointer
  100408. */
  100409. pointerY: number;
  100410. private _updatePointerPosition;
  100411. private _processPointerMove;
  100412. private _setRayOnPointerInfo;
  100413. private _checkPrePointerObservable;
  100414. /**
  100415. * Use this method to simulate a pointer move on a mesh
  100416. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100417. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100418. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100419. */
  100420. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100421. /**
  100422. * Use this method to simulate a pointer down on a mesh
  100423. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100424. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100425. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100426. */
  100427. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  100428. private _processPointerDown;
  100429. /** @hidden */
  100430. _isPointerSwiping(): boolean;
  100431. /**
  100432. * Use this method to simulate a pointer up on a mesh
  100433. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100434. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100435. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100436. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100437. */
  100438. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  100439. private _processPointerUp;
  100440. /**
  100441. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100442. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100443. * @returns true if the pointer was captured
  100444. */
  100445. isPointerCaptured(pointerId?: number): boolean;
  100446. /**
  100447. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100448. * @param attachUp defines if you want to attach events to pointerup
  100449. * @param attachDown defines if you want to attach events to pointerdown
  100450. * @param attachMove defines if you want to attach events to pointermove
  100451. */
  100452. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100453. /**
  100454. * Detaches all event handlers
  100455. */
  100456. detachControl(): void;
  100457. /**
  100458. * Force the value of meshUnderPointer
  100459. * @param mesh defines the mesh to use
  100460. */
  100461. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100462. /**
  100463. * Gets the mesh under the pointer
  100464. * @returns a Mesh or null if no mesh is under the pointer
  100465. */
  100466. getPointerOverMesh(): Nullable<AbstractMesh>;
  100467. }
  100468. }
  100469. declare module BABYLON {
  100470. /**
  100471. * Helper class used to generate session unique ID
  100472. */
  100473. export class UniqueIdGenerator {
  100474. private static _UniqueIdCounter;
  100475. /**
  100476. * Gets an unique (relatively to the current scene) Id
  100477. */
  100478. static readonly UniqueId: number;
  100479. }
  100480. }
  100481. declare module BABYLON {
  100482. /**
  100483. * This class defines the direct association between an animation and a target
  100484. */
  100485. export class TargetedAnimation {
  100486. /**
  100487. * Animation to perform
  100488. */
  100489. animation: Animation;
  100490. /**
  100491. * Target to animate
  100492. */
  100493. target: any;
  100494. /**
  100495. * Serialize the object
  100496. * @returns the JSON object representing the current entity
  100497. */
  100498. serialize(): any;
  100499. }
  100500. /**
  100501. * Use this class to create coordinated animations on multiple targets
  100502. */
  100503. export class AnimationGroup implements IDisposable {
  100504. /** The name of the animation group */
  100505. name: string;
  100506. private _scene;
  100507. private _targetedAnimations;
  100508. private _animatables;
  100509. private _from;
  100510. private _to;
  100511. private _isStarted;
  100512. private _isPaused;
  100513. private _speedRatio;
  100514. private _loopAnimation;
  100515. /**
  100516. * Gets or sets the unique id of the node
  100517. */
  100518. uniqueId: number;
  100519. /**
  100520. * This observable will notify when one animation have ended
  100521. */
  100522. onAnimationEndObservable: Observable<TargetedAnimation>;
  100523. /**
  100524. * Observer raised when one animation loops
  100525. */
  100526. onAnimationLoopObservable: Observable<TargetedAnimation>;
  100527. /**
  100528. * Observer raised when all animations have looped
  100529. */
  100530. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  100531. /**
  100532. * This observable will notify when all animations have ended.
  100533. */
  100534. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  100535. /**
  100536. * This observable will notify when all animations have paused.
  100537. */
  100538. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  100539. /**
  100540. * This observable will notify when all animations are playing.
  100541. */
  100542. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  100543. /**
  100544. * Gets the first frame
  100545. */
  100546. readonly from: number;
  100547. /**
  100548. * Gets the last frame
  100549. */
  100550. readonly to: number;
  100551. /**
  100552. * Define if the animations are started
  100553. */
  100554. readonly isStarted: boolean;
  100555. /**
  100556. * Gets a value indicating that the current group is playing
  100557. */
  100558. readonly isPlaying: boolean;
  100559. /**
  100560. * Gets or sets the speed ratio to use for all animations
  100561. */
  100562. /**
  100563. * Gets or sets the speed ratio to use for all animations
  100564. */
  100565. speedRatio: number;
  100566. /**
  100567. * Gets or sets if all animations should loop or not
  100568. */
  100569. loopAnimation: boolean;
  100570. /**
  100571. * Gets the targeted animations for this animation group
  100572. */
  100573. readonly targetedAnimations: Array<TargetedAnimation>;
  100574. /**
  100575. * returning the list of animatables controlled by this animation group.
  100576. */
  100577. readonly animatables: Array<Animatable>;
  100578. /**
  100579. * Instantiates a new Animation Group.
  100580. * This helps managing several animations at once.
  100581. * @see http://doc.babylonjs.com/how_to/group
  100582. * @param name Defines the name of the group
  100583. * @param scene Defines the scene the group belongs to
  100584. */
  100585. constructor(
  100586. /** The name of the animation group */
  100587. name: string, scene?: Nullable<Scene>);
  100588. /**
  100589. * Add an animation (with its target) in the group
  100590. * @param animation defines the animation we want to add
  100591. * @param target defines the target of the animation
  100592. * @returns the TargetedAnimation object
  100593. */
  100594. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  100595. /**
  100596. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  100597. * It can add constant keys at begin or end
  100598. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  100599. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  100600. * @returns the animation group
  100601. */
  100602. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  100603. private _animationLoopCount;
  100604. private _animationLoopFlags;
  100605. private _processLoop;
  100606. /**
  100607. * Start all animations on given targets
  100608. * @param loop defines if animations must loop
  100609. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  100610. * @param from defines the from key (optional)
  100611. * @param to defines the to key (optional)
  100612. * @returns the current animation group
  100613. */
  100614. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  100615. /**
  100616. * Pause all animations
  100617. * @returns the animation group
  100618. */
  100619. pause(): AnimationGroup;
  100620. /**
  100621. * Play all animations to initial state
  100622. * This function will start() the animations if they were not started or will restart() them if they were paused
  100623. * @param loop defines if animations must loop
  100624. * @returns the animation group
  100625. */
  100626. play(loop?: boolean): AnimationGroup;
  100627. /**
  100628. * Reset all animations to initial state
  100629. * @returns the animation group
  100630. */
  100631. reset(): AnimationGroup;
  100632. /**
  100633. * Restart animations from key 0
  100634. * @returns the animation group
  100635. */
  100636. restart(): AnimationGroup;
  100637. /**
  100638. * Stop all animations
  100639. * @returns the animation group
  100640. */
  100641. stop(): AnimationGroup;
  100642. /**
  100643. * Set animation weight for all animatables
  100644. * @param weight defines the weight to use
  100645. * @return the animationGroup
  100646. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100647. */
  100648. setWeightForAllAnimatables(weight: number): AnimationGroup;
  100649. /**
  100650. * Synchronize and normalize all animatables with a source animatable
  100651. * @param root defines the root animatable to synchronize with
  100652. * @return the animationGroup
  100653. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  100654. */
  100655. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  100656. /**
  100657. * Goes to a specific frame in this animation group
  100658. * @param frame the frame number to go to
  100659. * @return the animationGroup
  100660. */
  100661. goToFrame(frame: number): AnimationGroup;
  100662. /**
  100663. * Dispose all associated resources
  100664. */
  100665. dispose(): void;
  100666. private _checkAnimationGroupEnded;
  100667. /**
  100668. * Clone the current animation group and returns a copy
  100669. * @param newName defines the name of the new group
  100670. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  100671. * @returns the new aniamtion group
  100672. */
  100673. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  100674. /**
  100675. * Serializes the animationGroup to an object
  100676. * @returns Serialized object
  100677. */
  100678. serialize(): any;
  100679. /**
  100680. * Returns a new AnimationGroup object parsed from the source provided.
  100681. * @param parsedAnimationGroup defines the source
  100682. * @param scene defines the scene that will receive the animationGroup
  100683. * @returns a new AnimationGroup
  100684. */
  100685. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  100686. /**
  100687. * Returns the string "AnimationGroup"
  100688. * @returns "AnimationGroup"
  100689. */
  100690. getClassName(): string;
  100691. /**
  100692. * Creates a detailled string about the object
  100693. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  100694. * @returns a string representing the object
  100695. */
  100696. toString(fullDetails?: boolean): string;
  100697. }
  100698. }
  100699. declare module BABYLON {
  100700. /**
  100701. * Define an interface for all classes that will hold resources
  100702. */
  100703. export interface IDisposable {
  100704. /**
  100705. * Releases all held resources
  100706. */
  100707. dispose(): void;
  100708. }
  100709. /** Interface defining initialization parameters for Scene class */
  100710. export interface SceneOptions {
  100711. /**
  100712. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  100713. * It will improve performance when the number of geometries becomes important.
  100714. */
  100715. useGeometryUniqueIdsMap?: boolean;
  100716. /**
  100717. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  100718. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100719. */
  100720. useMaterialMeshMap?: boolean;
  100721. /**
  100722. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  100723. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  100724. */
  100725. useClonedMeshhMap?: boolean;
  100726. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  100727. virtual?: boolean;
  100728. }
  100729. /**
  100730. * Represents a scene to be rendered by the engine.
  100731. * @see http://doc.babylonjs.com/features/scene
  100732. */
  100733. export class Scene extends AbstractScene implements IAnimatable {
  100734. /** The fog is deactivated */
  100735. static readonly FOGMODE_NONE: number;
  100736. /** The fog density is following an exponential function */
  100737. static readonly FOGMODE_EXP: number;
  100738. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  100739. static readonly FOGMODE_EXP2: number;
  100740. /** The fog density is following a linear function. */
  100741. static readonly FOGMODE_LINEAR: number;
  100742. /**
  100743. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  100744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100745. */
  100746. static MinDeltaTime: number;
  100747. /**
  100748. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  100749. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100750. */
  100751. static MaxDeltaTime: number;
  100752. /**
  100753. * Factory used to create the default material.
  100754. * @param name The name of the material to create
  100755. * @param scene The scene to create the material for
  100756. * @returns The default material
  100757. */
  100758. static DefaultMaterialFactory(scene: Scene): Material;
  100759. /**
  100760. * Factory used to create the a collision coordinator.
  100761. * @returns The collision coordinator
  100762. */
  100763. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  100764. /** @hidden */
  100765. _inputManager: InputManager;
  100766. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  100767. cameraToUseForPointers: Nullable<Camera>;
  100768. /** @hidden */
  100769. readonly _isScene: boolean;
  100770. /**
  100771. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  100772. */
  100773. autoClear: boolean;
  100774. /**
  100775. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  100776. */
  100777. autoClearDepthAndStencil: boolean;
  100778. /**
  100779. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  100780. */
  100781. clearColor: Color4;
  100782. /**
  100783. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  100784. */
  100785. ambientColor: Color3;
  100786. /**
  100787. * This is use to store the default BRDF lookup for PBR materials in your scene.
  100788. * It should only be one of the following (if not the default embedded one):
  100789. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  100790. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  100791. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  100792. * The material properties need to be setup according to the type of texture in use.
  100793. */
  100794. environmentBRDFTexture: BaseTexture;
  100795. /** @hidden */
  100796. protected _environmentTexture: Nullable<BaseTexture>;
  100797. /**
  100798. * Texture used in all pbr material as the reflection texture.
  100799. * As in the majority of the scene they are the same (exception for multi room and so on),
  100800. * this is easier to reference from here than from all the materials.
  100801. */
  100802. /**
  100803. * Texture used in all pbr material as the reflection texture.
  100804. * As in the majority of the scene they are the same (exception for multi room and so on),
  100805. * this is easier to set here than in all the materials.
  100806. */
  100807. environmentTexture: Nullable<BaseTexture>;
  100808. /** @hidden */
  100809. protected _environmentIntensity: number;
  100810. /**
  100811. * Intensity of the environment in all pbr material.
  100812. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100813. * As in the majority of the scene they are the same (exception for multi room and so on),
  100814. * this is easier to reference from here than from all the materials.
  100815. */
  100816. /**
  100817. * Intensity of the environment in all pbr material.
  100818. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  100819. * As in the majority of the scene they are the same (exception for multi room and so on),
  100820. * this is easier to set here than in all the materials.
  100821. */
  100822. environmentIntensity: number;
  100823. /** @hidden */
  100824. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100825. /**
  100826. * Default image processing configuration used either in the rendering
  100827. * Forward main pass or through the imageProcessingPostProcess if present.
  100828. * As in the majority of the scene they are the same (exception for multi camera),
  100829. * this is easier to reference from here than from all the materials and post process.
  100830. *
  100831. * No setter as we it is a shared configuration, you can set the values instead.
  100832. */
  100833. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  100834. private _forceWireframe;
  100835. /**
  100836. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  100837. */
  100838. forceWireframe: boolean;
  100839. private _forcePointsCloud;
  100840. /**
  100841. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  100842. */
  100843. forcePointsCloud: boolean;
  100844. /**
  100845. * Gets or sets the active clipplane 1
  100846. */
  100847. clipPlane: Nullable<Plane>;
  100848. /**
  100849. * Gets or sets the active clipplane 2
  100850. */
  100851. clipPlane2: Nullable<Plane>;
  100852. /**
  100853. * Gets or sets the active clipplane 3
  100854. */
  100855. clipPlane3: Nullable<Plane>;
  100856. /**
  100857. * Gets or sets the active clipplane 4
  100858. */
  100859. clipPlane4: Nullable<Plane>;
  100860. /**
  100861. * Gets or sets a boolean indicating if animations are enabled
  100862. */
  100863. animationsEnabled: boolean;
  100864. private _animationPropertiesOverride;
  100865. /**
  100866. * Gets or sets the animation properties override
  100867. */
  100868. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  100869. /**
  100870. * Gets or sets a boolean indicating if a constant deltatime has to be used
  100871. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  100872. */
  100873. useConstantAnimationDeltaTime: boolean;
  100874. /**
  100875. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  100876. * Please note that it requires to run a ray cast through the scene on every frame
  100877. */
  100878. constantlyUpdateMeshUnderPointer: boolean;
  100879. /**
  100880. * Defines the HTML cursor to use when hovering over interactive elements
  100881. */
  100882. hoverCursor: string;
  100883. /**
  100884. * Defines the HTML default cursor to use (empty by default)
  100885. */
  100886. defaultCursor: string;
  100887. /**
  100888. * Defines wether cursors are handled by the scene.
  100889. */
  100890. doNotHandleCursors: boolean;
  100891. /**
  100892. * This is used to call preventDefault() on pointer down
  100893. * in order to block unwanted artifacts like system double clicks
  100894. */
  100895. preventDefaultOnPointerDown: boolean;
  100896. /**
  100897. * This is used to call preventDefault() on pointer up
  100898. * in order to block unwanted artifacts like system double clicks
  100899. */
  100900. preventDefaultOnPointerUp: boolean;
  100901. /**
  100902. * Gets or sets user defined metadata
  100903. */
  100904. metadata: any;
  100905. /**
  100906. * For internal use only. Please do not use.
  100907. */
  100908. reservedDataStore: any;
  100909. /**
  100910. * Gets the name of the plugin used to load this scene (null by default)
  100911. */
  100912. loadingPluginName: string;
  100913. /**
  100914. * Use this array to add regular expressions used to disable offline support for specific urls
  100915. */
  100916. disableOfflineSupportExceptionRules: RegExp[];
  100917. /**
  100918. * An event triggered when the scene is disposed.
  100919. */
  100920. onDisposeObservable: Observable<Scene>;
  100921. private _onDisposeObserver;
  100922. /** Sets a function to be executed when this scene is disposed. */
  100923. onDispose: () => void;
  100924. /**
  100925. * An event triggered before rendering the scene (right after animations and physics)
  100926. */
  100927. onBeforeRenderObservable: Observable<Scene>;
  100928. private _onBeforeRenderObserver;
  100929. /** Sets a function to be executed before rendering this scene */
  100930. beforeRender: Nullable<() => void>;
  100931. /**
  100932. * An event triggered after rendering the scene
  100933. */
  100934. onAfterRenderObservable: Observable<Scene>;
  100935. /**
  100936. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100937. */
  100938. onAfterRenderCameraObservable: Observable<Camera>;
  100939. private _onAfterRenderObserver;
  100940. /** Sets a function to be executed after rendering this scene */
  100941. afterRender: Nullable<() => void>;
  100942. /**
  100943. * An event triggered before animating the scene
  100944. */
  100945. onBeforeAnimationsObservable: Observable<Scene>;
  100946. /**
  100947. * An event triggered after animations processing
  100948. */
  100949. onAfterAnimationsObservable: Observable<Scene>;
  100950. /**
  100951. * An event triggered before draw calls are ready to be sent
  100952. */
  100953. onBeforeDrawPhaseObservable: Observable<Scene>;
  100954. /**
  100955. * An event triggered after draw calls have been sent
  100956. */
  100957. onAfterDrawPhaseObservable: Observable<Scene>;
  100958. /**
  100959. * An event triggered when the scene is ready
  100960. */
  100961. onReadyObservable: Observable<Scene>;
  100962. /**
  100963. * An event triggered before rendering a camera
  100964. */
  100965. onBeforeCameraRenderObservable: Observable<Camera>;
  100966. private _onBeforeCameraRenderObserver;
  100967. /** Sets a function to be executed before rendering a camera*/
  100968. beforeCameraRender: () => void;
  100969. /**
  100970. * An event triggered after rendering a camera
  100971. */
  100972. onAfterCameraRenderObservable: Observable<Camera>;
  100973. private _onAfterCameraRenderObserver;
  100974. /** Sets a function to be executed after rendering a camera*/
  100975. afterCameraRender: () => void;
  100976. /**
  100977. * An event triggered when active meshes evaluation is about to start
  100978. */
  100979. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100980. /**
  100981. * An event triggered when active meshes evaluation is done
  100982. */
  100983. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100984. /**
  100985. * An event triggered when particles rendering is about to start
  100986. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100987. */
  100988. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100989. /**
  100990. * An event triggered when particles rendering is done
  100991. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100992. */
  100993. onAfterParticlesRenderingObservable: Observable<Scene>;
  100994. /**
  100995. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100996. */
  100997. onDataLoadedObservable: Observable<Scene>;
  100998. /**
  100999. * An event triggered when a camera is created
  101000. */
  101001. onNewCameraAddedObservable: Observable<Camera>;
  101002. /**
  101003. * An event triggered when a camera is removed
  101004. */
  101005. onCameraRemovedObservable: Observable<Camera>;
  101006. /**
  101007. * An event triggered when a light is created
  101008. */
  101009. onNewLightAddedObservable: Observable<Light>;
  101010. /**
  101011. * An event triggered when a light is removed
  101012. */
  101013. onLightRemovedObservable: Observable<Light>;
  101014. /**
  101015. * An event triggered when a geometry is created
  101016. */
  101017. onNewGeometryAddedObservable: Observable<Geometry>;
  101018. /**
  101019. * An event triggered when a geometry is removed
  101020. */
  101021. onGeometryRemovedObservable: Observable<Geometry>;
  101022. /**
  101023. * An event triggered when a transform node is created
  101024. */
  101025. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  101026. /**
  101027. * An event triggered when a transform node is removed
  101028. */
  101029. onTransformNodeRemovedObservable: Observable<TransformNode>;
  101030. /**
  101031. * An event triggered when a mesh is created
  101032. */
  101033. onNewMeshAddedObservable: Observable<AbstractMesh>;
  101034. /**
  101035. * An event triggered when a mesh is removed
  101036. */
  101037. onMeshRemovedObservable: Observable<AbstractMesh>;
  101038. /**
  101039. * An event triggered when a skeleton is created
  101040. */
  101041. onNewSkeletonAddedObservable: Observable<Skeleton>;
  101042. /**
  101043. * An event triggered when a skeleton is removed
  101044. */
  101045. onSkeletonRemovedObservable: Observable<Skeleton>;
  101046. /**
  101047. * An event triggered when a material is created
  101048. */
  101049. onNewMaterialAddedObservable: Observable<Material>;
  101050. /**
  101051. * An event triggered when a material is removed
  101052. */
  101053. onMaterialRemovedObservable: Observable<Material>;
  101054. /**
  101055. * An event triggered when a texture is created
  101056. */
  101057. onNewTextureAddedObservable: Observable<BaseTexture>;
  101058. /**
  101059. * An event triggered when a texture is removed
  101060. */
  101061. onTextureRemovedObservable: Observable<BaseTexture>;
  101062. /**
  101063. * An event triggered when render targets are about to be rendered
  101064. * Can happen multiple times per frame.
  101065. */
  101066. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  101067. /**
  101068. * An event triggered when render targets were rendered.
  101069. * Can happen multiple times per frame.
  101070. */
  101071. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  101072. /**
  101073. * An event triggered before calculating deterministic simulation step
  101074. */
  101075. onBeforeStepObservable: Observable<Scene>;
  101076. /**
  101077. * An event triggered after calculating deterministic simulation step
  101078. */
  101079. onAfterStepObservable: Observable<Scene>;
  101080. /**
  101081. * An event triggered when the activeCamera property is updated
  101082. */
  101083. onActiveCameraChanged: Observable<Scene>;
  101084. /**
  101085. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  101086. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101087. * 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)
  101088. */
  101089. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101090. /**
  101091. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  101092. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  101093. * 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)
  101094. */
  101095. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  101096. /**
  101097. * This Observable will when a mesh has been imported into the scene.
  101098. */
  101099. onMeshImportedObservable: Observable<AbstractMesh>;
  101100. /**
  101101. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  101102. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  101103. */
  101104. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  101105. /** @hidden */
  101106. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  101107. /**
  101108. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  101109. */
  101110. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  101111. /**
  101112. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  101113. */
  101114. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  101115. /**
  101116. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  101117. */
  101118. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  101119. /** Callback called when a pointer move is detected */
  101120. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101121. /** Callback called when a pointer down is detected */
  101122. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  101123. /** Callback called when a pointer up is detected */
  101124. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  101125. /** Callback called when a pointer pick is detected */
  101126. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  101127. /**
  101128. * 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).
  101129. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  101130. */
  101131. onPrePointerObservable: Observable<PointerInfoPre>;
  101132. /**
  101133. * Observable event triggered each time an input event is received from the rendering canvas
  101134. */
  101135. onPointerObservable: Observable<PointerInfo>;
  101136. /**
  101137. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  101138. */
  101139. readonly unTranslatedPointer: Vector2;
  101140. /**
  101141. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  101142. */
  101143. static DragMovementThreshold: number;
  101144. /**
  101145. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  101146. */
  101147. static LongPressDelay: number;
  101148. /**
  101149. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  101150. */
  101151. static DoubleClickDelay: number;
  101152. /** If you need to check double click without raising a single click at first click, enable this flag */
  101153. static ExclusiveDoubleClickMode: boolean;
  101154. /** @hidden */
  101155. _mirroredCameraPosition: Nullable<Vector3>;
  101156. /**
  101157. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  101158. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  101159. */
  101160. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  101161. /**
  101162. * Observable event triggered each time an keyboard event is received from the hosting window
  101163. */
  101164. onKeyboardObservable: Observable<KeyboardInfo>;
  101165. private _useRightHandedSystem;
  101166. /**
  101167. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  101168. */
  101169. useRightHandedSystem: boolean;
  101170. private _timeAccumulator;
  101171. private _currentStepId;
  101172. private _currentInternalStep;
  101173. /**
  101174. * Sets the step Id used by deterministic lock step
  101175. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101176. * @param newStepId defines the step Id
  101177. */
  101178. setStepId(newStepId: number): void;
  101179. /**
  101180. * Gets the step Id used by deterministic lock step
  101181. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101182. * @returns the step Id
  101183. */
  101184. getStepId(): number;
  101185. /**
  101186. * Gets the internal step used by deterministic lock step
  101187. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101188. * @returns the internal step
  101189. */
  101190. getInternalStep(): number;
  101191. private _fogEnabled;
  101192. /**
  101193. * Gets or sets a boolean indicating if fog is enabled on this scene
  101194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101195. * (Default is true)
  101196. */
  101197. fogEnabled: boolean;
  101198. private _fogMode;
  101199. /**
  101200. * Gets or sets the fog mode to use
  101201. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101202. * | mode | value |
  101203. * | --- | --- |
  101204. * | FOGMODE_NONE | 0 |
  101205. * | FOGMODE_EXP | 1 |
  101206. * | FOGMODE_EXP2 | 2 |
  101207. * | FOGMODE_LINEAR | 3 |
  101208. */
  101209. fogMode: number;
  101210. /**
  101211. * Gets or sets the fog color to use
  101212. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101213. * (Default is Color3(0.2, 0.2, 0.3))
  101214. */
  101215. fogColor: Color3;
  101216. /**
  101217. * Gets or sets the fog density to use
  101218. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101219. * (Default is 0.1)
  101220. */
  101221. fogDensity: number;
  101222. /**
  101223. * Gets or sets the fog start distance to use
  101224. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101225. * (Default is 0)
  101226. */
  101227. fogStart: number;
  101228. /**
  101229. * Gets or sets the fog end distance to use
  101230. * @see http://doc.babylonjs.com/babylon101/environment#fog
  101231. * (Default is 1000)
  101232. */
  101233. fogEnd: number;
  101234. private _shadowsEnabled;
  101235. /**
  101236. * Gets or sets a boolean indicating if shadows are enabled on this scene
  101237. */
  101238. shadowsEnabled: boolean;
  101239. private _lightsEnabled;
  101240. /**
  101241. * Gets or sets a boolean indicating if lights are enabled on this scene
  101242. */
  101243. lightsEnabled: boolean;
  101244. /** All of the active cameras added to this scene. */
  101245. activeCameras: Camera[];
  101246. /** @hidden */
  101247. _activeCamera: Nullable<Camera>;
  101248. /** Gets or sets the current active camera */
  101249. activeCamera: Nullable<Camera>;
  101250. private _defaultMaterial;
  101251. /** The default material used on meshes when no material is affected */
  101252. /** The default material used on meshes when no material is affected */
  101253. defaultMaterial: Material;
  101254. private _texturesEnabled;
  101255. /**
  101256. * Gets or sets a boolean indicating if textures are enabled on this scene
  101257. */
  101258. texturesEnabled: boolean;
  101259. /**
  101260. * Gets or sets a boolean indicating if particles are enabled on this scene
  101261. */
  101262. particlesEnabled: boolean;
  101263. /**
  101264. * Gets or sets a boolean indicating if sprites are enabled on this scene
  101265. */
  101266. spritesEnabled: boolean;
  101267. private _skeletonsEnabled;
  101268. /**
  101269. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  101270. */
  101271. skeletonsEnabled: boolean;
  101272. /**
  101273. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  101274. */
  101275. lensFlaresEnabled: boolean;
  101276. /**
  101277. * Gets or sets a boolean indicating if collisions are enabled on this scene
  101278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101279. */
  101280. collisionsEnabled: boolean;
  101281. private _collisionCoordinator;
  101282. /** @hidden */
  101283. readonly collisionCoordinator: ICollisionCoordinator;
  101284. /**
  101285. * Defines the gravity applied to this scene (used only for collisions)
  101286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101287. */
  101288. gravity: Vector3;
  101289. /**
  101290. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  101291. */
  101292. postProcessesEnabled: boolean;
  101293. /**
  101294. * The list of postprocesses added to the scene
  101295. */
  101296. postProcesses: PostProcess[];
  101297. /**
  101298. * Gets the current postprocess manager
  101299. */
  101300. postProcessManager: PostProcessManager;
  101301. /**
  101302. * Gets or sets a boolean indicating if render targets are enabled on this scene
  101303. */
  101304. renderTargetsEnabled: boolean;
  101305. /**
  101306. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  101307. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  101308. */
  101309. dumpNextRenderTargets: boolean;
  101310. /**
  101311. * The list of user defined render targets added to the scene
  101312. */
  101313. customRenderTargets: RenderTargetTexture[];
  101314. /**
  101315. * Defines if texture loading must be delayed
  101316. * If true, textures will only be loaded when they need to be rendered
  101317. */
  101318. useDelayedTextureLoading: boolean;
  101319. /**
  101320. * Gets the list of meshes imported to the scene through SceneLoader
  101321. */
  101322. importedMeshesFiles: String[];
  101323. /**
  101324. * Gets or sets a boolean indicating if probes are enabled on this scene
  101325. */
  101326. probesEnabled: boolean;
  101327. /**
  101328. * Gets or sets the current offline provider to use to store scene data
  101329. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101330. */
  101331. offlineProvider: IOfflineProvider;
  101332. /**
  101333. * Gets or sets the action manager associated with the scene
  101334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101335. */
  101336. actionManager: AbstractActionManager;
  101337. private _meshesForIntersections;
  101338. /**
  101339. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  101340. */
  101341. proceduralTexturesEnabled: boolean;
  101342. private _engine;
  101343. private _totalVertices;
  101344. /** @hidden */
  101345. _activeIndices: PerfCounter;
  101346. /** @hidden */
  101347. _activeParticles: PerfCounter;
  101348. /** @hidden */
  101349. _activeBones: PerfCounter;
  101350. private _animationRatio;
  101351. /** @hidden */
  101352. _animationTimeLast: number;
  101353. /** @hidden */
  101354. _animationTime: number;
  101355. /**
  101356. * Gets or sets a general scale for animation speed
  101357. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  101358. */
  101359. animationTimeScale: number;
  101360. /** @hidden */
  101361. _cachedMaterial: Nullable<Material>;
  101362. /** @hidden */
  101363. _cachedEffect: Nullable<Effect>;
  101364. /** @hidden */
  101365. _cachedVisibility: Nullable<number>;
  101366. private _renderId;
  101367. private _frameId;
  101368. private _executeWhenReadyTimeoutId;
  101369. private _intermediateRendering;
  101370. private _viewUpdateFlag;
  101371. private _projectionUpdateFlag;
  101372. /** @hidden */
  101373. _toBeDisposed: Nullable<IDisposable>[];
  101374. private _activeRequests;
  101375. /** @hidden */
  101376. _pendingData: any[];
  101377. private _isDisposed;
  101378. /**
  101379. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  101380. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  101381. */
  101382. dispatchAllSubMeshesOfActiveMeshes: boolean;
  101383. private _activeMeshes;
  101384. private _processedMaterials;
  101385. private _renderTargets;
  101386. /** @hidden */
  101387. _activeParticleSystems: SmartArray<IParticleSystem>;
  101388. private _activeSkeletons;
  101389. private _softwareSkinnedMeshes;
  101390. private _renderingManager;
  101391. /** @hidden */
  101392. _activeAnimatables: Animatable[];
  101393. private _transformMatrix;
  101394. private _sceneUbo;
  101395. /** @hidden */
  101396. _viewMatrix: Matrix;
  101397. private _projectionMatrix;
  101398. /** @hidden */
  101399. _forcedViewPosition: Nullable<Vector3>;
  101400. /** @hidden */
  101401. _frustumPlanes: Plane[];
  101402. /**
  101403. * Gets the list of frustum planes (built from the active camera)
  101404. */
  101405. readonly frustumPlanes: Plane[];
  101406. /**
  101407. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  101408. * This is useful if there are more lights that the maximum simulteanous authorized
  101409. */
  101410. requireLightSorting: boolean;
  101411. /** @hidden */
  101412. readonly useMaterialMeshMap: boolean;
  101413. /** @hidden */
  101414. readonly useClonedMeshhMap: boolean;
  101415. private _externalData;
  101416. private _uid;
  101417. /**
  101418. * @hidden
  101419. * Backing store of defined scene components.
  101420. */
  101421. _components: ISceneComponent[];
  101422. /**
  101423. * @hidden
  101424. * Backing store of defined scene components.
  101425. */
  101426. _serializableComponents: ISceneSerializableComponent[];
  101427. /**
  101428. * List of components to register on the next registration step.
  101429. */
  101430. private _transientComponents;
  101431. /**
  101432. * Registers the transient components if needed.
  101433. */
  101434. private _registerTransientComponents;
  101435. /**
  101436. * @hidden
  101437. * Add a component to the scene.
  101438. * Note that the ccomponent could be registered on th next frame if this is called after
  101439. * the register component stage.
  101440. * @param component Defines the component to add to the scene
  101441. */
  101442. _addComponent(component: ISceneComponent): void;
  101443. /**
  101444. * @hidden
  101445. * Gets a component from the scene.
  101446. * @param name defines the name of the component to retrieve
  101447. * @returns the component or null if not present
  101448. */
  101449. _getComponent(name: string): Nullable<ISceneComponent>;
  101450. /**
  101451. * @hidden
  101452. * Defines the actions happening before camera updates.
  101453. */
  101454. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  101455. /**
  101456. * @hidden
  101457. * Defines the actions happening before clear the canvas.
  101458. */
  101459. _beforeClearStage: Stage<SimpleStageAction>;
  101460. /**
  101461. * @hidden
  101462. * Defines the actions when collecting render targets for the frame.
  101463. */
  101464. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101465. /**
  101466. * @hidden
  101467. * Defines the actions happening for one camera in the frame.
  101468. */
  101469. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  101470. /**
  101471. * @hidden
  101472. * Defines the actions happening during the per mesh ready checks.
  101473. */
  101474. _isReadyForMeshStage: Stage<MeshStageAction>;
  101475. /**
  101476. * @hidden
  101477. * Defines the actions happening before evaluate active mesh checks.
  101478. */
  101479. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  101480. /**
  101481. * @hidden
  101482. * Defines the actions happening during the evaluate sub mesh checks.
  101483. */
  101484. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  101485. /**
  101486. * @hidden
  101487. * Defines the actions happening during the active mesh stage.
  101488. */
  101489. _activeMeshStage: Stage<ActiveMeshStageAction>;
  101490. /**
  101491. * @hidden
  101492. * Defines the actions happening during the per camera render target step.
  101493. */
  101494. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  101495. /**
  101496. * @hidden
  101497. * Defines the actions happening just before the active camera is drawing.
  101498. */
  101499. _beforeCameraDrawStage: Stage<CameraStageAction>;
  101500. /**
  101501. * @hidden
  101502. * Defines the actions happening just before a render target is drawing.
  101503. */
  101504. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101505. /**
  101506. * @hidden
  101507. * Defines the actions happening just before a rendering group is drawing.
  101508. */
  101509. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101510. /**
  101511. * @hidden
  101512. * Defines the actions happening just before a mesh is drawing.
  101513. */
  101514. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101515. /**
  101516. * @hidden
  101517. * Defines the actions happening just after a mesh has been drawn.
  101518. */
  101519. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  101520. /**
  101521. * @hidden
  101522. * Defines the actions happening just after a rendering group has been drawn.
  101523. */
  101524. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  101525. /**
  101526. * @hidden
  101527. * Defines the actions happening just after the active camera has been drawn.
  101528. */
  101529. _afterCameraDrawStage: Stage<CameraStageAction>;
  101530. /**
  101531. * @hidden
  101532. * Defines the actions happening just after a render target has been drawn.
  101533. */
  101534. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  101535. /**
  101536. * @hidden
  101537. * Defines the actions happening just after rendering all cameras and computing intersections.
  101538. */
  101539. _afterRenderStage: Stage<SimpleStageAction>;
  101540. /**
  101541. * @hidden
  101542. * Defines the actions happening when a pointer move event happens.
  101543. */
  101544. _pointerMoveStage: Stage<PointerMoveStageAction>;
  101545. /**
  101546. * @hidden
  101547. * Defines the actions happening when a pointer down event happens.
  101548. */
  101549. _pointerDownStage: Stage<PointerUpDownStageAction>;
  101550. /**
  101551. * @hidden
  101552. * Defines the actions happening when a pointer up event happens.
  101553. */
  101554. _pointerUpStage: Stage<PointerUpDownStageAction>;
  101555. /**
  101556. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  101557. */
  101558. private geometriesByUniqueId;
  101559. /**
  101560. * Creates a new Scene
  101561. * @param engine defines the engine to use to render this scene
  101562. * @param options defines the scene options
  101563. */
  101564. constructor(engine: Engine, options?: SceneOptions);
  101565. /**
  101566. * Gets a string idenfifying the name of the class
  101567. * @returns "Scene" string
  101568. */
  101569. getClassName(): string;
  101570. private _defaultMeshCandidates;
  101571. /**
  101572. * @hidden
  101573. */
  101574. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  101575. private _defaultSubMeshCandidates;
  101576. /**
  101577. * @hidden
  101578. */
  101579. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  101580. /**
  101581. * Sets the default candidate providers for the scene.
  101582. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  101583. * and getCollidingSubMeshCandidates to their default function
  101584. */
  101585. setDefaultCandidateProviders(): void;
  101586. /**
  101587. * Gets the mesh that is currently under the pointer
  101588. */
  101589. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101590. /**
  101591. * Gets or sets the current on-screen X position of the pointer
  101592. */
  101593. pointerX: number;
  101594. /**
  101595. * Gets or sets the current on-screen Y position of the pointer
  101596. */
  101597. pointerY: number;
  101598. /**
  101599. * Gets the cached material (ie. the latest rendered one)
  101600. * @returns the cached material
  101601. */
  101602. getCachedMaterial(): Nullable<Material>;
  101603. /**
  101604. * Gets the cached effect (ie. the latest rendered one)
  101605. * @returns the cached effect
  101606. */
  101607. getCachedEffect(): Nullable<Effect>;
  101608. /**
  101609. * Gets the cached visibility state (ie. the latest rendered one)
  101610. * @returns the cached visibility state
  101611. */
  101612. getCachedVisibility(): Nullable<number>;
  101613. /**
  101614. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  101615. * @param material defines the current material
  101616. * @param effect defines the current effect
  101617. * @param visibility defines the current visibility state
  101618. * @returns true if one parameter is not cached
  101619. */
  101620. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  101621. /**
  101622. * Gets the engine associated with the scene
  101623. * @returns an Engine
  101624. */
  101625. getEngine(): Engine;
  101626. /**
  101627. * Gets the total number of vertices rendered per frame
  101628. * @returns the total number of vertices rendered per frame
  101629. */
  101630. getTotalVertices(): number;
  101631. /**
  101632. * Gets the performance counter for total vertices
  101633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101634. */
  101635. readonly totalVerticesPerfCounter: PerfCounter;
  101636. /**
  101637. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  101638. * @returns the total number of active indices rendered per frame
  101639. */
  101640. getActiveIndices(): number;
  101641. /**
  101642. * Gets the performance counter for active indices
  101643. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101644. */
  101645. readonly totalActiveIndicesPerfCounter: PerfCounter;
  101646. /**
  101647. * Gets the total number of active particles rendered per frame
  101648. * @returns the total number of active particles rendered per frame
  101649. */
  101650. getActiveParticles(): number;
  101651. /**
  101652. * Gets the performance counter for active particles
  101653. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101654. */
  101655. readonly activeParticlesPerfCounter: PerfCounter;
  101656. /**
  101657. * Gets the total number of active bones rendered per frame
  101658. * @returns the total number of active bones rendered per frame
  101659. */
  101660. getActiveBones(): number;
  101661. /**
  101662. * Gets the performance counter for active bones
  101663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  101664. */
  101665. readonly activeBonesPerfCounter: PerfCounter;
  101666. /**
  101667. * Gets the array of active meshes
  101668. * @returns an array of AbstractMesh
  101669. */
  101670. getActiveMeshes(): SmartArray<AbstractMesh>;
  101671. /**
  101672. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  101673. * @returns a number
  101674. */
  101675. getAnimationRatio(): number;
  101676. /**
  101677. * Gets an unique Id for the current render phase
  101678. * @returns a number
  101679. */
  101680. getRenderId(): number;
  101681. /**
  101682. * Gets an unique Id for the current frame
  101683. * @returns a number
  101684. */
  101685. getFrameId(): number;
  101686. /** Call this function if you want to manually increment the render Id*/
  101687. incrementRenderId(): void;
  101688. private _createUbo;
  101689. /**
  101690. * Use this method to simulate a pointer move on a mesh
  101691. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101692. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101693. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101694. * @returns the current scene
  101695. */
  101696. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101697. /**
  101698. * Use this method to simulate a pointer down on a mesh
  101699. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101700. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101701. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101702. * @returns the current scene
  101703. */
  101704. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  101705. /**
  101706. * Use this method to simulate a pointer up on a mesh
  101707. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101708. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101709. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101710. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101711. * @returns the current scene
  101712. */
  101713. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  101714. /**
  101715. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101716. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101717. * @returns true if the pointer was captured
  101718. */
  101719. isPointerCaptured(pointerId?: number): boolean;
  101720. /**
  101721. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101722. * @param attachUp defines if you want to attach events to pointerup
  101723. * @param attachDown defines if you want to attach events to pointerdown
  101724. * @param attachMove defines if you want to attach events to pointermove
  101725. */
  101726. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101727. /** Detaches all event handlers*/
  101728. detachControl(): void;
  101729. /**
  101730. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  101731. * Delay loaded resources are not taking in account
  101732. * @return true if all required resources are ready
  101733. */
  101734. isReady(): boolean;
  101735. /** Resets all cached information relative to material (including effect and visibility) */
  101736. resetCachedMaterial(): void;
  101737. /**
  101738. * Registers a function to be called before every frame render
  101739. * @param func defines the function to register
  101740. */
  101741. registerBeforeRender(func: () => void): void;
  101742. /**
  101743. * Unregisters a function called before every frame render
  101744. * @param func defines the function to unregister
  101745. */
  101746. unregisterBeforeRender(func: () => void): void;
  101747. /**
  101748. * Registers a function to be called after every frame render
  101749. * @param func defines the function to register
  101750. */
  101751. registerAfterRender(func: () => void): void;
  101752. /**
  101753. * Unregisters a function called after every frame render
  101754. * @param func defines the function to unregister
  101755. */
  101756. unregisterAfterRender(func: () => void): void;
  101757. private _executeOnceBeforeRender;
  101758. /**
  101759. * The provided function will run before render once and will be disposed afterwards.
  101760. * A timeout delay can be provided so that the function will be executed in N ms.
  101761. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  101762. * @param func The function to be executed.
  101763. * @param timeout optional delay in ms
  101764. */
  101765. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  101766. /** @hidden */
  101767. _addPendingData(data: any): void;
  101768. /** @hidden */
  101769. _removePendingData(data: any): void;
  101770. /**
  101771. * Returns the number of items waiting to be loaded
  101772. * @returns the number of items waiting to be loaded
  101773. */
  101774. getWaitingItemsCount(): number;
  101775. /**
  101776. * Returns a boolean indicating if the scene is still loading data
  101777. */
  101778. readonly isLoading: boolean;
  101779. /**
  101780. * Registers a function to be executed when the scene is ready
  101781. * @param {Function} func - the function to be executed
  101782. */
  101783. executeWhenReady(func: () => void): void;
  101784. /**
  101785. * Returns a promise that resolves when the scene is ready
  101786. * @returns A promise that resolves when the scene is ready
  101787. */
  101788. whenReadyAsync(): Promise<void>;
  101789. /** @hidden */
  101790. _checkIsReady(): void;
  101791. /**
  101792. * Gets all animatable attached to the scene
  101793. */
  101794. readonly animatables: Animatable[];
  101795. /**
  101796. * Resets the last animation time frame.
  101797. * Useful to override when animations start running when loading a scene for the first time.
  101798. */
  101799. resetLastAnimationTimeFrame(): void;
  101800. /**
  101801. * Gets the current view matrix
  101802. * @returns a Matrix
  101803. */
  101804. getViewMatrix(): Matrix;
  101805. /**
  101806. * Gets the current projection matrix
  101807. * @returns a Matrix
  101808. */
  101809. getProjectionMatrix(): Matrix;
  101810. /**
  101811. * Gets the current transform matrix
  101812. * @returns a Matrix made of View * Projection
  101813. */
  101814. getTransformMatrix(): Matrix;
  101815. /**
  101816. * Sets the current transform matrix
  101817. * @param viewL defines the View matrix to use
  101818. * @param projectionL defines the Projection matrix to use
  101819. * @param viewR defines the right View matrix to use (if provided)
  101820. * @param projectionR defines the right Projection matrix to use (if provided)
  101821. */
  101822. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  101823. /**
  101824. * Gets the uniform buffer used to store scene data
  101825. * @returns a UniformBuffer
  101826. */
  101827. getSceneUniformBuffer(): UniformBuffer;
  101828. /**
  101829. * Gets an unique (relatively to the current scene) Id
  101830. * @returns an unique number for the scene
  101831. */
  101832. getUniqueId(): number;
  101833. /**
  101834. * Add a mesh to the list of scene's meshes
  101835. * @param newMesh defines the mesh to add
  101836. * @param recursive if all child meshes should also be added to the scene
  101837. */
  101838. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  101839. /**
  101840. * Remove a mesh for the list of scene's meshes
  101841. * @param toRemove defines the mesh to remove
  101842. * @param recursive if all child meshes should also be removed from the scene
  101843. * @returns the index where the mesh was in the mesh list
  101844. */
  101845. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  101846. /**
  101847. * Add a transform node to the list of scene's transform nodes
  101848. * @param newTransformNode defines the transform node to add
  101849. */
  101850. addTransformNode(newTransformNode: TransformNode): void;
  101851. /**
  101852. * Remove a transform node for the list of scene's transform nodes
  101853. * @param toRemove defines the transform node to remove
  101854. * @returns the index where the transform node was in the transform node list
  101855. */
  101856. removeTransformNode(toRemove: TransformNode): number;
  101857. /**
  101858. * Remove a skeleton for the list of scene's skeletons
  101859. * @param toRemove defines the skeleton to remove
  101860. * @returns the index where the skeleton was in the skeleton list
  101861. */
  101862. removeSkeleton(toRemove: Skeleton): number;
  101863. /**
  101864. * Remove a morph target for the list of scene's morph targets
  101865. * @param toRemove defines the morph target to remove
  101866. * @returns the index where the morph target was in the morph target list
  101867. */
  101868. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  101869. /**
  101870. * Remove a light for the list of scene's lights
  101871. * @param toRemove defines the light to remove
  101872. * @returns the index where the light was in the light list
  101873. */
  101874. removeLight(toRemove: Light): number;
  101875. /**
  101876. * Remove a camera for the list of scene's cameras
  101877. * @param toRemove defines the camera to remove
  101878. * @returns the index where the camera was in the camera list
  101879. */
  101880. removeCamera(toRemove: Camera): number;
  101881. /**
  101882. * Remove a particle system for the list of scene's particle systems
  101883. * @param toRemove defines the particle system to remove
  101884. * @returns the index where the particle system was in the particle system list
  101885. */
  101886. removeParticleSystem(toRemove: IParticleSystem): number;
  101887. /**
  101888. * Remove a animation for the list of scene's animations
  101889. * @param toRemove defines the animation to remove
  101890. * @returns the index where the animation was in the animation list
  101891. */
  101892. removeAnimation(toRemove: Animation): number;
  101893. /**
  101894. * Will stop the animation of the given target
  101895. * @param target - the target
  101896. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  101897. * @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)
  101898. */
  101899. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  101900. /**
  101901. * Removes the given animation group from this scene.
  101902. * @param toRemove The animation group to remove
  101903. * @returns The index of the removed animation group
  101904. */
  101905. removeAnimationGroup(toRemove: AnimationGroup): number;
  101906. /**
  101907. * Removes the given multi-material from this scene.
  101908. * @param toRemove The multi-material to remove
  101909. * @returns The index of the removed multi-material
  101910. */
  101911. removeMultiMaterial(toRemove: MultiMaterial): number;
  101912. /**
  101913. * Removes the given material from this scene.
  101914. * @param toRemove The material to remove
  101915. * @returns The index of the removed material
  101916. */
  101917. removeMaterial(toRemove: Material): number;
  101918. /**
  101919. * Removes the given action manager from this scene.
  101920. * @param toRemove The action manager to remove
  101921. * @returns The index of the removed action manager
  101922. */
  101923. removeActionManager(toRemove: AbstractActionManager): number;
  101924. /**
  101925. * Removes the given texture from this scene.
  101926. * @param toRemove The texture to remove
  101927. * @returns The index of the removed texture
  101928. */
  101929. removeTexture(toRemove: BaseTexture): number;
  101930. /**
  101931. * Adds the given light to this scene
  101932. * @param newLight The light to add
  101933. */
  101934. addLight(newLight: Light): void;
  101935. /**
  101936. * Sorts the list list based on light priorities
  101937. */
  101938. sortLightsByPriority(): void;
  101939. /**
  101940. * Adds the given camera to this scene
  101941. * @param newCamera The camera to add
  101942. */
  101943. addCamera(newCamera: Camera): void;
  101944. /**
  101945. * Adds the given skeleton to this scene
  101946. * @param newSkeleton The skeleton to add
  101947. */
  101948. addSkeleton(newSkeleton: Skeleton): void;
  101949. /**
  101950. * Adds the given particle system to this scene
  101951. * @param newParticleSystem The particle system to add
  101952. */
  101953. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101954. /**
  101955. * Adds the given animation to this scene
  101956. * @param newAnimation The animation to add
  101957. */
  101958. addAnimation(newAnimation: Animation): void;
  101959. /**
  101960. * Adds the given animation group to this scene.
  101961. * @param newAnimationGroup The animation group to add
  101962. */
  101963. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101964. /**
  101965. * Adds the given multi-material to this scene
  101966. * @param newMultiMaterial The multi-material to add
  101967. */
  101968. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101969. /**
  101970. * Adds the given material to this scene
  101971. * @param newMaterial The material to add
  101972. */
  101973. addMaterial(newMaterial: Material): void;
  101974. /**
  101975. * Adds the given morph target to this scene
  101976. * @param newMorphTargetManager The morph target to add
  101977. */
  101978. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101979. /**
  101980. * Adds the given geometry to this scene
  101981. * @param newGeometry The geometry to add
  101982. */
  101983. addGeometry(newGeometry: Geometry): void;
  101984. /**
  101985. * Adds the given action manager to this scene
  101986. * @param newActionManager The action manager to add
  101987. */
  101988. addActionManager(newActionManager: AbstractActionManager): void;
  101989. /**
  101990. * Adds the given texture to this scene.
  101991. * @param newTexture The texture to add
  101992. */
  101993. addTexture(newTexture: BaseTexture): void;
  101994. /**
  101995. * Switch active camera
  101996. * @param newCamera defines the new active camera
  101997. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101998. */
  101999. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  102000. /**
  102001. * sets the active camera of the scene using its ID
  102002. * @param id defines the camera's ID
  102003. * @return the new active camera or null if none found.
  102004. */
  102005. setActiveCameraByID(id: string): Nullable<Camera>;
  102006. /**
  102007. * sets the active camera of the scene using its name
  102008. * @param name defines the camera's name
  102009. * @returns the new active camera or null if none found.
  102010. */
  102011. setActiveCameraByName(name: string): Nullable<Camera>;
  102012. /**
  102013. * get an animation group using its name
  102014. * @param name defines the material's name
  102015. * @return the animation group or null if none found.
  102016. */
  102017. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  102018. /**
  102019. * Get a material using its unique id
  102020. * @param uniqueId defines the material's unique id
  102021. * @return the material or null if none found.
  102022. */
  102023. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  102024. /**
  102025. * get a material using its id
  102026. * @param id defines the material's ID
  102027. * @return the material or null if none found.
  102028. */
  102029. getMaterialByID(id: string): Nullable<Material>;
  102030. /**
  102031. * Gets a the last added material using a given id
  102032. * @param id defines the material's ID
  102033. * @return the last material with the given id or null if none found.
  102034. */
  102035. getLastMaterialByID(id: string): Nullable<Material>;
  102036. /**
  102037. * Gets a material using its name
  102038. * @param name defines the material's name
  102039. * @return the material or null if none found.
  102040. */
  102041. getMaterialByName(name: string): Nullable<Material>;
  102042. /**
  102043. * Get a texture using its unique id
  102044. * @param uniqueId defines the texture's unique id
  102045. * @return the texture or null if none found.
  102046. */
  102047. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  102048. /**
  102049. * Gets a camera using its id
  102050. * @param id defines the id to look for
  102051. * @returns the camera or null if not found
  102052. */
  102053. getCameraByID(id: string): Nullable<Camera>;
  102054. /**
  102055. * Gets a camera using its unique id
  102056. * @param uniqueId defines the unique id to look for
  102057. * @returns the camera or null if not found
  102058. */
  102059. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  102060. /**
  102061. * Gets a camera using its name
  102062. * @param name defines the camera's name
  102063. * @return the camera or null if none found.
  102064. */
  102065. getCameraByName(name: string): Nullable<Camera>;
  102066. /**
  102067. * Gets a bone using its id
  102068. * @param id defines the bone's id
  102069. * @return the bone or null if not found
  102070. */
  102071. getBoneByID(id: string): Nullable<Bone>;
  102072. /**
  102073. * Gets a bone using its id
  102074. * @param name defines the bone's name
  102075. * @return the bone or null if not found
  102076. */
  102077. getBoneByName(name: string): Nullable<Bone>;
  102078. /**
  102079. * Gets a light node using its name
  102080. * @param name defines the the light's name
  102081. * @return the light or null if none found.
  102082. */
  102083. getLightByName(name: string): Nullable<Light>;
  102084. /**
  102085. * Gets a light node using its id
  102086. * @param id defines the light's id
  102087. * @return the light or null if none found.
  102088. */
  102089. getLightByID(id: string): Nullable<Light>;
  102090. /**
  102091. * Gets a light node using its scene-generated unique ID
  102092. * @param uniqueId defines the light's unique id
  102093. * @return the light or null if none found.
  102094. */
  102095. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  102096. /**
  102097. * Gets a particle system by id
  102098. * @param id defines the particle system id
  102099. * @return the corresponding system or null if none found
  102100. */
  102101. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  102102. /**
  102103. * Gets a geometry using its ID
  102104. * @param id defines the geometry's id
  102105. * @return the geometry or null if none found.
  102106. */
  102107. getGeometryByID(id: string): Nullable<Geometry>;
  102108. private _getGeometryByUniqueID;
  102109. /**
  102110. * Add a new geometry to this scene
  102111. * @param geometry defines the geometry to be added to the scene.
  102112. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  102113. * @return a boolean defining if the geometry was added or not
  102114. */
  102115. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  102116. /**
  102117. * Removes an existing geometry
  102118. * @param geometry defines the geometry to be removed from the scene
  102119. * @return a boolean defining if the geometry was removed or not
  102120. */
  102121. removeGeometry(geometry: Geometry): boolean;
  102122. /**
  102123. * Gets the list of geometries attached to the scene
  102124. * @returns an array of Geometry
  102125. */
  102126. getGeometries(): Geometry[];
  102127. /**
  102128. * Gets the first added mesh found of a given ID
  102129. * @param id defines the id to search for
  102130. * @return the mesh found or null if not found at all
  102131. */
  102132. getMeshByID(id: string): Nullable<AbstractMesh>;
  102133. /**
  102134. * Gets a list of meshes using their id
  102135. * @param id defines the id to search for
  102136. * @returns a list of meshes
  102137. */
  102138. getMeshesByID(id: string): Array<AbstractMesh>;
  102139. /**
  102140. * Gets the first added transform node found of a given ID
  102141. * @param id defines the id to search for
  102142. * @return the found transform node or null if not found at all.
  102143. */
  102144. getTransformNodeByID(id: string): Nullable<TransformNode>;
  102145. /**
  102146. * Gets a transform node with its auto-generated unique id
  102147. * @param uniqueId efines the unique id to search for
  102148. * @return the found transform node or null if not found at all.
  102149. */
  102150. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  102151. /**
  102152. * Gets a list of transform nodes using their id
  102153. * @param id defines the id to search for
  102154. * @returns a list of transform nodes
  102155. */
  102156. getTransformNodesByID(id: string): Array<TransformNode>;
  102157. /**
  102158. * Gets a mesh with its auto-generated unique id
  102159. * @param uniqueId defines the unique id to search for
  102160. * @return the found mesh or null if not found at all.
  102161. */
  102162. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  102163. /**
  102164. * Gets a the last added mesh using a given id
  102165. * @param id defines the id to search for
  102166. * @return the found mesh or null if not found at all.
  102167. */
  102168. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  102169. /**
  102170. * Gets a the last added node (Mesh, Camera, Light) using a given id
  102171. * @param id defines the id to search for
  102172. * @return the found node or null if not found at all
  102173. */
  102174. getLastEntryByID(id: string): Nullable<Node>;
  102175. /**
  102176. * Gets a node (Mesh, Camera, Light) using a given id
  102177. * @param id defines the id to search for
  102178. * @return the found node or null if not found at all
  102179. */
  102180. getNodeByID(id: string): Nullable<Node>;
  102181. /**
  102182. * Gets a node (Mesh, Camera, Light) using a given name
  102183. * @param name defines the name to search for
  102184. * @return the found node or null if not found at all.
  102185. */
  102186. getNodeByName(name: string): Nullable<Node>;
  102187. /**
  102188. * Gets a mesh using a given name
  102189. * @param name defines the name to search for
  102190. * @return the found mesh or null if not found at all.
  102191. */
  102192. getMeshByName(name: string): Nullable<AbstractMesh>;
  102193. /**
  102194. * Gets a transform node using a given name
  102195. * @param name defines the name to search for
  102196. * @return the found transform node or null if not found at all.
  102197. */
  102198. getTransformNodeByName(name: string): Nullable<TransformNode>;
  102199. /**
  102200. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  102201. * @param id defines the id to search for
  102202. * @return the found skeleton or null if not found at all.
  102203. */
  102204. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  102205. /**
  102206. * Gets a skeleton using a given auto generated unique id
  102207. * @param uniqueId defines the unique id to search for
  102208. * @return the found skeleton or null if not found at all.
  102209. */
  102210. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  102211. /**
  102212. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  102213. * @param id defines the id to search for
  102214. * @return the found skeleton or null if not found at all.
  102215. */
  102216. getSkeletonById(id: string): Nullable<Skeleton>;
  102217. /**
  102218. * Gets a skeleton using a given name
  102219. * @param name defines the name to search for
  102220. * @return the found skeleton or null if not found at all.
  102221. */
  102222. getSkeletonByName(name: string): Nullable<Skeleton>;
  102223. /**
  102224. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  102225. * @param id defines the id to search for
  102226. * @return the found morph target manager or null if not found at all.
  102227. */
  102228. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  102229. /**
  102230. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  102231. * @param id defines the id to search for
  102232. * @return the found morph target or null if not found at all.
  102233. */
  102234. getMorphTargetById(id: string): Nullable<MorphTarget>;
  102235. /**
  102236. * Gets a boolean indicating if the given mesh is active
  102237. * @param mesh defines the mesh to look for
  102238. * @returns true if the mesh is in the active list
  102239. */
  102240. isActiveMesh(mesh: AbstractMesh): boolean;
  102241. /**
  102242. * Return a unique id as a string which can serve as an identifier for the scene
  102243. */
  102244. readonly uid: string;
  102245. /**
  102246. * Add an externaly attached data from its key.
  102247. * This method call will fail and return false, if such key already exists.
  102248. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  102249. * @param key the unique key that identifies the data
  102250. * @param data the data object to associate to the key for this Engine instance
  102251. * @return true if no such key were already present and the data was added successfully, false otherwise
  102252. */
  102253. addExternalData<T>(key: string, data: T): boolean;
  102254. /**
  102255. * Get an externaly attached data from its key
  102256. * @param key the unique key that identifies the data
  102257. * @return the associated data, if present (can be null), or undefined if not present
  102258. */
  102259. getExternalData<T>(key: string): Nullable<T>;
  102260. /**
  102261. * Get an externaly attached data from its key, create it using a factory if it's not already present
  102262. * @param key the unique key that identifies the data
  102263. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  102264. * @return the associated data, can be null if the factory returned null.
  102265. */
  102266. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  102267. /**
  102268. * Remove an externaly attached data from the Engine instance
  102269. * @param key the unique key that identifies the data
  102270. * @return true if the data was successfully removed, false if it doesn't exist
  102271. */
  102272. removeExternalData(key: string): boolean;
  102273. private _evaluateSubMesh;
  102274. /**
  102275. * Clear the processed materials smart array preventing retention point in material dispose.
  102276. */
  102277. freeProcessedMaterials(): void;
  102278. private _preventFreeActiveMeshesAndRenderingGroups;
  102279. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  102280. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  102281. * when disposing several meshes in a row or a hierarchy of meshes.
  102282. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  102283. */
  102284. blockfreeActiveMeshesAndRenderingGroups: boolean;
  102285. /**
  102286. * Clear the active meshes smart array preventing retention point in mesh dispose.
  102287. */
  102288. freeActiveMeshes(): void;
  102289. /**
  102290. * Clear the info related to rendering groups preventing retention points during dispose.
  102291. */
  102292. freeRenderingGroups(): void;
  102293. /** @hidden */
  102294. _isInIntermediateRendering(): boolean;
  102295. /**
  102296. * Lambda returning the list of potentially active meshes.
  102297. */
  102298. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  102299. /**
  102300. * Lambda returning the list of potentially active sub meshes.
  102301. */
  102302. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  102303. /**
  102304. * Lambda returning the list of potentially intersecting sub meshes.
  102305. */
  102306. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  102307. /**
  102308. * Lambda returning the list of potentially colliding sub meshes.
  102309. */
  102310. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  102311. private _activeMeshesFrozen;
  102312. /**
  102313. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  102314. * @returns the current scene
  102315. */
  102316. freezeActiveMeshes(): Scene;
  102317. /**
  102318. * Use this function to restart evaluating active meshes on every frame
  102319. * @returns the current scene
  102320. */
  102321. unfreezeActiveMeshes(): Scene;
  102322. private _evaluateActiveMeshes;
  102323. private _activeMesh;
  102324. /**
  102325. * Update the transform matrix to update from the current active camera
  102326. * @param force defines a boolean used to force the update even if cache is up to date
  102327. */
  102328. updateTransformMatrix(force?: boolean): void;
  102329. private _bindFrameBuffer;
  102330. /** @hidden */
  102331. _allowPostProcessClearColor: boolean;
  102332. /** @hidden */
  102333. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  102334. private _processSubCameras;
  102335. private _checkIntersections;
  102336. /** @hidden */
  102337. _advancePhysicsEngineStep(step: number): void;
  102338. /**
  102339. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  102340. */
  102341. getDeterministicFrameTime: () => number;
  102342. /** @hidden */
  102343. _animate(): void;
  102344. /** Execute all animations (for a frame) */
  102345. animate(): void;
  102346. /**
  102347. * Render the scene
  102348. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  102349. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  102350. */
  102351. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  102352. /**
  102353. * Freeze all materials
  102354. * A frozen material will not be updatable but should be faster to render
  102355. */
  102356. freezeMaterials(): void;
  102357. /**
  102358. * Unfreeze all materials
  102359. * A frozen material will not be updatable but should be faster to render
  102360. */
  102361. unfreezeMaterials(): void;
  102362. /**
  102363. * Releases all held ressources
  102364. */
  102365. dispose(): void;
  102366. /**
  102367. * Gets if the scene is already disposed
  102368. */
  102369. readonly isDisposed: boolean;
  102370. /**
  102371. * Call this function to reduce memory footprint of the scene.
  102372. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  102373. */
  102374. clearCachedVertexData(): void;
  102375. /**
  102376. * This function will remove the local cached buffer data from texture.
  102377. * It will save memory but will prevent the texture from being rebuilt
  102378. */
  102379. cleanCachedTextureBuffer(): void;
  102380. /**
  102381. * Get the world extend vectors with an optional filter
  102382. *
  102383. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  102384. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  102385. */
  102386. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  102387. min: Vector3;
  102388. max: Vector3;
  102389. };
  102390. /**
  102391. * Creates a ray that can be used to pick in the scene
  102392. * @param x defines the x coordinate of the origin (on-screen)
  102393. * @param y defines the y coordinate of the origin (on-screen)
  102394. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102395. * @param camera defines the camera to use for the picking
  102396. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102397. * @returns a Ray
  102398. */
  102399. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  102400. /**
  102401. * Creates a ray that can be used to pick in the scene
  102402. * @param x defines the x coordinate of the origin (on-screen)
  102403. * @param y defines the y coordinate of the origin (on-screen)
  102404. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  102405. * @param result defines the ray where to store the picking ray
  102406. * @param camera defines the camera to use for the picking
  102407. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  102408. * @returns the current scene
  102409. */
  102410. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  102411. /**
  102412. * Creates a ray that can be used to pick in the scene
  102413. * @param x defines the x coordinate of the origin (on-screen)
  102414. * @param y defines the y coordinate of the origin (on-screen)
  102415. * @param camera defines the camera to use for the picking
  102416. * @returns a Ray
  102417. */
  102418. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  102419. /**
  102420. * Creates a ray that can be used to pick in the scene
  102421. * @param x defines the x coordinate of the origin (on-screen)
  102422. * @param y defines the y coordinate of the origin (on-screen)
  102423. * @param result defines the ray where to store the picking ray
  102424. * @param camera defines the camera to use for the picking
  102425. * @returns the current scene
  102426. */
  102427. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  102428. /** Launch a ray to try to pick a mesh in the scene
  102429. * @param x position on screen
  102430. * @param y position on screen
  102431. * @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
  102432. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  102433. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102434. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102435. * @returns a PickingInfo
  102436. */
  102437. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102438. /** Use the given ray to pick a mesh in the scene
  102439. * @param ray The ray to use to pick meshes
  102440. * @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
  102441. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  102442. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102443. * @returns a PickingInfo
  102444. */
  102445. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  102446. /**
  102447. * Launch a ray to try to pick a mesh in the scene
  102448. * @param x X position on screen
  102449. * @param y Y position on screen
  102450. * @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
  102451. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  102452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102453. * @returns an array of PickingInfo
  102454. */
  102455. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102456. /**
  102457. * Launch a ray to try to pick a mesh in the scene
  102458. * @param ray Ray to use
  102459. * @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
  102460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102461. * @returns an array of PickingInfo
  102462. */
  102463. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  102464. /**
  102465. * Force the value of meshUnderPointer
  102466. * @param mesh defines the mesh to use
  102467. */
  102468. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  102469. /**
  102470. * Gets the mesh under the pointer
  102471. * @returns a Mesh or null if no mesh is under the pointer
  102472. */
  102473. getPointerOverMesh(): Nullable<AbstractMesh>;
  102474. /** @hidden */
  102475. _rebuildGeometries(): void;
  102476. /** @hidden */
  102477. _rebuildTextures(): void;
  102478. private _getByTags;
  102479. /**
  102480. * Get a list of meshes by tags
  102481. * @param tagsQuery defines the tags query to use
  102482. * @param forEach defines a predicate used to filter results
  102483. * @returns an array of Mesh
  102484. */
  102485. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  102486. /**
  102487. * Get a list of cameras by tags
  102488. * @param tagsQuery defines the tags query to use
  102489. * @param forEach defines a predicate used to filter results
  102490. * @returns an array of Camera
  102491. */
  102492. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  102493. /**
  102494. * Get a list of lights by tags
  102495. * @param tagsQuery defines the tags query to use
  102496. * @param forEach defines a predicate used to filter results
  102497. * @returns an array of Light
  102498. */
  102499. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  102500. /**
  102501. * Get a list of materials by tags
  102502. * @param tagsQuery defines the tags query to use
  102503. * @param forEach defines a predicate used to filter results
  102504. * @returns an array of Material
  102505. */
  102506. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  102507. /**
  102508. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102509. * This allowed control for front to back rendering or reversly depending of the special needs.
  102510. *
  102511. * @param renderingGroupId The rendering group id corresponding to its index
  102512. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102513. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102514. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102515. */
  102516. 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;
  102517. /**
  102518. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102519. *
  102520. * @param renderingGroupId The rendering group id corresponding to its index
  102521. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102522. * @param depth Automatically clears depth between groups if true and autoClear is true.
  102523. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  102524. */
  102525. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  102526. /**
  102527. * Gets the current auto clear configuration for one rendering group of the rendering
  102528. * manager.
  102529. * @param index the rendering group index to get the information for
  102530. * @returns The auto clear setup for the requested rendering group
  102531. */
  102532. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  102533. private _blockMaterialDirtyMechanism;
  102534. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  102535. blockMaterialDirtyMechanism: boolean;
  102536. /**
  102537. * Will flag all materials as dirty to trigger new shader compilation
  102538. * @param flag defines the flag used to specify which material part must be marked as dirty
  102539. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  102540. */
  102541. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102542. /** @hidden */
  102543. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  102544. /** @hidden */
  102545. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102546. /** @hidden */
  102547. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  102548. /** @hidden */
  102549. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  102550. /** @hidden */
  102551. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102552. /** @hidden */
  102553. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102554. }
  102555. }
  102556. declare module BABYLON {
  102557. /**
  102558. * Set of assets to keep when moving a scene into an asset container.
  102559. */
  102560. export class KeepAssets extends AbstractScene {
  102561. }
  102562. /**
  102563. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  102564. */
  102565. export class InstantiatedEntries {
  102566. /**
  102567. * List of new root nodes (eg. nodes with no parent)
  102568. */
  102569. rootNodes: TransformNode[];
  102570. /**
  102571. * List of new skeletons
  102572. */
  102573. skeletons: Skeleton[];
  102574. /**
  102575. * List of new animation groups
  102576. */
  102577. animationGroups: AnimationGroup[];
  102578. }
  102579. /**
  102580. * Container with a set of assets that can be added or removed from a scene.
  102581. */
  102582. export class AssetContainer extends AbstractScene {
  102583. /**
  102584. * The scene the AssetContainer belongs to.
  102585. */
  102586. scene: Scene;
  102587. /**
  102588. * Instantiates an AssetContainer.
  102589. * @param scene The scene the AssetContainer belongs to.
  102590. */
  102591. constructor(scene: Scene);
  102592. /**
  102593. * Instantiate or clone all meshes and add the new ones to the scene.
  102594. * Skeletons and animation groups will all be cloned
  102595. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  102596. */
  102597. instantiateModelsToScene(): InstantiatedEntries;
  102598. /**
  102599. * Adds all the assets from the container to the scene.
  102600. */
  102601. addAllToScene(): void;
  102602. /**
  102603. * Removes all the assets in the container from the scene
  102604. */
  102605. removeAllFromScene(): void;
  102606. /**
  102607. * Disposes all the assets in the container
  102608. */
  102609. dispose(): void;
  102610. private _moveAssets;
  102611. /**
  102612. * Removes all the assets contained in the scene and adds them to the container.
  102613. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  102614. */
  102615. moveAllFromScene(keepAssets?: KeepAssets): void;
  102616. /**
  102617. * 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.
  102618. * @returns the root mesh
  102619. */
  102620. createRootMesh(): Mesh;
  102621. }
  102622. }
  102623. declare module BABYLON {
  102624. /**
  102625. * Defines how the parser contract is defined.
  102626. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  102627. */
  102628. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  102629. /**
  102630. * Defines how the individual parser contract is defined.
  102631. * These parser can parse an individual asset
  102632. */
  102633. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  102634. /**
  102635. * Base class of the scene acting as a container for the different elements composing a scene.
  102636. * This class is dynamically extended by the different components of the scene increasing
  102637. * flexibility and reducing coupling
  102638. */
  102639. export abstract class AbstractScene {
  102640. /**
  102641. * Stores the list of available parsers in the application.
  102642. */
  102643. private static _BabylonFileParsers;
  102644. /**
  102645. * Stores the list of available individual parsers in the application.
  102646. */
  102647. private static _IndividualBabylonFileParsers;
  102648. /**
  102649. * Adds a parser in the list of available ones
  102650. * @param name Defines the name of the parser
  102651. * @param parser Defines the parser to add
  102652. */
  102653. static AddParser(name: string, parser: BabylonFileParser): void;
  102654. /**
  102655. * Gets a general parser from the list of avaialble ones
  102656. * @param name Defines the name of the parser
  102657. * @returns the requested parser or null
  102658. */
  102659. static GetParser(name: string): Nullable<BabylonFileParser>;
  102660. /**
  102661. * Adds n individual parser in the list of available ones
  102662. * @param name Defines the name of the parser
  102663. * @param parser Defines the parser to add
  102664. */
  102665. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  102666. /**
  102667. * Gets an individual parser from the list of avaialble ones
  102668. * @param name Defines the name of the parser
  102669. * @returns the requested parser or null
  102670. */
  102671. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  102672. /**
  102673. * Parser json data and populate both a scene and its associated container object
  102674. * @param jsonData Defines the data to parse
  102675. * @param scene Defines the scene to parse the data for
  102676. * @param container Defines the container attached to the parsing sequence
  102677. * @param rootUrl Defines the root url of the data
  102678. */
  102679. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  102680. /**
  102681. * Gets the list of root nodes (ie. nodes with no parent)
  102682. */
  102683. rootNodes: Node[];
  102684. /** All of the cameras added to this scene
  102685. * @see http://doc.babylonjs.com/babylon101/cameras
  102686. */
  102687. cameras: Camera[];
  102688. /**
  102689. * All of the lights added to this scene
  102690. * @see http://doc.babylonjs.com/babylon101/lights
  102691. */
  102692. lights: Light[];
  102693. /**
  102694. * All of the (abstract) meshes added to this scene
  102695. */
  102696. meshes: AbstractMesh[];
  102697. /**
  102698. * The list of skeletons added to the scene
  102699. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102700. */
  102701. skeletons: Skeleton[];
  102702. /**
  102703. * All of the particle systems added to this scene
  102704. * @see http://doc.babylonjs.com/babylon101/particles
  102705. */
  102706. particleSystems: IParticleSystem[];
  102707. /**
  102708. * Gets a list of Animations associated with the scene
  102709. */
  102710. animations: Animation[];
  102711. /**
  102712. * All of the animation groups added to this scene
  102713. * @see http://doc.babylonjs.com/how_to/group
  102714. */
  102715. animationGroups: AnimationGroup[];
  102716. /**
  102717. * All of the multi-materials added to this scene
  102718. * @see http://doc.babylonjs.com/how_to/multi_materials
  102719. */
  102720. multiMaterials: MultiMaterial[];
  102721. /**
  102722. * All of the materials added to this scene
  102723. * In the context of a Scene, it is not supposed to be modified manually.
  102724. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  102725. * Note also that the order of the Material within the array is not significant and might change.
  102726. * @see http://doc.babylonjs.com/babylon101/materials
  102727. */
  102728. materials: Material[];
  102729. /**
  102730. * The list of morph target managers added to the scene
  102731. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  102732. */
  102733. morphTargetManagers: MorphTargetManager[];
  102734. /**
  102735. * The list of geometries used in the scene.
  102736. */
  102737. geometries: Geometry[];
  102738. /**
  102739. * All of the tranform nodes added to this scene
  102740. * In the context of a Scene, it is not supposed to be modified manually.
  102741. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  102742. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  102743. * @see http://doc.babylonjs.com/how_to/transformnode
  102744. */
  102745. transformNodes: TransformNode[];
  102746. /**
  102747. * ActionManagers available on the scene.
  102748. */
  102749. actionManagers: AbstractActionManager[];
  102750. /**
  102751. * Textures to keep.
  102752. */
  102753. textures: BaseTexture[];
  102754. /**
  102755. * Environment texture for the scene
  102756. */
  102757. environmentTexture: Nullable<BaseTexture>;
  102758. }
  102759. }
  102760. declare module BABYLON {
  102761. /**
  102762. * Interface used to define options for Sound class
  102763. */
  102764. export interface ISoundOptions {
  102765. /**
  102766. * Does the sound autoplay once loaded.
  102767. */
  102768. autoplay?: boolean;
  102769. /**
  102770. * Does the sound loop after it finishes playing once.
  102771. */
  102772. loop?: boolean;
  102773. /**
  102774. * Sound's volume
  102775. */
  102776. volume?: number;
  102777. /**
  102778. * Is it a spatial sound?
  102779. */
  102780. spatialSound?: boolean;
  102781. /**
  102782. * Maximum distance to hear that sound
  102783. */
  102784. maxDistance?: number;
  102785. /**
  102786. * Uses user defined attenuation function
  102787. */
  102788. useCustomAttenuation?: boolean;
  102789. /**
  102790. * Define the roll off factor of spatial sounds.
  102791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102792. */
  102793. rolloffFactor?: number;
  102794. /**
  102795. * Define the reference distance the sound should be heard perfectly.
  102796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102797. */
  102798. refDistance?: number;
  102799. /**
  102800. * Define the distance attenuation model the sound will follow.
  102801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102802. */
  102803. distanceModel?: string;
  102804. /**
  102805. * Defines the playback speed (1 by default)
  102806. */
  102807. playbackRate?: number;
  102808. /**
  102809. * Defines if the sound is from a streaming source
  102810. */
  102811. streaming?: boolean;
  102812. /**
  102813. * Defines an optional length (in seconds) inside the sound file
  102814. */
  102815. length?: number;
  102816. /**
  102817. * Defines an optional offset (in seconds) inside the sound file
  102818. */
  102819. offset?: number;
  102820. /**
  102821. * If true, URLs will not be required to state the audio file codec to use.
  102822. */
  102823. skipCodecCheck?: boolean;
  102824. }
  102825. /**
  102826. * Defines a sound that can be played in the application.
  102827. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  102828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102829. */
  102830. export class Sound {
  102831. /**
  102832. * The name of the sound in the scene.
  102833. */
  102834. name: string;
  102835. /**
  102836. * Does the sound autoplay once loaded.
  102837. */
  102838. autoplay: boolean;
  102839. /**
  102840. * Does the sound loop after it finishes playing once.
  102841. */
  102842. loop: boolean;
  102843. /**
  102844. * Does the sound use a custom attenuation curve to simulate the falloff
  102845. * happening when the source gets further away from the camera.
  102846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102847. */
  102848. useCustomAttenuation: boolean;
  102849. /**
  102850. * The sound track id this sound belongs to.
  102851. */
  102852. soundTrackId: number;
  102853. /**
  102854. * Is this sound currently played.
  102855. */
  102856. isPlaying: boolean;
  102857. /**
  102858. * Is this sound currently paused.
  102859. */
  102860. isPaused: boolean;
  102861. /**
  102862. * Does this sound enables spatial sound.
  102863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102864. */
  102865. spatialSound: boolean;
  102866. /**
  102867. * Define the reference distance the sound should be heard perfectly.
  102868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102869. */
  102870. refDistance: number;
  102871. /**
  102872. * Define the roll off factor of spatial sounds.
  102873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102874. */
  102875. rolloffFactor: number;
  102876. /**
  102877. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  102878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102879. */
  102880. maxDistance: number;
  102881. /**
  102882. * Define the distance attenuation model the sound will follow.
  102883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102884. */
  102885. distanceModel: string;
  102886. /**
  102887. * @hidden
  102888. * Back Compat
  102889. **/
  102890. onended: () => any;
  102891. /**
  102892. * Observable event when the current playing sound finishes.
  102893. */
  102894. onEndedObservable: Observable<Sound>;
  102895. private _panningModel;
  102896. private _playbackRate;
  102897. private _streaming;
  102898. private _startTime;
  102899. private _startOffset;
  102900. private _position;
  102901. /** @hidden */
  102902. _positionInEmitterSpace: boolean;
  102903. private _localDirection;
  102904. private _volume;
  102905. private _isReadyToPlay;
  102906. private _isDirectional;
  102907. private _readyToPlayCallback;
  102908. private _audioBuffer;
  102909. private _soundSource;
  102910. private _streamingSource;
  102911. private _soundPanner;
  102912. private _soundGain;
  102913. private _inputAudioNode;
  102914. private _outputAudioNode;
  102915. private _coneInnerAngle;
  102916. private _coneOuterAngle;
  102917. private _coneOuterGain;
  102918. private _scene;
  102919. private _connectedTransformNode;
  102920. private _customAttenuationFunction;
  102921. private _registerFunc;
  102922. private _isOutputConnected;
  102923. private _htmlAudioElement;
  102924. private _urlType;
  102925. private _length?;
  102926. private _offset?;
  102927. /** @hidden */
  102928. static _SceneComponentInitialization: (scene: Scene) => void;
  102929. /**
  102930. * Create a sound and attach it to a scene
  102931. * @param name Name of your sound
  102932. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  102933. * @param scene defines the scene the sound belongs to
  102934. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  102935. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  102936. */
  102937. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  102938. /**
  102939. * Release the sound and its associated resources
  102940. */
  102941. dispose(): void;
  102942. /**
  102943. * Gets if the sounds is ready to be played or not.
  102944. * @returns true if ready, otherwise false
  102945. */
  102946. isReady(): boolean;
  102947. private _soundLoaded;
  102948. /**
  102949. * Sets the data of the sound from an audiobuffer
  102950. * @param audioBuffer The audioBuffer containing the data
  102951. */
  102952. setAudioBuffer(audioBuffer: AudioBuffer): void;
  102953. /**
  102954. * Updates the current sounds options such as maxdistance, loop...
  102955. * @param options A JSON object containing values named as the object properties
  102956. */
  102957. updateOptions(options: ISoundOptions): void;
  102958. private _createSpatialParameters;
  102959. private _updateSpatialParameters;
  102960. /**
  102961. * Switch the panning model to HRTF:
  102962. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102964. */
  102965. switchPanningModelToHRTF(): void;
  102966. /**
  102967. * Switch the panning model to Equal Power:
  102968. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102970. */
  102971. switchPanningModelToEqualPower(): void;
  102972. private _switchPanningModel;
  102973. /**
  102974. * Connect this sound to a sound track audio node like gain...
  102975. * @param soundTrackAudioNode the sound track audio node to connect to
  102976. */
  102977. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102978. /**
  102979. * Transform this sound into a directional source
  102980. * @param coneInnerAngle Size of the inner cone in degree
  102981. * @param coneOuterAngle Size of the outer cone in degree
  102982. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102983. */
  102984. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102985. /**
  102986. * Gets or sets the inner angle for the directional cone.
  102987. */
  102988. /**
  102989. * Gets or sets the inner angle for the directional cone.
  102990. */
  102991. directionalConeInnerAngle: number;
  102992. /**
  102993. * Gets or sets the outer angle for the directional cone.
  102994. */
  102995. /**
  102996. * Gets or sets the outer angle for the directional cone.
  102997. */
  102998. directionalConeOuterAngle: number;
  102999. /**
  103000. * Sets the position of the emitter if spatial sound is enabled
  103001. * @param newPosition Defines the new posisiton
  103002. */
  103003. setPosition(newPosition: Vector3): void;
  103004. /**
  103005. * Sets the local direction of the emitter if spatial sound is enabled
  103006. * @param newLocalDirection Defines the new local direction
  103007. */
  103008. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  103009. private _updateDirection;
  103010. /** @hidden */
  103011. updateDistanceFromListener(): void;
  103012. /**
  103013. * Sets a new custom attenuation function for the sound.
  103014. * @param callback Defines the function used for the attenuation
  103015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103016. */
  103017. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  103018. /**
  103019. * Play the sound
  103020. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  103021. * @param offset (optional) Start the sound at a specific time in seconds
  103022. * @param length (optional) Sound duration (in seconds)
  103023. */
  103024. play(time?: number, offset?: number, length?: number): void;
  103025. private _onended;
  103026. /**
  103027. * Stop the sound
  103028. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  103029. */
  103030. stop(time?: number): void;
  103031. /**
  103032. * Put the sound in pause
  103033. */
  103034. pause(): void;
  103035. /**
  103036. * Sets a dedicated volume for this sounds
  103037. * @param newVolume Define the new volume of the sound
  103038. * @param time Define time for gradual change to new volume
  103039. */
  103040. setVolume(newVolume: number, time?: number): void;
  103041. /**
  103042. * Set the sound play back rate
  103043. * @param newPlaybackRate Define the playback rate the sound should be played at
  103044. */
  103045. setPlaybackRate(newPlaybackRate: number): void;
  103046. /**
  103047. * Gets the volume of the sound.
  103048. * @returns the volume of the sound
  103049. */
  103050. getVolume(): number;
  103051. /**
  103052. * Attach the sound to a dedicated mesh
  103053. * @param transformNode The transform node to connect the sound with
  103054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103055. */
  103056. attachToMesh(transformNode: TransformNode): void;
  103057. /**
  103058. * Detach the sound from the previously attached mesh
  103059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  103060. */
  103061. detachFromMesh(): void;
  103062. private _onRegisterAfterWorldMatrixUpdate;
  103063. /**
  103064. * Clone the current sound in the scene.
  103065. * @returns the new sound clone
  103066. */
  103067. clone(): Nullable<Sound>;
  103068. /**
  103069. * Gets the current underlying audio buffer containing the data
  103070. * @returns the audio buffer
  103071. */
  103072. getAudioBuffer(): Nullable<AudioBuffer>;
  103073. /**
  103074. * Serializes the Sound in a JSON representation
  103075. * @returns the JSON representation of the sound
  103076. */
  103077. serialize(): any;
  103078. /**
  103079. * Parse a JSON representation of a sound to innstantiate in a given scene
  103080. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  103081. * @param scene Define the scene the new parsed sound should be created in
  103082. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  103083. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  103084. * @returns the newly parsed sound
  103085. */
  103086. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  103087. }
  103088. }
  103089. declare module BABYLON {
  103090. /**
  103091. * This defines an action helpful to play a defined sound on a triggered action.
  103092. */
  103093. export class PlaySoundAction extends Action {
  103094. private _sound;
  103095. /**
  103096. * Instantiate the action
  103097. * @param triggerOptions defines the trigger options
  103098. * @param sound defines the sound to play
  103099. * @param condition defines the trigger related conditions
  103100. */
  103101. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103102. /** @hidden */
  103103. _prepare(): void;
  103104. /**
  103105. * Execute the action and play the sound.
  103106. */
  103107. execute(): void;
  103108. /**
  103109. * Serializes the actions and its related information.
  103110. * @param parent defines the object to serialize in
  103111. * @returns the serialized object
  103112. */
  103113. serialize(parent: any): any;
  103114. }
  103115. /**
  103116. * This defines an action helpful to stop a defined sound on a triggered action.
  103117. */
  103118. export class StopSoundAction extends Action {
  103119. private _sound;
  103120. /**
  103121. * Instantiate the action
  103122. * @param triggerOptions defines the trigger options
  103123. * @param sound defines the sound to stop
  103124. * @param condition defines the trigger related conditions
  103125. */
  103126. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  103127. /** @hidden */
  103128. _prepare(): void;
  103129. /**
  103130. * Execute the action and stop the sound.
  103131. */
  103132. execute(): void;
  103133. /**
  103134. * Serializes the actions and its related information.
  103135. * @param parent defines the object to serialize in
  103136. * @returns the serialized object
  103137. */
  103138. serialize(parent: any): any;
  103139. }
  103140. }
  103141. declare module BABYLON {
  103142. /**
  103143. * This defines an action responsible to change the value of a property
  103144. * by interpolating between its current value and the newly set one once triggered.
  103145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103146. */
  103147. export class InterpolateValueAction extends Action {
  103148. /**
  103149. * Defines the path of the property where the value should be interpolated
  103150. */
  103151. propertyPath: string;
  103152. /**
  103153. * Defines the target value at the end of the interpolation.
  103154. */
  103155. value: any;
  103156. /**
  103157. * Defines the time it will take for the property to interpolate to the value.
  103158. */
  103159. duration: number;
  103160. /**
  103161. * Defines if the other scene animations should be stopped when the action has been triggered
  103162. */
  103163. stopOtherAnimations?: boolean;
  103164. /**
  103165. * Defines a callback raised once the interpolation animation has been done.
  103166. */
  103167. onInterpolationDone?: () => void;
  103168. /**
  103169. * Observable triggered once the interpolation animation has been done.
  103170. */
  103171. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  103172. private _target;
  103173. private _effectiveTarget;
  103174. private _property;
  103175. /**
  103176. * Instantiate the action
  103177. * @param triggerOptions defines the trigger options
  103178. * @param target defines the object containing the value to interpolate
  103179. * @param propertyPath defines the path to the property in the target object
  103180. * @param value defines the target value at the end of the interpolation
  103181. * @param duration deines the time it will take for the property to interpolate to the value.
  103182. * @param condition defines the trigger related conditions
  103183. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  103184. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  103185. */
  103186. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  103187. /** @hidden */
  103188. _prepare(): void;
  103189. /**
  103190. * Execute the action starts the value interpolation.
  103191. */
  103192. execute(): void;
  103193. /**
  103194. * Serializes the actions and its related information.
  103195. * @param parent defines the object to serialize in
  103196. * @returns the serialized object
  103197. */
  103198. serialize(parent: any): any;
  103199. }
  103200. }
  103201. declare module BABYLON {
  103202. /**
  103203. * Options allowed during the creation of a sound track.
  103204. */
  103205. export interface ISoundTrackOptions {
  103206. /**
  103207. * The volume the sound track should take during creation
  103208. */
  103209. volume?: number;
  103210. /**
  103211. * Define if the sound track is the main sound track of the scene
  103212. */
  103213. mainTrack?: boolean;
  103214. }
  103215. /**
  103216. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  103217. * It will be also used in a future release to apply effects on a specific track.
  103218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103219. */
  103220. export class SoundTrack {
  103221. /**
  103222. * The unique identifier of the sound track in the scene.
  103223. */
  103224. id: number;
  103225. /**
  103226. * The list of sounds included in the sound track.
  103227. */
  103228. soundCollection: Array<Sound>;
  103229. private _outputAudioNode;
  103230. private _scene;
  103231. private _isMainTrack;
  103232. private _connectedAnalyser;
  103233. private _options;
  103234. private _isInitialized;
  103235. /**
  103236. * Creates a new sound track.
  103237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  103238. * @param scene Define the scene the sound track belongs to
  103239. * @param options
  103240. */
  103241. constructor(scene: Scene, options?: ISoundTrackOptions);
  103242. private _initializeSoundTrackAudioGraph;
  103243. /**
  103244. * Release the sound track and its associated resources
  103245. */
  103246. dispose(): void;
  103247. /**
  103248. * Adds a sound to this sound track
  103249. * @param sound define the cound to add
  103250. * @ignoreNaming
  103251. */
  103252. AddSound(sound: Sound): void;
  103253. /**
  103254. * Removes a sound to this sound track
  103255. * @param sound define the cound to remove
  103256. * @ignoreNaming
  103257. */
  103258. RemoveSound(sound: Sound): void;
  103259. /**
  103260. * Set a global volume for the full sound track.
  103261. * @param newVolume Define the new volume of the sound track
  103262. */
  103263. setVolume(newVolume: number): void;
  103264. /**
  103265. * Switch the panning model to HRTF:
  103266. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  103267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103268. */
  103269. switchPanningModelToHRTF(): void;
  103270. /**
  103271. * Switch the panning model to Equal Power:
  103272. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  103273. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103274. */
  103275. switchPanningModelToEqualPower(): void;
  103276. /**
  103277. * Connect the sound track to an audio analyser allowing some amazing
  103278. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103280. * @param analyser The analyser to connect to the engine
  103281. */
  103282. connectToAnalyser(analyser: Analyser): void;
  103283. }
  103284. }
  103285. declare module BABYLON {
  103286. interface AbstractScene {
  103287. /**
  103288. * The list of sounds used in the scene.
  103289. */
  103290. sounds: Nullable<Array<Sound>>;
  103291. }
  103292. interface Scene {
  103293. /**
  103294. * @hidden
  103295. * Backing field
  103296. */
  103297. _mainSoundTrack: SoundTrack;
  103298. /**
  103299. * The main sound track played by the scene.
  103300. * It cotains your primary collection of sounds.
  103301. */
  103302. mainSoundTrack: SoundTrack;
  103303. /**
  103304. * The list of sound tracks added to the scene
  103305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103306. */
  103307. soundTracks: Nullable<Array<SoundTrack>>;
  103308. /**
  103309. * Gets a sound using a given name
  103310. * @param name defines the name to search for
  103311. * @return the found sound or null if not found at all.
  103312. */
  103313. getSoundByName(name: string): Nullable<Sound>;
  103314. /**
  103315. * Gets or sets if audio support is enabled
  103316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103317. */
  103318. audioEnabled: boolean;
  103319. /**
  103320. * Gets or sets if audio will be output to headphones
  103321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103322. */
  103323. headphone: boolean;
  103324. /**
  103325. * Gets or sets custom audio listener position provider
  103326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103327. */
  103328. audioListenerPositionProvider: Nullable<() => Vector3>;
  103329. /**
  103330. * Gets or sets a refresh rate when using 3D audio positioning
  103331. */
  103332. audioPositioningRefreshRate: number;
  103333. }
  103334. /**
  103335. * Defines the sound scene component responsible to manage any sounds
  103336. * in a given scene.
  103337. */
  103338. export class AudioSceneComponent implements ISceneSerializableComponent {
  103339. /**
  103340. * The component name helpfull to identify the component in the list of scene components.
  103341. */
  103342. readonly name: string;
  103343. /**
  103344. * The scene the component belongs to.
  103345. */
  103346. scene: Scene;
  103347. private _audioEnabled;
  103348. /**
  103349. * Gets whether audio is enabled or not.
  103350. * Please use related enable/disable method to switch state.
  103351. */
  103352. readonly audioEnabled: boolean;
  103353. private _headphone;
  103354. /**
  103355. * Gets whether audio is outputing to headphone or not.
  103356. * Please use the according Switch methods to change output.
  103357. */
  103358. readonly headphone: boolean;
  103359. /**
  103360. * Gets or sets a refresh rate when using 3D audio positioning
  103361. */
  103362. audioPositioningRefreshRate: number;
  103363. private _audioListenerPositionProvider;
  103364. /**
  103365. * Gets the current audio listener position provider
  103366. */
  103367. /**
  103368. * Sets a custom listener position for all sounds in the scene
  103369. * By default, this is the position of the first active camera
  103370. */
  103371. audioListenerPositionProvider: Nullable<() => Vector3>;
  103372. /**
  103373. * Creates a new instance of the component for the given scene
  103374. * @param scene Defines the scene to register the component in
  103375. */
  103376. constructor(scene: Scene);
  103377. /**
  103378. * Registers the component in a given scene
  103379. */
  103380. register(): void;
  103381. /**
  103382. * Rebuilds the elements related to this component in case of
  103383. * context lost for instance.
  103384. */
  103385. rebuild(): void;
  103386. /**
  103387. * Serializes the component data to the specified json object
  103388. * @param serializationObject The object to serialize to
  103389. */
  103390. serialize(serializationObject: any): void;
  103391. /**
  103392. * Adds all the elements from the container to the scene
  103393. * @param container the container holding the elements
  103394. */
  103395. addFromContainer(container: AbstractScene): void;
  103396. /**
  103397. * Removes all the elements in the container from the scene
  103398. * @param container contains the elements to remove
  103399. * @param dispose if the removed element should be disposed (default: false)
  103400. */
  103401. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  103402. /**
  103403. * Disposes the component and the associated ressources.
  103404. */
  103405. dispose(): void;
  103406. /**
  103407. * Disables audio in the associated scene.
  103408. */
  103409. disableAudio(): void;
  103410. /**
  103411. * Enables audio in the associated scene.
  103412. */
  103413. enableAudio(): void;
  103414. /**
  103415. * Switch audio to headphone output.
  103416. */
  103417. switchAudioModeForHeadphones(): void;
  103418. /**
  103419. * Switch audio to normal speakers.
  103420. */
  103421. switchAudioModeForNormalSpeakers(): void;
  103422. private _cachedCameraDirection;
  103423. private _cachedCameraPosition;
  103424. private _lastCheck;
  103425. private _afterRender;
  103426. }
  103427. }
  103428. declare module BABYLON {
  103429. /**
  103430. * Wraps one or more Sound objects and selects one with random weight for playback.
  103431. */
  103432. export class WeightedSound {
  103433. /** When true a Sound will be selected and played when the current playing Sound completes. */
  103434. loop: boolean;
  103435. private _coneInnerAngle;
  103436. private _coneOuterAngle;
  103437. private _volume;
  103438. /** A Sound is currently playing. */
  103439. isPlaying: boolean;
  103440. /** A Sound is currently paused. */
  103441. isPaused: boolean;
  103442. private _sounds;
  103443. private _weights;
  103444. private _currentIndex?;
  103445. /**
  103446. * Creates a new WeightedSound from the list of sounds given.
  103447. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  103448. * @param sounds Array of Sounds that will be selected from.
  103449. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  103450. */
  103451. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  103452. /**
  103453. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  103454. */
  103455. /**
  103456. * The size of cone in degress for a directional sound in which there will be no attenuation.
  103457. */
  103458. directionalConeInnerAngle: number;
  103459. /**
  103460. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103461. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103462. */
  103463. /**
  103464. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  103465. * Listener angles between innerAngle and outerAngle will falloff linearly.
  103466. */
  103467. directionalConeOuterAngle: number;
  103468. /**
  103469. * Playback volume.
  103470. */
  103471. /**
  103472. * Playback volume.
  103473. */
  103474. volume: number;
  103475. private _onended;
  103476. /**
  103477. * Suspend playback
  103478. */
  103479. pause(): void;
  103480. /**
  103481. * Stop playback
  103482. */
  103483. stop(): void;
  103484. /**
  103485. * Start playback.
  103486. * @param startOffset Position the clip head at a specific time in seconds.
  103487. */
  103488. play(startOffset?: number): void;
  103489. }
  103490. }
  103491. declare module BABYLON {
  103492. /**
  103493. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  103494. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103495. */
  103496. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  103497. /**
  103498. * Gets the name of the behavior.
  103499. */
  103500. readonly name: string;
  103501. /**
  103502. * The easing function used by animations
  103503. */
  103504. static EasingFunction: BackEase;
  103505. /**
  103506. * The easing mode used by animations
  103507. */
  103508. static EasingMode: number;
  103509. /**
  103510. * The duration of the animation, in milliseconds
  103511. */
  103512. transitionDuration: number;
  103513. /**
  103514. * Length of the distance animated by the transition when lower radius is reached
  103515. */
  103516. lowerRadiusTransitionRange: number;
  103517. /**
  103518. * Length of the distance animated by the transition when upper radius is reached
  103519. */
  103520. upperRadiusTransitionRange: number;
  103521. private _autoTransitionRange;
  103522. /**
  103523. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103524. */
  103525. /**
  103526. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  103527. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  103528. */
  103529. autoTransitionRange: boolean;
  103530. private _attachedCamera;
  103531. private _onAfterCheckInputsObserver;
  103532. private _onMeshTargetChangedObserver;
  103533. /**
  103534. * Initializes the behavior.
  103535. */
  103536. init(): void;
  103537. /**
  103538. * Attaches the behavior to its arc rotate camera.
  103539. * @param camera Defines the camera to attach the behavior to
  103540. */
  103541. attach(camera: ArcRotateCamera): void;
  103542. /**
  103543. * Detaches the behavior from its current arc rotate camera.
  103544. */
  103545. detach(): void;
  103546. private _radiusIsAnimating;
  103547. private _radiusBounceTransition;
  103548. private _animatables;
  103549. private _cachedWheelPrecision;
  103550. /**
  103551. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  103552. * @param radiusLimit The limit to check against.
  103553. * @return Bool to indicate if at limit.
  103554. */
  103555. private _isRadiusAtLimit;
  103556. /**
  103557. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  103558. * @param radiusDelta The delta by which to animate to. Can be negative.
  103559. */
  103560. private _applyBoundRadiusAnimation;
  103561. /**
  103562. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  103563. */
  103564. protected _clearAnimationLocks(): void;
  103565. /**
  103566. * Stops and removes all animations that have been applied to the camera
  103567. */
  103568. stopAllAnimations(): void;
  103569. }
  103570. }
  103571. declare module BABYLON {
  103572. /**
  103573. * 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.
  103574. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103575. */
  103576. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  103577. /**
  103578. * Gets the name of the behavior.
  103579. */
  103580. readonly name: string;
  103581. private _mode;
  103582. private _radiusScale;
  103583. private _positionScale;
  103584. private _defaultElevation;
  103585. private _elevationReturnTime;
  103586. private _elevationReturnWaitTime;
  103587. private _zoomStopsAnimation;
  103588. private _framingTime;
  103589. /**
  103590. * The easing function used by animations
  103591. */
  103592. static EasingFunction: ExponentialEase;
  103593. /**
  103594. * The easing mode used by animations
  103595. */
  103596. static EasingMode: number;
  103597. /**
  103598. * Sets the current mode used by the behavior
  103599. */
  103600. /**
  103601. * Gets current mode used by the behavior.
  103602. */
  103603. mode: number;
  103604. /**
  103605. * Sets the scale applied to the radius (1 by default)
  103606. */
  103607. /**
  103608. * Gets the scale applied to the radius
  103609. */
  103610. radiusScale: number;
  103611. /**
  103612. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103613. */
  103614. /**
  103615. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  103616. */
  103617. positionScale: number;
  103618. /**
  103619. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103620. * behaviour is triggered, in radians.
  103621. */
  103622. /**
  103623. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  103624. * behaviour is triggered, in radians.
  103625. */
  103626. defaultElevation: number;
  103627. /**
  103628. * Sets the time (in milliseconds) taken to return to the default beta position.
  103629. * Negative value indicates camera should not return to default.
  103630. */
  103631. /**
  103632. * Gets the time (in milliseconds) taken to return to the default beta position.
  103633. * Negative value indicates camera should not return to default.
  103634. */
  103635. elevationReturnTime: number;
  103636. /**
  103637. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103638. */
  103639. /**
  103640. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  103641. */
  103642. elevationReturnWaitTime: number;
  103643. /**
  103644. * Sets the flag that indicates if user zooming should stop animation.
  103645. */
  103646. /**
  103647. * Gets the flag that indicates if user zooming should stop animation.
  103648. */
  103649. zoomStopsAnimation: boolean;
  103650. /**
  103651. * Sets the transition time when framing the mesh, in milliseconds
  103652. */
  103653. /**
  103654. * Gets the transition time when framing the mesh, in milliseconds
  103655. */
  103656. framingTime: number;
  103657. /**
  103658. * Define if the behavior should automatically change the configured
  103659. * camera limits and sensibilities.
  103660. */
  103661. autoCorrectCameraLimitsAndSensibility: boolean;
  103662. private _onPrePointerObservableObserver;
  103663. private _onAfterCheckInputsObserver;
  103664. private _onMeshTargetChangedObserver;
  103665. private _attachedCamera;
  103666. private _isPointerDown;
  103667. private _lastInteractionTime;
  103668. /**
  103669. * Initializes the behavior.
  103670. */
  103671. init(): void;
  103672. /**
  103673. * Attaches the behavior to its arc rotate camera.
  103674. * @param camera Defines the camera to attach the behavior to
  103675. */
  103676. attach(camera: ArcRotateCamera): void;
  103677. /**
  103678. * Detaches the behavior from its current arc rotate camera.
  103679. */
  103680. detach(): void;
  103681. private _animatables;
  103682. private _betaIsAnimating;
  103683. private _betaTransition;
  103684. private _radiusTransition;
  103685. private _vectorTransition;
  103686. /**
  103687. * Targets the given mesh and updates zoom level accordingly.
  103688. * @param mesh The mesh to target.
  103689. * @param radius Optional. If a cached radius position already exists, overrides default.
  103690. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103691. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103692. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103693. */
  103694. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103695. /**
  103696. * Targets the given mesh with its children and updates zoom level accordingly.
  103697. * @param mesh The mesh to target.
  103698. * @param radius Optional. If a cached radius position already exists, overrides default.
  103699. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103700. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103701. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103702. */
  103703. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103704. /**
  103705. * Targets the given meshes with their children and updates zoom level accordingly.
  103706. * @param meshes The mesh to target.
  103707. * @param radius Optional. If a cached radius position already exists, overrides default.
  103708. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  103709. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103710. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103711. */
  103712. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103713. /**
  103714. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  103715. * @param minimumWorld Determines the smaller position of the bounding box extend
  103716. * @param maximumWorld Determines the bigger position of the bounding box extend
  103717. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  103718. * @param onAnimationEnd Callback triggered at the end of the framing animation
  103719. */
  103720. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  103721. /**
  103722. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  103723. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  103724. * frustum width.
  103725. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  103726. * to fully enclose the mesh in the viewing frustum.
  103727. */
  103728. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  103729. /**
  103730. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  103731. * is automatically returned to its default position (expected to be above ground plane).
  103732. */
  103733. private _maintainCameraAboveGround;
  103734. /**
  103735. * Returns the frustum slope based on the canvas ratio and camera FOV
  103736. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  103737. */
  103738. private _getFrustumSlope;
  103739. /**
  103740. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  103741. */
  103742. private _clearAnimationLocks;
  103743. /**
  103744. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103745. */
  103746. private _applyUserInteraction;
  103747. /**
  103748. * Stops and removes all animations that have been applied to the camera
  103749. */
  103750. stopAllAnimations(): void;
  103751. /**
  103752. * Gets a value indicating if the user is moving the camera
  103753. */
  103754. readonly isUserIsMoving: boolean;
  103755. /**
  103756. * The camera can move all the way towards the mesh.
  103757. */
  103758. static IgnoreBoundsSizeMode: number;
  103759. /**
  103760. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  103761. */
  103762. static FitFrustumSidesMode: number;
  103763. }
  103764. }
  103765. declare module BABYLON {
  103766. /**
  103767. * Base class for Camera Pointer Inputs.
  103768. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  103769. * for example usage.
  103770. */
  103771. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  103772. /**
  103773. * Defines the camera the input is attached to.
  103774. */
  103775. abstract camera: Camera;
  103776. /**
  103777. * Whether keyboard modifier keys are pressed at time of last mouse event.
  103778. */
  103779. protected _altKey: boolean;
  103780. protected _ctrlKey: boolean;
  103781. protected _metaKey: boolean;
  103782. protected _shiftKey: boolean;
  103783. /**
  103784. * Which mouse buttons were pressed at time of last mouse event.
  103785. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  103786. */
  103787. protected _buttonsPressed: number;
  103788. /**
  103789. * Defines the buttons associated with the input to handle camera move.
  103790. */
  103791. buttons: number[];
  103792. /**
  103793. * Attach the input controls to a specific dom element to get the input from.
  103794. * @param element Defines the element the controls should be listened from
  103795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103796. */
  103797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103798. /**
  103799. * Detach the current controls from the specified dom element.
  103800. * @param element Defines the element to stop listening the inputs from
  103801. */
  103802. detachControl(element: Nullable<HTMLElement>): void;
  103803. /**
  103804. * Gets the class name of the current input.
  103805. * @returns the class name
  103806. */
  103807. getClassName(): string;
  103808. /**
  103809. * Get the friendly name associated with the input class.
  103810. * @returns the input friendly name
  103811. */
  103812. getSimpleName(): string;
  103813. /**
  103814. * Called on pointer POINTERDOUBLETAP event.
  103815. * Override this method to provide functionality on POINTERDOUBLETAP event.
  103816. */
  103817. protected onDoubleTap(type: string): void;
  103818. /**
  103819. * Called on pointer POINTERMOVE event if only a single touch is active.
  103820. * Override this method to provide functionality.
  103821. */
  103822. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103823. /**
  103824. * Called on pointer POINTERMOVE event if multiple touches are active.
  103825. * Override this method to provide functionality.
  103826. */
  103827. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103828. /**
  103829. * Called on JS contextmenu event.
  103830. * Override this method to provide functionality.
  103831. */
  103832. protected onContextMenu(evt: PointerEvent): void;
  103833. /**
  103834. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103835. * press.
  103836. * Override this method to provide functionality.
  103837. */
  103838. protected onButtonDown(evt: PointerEvent): void;
  103839. /**
  103840. * Called each time a new POINTERUP event occurs. Ie, for each button
  103841. * release.
  103842. * Override this method to provide functionality.
  103843. */
  103844. protected onButtonUp(evt: PointerEvent): void;
  103845. /**
  103846. * Called when window becomes inactive.
  103847. * Override this method to provide functionality.
  103848. */
  103849. protected onLostFocus(): void;
  103850. private _pointerInput;
  103851. private _observer;
  103852. private _onLostFocus;
  103853. private pointA;
  103854. private pointB;
  103855. }
  103856. }
  103857. declare module BABYLON {
  103858. /**
  103859. * Manage the pointers inputs to control an arc rotate camera.
  103860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103861. */
  103862. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  103863. /**
  103864. * Defines the camera the input is attached to.
  103865. */
  103866. camera: ArcRotateCamera;
  103867. /**
  103868. * Gets the class name of the current input.
  103869. * @returns the class name
  103870. */
  103871. getClassName(): string;
  103872. /**
  103873. * Defines the buttons associated with the input to handle camera move.
  103874. */
  103875. buttons: number[];
  103876. /**
  103877. * Defines the pointer angular sensibility along the X axis or how fast is
  103878. * the camera rotating.
  103879. */
  103880. angularSensibilityX: number;
  103881. /**
  103882. * Defines the pointer angular sensibility along the Y axis or how fast is
  103883. * the camera rotating.
  103884. */
  103885. angularSensibilityY: number;
  103886. /**
  103887. * Defines the pointer pinch precision or how fast is the camera zooming.
  103888. */
  103889. pinchPrecision: number;
  103890. /**
  103891. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103892. * from 0.
  103893. * It defines the percentage of current camera.radius to use as delta when
  103894. * pinch zoom is used.
  103895. */
  103896. pinchDeltaPercentage: number;
  103897. /**
  103898. * Defines the pointer panning sensibility or how fast is the camera moving.
  103899. */
  103900. panningSensibility: number;
  103901. /**
  103902. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  103903. */
  103904. multiTouchPanning: boolean;
  103905. /**
  103906. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  103907. * zoom (pinch) through multitouch.
  103908. */
  103909. multiTouchPanAndZoom: boolean;
  103910. /**
  103911. * Revers pinch action direction.
  103912. */
  103913. pinchInwards: boolean;
  103914. private _isPanClick;
  103915. private _twoFingerActivityCount;
  103916. private _isPinching;
  103917. /**
  103918. * Called on pointer POINTERMOVE event if only a single touch is active.
  103919. */
  103920. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103921. /**
  103922. * Called on pointer POINTERDOUBLETAP event.
  103923. */
  103924. protected onDoubleTap(type: string): void;
  103925. /**
  103926. * Called on pointer POINTERMOVE event if multiple touches are active.
  103927. */
  103928. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103929. /**
  103930. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  103931. * press.
  103932. */
  103933. protected onButtonDown(evt: PointerEvent): void;
  103934. /**
  103935. * Called each time a new POINTERUP event occurs. Ie, for each button
  103936. * release.
  103937. */
  103938. protected onButtonUp(evt: PointerEvent): void;
  103939. /**
  103940. * Called when window becomes inactive.
  103941. */
  103942. protected onLostFocus(): void;
  103943. }
  103944. }
  103945. declare module BABYLON {
  103946. /**
  103947. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  103948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103949. */
  103950. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  103951. /**
  103952. * Defines the camera the input is attached to.
  103953. */
  103954. camera: ArcRotateCamera;
  103955. /**
  103956. * Defines the list of key codes associated with the up action (increase alpha)
  103957. */
  103958. keysUp: number[];
  103959. /**
  103960. * Defines the list of key codes associated with the down action (decrease alpha)
  103961. */
  103962. keysDown: number[];
  103963. /**
  103964. * Defines the list of key codes associated with the left action (increase beta)
  103965. */
  103966. keysLeft: number[];
  103967. /**
  103968. * Defines the list of key codes associated with the right action (decrease beta)
  103969. */
  103970. keysRight: number[];
  103971. /**
  103972. * Defines the list of key codes associated with the reset action.
  103973. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103974. */
  103975. keysReset: number[];
  103976. /**
  103977. * Defines the panning sensibility of the inputs.
  103978. * (How fast is the camera paning)
  103979. */
  103980. panningSensibility: number;
  103981. /**
  103982. * Defines the zooming sensibility of the inputs.
  103983. * (How fast is the camera zooming)
  103984. */
  103985. zoomingSensibility: number;
  103986. /**
  103987. * Defines wether maintaining the alt key down switch the movement mode from
  103988. * orientation to zoom.
  103989. */
  103990. useAltToZoom: boolean;
  103991. /**
  103992. * Rotation speed of the camera
  103993. */
  103994. angularSpeed: number;
  103995. private _keys;
  103996. private _ctrlPressed;
  103997. private _altPressed;
  103998. private _onCanvasBlurObserver;
  103999. private _onKeyboardObserver;
  104000. private _engine;
  104001. private _scene;
  104002. /**
  104003. * Attach the input controls to a specific dom element to get the input from.
  104004. * @param element Defines the element the controls should be listened from
  104005. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104006. */
  104007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104008. /**
  104009. * Detach the current controls from the specified dom element.
  104010. * @param element Defines the element to stop listening the inputs from
  104011. */
  104012. detachControl(element: Nullable<HTMLElement>): void;
  104013. /**
  104014. * Update the current camera state depending on the inputs that have been used this frame.
  104015. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104016. */
  104017. checkInputs(): void;
  104018. /**
  104019. * Gets the class name of the current intput.
  104020. * @returns the class name
  104021. */
  104022. getClassName(): string;
  104023. /**
  104024. * Get the friendly name associated with the input class.
  104025. * @returns the input friendly name
  104026. */
  104027. getSimpleName(): string;
  104028. }
  104029. }
  104030. declare module BABYLON {
  104031. /**
  104032. * Manage the mouse wheel inputs to control an arc rotate camera.
  104033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104034. */
  104035. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  104036. /**
  104037. * Defines the camera the input is attached to.
  104038. */
  104039. camera: ArcRotateCamera;
  104040. /**
  104041. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104042. */
  104043. wheelPrecision: number;
  104044. /**
  104045. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104046. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104047. */
  104048. wheelDeltaPercentage: number;
  104049. private _wheel;
  104050. private _observer;
  104051. private computeDeltaFromMouseWheelLegacyEvent;
  104052. /**
  104053. * Attach the input controls to a specific dom element to get the input from.
  104054. * @param element Defines the element the controls should be listened from
  104055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104056. */
  104057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104058. /**
  104059. * Detach the current controls from the specified dom element.
  104060. * @param element Defines the element to stop listening the inputs from
  104061. */
  104062. detachControl(element: Nullable<HTMLElement>): void;
  104063. /**
  104064. * Gets the class name of the current intput.
  104065. * @returns the class name
  104066. */
  104067. getClassName(): string;
  104068. /**
  104069. * Get the friendly name associated with the input class.
  104070. * @returns the input friendly name
  104071. */
  104072. getSimpleName(): string;
  104073. }
  104074. }
  104075. declare module BABYLON {
  104076. /**
  104077. * Default Inputs manager for the ArcRotateCamera.
  104078. * It groups all the default supported inputs for ease of use.
  104079. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104080. */
  104081. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  104082. /**
  104083. * Instantiates a new ArcRotateCameraInputsManager.
  104084. * @param camera Defines the camera the inputs belong to
  104085. */
  104086. constructor(camera: ArcRotateCamera);
  104087. /**
  104088. * Add mouse wheel input support to the input manager.
  104089. * @returns the current input manager
  104090. */
  104091. addMouseWheel(): ArcRotateCameraInputsManager;
  104092. /**
  104093. * Add pointers input support to the input manager.
  104094. * @returns the current input manager
  104095. */
  104096. addPointers(): ArcRotateCameraInputsManager;
  104097. /**
  104098. * Add keyboard input support to the input manager.
  104099. * @returns the current input manager
  104100. */
  104101. addKeyboard(): ArcRotateCameraInputsManager;
  104102. }
  104103. }
  104104. declare module BABYLON {
  104105. /**
  104106. * This represents an orbital type of camera.
  104107. *
  104108. * 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.
  104109. * 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.
  104110. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  104111. */
  104112. export class ArcRotateCamera extends TargetCamera {
  104113. /**
  104114. * Defines the rotation angle of the camera along the longitudinal axis.
  104115. */
  104116. alpha: number;
  104117. /**
  104118. * Defines the rotation angle of the camera along the latitudinal axis.
  104119. */
  104120. beta: number;
  104121. /**
  104122. * Defines the radius of the camera from it s target point.
  104123. */
  104124. radius: number;
  104125. protected _target: Vector3;
  104126. protected _targetHost: Nullable<AbstractMesh>;
  104127. /**
  104128. * Defines the target point of the camera.
  104129. * The camera looks towards it form the radius distance.
  104130. */
  104131. target: Vector3;
  104132. /**
  104133. * Define the current local position of the camera in the scene
  104134. */
  104135. position: Vector3;
  104136. protected _upVector: Vector3;
  104137. protected _upToYMatrix: Matrix;
  104138. protected _YToUpMatrix: Matrix;
  104139. /**
  104140. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  104141. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  104142. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  104143. */
  104144. upVector: Vector3;
  104145. /**
  104146. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  104147. */
  104148. setMatUp(): void;
  104149. /**
  104150. * Current inertia value on the longitudinal axis.
  104151. * The bigger this number the longer it will take for the camera to stop.
  104152. */
  104153. inertialAlphaOffset: number;
  104154. /**
  104155. * Current inertia value on the latitudinal axis.
  104156. * The bigger this number the longer it will take for the camera to stop.
  104157. */
  104158. inertialBetaOffset: number;
  104159. /**
  104160. * Current inertia value on the radius axis.
  104161. * The bigger this number the longer it will take for the camera to stop.
  104162. */
  104163. inertialRadiusOffset: number;
  104164. /**
  104165. * Minimum allowed angle on the longitudinal axis.
  104166. * This can help limiting how the Camera is able to move in the scene.
  104167. */
  104168. lowerAlphaLimit: Nullable<number>;
  104169. /**
  104170. * Maximum allowed angle on the longitudinal axis.
  104171. * This can help limiting how the Camera is able to move in the scene.
  104172. */
  104173. upperAlphaLimit: Nullable<number>;
  104174. /**
  104175. * Minimum allowed angle on the latitudinal axis.
  104176. * This can help limiting how the Camera is able to move in the scene.
  104177. */
  104178. lowerBetaLimit: number;
  104179. /**
  104180. * Maximum allowed angle on the latitudinal axis.
  104181. * This can help limiting how the Camera is able to move in the scene.
  104182. */
  104183. upperBetaLimit: number;
  104184. /**
  104185. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  104186. * This can help limiting how the Camera is able to move in the scene.
  104187. */
  104188. lowerRadiusLimit: Nullable<number>;
  104189. /**
  104190. * Maximum allowed distance of the camera to the target (The camera can not get further).
  104191. * This can help limiting how the Camera is able to move in the scene.
  104192. */
  104193. upperRadiusLimit: Nullable<number>;
  104194. /**
  104195. * Defines the current inertia value used during panning of the camera along the X axis.
  104196. */
  104197. inertialPanningX: number;
  104198. /**
  104199. * Defines the current inertia value used during panning of the camera along the Y axis.
  104200. */
  104201. inertialPanningY: number;
  104202. /**
  104203. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  104204. * Basically if your fingers moves away from more than this distance you will be considered
  104205. * in pinch mode.
  104206. */
  104207. pinchToPanMaxDistance: number;
  104208. /**
  104209. * Defines the maximum distance the camera can pan.
  104210. * This could help keeping the cammera always in your scene.
  104211. */
  104212. panningDistanceLimit: Nullable<number>;
  104213. /**
  104214. * Defines the target of the camera before paning.
  104215. */
  104216. panningOriginTarget: Vector3;
  104217. /**
  104218. * Defines the value of the inertia used during panning.
  104219. * 0 would mean stop inertia and one would mean no decelleration at all.
  104220. */
  104221. panningInertia: number;
  104222. /**
  104223. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  104224. */
  104225. angularSensibilityX: number;
  104226. /**
  104227. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  104228. */
  104229. angularSensibilityY: number;
  104230. /**
  104231. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  104232. */
  104233. pinchPrecision: number;
  104234. /**
  104235. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  104236. * It will be used instead of pinchDeltaPrecision if different from 0.
  104237. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104238. */
  104239. pinchDeltaPercentage: number;
  104240. /**
  104241. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  104242. */
  104243. panningSensibility: number;
  104244. /**
  104245. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  104246. */
  104247. keysUp: number[];
  104248. /**
  104249. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  104250. */
  104251. keysDown: number[];
  104252. /**
  104253. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  104254. */
  104255. keysLeft: number[];
  104256. /**
  104257. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  104258. */
  104259. keysRight: number[];
  104260. /**
  104261. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  104262. */
  104263. wheelPrecision: number;
  104264. /**
  104265. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  104266. * It will be used instead of pinchDeltaPrecision if different from 0.
  104267. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  104268. */
  104269. wheelDeltaPercentage: number;
  104270. /**
  104271. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  104272. */
  104273. zoomOnFactor: number;
  104274. /**
  104275. * Defines a screen offset for the camera position.
  104276. */
  104277. targetScreenOffset: Vector2;
  104278. /**
  104279. * Allows the camera to be completely reversed.
  104280. * If false the camera can not arrive upside down.
  104281. */
  104282. allowUpsideDown: boolean;
  104283. /**
  104284. * Define if double tap/click is used to restore the previously saved state of the camera.
  104285. */
  104286. useInputToRestoreState: boolean;
  104287. /** @hidden */
  104288. _viewMatrix: Matrix;
  104289. /** @hidden */
  104290. _useCtrlForPanning: boolean;
  104291. /** @hidden */
  104292. _panningMouseButton: number;
  104293. /**
  104294. * Defines the input associated to the camera.
  104295. */
  104296. inputs: ArcRotateCameraInputsManager;
  104297. /** @hidden */
  104298. _reset: () => void;
  104299. /**
  104300. * Defines the allowed panning axis.
  104301. */
  104302. panningAxis: Vector3;
  104303. protected _localDirection: Vector3;
  104304. protected _transformedDirection: Vector3;
  104305. private _bouncingBehavior;
  104306. /**
  104307. * Gets the bouncing behavior of the camera if it has been enabled.
  104308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104309. */
  104310. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  104311. /**
  104312. * Defines if the bouncing behavior of the camera is enabled on the camera.
  104313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104314. */
  104315. useBouncingBehavior: boolean;
  104316. private _framingBehavior;
  104317. /**
  104318. * Gets the framing behavior of the camera if it has been enabled.
  104319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104320. */
  104321. readonly framingBehavior: Nullable<FramingBehavior>;
  104322. /**
  104323. * Defines if the framing behavior of the camera is enabled on the camera.
  104324. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104325. */
  104326. useFramingBehavior: boolean;
  104327. private _autoRotationBehavior;
  104328. /**
  104329. * Gets the auto rotation behavior of the camera if it has been enabled.
  104330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104331. */
  104332. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  104333. /**
  104334. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  104335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104336. */
  104337. useAutoRotationBehavior: boolean;
  104338. /**
  104339. * Observable triggered when the mesh target has been changed on the camera.
  104340. */
  104341. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  104342. /**
  104343. * Event raised when the camera is colliding with a mesh.
  104344. */
  104345. onCollide: (collidedMesh: AbstractMesh) => void;
  104346. /**
  104347. * Defines whether the camera should check collision with the objects oh the scene.
  104348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  104349. */
  104350. checkCollisions: boolean;
  104351. /**
  104352. * Defines the collision radius of the camera.
  104353. * This simulates a sphere around the camera.
  104354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104355. */
  104356. collisionRadius: Vector3;
  104357. protected _collider: Collider;
  104358. protected _previousPosition: Vector3;
  104359. protected _collisionVelocity: Vector3;
  104360. protected _newPosition: Vector3;
  104361. protected _previousAlpha: number;
  104362. protected _previousBeta: number;
  104363. protected _previousRadius: number;
  104364. protected _collisionTriggered: boolean;
  104365. protected _targetBoundingCenter: Nullable<Vector3>;
  104366. private _computationVector;
  104367. /**
  104368. * Instantiates a new ArcRotateCamera in a given scene
  104369. * @param name Defines the name of the camera
  104370. * @param alpha Defines the camera rotation along the logitudinal axis
  104371. * @param beta Defines the camera rotation along the latitudinal axis
  104372. * @param radius Defines the camera distance from its target
  104373. * @param target Defines the camera target
  104374. * @param scene Defines the scene the camera belongs to
  104375. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  104376. */
  104377. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104378. /** @hidden */
  104379. _initCache(): void;
  104380. /** @hidden */
  104381. _updateCache(ignoreParentClass?: boolean): void;
  104382. protected _getTargetPosition(): Vector3;
  104383. private _storedAlpha;
  104384. private _storedBeta;
  104385. private _storedRadius;
  104386. private _storedTarget;
  104387. private _storedTargetScreenOffset;
  104388. /**
  104389. * Stores the current state of the camera (alpha, beta, radius and target)
  104390. * @returns the camera itself
  104391. */
  104392. storeState(): Camera;
  104393. /**
  104394. * @hidden
  104395. * Restored camera state. You must call storeState() first
  104396. */
  104397. _restoreStateValues(): boolean;
  104398. /** @hidden */
  104399. _isSynchronizedViewMatrix(): boolean;
  104400. /**
  104401. * Attached controls to the current camera.
  104402. * @param element Defines the element the controls should be listened from
  104403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104404. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  104405. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  104406. */
  104407. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  104408. /**
  104409. * Detach the current controls from the camera.
  104410. * The camera will stop reacting to inputs.
  104411. * @param element Defines the element to stop listening the inputs from
  104412. */
  104413. detachControl(element: HTMLElement): void;
  104414. /** @hidden */
  104415. _checkInputs(): void;
  104416. protected _checkLimits(): void;
  104417. /**
  104418. * Rebuilds angles (alpha, beta) and radius from the give position and target
  104419. */
  104420. rebuildAnglesAndRadius(): void;
  104421. /**
  104422. * Use a position to define the current camera related information like alpha, beta and radius
  104423. * @param position Defines the position to set the camera at
  104424. */
  104425. setPosition(position: Vector3): void;
  104426. /**
  104427. * Defines the target the camera should look at.
  104428. * This will automatically adapt alpha beta and radius to fit within the new target.
  104429. * @param target Defines the new target as a Vector or a mesh
  104430. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  104431. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  104432. */
  104433. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  104434. /** @hidden */
  104435. _getViewMatrix(): Matrix;
  104436. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  104437. /**
  104438. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  104439. * @param meshes Defines the mesh to zoom on
  104440. * @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)
  104441. */
  104442. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  104443. /**
  104444. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  104445. * The target will be changed but the radius
  104446. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  104447. * @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)
  104448. */
  104449. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  104450. min: Vector3;
  104451. max: Vector3;
  104452. distance: number;
  104453. }, doNotUpdateMaxZ?: boolean): void;
  104454. /**
  104455. * @override
  104456. * Override Camera.createRigCamera
  104457. */
  104458. createRigCamera(name: string, cameraIndex: number): Camera;
  104459. /**
  104460. * @hidden
  104461. * @override
  104462. * Override Camera._updateRigCameras
  104463. */
  104464. _updateRigCameras(): void;
  104465. /**
  104466. * Destroy the camera and release the current resources hold by it.
  104467. */
  104468. dispose(): void;
  104469. /**
  104470. * Gets the current object class name.
  104471. * @return the class name
  104472. */
  104473. getClassName(): string;
  104474. }
  104475. }
  104476. declare module BABYLON {
  104477. /**
  104478. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  104479. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  104480. */
  104481. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  104482. /**
  104483. * Gets the name of the behavior.
  104484. */
  104485. readonly name: string;
  104486. private _zoomStopsAnimation;
  104487. private _idleRotationSpeed;
  104488. private _idleRotationWaitTime;
  104489. private _idleRotationSpinupTime;
  104490. /**
  104491. * Sets the flag that indicates if user zooming should stop animation.
  104492. */
  104493. /**
  104494. * Gets the flag that indicates if user zooming should stop animation.
  104495. */
  104496. zoomStopsAnimation: boolean;
  104497. /**
  104498. * Sets the default speed at which the camera rotates around the model.
  104499. */
  104500. /**
  104501. * Gets the default speed at which the camera rotates around the model.
  104502. */
  104503. idleRotationSpeed: number;
  104504. /**
  104505. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  104506. */
  104507. /**
  104508. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  104509. */
  104510. idleRotationWaitTime: number;
  104511. /**
  104512. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104513. */
  104514. /**
  104515. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  104516. */
  104517. idleRotationSpinupTime: number;
  104518. /**
  104519. * Gets a value indicating if the camera is currently rotating because of this behavior
  104520. */
  104521. readonly rotationInProgress: boolean;
  104522. private _onPrePointerObservableObserver;
  104523. private _onAfterCheckInputsObserver;
  104524. private _attachedCamera;
  104525. private _isPointerDown;
  104526. private _lastFrameTime;
  104527. private _lastInteractionTime;
  104528. private _cameraRotationSpeed;
  104529. /**
  104530. * Initializes the behavior.
  104531. */
  104532. init(): void;
  104533. /**
  104534. * Attaches the behavior to its arc rotate camera.
  104535. * @param camera Defines the camera to attach the behavior to
  104536. */
  104537. attach(camera: ArcRotateCamera): void;
  104538. /**
  104539. * Detaches the behavior from its current arc rotate camera.
  104540. */
  104541. detach(): void;
  104542. /**
  104543. * Returns true if user is scrolling.
  104544. * @return true if user is scrolling.
  104545. */
  104546. private _userIsZooming;
  104547. private _lastFrameRadius;
  104548. private _shouldAnimationStopForInteraction;
  104549. /**
  104550. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104551. */
  104552. private _applyUserInteraction;
  104553. private _userIsMoving;
  104554. }
  104555. }
  104556. declare module BABYLON {
  104557. /**
  104558. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  104559. */
  104560. export class AttachToBoxBehavior implements Behavior<Mesh> {
  104561. private ui;
  104562. /**
  104563. * The name of the behavior
  104564. */
  104565. name: string;
  104566. /**
  104567. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  104568. */
  104569. distanceAwayFromFace: number;
  104570. /**
  104571. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  104572. */
  104573. distanceAwayFromBottomOfFace: number;
  104574. private _faceVectors;
  104575. private _target;
  104576. private _scene;
  104577. private _onRenderObserver;
  104578. private _tmpMatrix;
  104579. private _tmpVector;
  104580. /**
  104581. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  104582. * @param ui The transform node that should be attched to the mesh
  104583. */
  104584. constructor(ui: TransformNode);
  104585. /**
  104586. * Initializes the behavior
  104587. */
  104588. init(): void;
  104589. private _closestFace;
  104590. private _zeroVector;
  104591. private _lookAtTmpMatrix;
  104592. private _lookAtToRef;
  104593. /**
  104594. * Attaches the AttachToBoxBehavior to the passed in mesh
  104595. * @param target The mesh that the specified node will be attached to
  104596. */
  104597. attach(target: Mesh): void;
  104598. /**
  104599. * Detaches the behavior from the mesh
  104600. */
  104601. detach(): void;
  104602. }
  104603. }
  104604. declare module BABYLON {
  104605. /**
  104606. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  104607. */
  104608. export class FadeInOutBehavior implements Behavior<Mesh> {
  104609. /**
  104610. * Time in milliseconds to delay before fading in (Default: 0)
  104611. */
  104612. delay: number;
  104613. /**
  104614. * Time in milliseconds for the mesh to fade in (Default: 300)
  104615. */
  104616. fadeInTime: number;
  104617. private _millisecondsPerFrame;
  104618. private _hovered;
  104619. private _hoverValue;
  104620. private _ownerNode;
  104621. /**
  104622. * Instatiates the FadeInOutBehavior
  104623. */
  104624. constructor();
  104625. /**
  104626. * The name of the behavior
  104627. */
  104628. readonly name: string;
  104629. /**
  104630. * Initializes the behavior
  104631. */
  104632. init(): void;
  104633. /**
  104634. * Attaches the fade behavior on the passed in mesh
  104635. * @param ownerNode The mesh that will be faded in/out once attached
  104636. */
  104637. attach(ownerNode: Mesh): void;
  104638. /**
  104639. * Detaches the behavior from the mesh
  104640. */
  104641. detach(): void;
  104642. /**
  104643. * Triggers the mesh to begin fading in or out
  104644. * @param value if the object should fade in or out (true to fade in)
  104645. */
  104646. fadeIn(value: boolean): void;
  104647. private _update;
  104648. private _setAllVisibility;
  104649. }
  104650. }
  104651. declare module BABYLON {
  104652. /**
  104653. * Class containing a set of static utilities functions for managing Pivots
  104654. * @hidden
  104655. */
  104656. export class PivotTools {
  104657. private static _PivotCached;
  104658. private static _OldPivotPoint;
  104659. private static _PivotTranslation;
  104660. private static _PivotTmpVector;
  104661. /** @hidden */
  104662. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  104663. /** @hidden */
  104664. static _RestorePivotPoint(mesh: AbstractMesh): void;
  104665. }
  104666. }
  104667. declare module BABYLON {
  104668. /**
  104669. * Class containing static functions to help procedurally build meshes
  104670. */
  104671. export class PlaneBuilder {
  104672. /**
  104673. * Creates a plane mesh
  104674. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  104675. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  104676. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  104677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104680. * @param name defines the name of the mesh
  104681. * @param options defines the options used to create the mesh
  104682. * @param scene defines the hosting scene
  104683. * @returns the plane mesh
  104684. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  104685. */
  104686. static CreatePlane(name: string, options: {
  104687. size?: number;
  104688. width?: number;
  104689. height?: number;
  104690. sideOrientation?: number;
  104691. frontUVs?: Vector4;
  104692. backUVs?: Vector4;
  104693. updatable?: boolean;
  104694. sourcePlane?: Plane;
  104695. }, scene?: Nullable<Scene>): Mesh;
  104696. }
  104697. }
  104698. declare module BABYLON {
  104699. /**
  104700. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  104701. */
  104702. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  104703. private static _AnyMouseID;
  104704. /**
  104705. * Abstract mesh the behavior is set on
  104706. */
  104707. attachedNode: AbstractMesh;
  104708. private _dragPlane;
  104709. private _scene;
  104710. private _pointerObserver;
  104711. private _beforeRenderObserver;
  104712. private static _planeScene;
  104713. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  104714. /**
  104715. * 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)
  104716. */
  104717. maxDragAngle: number;
  104718. /**
  104719. * @hidden
  104720. */
  104721. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  104722. /**
  104723. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104724. */
  104725. currentDraggingPointerID: number;
  104726. /**
  104727. * The last position where the pointer hit the drag plane in world space
  104728. */
  104729. lastDragPosition: Vector3;
  104730. /**
  104731. * If the behavior is currently in a dragging state
  104732. */
  104733. dragging: boolean;
  104734. /**
  104735. * 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)
  104736. */
  104737. dragDeltaRatio: number;
  104738. /**
  104739. * If the drag plane orientation should be updated during the dragging (Default: true)
  104740. */
  104741. updateDragPlane: boolean;
  104742. private _debugMode;
  104743. private _moving;
  104744. /**
  104745. * Fires each time the attached mesh is dragged with the pointer
  104746. * * delta between last drag position and current drag position in world space
  104747. * * dragDistance along the drag axis
  104748. * * dragPlaneNormal normal of the current drag plane used during the drag
  104749. * * dragPlanePoint in world space where the drag intersects the drag plane
  104750. */
  104751. onDragObservable: Observable<{
  104752. delta: Vector3;
  104753. dragPlanePoint: Vector3;
  104754. dragPlaneNormal: Vector3;
  104755. dragDistance: number;
  104756. pointerId: number;
  104757. }>;
  104758. /**
  104759. * Fires each time a drag begins (eg. mouse down on mesh)
  104760. */
  104761. onDragStartObservable: Observable<{
  104762. dragPlanePoint: Vector3;
  104763. pointerId: number;
  104764. }>;
  104765. /**
  104766. * Fires each time a drag ends (eg. mouse release after drag)
  104767. */
  104768. onDragEndObservable: Observable<{
  104769. dragPlanePoint: Vector3;
  104770. pointerId: number;
  104771. }>;
  104772. /**
  104773. * If the attached mesh should be moved when dragged
  104774. */
  104775. moveAttached: boolean;
  104776. /**
  104777. * If the drag behavior will react to drag events (Default: true)
  104778. */
  104779. enabled: boolean;
  104780. /**
  104781. * If pointer events should start and release the drag (Default: true)
  104782. */
  104783. startAndReleaseDragOnPointerEvents: boolean;
  104784. /**
  104785. * If camera controls should be detached during the drag
  104786. */
  104787. detachCameraControls: boolean;
  104788. /**
  104789. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  104790. */
  104791. useObjectOrienationForDragging: boolean;
  104792. private _options;
  104793. /**
  104794. * Creates a pointer drag behavior that can be attached to a mesh
  104795. * @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)
  104796. */
  104797. constructor(options?: {
  104798. dragAxis?: Vector3;
  104799. dragPlaneNormal?: Vector3;
  104800. });
  104801. /**
  104802. * Predicate to determine if it is valid to move the object to a new position when it is moved
  104803. */
  104804. validateDrag: (targetPosition: Vector3) => boolean;
  104805. /**
  104806. * The name of the behavior
  104807. */
  104808. readonly name: string;
  104809. /**
  104810. * Initializes the behavior
  104811. */
  104812. init(): void;
  104813. private _tmpVector;
  104814. private _alternatePickedPoint;
  104815. private _worldDragAxis;
  104816. private _targetPosition;
  104817. private _attachedElement;
  104818. /**
  104819. * Attaches the drag behavior the passed in mesh
  104820. * @param ownerNode The mesh that will be dragged around once attached
  104821. * @param predicate Predicate to use for pick filtering
  104822. */
  104823. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  104824. /**
  104825. * Force relase the drag action by code.
  104826. */
  104827. releaseDrag(): void;
  104828. private _startDragRay;
  104829. private _lastPointerRay;
  104830. /**
  104831. * Simulates the start of a pointer drag event on the behavior
  104832. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  104833. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  104834. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  104835. */
  104836. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  104837. private _startDrag;
  104838. private _dragDelta;
  104839. private _moveDrag;
  104840. private _pickWithRayOnDragPlane;
  104841. private _pointA;
  104842. private _pointB;
  104843. private _pointC;
  104844. private _lineA;
  104845. private _lineB;
  104846. private _localAxis;
  104847. private _lookAt;
  104848. private _updateDragPlanePosition;
  104849. /**
  104850. * Detaches the behavior from the mesh
  104851. */
  104852. detach(): void;
  104853. }
  104854. }
  104855. declare module BABYLON {
  104856. /**
  104857. * A behavior that when attached to a mesh will allow the mesh to be scaled
  104858. */
  104859. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  104860. private _dragBehaviorA;
  104861. private _dragBehaviorB;
  104862. private _startDistance;
  104863. private _initialScale;
  104864. private _targetScale;
  104865. private _ownerNode;
  104866. private _sceneRenderObserver;
  104867. /**
  104868. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  104869. */
  104870. constructor();
  104871. /**
  104872. * The name of the behavior
  104873. */
  104874. readonly name: string;
  104875. /**
  104876. * Initializes the behavior
  104877. */
  104878. init(): void;
  104879. private _getCurrentDistance;
  104880. /**
  104881. * Attaches the scale behavior the passed in mesh
  104882. * @param ownerNode The mesh that will be scaled around once attached
  104883. */
  104884. attach(ownerNode: Mesh): void;
  104885. /**
  104886. * Detaches the behavior from the mesh
  104887. */
  104888. detach(): void;
  104889. }
  104890. }
  104891. declare module BABYLON {
  104892. /**
  104893. * 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
  104894. */
  104895. export class SixDofDragBehavior implements Behavior<Mesh> {
  104896. private static _virtualScene;
  104897. private _ownerNode;
  104898. private _sceneRenderObserver;
  104899. private _scene;
  104900. private _targetPosition;
  104901. private _virtualOriginMesh;
  104902. private _virtualDragMesh;
  104903. private _pointerObserver;
  104904. private _moving;
  104905. private _startingOrientation;
  104906. /**
  104907. * 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)
  104908. */
  104909. private zDragFactor;
  104910. /**
  104911. * If the object should rotate to face the drag origin
  104912. */
  104913. rotateDraggedObject: boolean;
  104914. /**
  104915. * If the behavior is currently in a dragging state
  104916. */
  104917. dragging: boolean;
  104918. /**
  104919. * 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)
  104920. */
  104921. dragDeltaRatio: number;
  104922. /**
  104923. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  104924. */
  104925. currentDraggingPointerID: number;
  104926. /**
  104927. * If camera controls should be detached during the drag
  104928. */
  104929. detachCameraControls: boolean;
  104930. /**
  104931. * Fires each time a drag starts
  104932. */
  104933. onDragStartObservable: Observable<{}>;
  104934. /**
  104935. * Fires each time a drag ends (eg. mouse release after drag)
  104936. */
  104937. onDragEndObservable: Observable<{}>;
  104938. /**
  104939. * 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
  104940. */
  104941. constructor();
  104942. /**
  104943. * The name of the behavior
  104944. */
  104945. readonly name: string;
  104946. /**
  104947. * Initializes the behavior
  104948. */
  104949. init(): void;
  104950. /**
  104951. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  104952. */
  104953. private readonly _pointerCamera;
  104954. /**
  104955. * Attaches the scale behavior the passed in mesh
  104956. * @param ownerNode The mesh that will be scaled around once attached
  104957. */
  104958. attach(ownerNode: Mesh): void;
  104959. /**
  104960. * Detaches the behavior from the mesh
  104961. */
  104962. detach(): void;
  104963. }
  104964. }
  104965. declare module BABYLON {
  104966. /**
  104967. * Class used to apply inverse kinematics to bones
  104968. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  104969. */
  104970. export class BoneIKController {
  104971. private static _tmpVecs;
  104972. private static _tmpQuat;
  104973. private static _tmpMats;
  104974. /**
  104975. * Gets or sets the target mesh
  104976. */
  104977. targetMesh: AbstractMesh;
  104978. /** Gets or sets the mesh used as pole */
  104979. poleTargetMesh: AbstractMesh;
  104980. /**
  104981. * Gets or sets the bone used as pole
  104982. */
  104983. poleTargetBone: Nullable<Bone>;
  104984. /**
  104985. * Gets or sets the target position
  104986. */
  104987. targetPosition: Vector3;
  104988. /**
  104989. * Gets or sets the pole target position
  104990. */
  104991. poleTargetPosition: Vector3;
  104992. /**
  104993. * Gets or sets the pole target local offset
  104994. */
  104995. poleTargetLocalOffset: Vector3;
  104996. /**
  104997. * Gets or sets the pole angle
  104998. */
  104999. poleAngle: number;
  105000. /**
  105001. * Gets or sets the mesh associated with the controller
  105002. */
  105003. mesh: AbstractMesh;
  105004. /**
  105005. * 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)
  105006. */
  105007. slerpAmount: number;
  105008. private _bone1Quat;
  105009. private _bone1Mat;
  105010. private _bone2Ang;
  105011. private _bone1;
  105012. private _bone2;
  105013. private _bone1Length;
  105014. private _bone2Length;
  105015. private _maxAngle;
  105016. private _maxReach;
  105017. private _rightHandedSystem;
  105018. private _bendAxis;
  105019. private _slerping;
  105020. private _adjustRoll;
  105021. /**
  105022. * Gets or sets maximum allowed angle
  105023. */
  105024. maxAngle: number;
  105025. /**
  105026. * Creates a new BoneIKController
  105027. * @param mesh defines the mesh to control
  105028. * @param bone defines the bone to control
  105029. * @param options defines options to set up the controller
  105030. */
  105031. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  105032. targetMesh?: AbstractMesh;
  105033. poleTargetMesh?: AbstractMesh;
  105034. poleTargetBone?: Bone;
  105035. poleTargetLocalOffset?: Vector3;
  105036. poleAngle?: number;
  105037. bendAxis?: Vector3;
  105038. maxAngle?: number;
  105039. slerpAmount?: number;
  105040. });
  105041. private _setMaxAngle;
  105042. /**
  105043. * Force the controller to update the bones
  105044. */
  105045. update(): void;
  105046. }
  105047. }
  105048. declare module BABYLON {
  105049. /**
  105050. * Class used to make a bone look toward a point in space
  105051. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  105052. */
  105053. export class BoneLookController {
  105054. private static _tmpVecs;
  105055. private static _tmpQuat;
  105056. private static _tmpMats;
  105057. /**
  105058. * The target Vector3 that the bone will look at
  105059. */
  105060. target: Vector3;
  105061. /**
  105062. * The mesh that the bone is attached to
  105063. */
  105064. mesh: AbstractMesh;
  105065. /**
  105066. * The bone that will be looking to the target
  105067. */
  105068. bone: Bone;
  105069. /**
  105070. * The up axis of the coordinate system that is used when the bone is rotated
  105071. */
  105072. upAxis: Vector3;
  105073. /**
  105074. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  105075. */
  105076. upAxisSpace: Space;
  105077. /**
  105078. * Used to make an adjustment to the yaw of the bone
  105079. */
  105080. adjustYaw: number;
  105081. /**
  105082. * Used to make an adjustment to the pitch of the bone
  105083. */
  105084. adjustPitch: number;
  105085. /**
  105086. * Used to make an adjustment to the roll of the bone
  105087. */
  105088. adjustRoll: number;
  105089. /**
  105090. * 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)
  105091. */
  105092. slerpAmount: number;
  105093. private _minYaw;
  105094. private _maxYaw;
  105095. private _minPitch;
  105096. private _maxPitch;
  105097. private _minYawSin;
  105098. private _minYawCos;
  105099. private _maxYawSin;
  105100. private _maxYawCos;
  105101. private _midYawConstraint;
  105102. private _minPitchTan;
  105103. private _maxPitchTan;
  105104. private _boneQuat;
  105105. private _slerping;
  105106. private _transformYawPitch;
  105107. private _transformYawPitchInv;
  105108. private _firstFrameSkipped;
  105109. private _yawRange;
  105110. private _fowardAxis;
  105111. /**
  105112. * Gets or sets the minimum yaw angle that the bone can look to
  105113. */
  105114. minYaw: number;
  105115. /**
  105116. * Gets or sets the maximum yaw angle that the bone can look to
  105117. */
  105118. maxYaw: number;
  105119. /**
  105120. * Gets or sets the minimum pitch angle that the bone can look to
  105121. */
  105122. minPitch: number;
  105123. /**
  105124. * Gets or sets the maximum pitch angle that the bone can look to
  105125. */
  105126. maxPitch: number;
  105127. /**
  105128. * Create a BoneLookController
  105129. * @param mesh the mesh that the bone belongs to
  105130. * @param bone the bone that will be looking to the target
  105131. * @param target the target Vector3 to look at
  105132. * @param options optional settings:
  105133. * * maxYaw: the maximum angle the bone will yaw to
  105134. * * minYaw: the minimum angle the bone will yaw to
  105135. * * maxPitch: the maximum angle the bone will pitch to
  105136. * * minPitch: the minimum angle the bone will yaw to
  105137. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  105138. * * upAxis: the up axis of the coordinate system
  105139. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  105140. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  105141. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  105142. * * adjustYaw: used to make an adjustment to the yaw of the bone
  105143. * * adjustPitch: used to make an adjustment to the pitch of the bone
  105144. * * adjustRoll: used to make an adjustment to the roll of the bone
  105145. **/
  105146. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  105147. maxYaw?: number;
  105148. minYaw?: number;
  105149. maxPitch?: number;
  105150. minPitch?: number;
  105151. slerpAmount?: number;
  105152. upAxis?: Vector3;
  105153. upAxisSpace?: Space;
  105154. yawAxis?: Vector3;
  105155. pitchAxis?: Vector3;
  105156. adjustYaw?: number;
  105157. adjustPitch?: number;
  105158. adjustRoll?: number;
  105159. });
  105160. /**
  105161. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  105162. */
  105163. update(): void;
  105164. private _getAngleDiff;
  105165. private _getAngleBetween;
  105166. private _isAngleBetween;
  105167. }
  105168. }
  105169. declare module BABYLON {
  105170. /**
  105171. * Manage the gamepad inputs to control an arc rotate camera.
  105172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105173. */
  105174. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  105175. /**
  105176. * Defines the camera the input is attached to.
  105177. */
  105178. camera: ArcRotateCamera;
  105179. /**
  105180. * Defines the gamepad the input is gathering event from.
  105181. */
  105182. gamepad: Nullable<Gamepad>;
  105183. /**
  105184. * Defines the gamepad rotation sensiblity.
  105185. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105186. */
  105187. gamepadRotationSensibility: number;
  105188. /**
  105189. * Defines the gamepad move sensiblity.
  105190. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105191. */
  105192. gamepadMoveSensibility: number;
  105193. private _yAxisScale;
  105194. /**
  105195. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105196. */
  105197. invertYAxis: boolean;
  105198. private _onGamepadConnectedObserver;
  105199. private _onGamepadDisconnectedObserver;
  105200. /**
  105201. * Attach the input controls to a specific dom element to get the input from.
  105202. * @param element Defines the element the controls should be listened from
  105203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105204. */
  105205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105206. /**
  105207. * Detach the current controls from the specified dom element.
  105208. * @param element Defines the element to stop listening the inputs from
  105209. */
  105210. detachControl(element: Nullable<HTMLElement>): void;
  105211. /**
  105212. * Update the current camera state depending on the inputs that have been used this frame.
  105213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105214. */
  105215. checkInputs(): void;
  105216. /**
  105217. * Gets the class name of the current intput.
  105218. * @returns the class name
  105219. */
  105220. getClassName(): string;
  105221. /**
  105222. * Get the friendly name associated with the input class.
  105223. * @returns the input friendly name
  105224. */
  105225. getSimpleName(): string;
  105226. }
  105227. }
  105228. declare module BABYLON {
  105229. interface ArcRotateCameraInputsManager {
  105230. /**
  105231. * Add orientation input support to the input manager.
  105232. * @returns the current input manager
  105233. */
  105234. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  105235. }
  105236. /**
  105237. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  105238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105239. */
  105240. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  105241. /**
  105242. * Defines the camera the input is attached to.
  105243. */
  105244. camera: ArcRotateCamera;
  105245. /**
  105246. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  105247. */
  105248. alphaCorrection: number;
  105249. /**
  105250. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  105251. */
  105252. gammaCorrection: number;
  105253. private _alpha;
  105254. private _gamma;
  105255. private _dirty;
  105256. private _deviceOrientationHandler;
  105257. /**
  105258. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  105259. */
  105260. constructor();
  105261. /**
  105262. * Attach the input controls to a specific dom element to get the input from.
  105263. * @param element Defines the element the controls should be listened from
  105264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105265. */
  105266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105267. /** @hidden */
  105268. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  105269. /**
  105270. * Update the current camera state depending on the inputs that have been used this frame.
  105271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105272. */
  105273. checkInputs(): void;
  105274. /**
  105275. * Detach the current controls from the specified dom element.
  105276. * @param element Defines the element to stop listening the inputs from
  105277. */
  105278. detachControl(element: Nullable<HTMLElement>): void;
  105279. /**
  105280. * Gets the class name of the current intput.
  105281. * @returns the class name
  105282. */
  105283. getClassName(): string;
  105284. /**
  105285. * Get the friendly name associated with the input class.
  105286. * @returns the input friendly name
  105287. */
  105288. getSimpleName(): string;
  105289. }
  105290. }
  105291. declare module BABYLON {
  105292. /**
  105293. * Listen to mouse events to control the camera.
  105294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105295. */
  105296. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  105297. /**
  105298. * Defines the camera the input is attached to.
  105299. */
  105300. camera: FlyCamera;
  105301. /**
  105302. * Defines if touch is enabled. (Default is true.)
  105303. */
  105304. touchEnabled: boolean;
  105305. /**
  105306. * Defines the buttons associated with the input to handle camera rotation.
  105307. */
  105308. buttons: number[];
  105309. /**
  105310. * Assign buttons for Yaw control.
  105311. */
  105312. buttonsYaw: number[];
  105313. /**
  105314. * Assign buttons for Pitch control.
  105315. */
  105316. buttonsPitch: number[];
  105317. /**
  105318. * Assign buttons for Roll control.
  105319. */
  105320. buttonsRoll: number[];
  105321. /**
  105322. * Detect if any button is being pressed while mouse is moved.
  105323. * -1 = Mouse locked.
  105324. * 0 = Left button.
  105325. * 1 = Middle Button.
  105326. * 2 = Right Button.
  105327. */
  105328. activeButton: number;
  105329. /**
  105330. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  105331. * Higher values reduce its sensitivity.
  105332. */
  105333. angularSensibility: number;
  105334. private _mousemoveCallback;
  105335. private _observer;
  105336. private _rollObserver;
  105337. private previousPosition;
  105338. private noPreventDefault;
  105339. private element;
  105340. /**
  105341. * Listen to mouse events to control the camera.
  105342. * @param touchEnabled Define if touch is enabled. (Default is true.)
  105343. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105344. */
  105345. constructor(touchEnabled?: boolean);
  105346. /**
  105347. * Attach the mouse control to the HTML DOM element.
  105348. * @param element Defines the element that listens to the input events.
  105349. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  105350. */
  105351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105352. /**
  105353. * Detach the current controls from the specified dom element.
  105354. * @param element Defines the element to stop listening the inputs from
  105355. */
  105356. detachControl(element: Nullable<HTMLElement>): void;
  105357. /**
  105358. * Gets the class name of the current input.
  105359. * @returns the class name.
  105360. */
  105361. getClassName(): string;
  105362. /**
  105363. * Get the friendly name associated with the input class.
  105364. * @returns the input's friendly name.
  105365. */
  105366. getSimpleName(): string;
  105367. private _pointerInput;
  105368. private _onMouseMove;
  105369. /**
  105370. * Rotate camera by mouse offset.
  105371. */
  105372. private rotateCamera;
  105373. }
  105374. }
  105375. declare module BABYLON {
  105376. /**
  105377. * Default Inputs manager for the FlyCamera.
  105378. * It groups all the default supported inputs for ease of use.
  105379. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105380. */
  105381. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  105382. /**
  105383. * Instantiates a new FlyCameraInputsManager.
  105384. * @param camera Defines the camera the inputs belong to.
  105385. */
  105386. constructor(camera: FlyCamera);
  105387. /**
  105388. * Add keyboard input support to the input manager.
  105389. * @returns the new FlyCameraKeyboardMoveInput().
  105390. */
  105391. addKeyboard(): FlyCameraInputsManager;
  105392. /**
  105393. * Add mouse input support to the input manager.
  105394. * @param touchEnabled Enable touch screen support.
  105395. * @returns the new FlyCameraMouseInput().
  105396. */
  105397. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  105398. }
  105399. }
  105400. declare module BABYLON {
  105401. /**
  105402. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105403. * such as in a 3D Space Shooter or a Flight Simulator.
  105404. */
  105405. export class FlyCamera extends TargetCamera {
  105406. /**
  105407. * Define the collision ellipsoid of the camera.
  105408. * This is helpful for simulating a camera body, like a player's body.
  105409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105410. */
  105411. ellipsoid: Vector3;
  105412. /**
  105413. * Define an offset for the position of the ellipsoid around the camera.
  105414. * This can be helpful if the camera is attached away from the player's body center,
  105415. * such as at its head.
  105416. */
  105417. ellipsoidOffset: Vector3;
  105418. /**
  105419. * Enable or disable collisions of the camera with the rest of the scene objects.
  105420. */
  105421. checkCollisions: boolean;
  105422. /**
  105423. * Enable or disable gravity on the camera.
  105424. */
  105425. applyGravity: boolean;
  105426. /**
  105427. * Define the current direction the camera is moving to.
  105428. */
  105429. cameraDirection: Vector3;
  105430. /**
  105431. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  105432. * This overrides and empties cameraRotation.
  105433. */
  105434. rotationQuaternion: Quaternion;
  105435. /**
  105436. * Track Roll to maintain the wanted Rolling when looking around.
  105437. */
  105438. _trackRoll: number;
  105439. /**
  105440. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  105441. */
  105442. rollCorrect: number;
  105443. /**
  105444. * Mimic a banked turn, Rolling the camera when Yawing.
  105445. * It's recommended to use rollCorrect = 10 for faster banking correction.
  105446. */
  105447. bankedTurn: boolean;
  105448. /**
  105449. * Limit in radians for how much Roll banking will add. (Default: 90°)
  105450. */
  105451. bankedTurnLimit: number;
  105452. /**
  105453. * Value of 0 disables the banked Roll.
  105454. * Value of 1 is equal to the Yaw angle in radians.
  105455. */
  105456. bankedTurnMultiplier: number;
  105457. /**
  105458. * The inputs manager loads all the input sources, such as keyboard and mouse.
  105459. */
  105460. inputs: FlyCameraInputsManager;
  105461. /**
  105462. * Gets the input sensibility for mouse input.
  105463. * Higher values reduce sensitivity.
  105464. */
  105465. /**
  105466. * Sets the input sensibility for a mouse input.
  105467. * Higher values reduce sensitivity.
  105468. */
  105469. angularSensibility: number;
  105470. /**
  105471. * Get the keys for camera movement forward.
  105472. */
  105473. /**
  105474. * Set the keys for camera movement forward.
  105475. */
  105476. keysForward: number[];
  105477. /**
  105478. * Get the keys for camera movement backward.
  105479. */
  105480. keysBackward: number[];
  105481. /**
  105482. * Get the keys for camera movement up.
  105483. */
  105484. /**
  105485. * Set the keys for camera movement up.
  105486. */
  105487. keysUp: number[];
  105488. /**
  105489. * Get the keys for camera movement down.
  105490. */
  105491. /**
  105492. * Set the keys for camera movement down.
  105493. */
  105494. keysDown: number[];
  105495. /**
  105496. * Get the keys for camera movement left.
  105497. */
  105498. /**
  105499. * Set the keys for camera movement left.
  105500. */
  105501. keysLeft: number[];
  105502. /**
  105503. * Set the keys for camera movement right.
  105504. */
  105505. /**
  105506. * Set the keys for camera movement right.
  105507. */
  105508. keysRight: number[];
  105509. /**
  105510. * Event raised when the camera collides with a mesh in the scene.
  105511. */
  105512. onCollide: (collidedMesh: AbstractMesh) => void;
  105513. private _collider;
  105514. private _needMoveForGravity;
  105515. private _oldPosition;
  105516. private _diffPosition;
  105517. private _newPosition;
  105518. /** @hidden */
  105519. _localDirection: Vector3;
  105520. /** @hidden */
  105521. _transformedDirection: Vector3;
  105522. /**
  105523. * Instantiates a FlyCamera.
  105524. * This is a flying camera, designed for 3D movement and rotation in all directions,
  105525. * such as in a 3D Space Shooter or a Flight Simulator.
  105526. * @param name Define the name of the camera in the scene.
  105527. * @param position Define the starting position of the camera in the scene.
  105528. * @param scene Define the scene the camera belongs to.
  105529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  105530. */
  105531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105532. /**
  105533. * Attach a control to the HTML DOM element.
  105534. * @param element Defines the element that listens to the input events.
  105535. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  105536. */
  105537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105538. /**
  105539. * Detach a control from the HTML DOM element.
  105540. * The camera will stop reacting to that input.
  105541. * @param element Defines the element that listens to the input events.
  105542. */
  105543. detachControl(element: HTMLElement): void;
  105544. private _collisionMask;
  105545. /**
  105546. * Get the mask that the camera ignores in collision events.
  105547. */
  105548. /**
  105549. * Set the mask that the camera ignores in collision events.
  105550. */
  105551. collisionMask: number;
  105552. /** @hidden */
  105553. _collideWithWorld(displacement: Vector3): void;
  105554. /** @hidden */
  105555. private _onCollisionPositionChange;
  105556. /** @hidden */
  105557. _checkInputs(): void;
  105558. /** @hidden */
  105559. _decideIfNeedsToMove(): boolean;
  105560. /** @hidden */
  105561. _updatePosition(): void;
  105562. /**
  105563. * Restore the Roll to its target value at the rate specified.
  105564. * @param rate - Higher means slower restoring.
  105565. * @hidden
  105566. */
  105567. restoreRoll(rate: number): void;
  105568. /**
  105569. * Destroy the camera and release the current resources held by it.
  105570. */
  105571. dispose(): void;
  105572. /**
  105573. * Get the current object class name.
  105574. * @returns the class name.
  105575. */
  105576. getClassName(): string;
  105577. }
  105578. }
  105579. declare module BABYLON {
  105580. /**
  105581. * Listen to keyboard events to control the camera.
  105582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105583. */
  105584. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  105585. /**
  105586. * Defines the camera the input is attached to.
  105587. */
  105588. camera: FlyCamera;
  105589. /**
  105590. * The list of keyboard keys used to control the forward move of the camera.
  105591. */
  105592. keysForward: number[];
  105593. /**
  105594. * The list of keyboard keys used to control the backward move of the camera.
  105595. */
  105596. keysBackward: number[];
  105597. /**
  105598. * The list of keyboard keys used to control the forward move of the camera.
  105599. */
  105600. keysUp: number[];
  105601. /**
  105602. * The list of keyboard keys used to control the backward move of the camera.
  105603. */
  105604. keysDown: number[];
  105605. /**
  105606. * The list of keyboard keys used to control the right strafe move of the camera.
  105607. */
  105608. keysRight: number[];
  105609. /**
  105610. * The list of keyboard keys used to control the left strafe move of the camera.
  105611. */
  105612. keysLeft: number[];
  105613. private _keys;
  105614. private _onCanvasBlurObserver;
  105615. private _onKeyboardObserver;
  105616. private _engine;
  105617. private _scene;
  105618. /**
  105619. * Attach the input controls to a specific dom element to get the input from.
  105620. * @param element Defines the element the controls should be listened from
  105621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105622. */
  105623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105624. /**
  105625. * Detach the current controls from the specified dom element.
  105626. * @param element Defines the element to stop listening the inputs from
  105627. */
  105628. detachControl(element: Nullable<HTMLElement>): void;
  105629. /**
  105630. * Gets the class name of the current intput.
  105631. * @returns the class name
  105632. */
  105633. getClassName(): string;
  105634. /** @hidden */
  105635. _onLostFocus(e: FocusEvent): void;
  105636. /**
  105637. * Get the friendly name associated with the input class.
  105638. * @returns the input friendly name
  105639. */
  105640. getSimpleName(): string;
  105641. /**
  105642. * Update the current camera state depending on the inputs that have been used this frame.
  105643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105644. */
  105645. checkInputs(): void;
  105646. }
  105647. }
  105648. declare module BABYLON {
  105649. /**
  105650. * Manage the mouse wheel inputs to control a follow camera.
  105651. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105652. */
  105653. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  105654. /**
  105655. * Defines the camera the input is attached to.
  105656. */
  105657. camera: FollowCamera;
  105658. /**
  105659. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  105660. */
  105661. axisControlRadius: boolean;
  105662. /**
  105663. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  105664. */
  105665. axisControlHeight: boolean;
  105666. /**
  105667. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  105668. */
  105669. axisControlRotation: boolean;
  105670. /**
  105671. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  105672. * relation to mouseWheel events.
  105673. */
  105674. wheelPrecision: number;
  105675. /**
  105676. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105677. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105678. */
  105679. wheelDeltaPercentage: number;
  105680. private _wheel;
  105681. private _observer;
  105682. /**
  105683. * Attach the input controls to a specific dom element to get the input from.
  105684. * @param element Defines the element the controls should be listened from
  105685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105686. */
  105687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105688. /**
  105689. * Detach the current controls from the specified dom element.
  105690. * @param element Defines the element to stop listening the inputs from
  105691. */
  105692. detachControl(element: Nullable<HTMLElement>): void;
  105693. /**
  105694. * Gets the class name of the current intput.
  105695. * @returns the class name
  105696. */
  105697. getClassName(): string;
  105698. /**
  105699. * Get the friendly name associated with the input class.
  105700. * @returns the input friendly name
  105701. */
  105702. getSimpleName(): string;
  105703. }
  105704. }
  105705. declare module BABYLON {
  105706. /**
  105707. * Manage the pointers inputs to control an follow camera.
  105708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105709. */
  105710. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  105711. /**
  105712. * Defines the camera the input is attached to.
  105713. */
  105714. camera: FollowCamera;
  105715. /**
  105716. * Gets the class name of the current input.
  105717. * @returns the class name
  105718. */
  105719. getClassName(): string;
  105720. /**
  105721. * Defines the pointer angular sensibility along the X axis or how fast is
  105722. * the camera rotating.
  105723. * A negative number will reverse the axis direction.
  105724. */
  105725. angularSensibilityX: number;
  105726. /**
  105727. * Defines the pointer angular sensibility along the Y axis or how fast is
  105728. * the camera rotating.
  105729. * A negative number will reverse the axis direction.
  105730. */
  105731. angularSensibilityY: number;
  105732. /**
  105733. * Defines the pointer pinch precision or how fast is the camera zooming.
  105734. * A negative number will reverse the axis direction.
  105735. */
  105736. pinchPrecision: number;
  105737. /**
  105738. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  105739. * from 0.
  105740. * It defines the percentage of current camera.radius to use as delta when
  105741. * pinch zoom is used.
  105742. */
  105743. pinchDeltaPercentage: number;
  105744. /**
  105745. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  105746. */
  105747. axisXControlRadius: boolean;
  105748. /**
  105749. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  105750. */
  105751. axisXControlHeight: boolean;
  105752. /**
  105753. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  105754. */
  105755. axisXControlRotation: boolean;
  105756. /**
  105757. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  105758. */
  105759. axisYControlRadius: boolean;
  105760. /**
  105761. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  105762. */
  105763. axisYControlHeight: boolean;
  105764. /**
  105765. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  105766. */
  105767. axisYControlRotation: boolean;
  105768. /**
  105769. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  105770. */
  105771. axisPinchControlRadius: boolean;
  105772. /**
  105773. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  105774. */
  105775. axisPinchControlHeight: boolean;
  105776. /**
  105777. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  105778. */
  105779. axisPinchControlRotation: boolean;
  105780. /**
  105781. * Log error messages if basic misconfiguration has occurred.
  105782. */
  105783. warningEnable: boolean;
  105784. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105785. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105786. private _warningCounter;
  105787. private _warning;
  105788. }
  105789. }
  105790. declare module BABYLON {
  105791. /**
  105792. * Default Inputs manager for the FollowCamera.
  105793. * It groups all the default supported inputs for ease of use.
  105794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105795. */
  105796. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  105797. /**
  105798. * Instantiates a new FollowCameraInputsManager.
  105799. * @param camera Defines the camera the inputs belong to
  105800. */
  105801. constructor(camera: FollowCamera);
  105802. /**
  105803. * Add keyboard input support to the input manager.
  105804. * @returns the current input manager
  105805. */
  105806. addKeyboard(): FollowCameraInputsManager;
  105807. /**
  105808. * Add mouse wheel input support to the input manager.
  105809. * @returns the current input manager
  105810. */
  105811. addMouseWheel(): FollowCameraInputsManager;
  105812. /**
  105813. * Add pointers input support to the input manager.
  105814. * @returns the current input manager
  105815. */
  105816. addPointers(): FollowCameraInputsManager;
  105817. /**
  105818. * Add orientation input support to the input manager.
  105819. * @returns the current input manager
  105820. */
  105821. addVRDeviceOrientation(): FollowCameraInputsManager;
  105822. }
  105823. }
  105824. declare module BABYLON {
  105825. /**
  105826. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  105827. * an arc rotate version arcFollowCamera are available.
  105828. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105829. */
  105830. export class FollowCamera extends TargetCamera {
  105831. /**
  105832. * Distance the follow camera should follow an object at
  105833. */
  105834. radius: number;
  105835. /**
  105836. * Minimum allowed distance of the camera to the axis of rotation
  105837. * (The camera can not get closer).
  105838. * This can help limiting how the Camera is able to move in the scene.
  105839. */
  105840. lowerRadiusLimit: Nullable<number>;
  105841. /**
  105842. * Maximum allowed distance of the camera to the axis of rotation
  105843. * (The camera can not get further).
  105844. * This can help limiting how the Camera is able to move in the scene.
  105845. */
  105846. upperRadiusLimit: Nullable<number>;
  105847. /**
  105848. * Define a rotation offset between the camera and the object it follows
  105849. */
  105850. rotationOffset: number;
  105851. /**
  105852. * Minimum allowed angle to camera position relative to target object.
  105853. * This can help limiting how the Camera is able to move in the scene.
  105854. */
  105855. lowerRotationOffsetLimit: Nullable<number>;
  105856. /**
  105857. * Maximum allowed angle to camera position relative to target object.
  105858. * This can help limiting how the Camera is able to move in the scene.
  105859. */
  105860. upperRotationOffsetLimit: Nullable<number>;
  105861. /**
  105862. * Define a height offset between the camera and the object it follows.
  105863. * It can help following an object from the top (like a car chaing a plane)
  105864. */
  105865. heightOffset: number;
  105866. /**
  105867. * Minimum allowed height of camera position relative to target object.
  105868. * This can help limiting how the Camera is able to move in the scene.
  105869. */
  105870. lowerHeightOffsetLimit: Nullable<number>;
  105871. /**
  105872. * Maximum allowed height of camera position relative to target object.
  105873. * This can help limiting how the Camera is able to move in the scene.
  105874. */
  105875. upperHeightOffsetLimit: Nullable<number>;
  105876. /**
  105877. * Define how fast the camera can accelerate to follow it s target.
  105878. */
  105879. cameraAcceleration: number;
  105880. /**
  105881. * Define the speed limit of the camera following an object.
  105882. */
  105883. maxCameraSpeed: number;
  105884. /**
  105885. * Define the target of the camera.
  105886. */
  105887. lockedTarget: Nullable<AbstractMesh>;
  105888. /**
  105889. * Defines the input associated with the camera.
  105890. */
  105891. inputs: FollowCameraInputsManager;
  105892. /**
  105893. * Instantiates the follow camera.
  105894. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105895. * @param name Define the name of the camera in the scene
  105896. * @param position Define the position of the camera
  105897. * @param scene Define the scene the camera belong to
  105898. * @param lockedTarget Define the target of the camera
  105899. */
  105900. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  105901. private _follow;
  105902. /**
  105903. * Attached controls to the current camera.
  105904. * @param element Defines the element the controls should be listened from
  105905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105906. */
  105907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105908. /**
  105909. * Detach the current controls from the camera.
  105910. * The camera will stop reacting to inputs.
  105911. * @param element Defines the element to stop listening the inputs from
  105912. */
  105913. detachControl(element: HTMLElement): void;
  105914. /** @hidden */
  105915. _checkInputs(): void;
  105916. private _checkLimits;
  105917. /**
  105918. * Gets the camera class name.
  105919. * @returns the class name
  105920. */
  105921. getClassName(): string;
  105922. }
  105923. /**
  105924. * Arc Rotate version of the follow camera.
  105925. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  105926. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105927. */
  105928. export class ArcFollowCamera extends TargetCamera {
  105929. /** The longitudinal angle of the camera */
  105930. alpha: number;
  105931. /** The latitudinal angle of the camera */
  105932. beta: number;
  105933. /** The radius of the camera from its target */
  105934. radius: number;
  105935. /** Define the camera target (the messh it should follow) */
  105936. target: Nullable<AbstractMesh>;
  105937. private _cartesianCoordinates;
  105938. /**
  105939. * Instantiates a new ArcFollowCamera
  105940. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  105941. * @param name Define the name of the camera
  105942. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  105943. * @param beta Define the rotation angle of the camera around the elevation axis
  105944. * @param radius Define the radius of the camera from its target point
  105945. * @param target Define the target of the camera
  105946. * @param scene Define the scene the camera belongs to
  105947. */
  105948. constructor(name: string,
  105949. /** The longitudinal angle of the camera */
  105950. alpha: number,
  105951. /** The latitudinal angle of the camera */
  105952. beta: number,
  105953. /** The radius of the camera from its target */
  105954. radius: number,
  105955. /** Define the camera target (the messh it should follow) */
  105956. target: Nullable<AbstractMesh>, scene: Scene);
  105957. private _follow;
  105958. /** @hidden */
  105959. _checkInputs(): void;
  105960. /**
  105961. * Returns the class name of the object.
  105962. * It is mostly used internally for serialization purposes.
  105963. */
  105964. getClassName(): string;
  105965. }
  105966. }
  105967. declare module BABYLON {
  105968. /**
  105969. * Manage the keyboard inputs to control the movement of a follow camera.
  105970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105971. */
  105972. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  105973. /**
  105974. * Defines the camera the input is attached to.
  105975. */
  105976. camera: FollowCamera;
  105977. /**
  105978. * Defines the list of key codes associated with the up action (increase heightOffset)
  105979. */
  105980. keysHeightOffsetIncr: number[];
  105981. /**
  105982. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105983. */
  105984. keysHeightOffsetDecr: number[];
  105985. /**
  105986. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105987. */
  105988. keysHeightOffsetModifierAlt: boolean;
  105989. /**
  105990. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105991. */
  105992. keysHeightOffsetModifierCtrl: boolean;
  105993. /**
  105994. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105995. */
  105996. keysHeightOffsetModifierShift: boolean;
  105997. /**
  105998. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105999. */
  106000. keysRotationOffsetIncr: number[];
  106001. /**
  106002. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  106003. */
  106004. keysRotationOffsetDecr: number[];
  106005. /**
  106006. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  106007. */
  106008. keysRotationOffsetModifierAlt: boolean;
  106009. /**
  106010. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  106011. */
  106012. keysRotationOffsetModifierCtrl: boolean;
  106013. /**
  106014. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  106015. */
  106016. keysRotationOffsetModifierShift: boolean;
  106017. /**
  106018. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  106019. */
  106020. keysRadiusIncr: number[];
  106021. /**
  106022. * Defines the list of key codes associated with the zoom-out action (increase radius)
  106023. */
  106024. keysRadiusDecr: number[];
  106025. /**
  106026. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  106027. */
  106028. keysRadiusModifierAlt: boolean;
  106029. /**
  106030. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  106031. */
  106032. keysRadiusModifierCtrl: boolean;
  106033. /**
  106034. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  106035. */
  106036. keysRadiusModifierShift: boolean;
  106037. /**
  106038. * Defines the rate of change of heightOffset.
  106039. */
  106040. heightSensibility: number;
  106041. /**
  106042. * Defines the rate of change of rotationOffset.
  106043. */
  106044. rotationSensibility: number;
  106045. /**
  106046. * Defines the rate of change of radius.
  106047. */
  106048. radiusSensibility: number;
  106049. private _keys;
  106050. private _ctrlPressed;
  106051. private _altPressed;
  106052. private _shiftPressed;
  106053. private _onCanvasBlurObserver;
  106054. private _onKeyboardObserver;
  106055. private _engine;
  106056. private _scene;
  106057. /**
  106058. * Attach the input controls to a specific dom element to get the input from.
  106059. * @param element Defines the element the controls should be listened from
  106060. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106061. */
  106062. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106063. /**
  106064. * Detach the current controls from the specified dom element.
  106065. * @param element Defines the element to stop listening the inputs from
  106066. */
  106067. detachControl(element: Nullable<HTMLElement>): void;
  106068. /**
  106069. * Update the current camera state depending on the inputs that have been used this frame.
  106070. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106071. */
  106072. checkInputs(): void;
  106073. /**
  106074. * Gets the class name of the current input.
  106075. * @returns the class name
  106076. */
  106077. getClassName(): string;
  106078. /**
  106079. * Get the friendly name associated with the input class.
  106080. * @returns the input friendly name
  106081. */
  106082. getSimpleName(): string;
  106083. /**
  106084. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106085. * allow modification of the heightOffset value.
  106086. */
  106087. private _modifierHeightOffset;
  106088. /**
  106089. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106090. * allow modification of the rotationOffset value.
  106091. */
  106092. private _modifierRotationOffset;
  106093. /**
  106094. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  106095. * allow modification of the radius value.
  106096. */
  106097. private _modifierRadius;
  106098. }
  106099. }
  106100. declare module BABYLON {
  106101. interface FreeCameraInputsManager {
  106102. /**
  106103. * @hidden
  106104. */
  106105. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  106106. /**
  106107. * Add orientation input support to the input manager.
  106108. * @returns the current input manager
  106109. */
  106110. addDeviceOrientation(): FreeCameraInputsManager;
  106111. }
  106112. /**
  106113. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  106114. * Screen rotation is taken into account.
  106115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106116. */
  106117. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  106118. private _camera;
  106119. private _screenOrientationAngle;
  106120. private _constantTranform;
  106121. private _screenQuaternion;
  106122. private _alpha;
  106123. private _beta;
  106124. private _gamma;
  106125. /**
  106126. * Can be used to detect if a device orientation sensor is availible on a device
  106127. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  106128. * @returns a promise that will resolve on orientation change
  106129. */
  106130. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  106131. /**
  106132. * @hidden
  106133. */
  106134. _onDeviceOrientationChangedObservable: Observable<void>;
  106135. /**
  106136. * Instantiates a new input
  106137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106138. */
  106139. constructor();
  106140. /**
  106141. * Define the camera controlled by the input.
  106142. */
  106143. camera: FreeCamera;
  106144. /**
  106145. * Attach the input controls to a specific dom element to get the input from.
  106146. * @param element Defines the element the controls should be listened from
  106147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106148. */
  106149. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106150. private _orientationChanged;
  106151. private _deviceOrientation;
  106152. /**
  106153. * Detach the current controls from the specified dom element.
  106154. * @param element Defines the element to stop listening the inputs from
  106155. */
  106156. detachControl(element: Nullable<HTMLElement>): void;
  106157. /**
  106158. * Update the current camera state depending on the inputs that have been used this frame.
  106159. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106160. */
  106161. checkInputs(): void;
  106162. /**
  106163. * Gets the class name of the current intput.
  106164. * @returns the class name
  106165. */
  106166. getClassName(): string;
  106167. /**
  106168. * Get the friendly name associated with the input class.
  106169. * @returns the input friendly name
  106170. */
  106171. getSimpleName(): string;
  106172. }
  106173. }
  106174. declare module BABYLON {
  106175. /**
  106176. * Manage the gamepad inputs to control a free camera.
  106177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106178. */
  106179. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  106180. /**
  106181. * Define the camera the input is attached to.
  106182. */
  106183. camera: FreeCamera;
  106184. /**
  106185. * Define the Gamepad controlling the input
  106186. */
  106187. gamepad: Nullable<Gamepad>;
  106188. /**
  106189. * Defines the gamepad rotation sensiblity.
  106190. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106191. */
  106192. gamepadAngularSensibility: number;
  106193. /**
  106194. * Defines the gamepad move sensiblity.
  106195. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106196. */
  106197. gamepadMoveSensibility: number;
  106198. private _yAxisScale;
  106199. /**
  106200. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106201. */
  106202. invertYAxis: boolean;
  106203. private _onGamepadConnectedObserver;
  106204. private _onGamepadDisconnectedObserver;
  106205. private _cameraTransform;
  106206. private _deltaTransform;
  106207. private _vector3;
  106208. private _vector2;
  106209. /**
  106210. * Attach the input controls to a specific dom element to get the input from.
  106211. * @param element Defines the element the controls should be listened from
  106212. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106213. */
  106214. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106215. /**
  106216. * Detach the current controls from the specified dom element.
  106217. * @param element Defines the element to stop listening the inputs from
  106218. */
  106219. detachControl(element: Nullable<HTMLElement>): void;
  106220. /**
  106221. * Update the current camera state depending on the inputs that have been used this frame.
  106222. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106223. */
  106224. checkInputs(): void;
  106225. /**
  106226. * Gets the class name of the current intput.
  106227. * @returns the class name
  106228. */
  106229. getClassName(): string;
  106230. /**
  106231. * Get the friendly name associated with the input class.
  106232. * @returns the input friendly name
  106233. */
  106234. getSimpleName(): string;
  106235. }
  106236. }
  106237. declare module BABYLON {
  106238. /**
  106239. * Defines the potential axis of a Joystick
  106240. */
  106241. export enum JoystickAxis {
  106242. /** X axis */
  106243. X = 0,
  106244. /** Y axis */
  106245. Y = 1,
  106246. /** Z axis */
  106247. Z = 2
  106248. }
  106249. /**
  106250. * Class used to define virtual joystick (used in touch mode)
  106251. */
  106252. export class VirtualJoystick {
  106253. /**
  106254. * Gets or sets a boolean indicating that left and right values must be inverted
  106255. */
  106256. reverseLeftRight: boolean;
  106257. /**
  106258. * Gets or sets a boolean indicating that up and down values must be inverted
  106259. */
  106260. reverseUpDown: boolean;
  106261. /**
  106262. * Gets the offset value for the position (ie. the change of the position value)
  106263. */
  106264. deltaPosition: Vector3;
  106265. /**
  106266. * Gets a boolean indicating if the virtual joystick was pressed
  106267. */
  106268. pressed: boolean;
  106269. /**
  106270. * Canvas the virtual joystick will render onto, default z-index of this is 5
  106271. */
  106272. static Canvas: Nullable<HTMLCanvasElement>;
  106273. private static _globalJoystickIndex;
  106274. private static vjCanvasContext;
  106275. private static vjCanvasWidth;
  106276. private static vjCanvasHeight;
  106277. private static halfWidth;
  106278. private _action;
  106279. private _axisTargetedByLeftAndRight;
  106280. private _axisTargetedByUpAndDown;
  106281. private _joystickSensibility;
  106282. private _inversedSensibility;
  106283. private _joystickPointerID;
  106284. private _joystickColor;
  106285. private _joystickPointerPos;
  106286. private _joystickPreviousPointerPos;
  106287. private _joystickPointerStartPos;
  106288. private _deltaJoystickVector;
  106289. private _leftJoystick;
  106290. private _touches;
  106291. private _onPointerDownHandlerRef;
  106292. private _onPointerMoveHandlerRef;
  106293. private _onPointerUpHandlerRef;
  106294. private _onResize;
  106295. /**
  106296. * Creates a new virtual joystick
  106297. * @param leftJoystick defines that the joystick is for left hand (false by default)
  106298. */
  106299. constructor(leftJoystick?: boolean);
  106300. /**
  106301. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  106302. * @param newJoystickSensibility defines the new sensibility
  106303. */
  106304. setJoystickSensibility(newJoystickSensibility: number): void;
  106305. private _onPointerDown;
  106306. private _onPointerMove;
  106307. private _onPointerUp;
  106308. /**
  106309. * Change the color of the virtual joystick
  106310. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  106311. */
  106312. setJoystickColor(newColor: string): void;
  106313. /**
  106314. * Defines a callback to call when the joystick is touched
  106315. * @param action defines the callback
  106316. */
  106317. setActionOnTouch(action: () => any): void;
  106318. /**
  106319. * Defines which axis you'd like to control for left & right
  106320. * @param axis defines the axis to use
  106321. */
  106322. setAxisForLeftRight(axis: JoystickAxis): void;
  106323. /**
  106324. * Defines which axis you'd like to control for up & down
  106325. * @param axis defines the axis to use
  106326. */
  106327. setAxisForUpDown(axis: JoystickAxis): void;
  106328. private _drawVirtualJoystick;
  106329. /**
  106330. * Release internal HTML canvas
  106331. */
  106332. releaseCanvas(): void;
  106333. }
  106334. }
  106335. declare module BABYLON {
  106336. interface FreeCameraInputsManager {
  106337. /**
  106338. * Add virtual joystick input support to the input manager.
  106339. * @returns the current input manager
  106340. */
  106341. addVirtualJoystick(): FreeCameraInputsManager;
  106342. }
  106343. /**
  106344. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  106345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106346. */
  106347. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  106348. /**
  106349. * Defines the camera the input is attached to.
  106350. */
  106351. camera: FreeCamera;
  106352. private _leftjoystick;
  106353. private _rightjoystick;
  106354. /**
  106355. * Gets the left stick of the virtual joystick.
  106356. * @returns The virtual Joystick
  106357. */
  106358. getLeftJoystick(): VirtualJoystick;
  106359. /**
  106360. * Gets the right stick of the virtual joystick.
  106361. * @returns The virtual Joystick
  106362. */
  106363. getRightJoystick(): VirtualJoystick;
  106364. /**
  106365. * Update the current camera state depending on the inputs that have been used this frame.
  106366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106367. */
  106368. checkInputs(): void;
  106369. /**
  106370. * Attach the input controls to a specific dom element to get the input from.
  106371. * @param element Defines the element the controls should be listened from
  106372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106373. */
  106374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106375. /**
  106376. * Detach the current controls from the specified dom element.
  106377. * @param element Defines the element to stop listening the inputs from
  106378. */
  106379. detachControl(element: Nullable<HTMLElement>): void;
  106380. /**
  106381. * Gets the class name of the current intput.
  106382. * @returns the class name
  106383. */
  106384. getClassName(): string;
  106385. /**
  106386. * Get the friendly name associated with the input class.
  106387. * @returns the input friendly name
  106388. */
  106389. getSimpleName(): string;
  106390. }
  106391. }
  106392. declare module BABYLON {
  106393. /**
  106394. * This represents a FPS type of camera controlled by touch.
  106395. * This is like a universal camera minus the Gamepad controls.
  106396. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106397. */
  106398. export class TouchCamera extends FreeCamera {
  106399. /**
  106400. * Defines the touch sensibility for rotation.
  106401. * The higher the faster.
  106402. */
  106403. touchAngularSensibility: number;
  106404. /**
  106405. * Defines the touch sensibility for move.
  106406. * The higher the faster.
  106407. */
  106408. touchMoveSensibility: number;
  106409. /**
  106410. * Instantiates a new touch camera.
  106411. * This represents a FPS type of camera controlled by touch.
  106412. * This is like a universal camera minus the Gamepad controls.
  106413. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106414. * @param name Define the name of the camera in the scene
  106415. * @param position Define the start position of the camera in the scene
  106416. * @param scene Define the scene the camera belongs to
  106417. */
  106418. constructor(name: string, position: Vector3, scene: Scene);
  106419. /**
  106420. * Gets the current object class name.
  106421. * @return the class name
  106422. */
  106423. getClassName(): string;
  106424. /** @hidden */
  106425. _setupInputs(): void;
  106426. }
  106427. }
  106428. declare module BABYLON {
  106429. /**
  106430. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  106431. * being tilted forward or back and left or right.
  106432. */
  106433. export class DeviceOrientationCamera extends FreeCamera {
  106434. private _initialQuaternion;
  106435. private _quaternionCache;
  106436. private _tmpDragQuaternion;
  106437. private _disablePointerInputWhenUsingDeviceOrientation;
  106438. /**
  106439. * Creates a new device orientation camera
  106440. * @param name The name of the camera
  106441. * @param position The start position camera
  106442. * @param scene The scene the camera belongs to
  106443. */
  106444. constructor(name: string, position: Vector3, scene: Scene);
  106445. /**
  106446. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  106447. */
  106448. disablePointerInputWhenUsingDeviceOrientation: boolean;
  106449. private _dragFactor;
  106450. /**
  106451. * Enabled turning on the y axis when the orientation sensor is active
  106452. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  106453. */
  106454. enableHorizontalDragging(dragFactor?: number): void;
  106455. /**
  106456. * Gets the current instance class name ("DeviceOrientationCamera").
  106457. * This helps avoiding instanceof at run time.
  106458. * @returns the class name
  106459. */
  106460. getClassName(): string;
  106461. /**
  106462. * @hidden
  106463. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  106464. */
  106465. _checkInputs(): void;
  106466. /**
  106467. * Reset the camera to its default orientation on the specified axis only.
  106468. * @param axis The axis to reset
  106469. */
  106470. resetToCurrentRotation(axis?: Axis): void;
  106471. }
  106472. }
  106473. declare module BABYLON {
  106474. /**
  106475. * Defines supported buttons for XBox360 compatible gamepads
  106476. */
  106477. export enum Xbox360Button {
  106478. /** A */
  106479. A = 0,
  106480. /** B */
  106481. B = 1,
  106482. /** X */
  106483. X = 2,
  106484. /** Y */
  106485. Y = 3,
  106486. /** Start */
  106487. Start = 4,
  106488. /** Back */
  106489. Back = 5,
  106490. /** Left button */
  106491. LB = 6,
  106492. /** Right button */
  106493. RB = 7,
  106494. /** Left stick */
  106495. LeftStick = 8,
  106496. /** Right stick */
  106497. RightStick = 9
  106498. }
  106499. /** Defines values for XBox360 DPad */
  106500. export enum Xbox360Dpad {
  106501. /** Up */
  106502. Up = 0,
  106503. /** Down */
  106504. Down = 1,
  106505. /** Left */
  106506. Left = 2,
  106507. /** Right */
  106508. Right = 3
  106509. }
  106510. /**
  106511. * Defines a XBox360 gamepad
  106512. */
  106513. export class Xbox360Pad extends Gamepad {
  106514. private _leftTrigger;
  106515. private _rightTrigger;
  106516. private _onlefttriggerchanged;
  106517. private _onrighttriggerchanged;
  106518. private _onbuttondown;
  106519. private _onbuttonup;
  106520. private _ondpaddown;
  106521. private _ondpadup;
  106522. /** Observable raised when a button is pressed */
  106523. onButtonDownObservable: Observable<Xbox360Button>;
  106524. /** Observable raised when a button is released */
  106525. onButtonUpObservable: Observable<Xbox360Button>;
  106526. /** Observable raised when a pad is pressed */
  106527. onPadDownObservable: Observable<Xbox360Dpad>;
  106528. /** Observable raised when a pad is released */
  106529. onPadUpObservable: Observable<Xbox360Dpad>;
  106530. private _buttonA;
  106531. private _buttonB;
  106532. private _buttonX;
  106533. private _buttonY;
  106534. private _buttonBack;
  106535. private _buttonStart;
  106536. private _buttonLB;
  106537. private _buttonRB;
  106538. private _buttonLeftStick;
  106539. private _buttonRightStick;
  106540. private _dPadUp;
  106541. private _dPadDown;
  106542. private _dPadLeft;
  106543. private _dPadRight;
  106544. private _isXboxOnePad;
  106545. /**
  106546. * Creates a new XBox360 gamepad object
  106547. * @param id defines the id of this gamepad
  106548. * @param index defines its index
  106549. * @param gamepad defines the internal HTML gamepad object
  106550. * @param xboxOne defines if it is a XBox One gamepad
  106551. */
  106552. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  106553. /**
  106554. * Defines the callback to call when left trigger is pressed
  106555. * @param callback defines the callback to use
  106556. */
  106557. onlefttriggerchanged(callback: (value: number) => void): void;
  106558. /**
  106559. * Defines the callback to call when right trigger is pressed
  106560. * @param callback defines the callback to use
  106561. */
  106562. onrighttriggerchanged(callback: (value: number) => void): void;
  106563. /**
  106564. * Gets the left trigger value
  106565. */
  106566. /**
  106567. * Sets the left trigger value
  106568. */
  106569. leftTrigger: number;
  106570. /**
  106571. * Gets the right trigger value
  106572. */
  106573. /**
  106574. * Sets the right trigger value
  106575. */
  106576. rightTrigger: number;
  106577. /**
  106578. * Defines the callback to call when a button is pressed
  106579. * @param callback defines the callback to use
  106580. */
  106581. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  106582. /**
  106583. * Defines the callback to call when a button is released
  106584. * @param callback defines the callback to use
  106585. */
  106586. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  106587. /**
  106588. * Defines the callback to call when a pad is pressed
  106589. * @param callback defines the callback to use
  106590. */
  106591. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  106592. /**
  106593. * Defines the callback to call when a pad is released
  106594. * @param callback defines the callback to use
  106595. */
  106596. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  106597. private _setButtonValue;
  106598. private _setDPadValue;
  106599. /**
  106600. * Gets the value of the `A` button
  106601. */
  106602. /**
  106603. * Sets the value of the `A` button
  106604. */
  106605. buttonA: number;
  106606. /**
  106607. * Gets the value of the `B` button
  106608. */
  106609. /**
  106610. * Sets the value of the `B` button
  106611. */
  106612. buttonB: number;
  106613. /**
  106614. * Gets the value of the `X` button
  106615. */
  106616. /**
  106617. * Sets the value of the `X` button
  106618. */
  106619. buttonX: number;
  106620. /**
  106621. * Gets the value of the `Y` button
  106622. */
  106623. /**
  106624. * Sets the value of the `Y` button
  106625. */
  106626. buttonY: number;
  106627. /**
  106628. * Gets the value of the `Start` button
  106629. */
  106630. /**
  106631. * Sets the value of the `Start` button
  106632. */
  106633. buttonStart: number;
  106634. /**
  106635. * Gets the value of the `Back` button
  106636. */
  106637. /**
  106638. * Sets the value of the `Back` button
  106639. */
  106640. buttonBack: number;
  106641. /**
  106642. * Gets the value of the `Left` button
  106643. */
  106644. /**
  106645. * Sets the value of the `Left` button
  106646. */
  106647. buttonLB: number;
  106648. /**
  106649. * Gets the value of the `Right` button
  106650. */
  106651. /**
  106652. * Sets the value of the `Right` button
  106653. */
  106654. buttonRB: number;
  106655. /**
  106656. * Gets the value of the Left joystick
  106657. */
  106658. /**
  106659. * Sets the value of the Left joystick
  106660. */
  106661. buttonLeftStick: number;
  106662. /**
  106663. * Gets the value of the Right joystick
  106664. */
  106665. /**
  106666. * Sets the value of the Right joystick
  106667. */
  106668. buttonRightStick: number;
  106669. /**
  106670. * Gets the value of D-pad up
  106671. */
  106672. /**
  106673. * Sets the value of D-pad up
  106674. */
  106675. dPadUp: number;
  106676. /**
  106677. * Gets the value of D-pad down
  106678. */
  106679. /**
  106680. * Sets the value of D-pad down
  106681. */
  106682. dPadDown: number;
  106683. /**
  106684. * Gets the value of D-pad left
  106685. */
  106686. /**
  106687. * Sets the value of D-pad left
  106688. */
  106689. dPadLeft: number;
  106690. /**
  106691. * Gets the value of D-pad right
  106692. */
  106693. /**
  106694. * Sets the value of D-pad right
  106695. */
  106696. dPadRight: number;
  106697. /**
  106698. * Force the gamepad to synchronize with device values
  106699. */
  106700. update(): void;
  106701. /**
  106702. * Disposes the gamepad
  106703. */
  106704. dispose(): void;
  106705. }
  106706. }
  106707. declare module BABYLON {
  106708. /**
  106709. * Defines supported buttons for DualShock compatible gamepads
  106710. */
  106711. export enum DualShockButton {
  106712. /** Cross */
  106713. Cross = 0,
  106714. /** Circle */
  106715. Circle = 1,
  106716. /** Square */
  106717. Square = 2,
  106718. /** Triangle */
  106719. Triangle = 3,
  106720. /** Options */
  106721. Options = 4,
  106722. /** Share */
  106723. Share = 5,
  106724. /** L1 */
  106725. L1 = 6,
  106726. /** R1 */
  106727. R1 = 7,
  106728. /** Left stick */
  106729. LeftStick = 8,
  106730. /** Right stick */
  106731. RightStick = 9
  106732. }
  106733. /** Defines values for DualShock DPad */
  106734. export enum DualShockDpad {
  106735. /** Up */
  106736. Up = 0,
  106737. /** Down */
  106738. Down = 1,
  106739. /** Left */
  106740. Left = 2,
  106741. /** Right */
  106742. Right = 3
  106743. }
  106744. /**
  106745. * Defines a DualShock gamepad
  106746. */
  106747. export class DualShockPad extends Gamepad {
  106748. private _leftTrigger;
  106749. private _rightTrigger;
  106750. private _onlefttriggerchanged;
  106751. private _onrighttriggerchanged;
  106752. private _onbuttondown;
  106753. private _onbuttonup;
  106754. private _ondpaddown;
  106755. private _ondpadup;
  106756. /** Observable raised when a button is pressed */
  106757. onButtonDownObservable: Observable<DualShockButton>;
  106758. /** Observable raised when a button is released */
  106759. onButtonUpObservable: Observable<DualShockButton>;
  106760. /** Observable raised when a pad is pressed */
  106761. onPadDownObservable: Observable<DualShockDpad>;
  106762. /** Observable raised when a pad is released */
  106763. onPadUpObservable: Observable<DualShockDpad>;
  106764. private _buttonCross;
  106765. private _buttonCircle;
  106766. private _buttonSquare;
  106767. private _buttonTriangle;
  106768. private _buttonShare;
  106769. private _buttonOptions;
  106770. private _buttonL1;
  106771. private _buttonR1;
  106772. private _buttonLeftStick;
  106773. private _buttonRightStick;
  106774. private _dPadUp;
  106775. private _dPadDown;
  106776. private _dPadLeft;
  106777. private _dPadRight;
  106778. /**
  106779. * Creates a new DualShock gamepad object
  106780. * @param id defines the id of this gamepad
  106781. * @param index defines its index
  106782. * @param gamepad defines the internal HTML gamepad object
  106783. */
  106784. constructor(id: string, index: number, gamepad: any);
  106785. /**
  106786. * Defines the callback to call when left trigger is pressed
  106787. * @param callback defines the callback to use
  106788. */
  106789. onlefttriggerchanged(callback: (value: number) => void): void;
  106790. /**
  106791. * Defines the callback to call when right trigger is pressed
  106792. * @param callback defines the callback to use
  106793. */
  106794. onrighttriggerchanged(callback: (value: number) => void): void;
  106795. /**
  106796. * Gets the left trigger value
  106797. */
  106798. /**
  106799. * Sets the left trigger value
  106800. */
  106801. leftTrigger: number;
  106802. /**
  106803. * Gets the right trigger value
  106804. */
  106805. /**
  106806. * Sets the right trigger value
  106807. */
  106808. rightTrigger: number;
  106809. /**
  106810. * Defines the callback to call when a button is pressed
  106811. * @param callback defines the callback to use
  106812. */
  106813. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  106814. /**
  106815. * Defines the callback to call when a button is released
  106816. * @param callback defines the callback to use
  106817. */
  106818. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  106819. /**
  106820. * Defines the callback to call when a pad is pressed
  106821. * @param callback defines the callback to use
  106822. */
  106823. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  106824. /**
  106825. * Defines the callback to call when a pad is released
  106826. * @param callback defines the callback to use
  106827. */
  106828. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  106829. private _setButtonValue;
  106830. private _setDPadValue;
  106831. /**
  106832. * Gets the value of the `Cross` button
  106833. */
  106834. /**
  106835. * Sets the value of the `Cross` button
  106836. */
  106837. buttonCross: number;
  106838. /**
  106839. * Gets the value of the `Circle` button
  106840. */
  106841. /**
  106842. * Sets the value of the `Circle` button
  106843. */
  106844. buttonCircle: number;
  106845. /**
  106846. * Gets the value of the `Square` button
  106847. */
  106848. /**
  106849. * Sets the value of the `Square` button
  106850. */
  106851. buttonSquare: number;
  106852. /**
  106853. * Gets the value of the `Triangle` button
  106854. */
  106855. /**
  106856. * Sets the value of the `Triangle` button
  106857. */
  106858. buttonTriangle: number;
  106859. /**
  106860. * Gets the value of the `Options` button
  106861. */
  106862. /**
  106863. * Sets the value of the `Options` button
  106864. */
  106865. buttonOptions: number;
  106866. /**
  106867. * Gets the value of the `Share` button
  106868. */
  106869. /**
  106870. * Sets the value of the `Share` button
  106871. */
  106872. buttonShare: number;
  106873. /**
  106874. * Gets the value of the `L1` button
  106875. */
  106876. /**
  106877. * Sets the value of the `L1` button
  106878. */
  106879. buttonL1: number;
  106880. /**
  106881. * Gets the value of the `R1` button
  106882. */
  106883. /**
  106884. * Sets the value of the `R1` button
  106885. */
  106886. buttonR1: number;
  106887. /**
  106888. * Gets the value of the Left joystick
  106889. */
  106890. /**
  106891. * Sets the value of the Left joystick
  106892. */
  106893. buttonLeftStick: number;
  106894. /**
  106895. * Gets the value of the Right joystick
  106896. */
  106897. /**
  106898. * Sets the value of the Right joystick
  106899. */
  106900. buttonRightStick: number;
  106901. /**
  106902. * Gets the value of D-pad up
  106903. */
  106904. /**
  106905. * Sets the value of D-pad up
  106906. */
  106907. dPadUp: number;
  106908. /**
  106909. * Gets the value of D-pad down
  106910. */
  106911. /**
  106912. * Sets the value of D-pad down
  106913. */
  106914. dPadDown: number;
  106915. /**
  106916. * Gets the value of D-pad left
  106917. */
  106918. /**
  106919. * Sets the value of D-pad left
  106920. */
  106921. dPadLeft: number;
  106922. /**
  106923. * Gets the value of D-pad right
  106924. */
  106925. /**
  106926. * Sets the value of D-pad right
  106927. */
  106928. dPadRight: number;
  106929. /**
  106930. * Force the gamepad to synchronize with device values
  106931. */
  106932. update(): void;
  106933. /**
  106934. * Disposes the gamepad
  106935. */
  106936. dispose(): void;
  106937. }
  106938. }
  106939. declare module BABYLON {
  106940. /**
  106941. * Manager for handling gamepads
  106942. */
  106943. export class GamepadManager {
  106944. private _scene?;
  106945. private _babylonGamepads;
  106946. private _oneGamepadConnected;
  106947. /** @hidden */
  106948. _isMonitoring: boolean;
  106949. private _gamepadEventSupported;
  106950. private _gamepadSupport;
  106951. /**
  106952. * observable to be triggered when the gamepad controller has been connected
  106953. */
  106954. onGamepadConnectedObservable: Observable<Gamepad>;
  106955. /**
  106956. * observable to be triggered when the gamepad controller has been disconnected
  106957. */
  106958. onGamepadDisconnectedObservable: Observable<Gamepad>;
  106959. private _onGamepadConnectedEvent;
  106960. private _onGamepadDisconnectedEvent;
  106961. /**
  106962. * Initializes the gamepad manager
  106963. * @param _scene BabylonJS scene
  106964. */
  106965. constructor(_scene?: Scene | undefined);
  106966. /**
  106967. * The gamepads in the game pad manager
  106968. */
  106969. readonly gamepads: Gamepad[];
  106970. /**
  106971. * Get the gamepad controllers based on type
  106972. * @param type The type of gamepad controller
  106973. * @returns Nullable gamepad
  106974. */
  106975. getGamepadByType(type?: number): Nullable<Gamepad>;
  106976. /**
  106977. * Disposes the gamepad manager
  106978. */
  106979. dispose(): void;
  106980. private _addNewGamepad;
  106981. private _startMonitoringGamepads;
  106982. private _stopMonitoringGamepads;
  106983. /** @hidden */
  106984. _checkGamepadsStatus(): void;
  106985. private _updateGamepadObjects;
  106986. }
  106987. }
  106988. declare module BABYLON {
  106989. interface Scene {
  106990. /** @hidden */
  106991. _gamepadManager: Nullable<GamepadManager>;
  106992. /**
  106993. * Gets the gamepad manager associated with the scene
  106994. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106995. */
  106996. gamepadManager: GamepadManager;
  106997. }
  106998. /**
  106999. * Interface representing a free camera inputs manager
  107000. */
  107001. interface FreeCameraInputsManager {
  107002. /**
  107003. * Adds gamepad input support to the FreeCameraInputsManager.
  107004. * @returns the FreeCameraInputsManager
  107005. */
  107006. addGamepad(): FreeCameraInputsManager;
  107007. }
  107008. /**
  107009. * Interface representing an arc rotate camera inputs manager
  107010. */
  107011. interface ArcRotateCameraInputsManager {
  107012. /**
  107013. * Adds gamepad input support to the ArcRotateCamera InputManager.
  107014. * @returns the camera inputs manager
  107015. */
  107016. addGamepad(): ArcRotateCameraInputsManager;
  107017. }
  107018. /**
  107019. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  107020. */
  107021. export class GamepadSystemSceneComponent implements ISceneComponent {
  107022. /**
  107023. * The component name helpfull to identify the component in the list of scene components.
  107024. */
  107025. readonly name: string;
  107026. /**
  107027. * The scene the component belongs to.
  107028. */
  107029. scene: Scene;
  107030. /**
  107031. * Creates a new instance of the component for the given scene
  107032. * @param scene Defines the scene to register the component in
  107033. */
  107034. constructor(scene: Scene);
  107035. /**
  107036. * Registers the component in a given scene
  107037. */
  107038. register(): void;
  107039. /**
  107040. * Rebuilds the elements related to this component in case of
  107041. * context lost for instance.
  107042. */
  107043. rebuild(): void;
  107044. /**
  107045. * Disposes the component and the associated ressources
  107046. */
  107047. dispose(): void;
  107048. private _beforeCameraUpdate;
  107049. }
  107050. }
  107051. declare module BABYLON {
  107052. /**
  107053. * 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,
  107054. * which still works and will still be found in many Playgrounds.
  107055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107056. */
  107057. export class UniversalCamera extends TouchCamera {
  107058. /**
  107059. * Defines the gamepad rotation sensiblity.
  107060. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107061. */
  107062. gamepadAngularSensibility: number;
  107063. /**
  107064. * Defines the gamepad move sensiblity.
  107065. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107066. */
  107067. gamepadMoveSensibility: number;
  107068. /**
  107069. * 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,
  107070. * which still works and will still be found in many Playgrounds.
  107071. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107072. * @param name Define the name of the camera in the scene
  107073. * @param position Define the start position of the camera in the scene
  107074. * @param scene Define the scene the camera belongs to
  107075. */
  107076. constructor(name: string, position: Vector3, scene: Scene);
  107077. /**
  107078. * Gets the current object class name.
  107079. * @return the class name
  107080. */
  107081. getClassName(): string;
  107082. }
  107083. }
  107084. declare module BABYLON {
  107085. /**
  107086. * This represents a FPS type of camera. This is only here for back compat purpose.
  107087. * Please use the UniversalCamera instead as both are identical.
  107088. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107089. */
  107090. export class GamepadCamera extends UniversalCamera {
  107091. /**
  107092. * Instantiates a new Gamepad Camera
  107093. * This represents a FPS type of camera. This is only here for back compat purpose.
  107094. * Please use the UniversalCamera instead as both are identical.
  107095. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107096. * @param name Define the name of the camera in the scene
  107097. * @param position Define the start position of the camera in the scene
  107098. * @param scene Define the scene the camera belongs to
  107099. */
  107100. constructor(name: string, position: Vector3, scene: Scene);
  107101. /**
  107102. * Gets the current object class name.
  107103. * @return the class name
  107104. */
  107105. getClassName(): string;
  107106. }
  107107. }
  107108. declare module BABYLON {
  107109. /** @hidden */
  107110. export var passPixelShader: {
  107111. name: string;
  107112. shader: string;
  107113. };
  107114. }
  107115. declare module BABYLON {
  107116. /** @hidden */
  107117. export var passCubePixelShader: {
  107118. name: string;
  107119. shader: string;
  107120. };
  107121. }
  107122. declare module BABYLON {
  107123. /**
  107124. * PassPostProcess which produces an output the same as it's input
  107125. */
  107126. export class PassPostProcess extends PostProcess {
  107127. /**
  107128. * Creates the PassPostProcess
  107129. * @param name The name of the effect.
  107130. * @param options The required width/height ratio to downsize to before computing the render pass.
  107131. * @param camera The camera to apply the render pass to.
  107132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107133. * @param engine The engine which the post process will be applied. (default: current engine)
  107134. * @param reusable If the post process can be reused on the same frame. (default: false)
  107135. * @param textureType The type of texture to be used when performing the post processing.
  107136. * @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)
  107137. */
  107138. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107139. }
  107140. /**
  107141. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  107142. */
  107143. export class PassCubePostProcess extends PostProcess {
  107144. private _face;
  107145. /**
  107146. * Gets or sets the cube face to display.
  107147. * * 0 is +X
  107148. * * 1 is -X
  107149. * * 2 is +Y
  107150. * * 3 is -Y
  107151. * * 4 is +Z
  107152. * * 5 is -Z
  107153. */
  107154. face: number;
  107155. /**
  107156. * Creates the PassCubePostProcess
  107157. * @param name The name of the effect.
  107158. * @param options The required width/height ratio to downsize to before computing the render pass.
  107159. * @param camera The camera to apply the render pass to.
  107160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107161. * @param engine The engine which the post process will be applied. (default: current engine)
  107162. * @param reusable If the post process can be reused on the same frame. (default: false)
  107163. * @param textureType The type of texture to be used when performing the post processing.
  107164. * @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)
  107165. */
  107166. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  107167. }
  107168. }
  107169. declare module BABYLON {
  107170. /** @hidden */
  107171. export var anaglyphPixelShader: {
  107172. name: string;
  107173. shader: string;
  107174. };
  107175. }
  107176. declare module BABYLON {
  107177. /**
  107178. * Postprocess used to generate anaglyphic rendering
  107179. */
  107180. export class AnaglyphPostProcess extends PostProcess {
  107181. private _passedProcess;
  107182. /**
  107183. * Creates a new AnaglyphPostProcess
  107184. * @param name defines postprocess name
  107185. * @param options defines creation options or target ratio scale
  107186. * @param rigCameras defines cameras using this postprocess
  107187. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  107188. * @param engine defines hosting engine
  107189. * @param reusable defines if the postprocess will be reused multiple times per frame
  107190. */
  107191. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  107192. }
  107193. }
  107194. declare module BABYLON {
  107195. /**
  107196. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  107197. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107198. */
  107199. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  107200. /**
  107201. * Creates a new AnaglyphArcRotateCamera
  107202. * @param name defines camera name
  107203. * @param alpha defines alpha angle (in radians)
  107204. * @param beta defines beta angle (in radians)
  107205. * @param radius defines radius
  107206. * @param target defines camera target
  107207. * @param interaxialDistance defines distance between each color axis
  107208. * @param scene defines the hosting scene
  107209. */
  107210. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  107211. /**
  107212. * Gets camera class name
  107213. * @returns AnaglyphArcRotateCamera
  107214. */
  107215. getClassName(): string;
  107216. }
  107217. }
  107218. declare module BABYLON {
  107219. /**
  107220. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  107221. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107222. */
  107223. export class AnaglyphFreeCamera extends FreeCamera {
  107224. /**
  107225. * Creates a new AnaglyphFreeCamera
  107226. * @param name defines camera name
  107227. * @param position defines initial position
  107228. * @param interaxialDistance defines distance between each color axis
  107229. * @param scene defines the hosting scene
  107230. */
  107231. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107232. /**
  107233. * Gets camera class name
  107234. * @returns AnaglyphFreeCamera
  107235. */
  107236. getClassName(): string;
  107237. }
  107238. }
  107239. declare module BABYLON {
  107240. /**
  107241. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  107242. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107243. */
  107244. export class AnaglyphGamepadCamera extends GamepadCamera {
  107245. /**
  107246. * Creates a new AnaglyphGamepadCamera
  107247. * @param name defines camera name
  107248. * @param position defines initial position
  107249. * @param interaxialDistance defines distance between each color axis
  107250. * @param scene defines the hosting scene
  107251. */
  107252. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107253. /**
  107254. * Gets camera class name
  107255. * @returns AnaglyphGamepadCamera
  107256. */
  107257. getClassName(): string;
  107258. }
  107259. }
  107260. declare module BABYLON {
  107261. /**
  107262. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  107263. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  107264. */
  107265. export class AnaglyphUniversalCamera extends UniversalCamera {
  107266. /**
  107267. * Creates a new AnaglyphUniversalCamera
  107268. * @param name defines camera name
  107269. * @param position defines initial position
  107270. * @param interaxialDistance defines distance between each color axis
  107271. * @param scene defines the hosting scene
  107272. */
  107273. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  107274. /**
  107275. * Gets camera class name
  107276. * @returns AnaglyphUniversalCamera
  107277. */
  107278. getClassName(): string;
  107279. }
  107280. }
  107281. declare module BABYLON {
  107282. /** @hidden */
  107283. export var stereoscopicInterlacePixelShader: {
  107284. name: string;
  107285. shader: string;
  107286. };
  107287. }
  107288. declare module BABYLON {
  107289. /**
  107290. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  107291. */
  107292. export class StereoscopicInterlacePostProcess extends PostProcess {
  107293. private _stepSize;
  107294. private _passedProcess;
  107295. /**
  107296. * Initializes a StereoscopicInterlacePostProcess
  107297. * @param name The name of the effect.
  107298. * @param rigCameras The rig cameras to be appled to the post process
  107299. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  107300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107301. * @param engine The engine which the post process will be applied. (default: current engine)
  107302. * @param reusable If the post process can be reused on the same frame. (default: false)
  107303. */
  107304. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107305. }
  107306. }
  107307. declare module BABYLON {
  107308. /**
  107309. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  107310. * @see http://doc.babylonjs.com/features/cameras
  107311. */
  107312. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  107313. /**
  107314. * Creates a new StereoscopicArcRotateCamera
  107315. * @param name defines camera name
  107316. * @param alpha defines alpha angle (in radians)
  107317. * @param beta defines beta angle (in radians)
  107318. * @param radius defines radius
  107319. * @param target defines camera target
  107320. * @param interaxialDistance defines distance between each color axis
  107321. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107322. * @param scene defines the hosting scene
  107323. */
  107324. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107325. /**
  107326. * Gets camera class name
  107327. * @returns StereoscopicArcRotateCamera
  107328. */
  107329. getClassName(): string;
  107330. }
  107331. }
  107332. declare module BABYLON {
  107333. /**
  107334. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  107335. * @see http://doc.babylonjs.com/features/cameras
  107336. */
  107337. export class StereoscopicFreeCamera extends FreeCamera {
  107338. /**
  107339. * Creates a new StereoscopicFreeCamera
  107340. * @param name defines camera name
  107341. * @param position defines initial position
  107342. * @param interaxialDistance defines distance between each color axis
  107343. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107344. * @param scene defines the hosting scene
  107345. */
  107346. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107347. /**
  107348. * Gets camera class name
  107349. * @returns StereoscopicFreeCamera
  107350. */
  107351. getClassName(): string;
  107352. }
  107353. }
  107354. declare module BABYLON {
  107355. /**
  107356. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  107357. * @see http://doc.babylonjs.com/features/cameras
  107358. */
  107359. export class StereoscopicGamepadCamera extends GamepadCamera {
  107360. /**
  107361. * Creates a new StereoscopicGamepadCamera
  107362. * @param name defines camera name
  107363. * @param position defines initial position
  107364. * @param interaxialDistance defines distance between each color axis
  107365. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107366. * @param scene defines the hosting scene
  107367. */
  107368. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107369. /**
  107370. * Gets camera class name
  107371. * @returns StereoscopicGamepadCamera
  107372. */
  107373. getClassName(): string;
  107374. }
  107375. }
  107376. declare module BABYLON {
  107377. /**
  107378. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  107379. * @see http://doc.babylonjs.com/features/cameras
  107380. */
  107381. export class StereoscopicUniversalCamera extends UniversalCamera {
  107382. /**
  107383. * Creates a new StereoscopicUniversalCamera
  107384. * @param name defines camera name
  107385. * @param position defines initial position
  107386. * @param interaxialDistance defines distance between each color axis
  107387. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  107388. * @param scene defines the hosting scene
  107389. */
  107390. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  107391. /**
  107392. * Gets camera class name
  107393. * @returns StereoscopicUniversalCamera
  107394. */
  107395. getClassName(): string;
  107396. }
  107397. }
  107398. declare module BABYLON {
  107399. /**
  107400. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  107401. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107402. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107403. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107404. */
  107405. export class VirtualJoysticksCamera extends FreeCamera {
  107406. /**
  107407. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  107408. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  107409. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  107410. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  107411. * @param name Define the name of the camera in the scene
  107412. * @param position Define the start position of the camera in the scene
  107413. * @param scene Define the scene the camera belongs to
  107414. */
  107415. constructor(name: string, position: Vector3, scene: Scene);
  107416. /**
  107417. * Gets the current object class name.
  107418. * @return the class name
  107419. */
  107420. getClassName(): string;
  107421. }
  107422. }
  107423. declare module BABYLON {
  107424. /**
  107425. * This represents all the required metrics to create a VR camera.
  107426. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  107427. */
  107428. export class VRCameraMetrics {
  107429. /**
  107430. * Define the horizontal resolution off the screen.
  107431. */
  107432. hResolution: number;
  107433. /**
  107434. * Define the vertical resolution off the screen.
  107435. */
  107436. vResolution: number;
  107437. /**
  107438. * Define the horizontal screen size.
  107439. */
  107440. hScreenSize: number;
  107441. /**
  107442. * Define the vertical screen size.
  107443. */
  107444. vScreenSize: number;
  107445. /**
  107446. * Define the vertical screen center position.
  107447. */
  107448. vScreenCenter: number;
  107449. /**
  107450. * Define the distance of the eyes to the screen.
  107451. */
  107452. eyeToScreenDistance: number;
  107453. /**
  107454. * Define the distance between both lenses
  107455. */
  107456. lensSeparationDistance: number;
  107457. /**
  107458. * Define the distance between both viewer's eyes.
  107459. */
  107460. interpupillaryDistance: number;
  107461. /**
  107462. * Define the distortion factor of the VR postprocess.
  107463. * Please, touch with care.
  107464. */
  107465. distortionK: number[];
  107466. /**
  107467. * Define the chromatic aberration correction factors for the VR post process.
  107468. */
  107469. chromaAbCorrection: number[];
  107470. /**
  107471. * Define the scale factor of the post process.
  107472. * The smaller the better but the slower.
  107473. */
  107474. postProcessScaleFactor: number;
  107475. /**
  107476. * Define an offset for the lens center.
  107477. */
  107478. lensCenterOffset: number;
  107479. /**
  107480. * Define if the current vr camera should compensate the distortion of the lense or not.
  107481. */
  107482. compensateDistortion: boolean;
  107483. /**
  107484. * Defines if multiview should be enabled when rendering (Default: false)
  107485. */
  107486. multiviewEnabled: boolean;
  107487. /**
  107488. * Gets the rendering aspect ratio based on the provided resolutions.
  107489. */
  107490. readonly aspectRatio: number;
  107491. /**
  107492. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  107493. */
  107494. readonly aspectRatioFov: number;
  107495. /**
  107496. * @hidden
  107497. */
  107498. readonly leftHMatrix: Matrix;
  107499. /**
  107500. * @hidden
  107501. */
  107502. readonly rightHMatrix: Matrix;
  107503. /**
  107504. * @hidden
  107505. */
  107506. readonly leftPreViewMatrix: Matrix;
  107507. /**
  107508. * @hidden
  107509. */
  107510. readonly rightPreViewMatrix: Matrix;
  107511. /**
  107512. * Get the default VRMetrics based on the most generic setup.
  107513. * @returns the default vr metrics
  107514. */
  107515. static GetDefault(): VRCameraMetrics;
  107516. }
  107517. }
  107518. declare module BABYLON {
  107519. /** @hidden */
  107520. export var vrDistortionCorrectionPixelShader: {
  107521. name: string;
  107522. shader: string;
  107523. };
  107524. }
  107525. declare module BABYLON {
  107526. /**
  107527. * VRDistortionCorrectionPostProcess used for mobile VR
  107528. */
  107529. export class VRDistortionCorrectionPostProcess extends PostProcess {
  107530. private _isRightEye;
  107531. private _distortionFactors;
  107532. private _postProcessScaleFactor;
  107533. private _lensCenterOffset;
  107534. private _scaleIn;
  107535. private _scaleFactor;
  107536. private _lensCenter;
  107537. /**
  107538. * Initializes the VRDistortionCorrectionPostProcess
  107539. * @param name The name of the effect.
  107540. * @param camera The camera to apply the render pass to.
  107541. * @param isRightEye If this is for the right eye distortion
  107542. * @param vrMetrics All the required metrics for the VR camera
  107543. */
  107544. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  107545. }
  107546. }
  107547. declare module BABYLON {
  107548. /**
  107549. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  107550. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107551. */
  107552. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  107553. /**
  107554. * Creates a new VRDeviceOrientationArcRotateCamera
  107555. * @param name defines camera name
  107556. * @param alpha defines the camera rotation along the logitudinal axis
  107557. * @param beta defines the camera rotation along the latitudinal axis
  107558. * @param radius defines the camera distance from its target
  107559. * @param target defines the camera target
  107560. * @param scene defines the scene the camera belongs to
  107561. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107562. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107563. */
  107564. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107565. /**
  107566. * Gets camera class name
  107567. * @returns VRDeviceOrientationArcRotateCamera
  107568. */
  107569. getClassName(): string;
  107570. }
  107571. }
  107572. declare module BABYLON {
  107573. /**
  107574. * Camera used to simulate VR rendering (based on FreeCamera)
  107575. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107576. */
  107577. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  107578. /**
  107579. * Creates a new VRDeviceOrientationFreeCamera
  107580. * @param name defines camera name
  107581. * @param position defines the start position of the camera
  107582. * @param scene defines the scene the camera belongs to
  107583. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107584. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107585. */
  107586. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107587. /**
  107588. * Gets camera class name
  107589. * @returns VRDeviceOrientationFreeCamera
  107590. */
  107591. getClassName(): string;
  107592. }
  107593. }
  107594. declare module BABYLON {
  107595. /**
  107596. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  107597. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  107598. */
  107599. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  107600. /**
  107601. * Creates a new VRDeviceOrientationGamepadCamera
  107602. * @param name defines camera name
  107603. * @param position defines the start position of the camera
  107604. * @param scene defines the scene the camera belongs to
  107605. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  107606. * @param vrCameraMetrics defines the vr metrics associated to the camera
  107607. */
  107608. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  107609. /**
  107610. * Gets camera class name
  107611. * @returns VRDeviceOrientationGamepadCamera
  107612. */
  107613. getClassName(): string;
  107614. }
  107615. }
  107616. declare module BABYLON {
  107617. /**
  107618. * Base class of materials working in push mode in babylon JS
  107619. * @hidden
  107620. */
  107621. export class PushMaterial extends Material {
  107622. protected _activeEffect: Effect;
  107623. protected _normalMatrix: Matrix;
  107624. /**
  107625. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  107626. * This means that the material can keep using a previous shader while a new one is being compiled.
  107627. * This is mostly used when shader parallel compilation is supported (true by default)
  107628. */
  107629. allowShaderHotSwapping: boolean;
  107630. constructor(name: string, scene: Scene);
  107631. getEffect(): Effect;
  107632. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  107633. /**
  107634. * Binds the given world matrix to the active effect
  107635. *
  107636. * @param world the matrix to bind
  107637. */
  107638. bindOnlyWorldMatrix(world: Matrix): void;
  107639. /**
  107640. * Binds the given normal matrix to the active effect
  107641. *
  107642. * @param normalMatrix the matrix to bind
  107643. */
  107644. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  107645. bind(world: Matrix, mesh?: Mesh): void;
  107646. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  107647. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  107648. }
  107649. }
  107650. declare module BABYLON {
  107651. /**
  107652. * This groups all the flags used to control the materials channel.
  107653. */
  107654. export class MaterialFlags {
  107655. private static _DiffuseTextureEnabled;
  107656. /**
  107657. * Are diffuse textures enabled in the application.
  107658. */
  107659. static DiffuseTextureEnabled: boolean;
  107660. private static _AmbientTextureEnabled;
  107661. /**
  107662. * Are ambient textures enabled in the application.
  107663. */
  107664. static AmbientTextureEnabled: boolean;
  107665. private static _OpacityTextureEnabled;
  107666. /**
  107667. * Are opacity textures enabled in the application.
  107668. */
  107669. static OpacityTextureEnabled: boolean;
  107670. private static _ReflectionTextureEnabled;
  107671. /**
  107672. * Are reflection textures enabled in the application.
  107673. */
  107674. static ReflectionTextureEnabled: boolean;
  107675. private static _EmissiveTextureEnabled;
  107676. /**
  107677. * Are emissive textures enabled in the application.
  107678. */
  107679. static EmissiveTextureEnabled: boolean;
  107680. private static _SpecularTextureEnabled;
  107681. /**
  107682. * Are specular textures enabled in the application.
  107683. */
  107684. static SpecularTextureEnabled: boolean;
  107685. private static _BumpTextureEnabled;
  107686. /**
  107687. * Are bump textures enabled in the application.
  107688. */
  107689. static BumpTextureEnabled: boolean;
  107690. private static _LightmapTextureEnabled;
  107691. /**
  107692. * Are lightmap textures enabled in the application.
  107693. */
  107694. static LightmapTextureEnabled: boolean;
  107695. private static _RefractionTextureEnabled;
  107696. /**
  107697. * Are refraction textures enabled in the application.
  107698. */
  107699. static RefractionTextureEnabled: boolean;
  107700. private static _ColorGradingTextureEnabled;
  107701. /**
  107702. * Are color grading textures enabled in the application.
  107703. */
  107704. static ColorGradingTextureEnabled: boolean;
  107705. private static _FresnelEnabled;
  107706. /**
  107707. * Are fresnels enabled in the application.
  107708. */
  107709. static FresnelEnabled: boolean;
  107710. private static _ClearCoatTextureEnabled;
  107711. /**
  107712. * Are clear coat textures enabled in the application.
  107713. */
  107714. static ClearCoatTextureEnabled: boolean;
  107715. private static _ClearCoatBumpTextureEnabled;
  107716. /**
  107717. * Are clear coat bump textures enabled in the application.
  107718. */
  107719. static ClearCoatBumpTextureEnabled: boolean;
  107720. private static _ClearCoatTintTextureEnabled;
  107721. /**
  107722. * Are clear coat tint textures enabled in the application.
  107723. */
  107724. static ClearCoatTintTextureEnabled: boolean;
  107725. private static _SheenTextureEnabled;
  107726. /**
  107727. * Are sheen textures enabled in the application.
  107728. */
  107729. static SheenTextureEnabled: boolean;
  107730. private static _AnisotropicTextureEnabled;
  107731. /**
  107732. * Are anisotropic textures enabled in the application.
  107733. */
  107734. static AnisotropicTextureEnabled: boolean;
  107735. private static _ThicknessTextureEnabled;
  107736. /**
  107737. * Are thickness textures enabled in the application.
  107738. */
  107739. static ThicknessTextureEnabled: boolean;
  107740. }
  107741. }
  107742. declare module BABYLON {
  107743. /** @hidden */
  107744. export var defaultFragmentDeclaration: {
  107745. name: string;
  107746. shader: string;
  107747. };
  107748. }
  107749. declare module BABYLON {
  107750. /** @hidden */
  107751. export var defaultUboDeclaration: {
  107752. name: string;
  107753. shader: string;
  107754. };
  107755. }
  107756. declare module BABYLON {
  107757. /** @hidden */
  107758. export var lightFragmentDeclaration: {
  107759. name: string;
  107760. shader: string;
  107761. };
  107762. }
  107763. declare module BABYLON {
  107764. /** @hidden */
  107765. export var lightUboDeclaration: {
  107766. name: string;
  107767. shader: string;
  107768. };
  107769. }
  107770. declare module BABYLON {
  107771. /** @hidden */
  107772. export var lightsFragmentFunctions: {
  107773. name: string;
  107774. shader: string;
  107775. };
  107776. }
  107777. declare module BABYLON {
  107778. /** @hidden */
  107779. export var shadowsFragmentFunctions: {
  107780. name: string;
  107781. shader: string;
  107782. };
  107783. }
  107784. declare module BABYLON {
  107785. /** @hidden */
  107786. export var fresnelFunction: {
  107787. name: string;
  107788. shader: string;
  107789. };
  107790. }
  107791. declare module BABYLON {
  107792. /** @hidden */
  107793. export var reflectionFunction: {
  107794. name: string;
  107795. shader: string;
  107796. };
  107797. }
  107798. declare module BABYLON {
  107799. /** @hidden */
  107800. export var bumpFragmentFunctions: {
  107801. name: string;
  107802. shader: string;
  107803. };
  107804. }
  107805. declare module BABYLON {
  107806. /** @hidden */
  107807. export var logDepthDeclaration: {
  107808. name: string;
  107809. shader: string;
  107810. };
  107811. }
  107812. declare module BABYLON {
  107813. /** @hidden */
  107814. export var bumpFragment: {
  107815. name: string;
  107816. shader: string;
  107817. };
  107818. }
  107819. declare module BABYLON {
  107820. /** @hidden */
  107821. export var depthPrePass: {
  107822. name: string;
  107823. shader: string;
  107824. };
  107825. }
  107826. declare module BABYLON {
  107827. /** @hidden */
  107828. export var lightFragment: {
  107829. name: string;
  107830. shader: string;
  107831. };
  107832. }
  107833. declare module BABYLON {
  107834. /** @hidden */
  107835. export var logDepthFragment: {
  107836. name: string;
  107837. shader: string;
  107838. };
  107839. }
  107840. declare module BABYLON {
  107841. /** @hidden */
  107842. export var defaultPixelShader: {
  107843. name: string;
  107844. shader: string;
  107845. };
  107846. }
  107847. declare module BABYLON {
  107848. /** @hidden */
  107849. export var defaultVertexDeclaration: {
  107850. name: string;
  107851. shader: string;
  107852. };
  107853. }
  107854. declare module BABYLON {
  107855. /** @hidden */
  107856. export var bumpVertexDeclaration: {
  107857. name: string;
  107858. shader: string;
  107859. };
  107860. }
  107861. declare module BABYLON {
  107862. /** @hidden */
  107863. export var bumpVertex: {
  107864. name: string;
  107865. shader: string;
  107866. };
  107867. }
  107868. declare module BABYLON {
  107869. /** @hidden */
  107870. export var fogVertex: {
  107871. name: string;
  107872. shader: string;
  107873. };
  107874. }
  107875. declare module BABYLON {
  107876. /** @hidden */
  107877. export var shadowsVertex: {
  107878. name: string;
  107879. shader: string;
  107880. };
  107881. }
  107882. declare module BABYLON {
  107883. /** @hidden */
  107884. export var pointCloudVertex: {
  107885. name: string;
  107886. shader: string;
  107887. };
  107888. }
  107889. declare module BABYLON {
  107890. /** @hidden */
  107891. export var logDepthVertex: {
  107892. name: string;
  107893. shader: string;
  107894. };
  107895. }
  107896. declare module BABYLON {
  107897. /** @hidden */
  107898. export var defaultVertexShader: {
  107899. name: string;
  107900. shader: string;
  107901. };
  107902. }
  107903. declare module BABYLON {
  107904. /** @hidden */
  107905. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  107906. MAINUV1: boolean;
  107907. MAINUV2: boolean;
  107908. DIFFUSE: boolean;
  107909. DIFFUSEDIRECTUV: number;
  107910. AMBIENT: boolean;
  107911. AMBIENTDIRECTUV: number;
  107912. OPACITY: boolean;
  107913. OPACITYDIRECTUV: number;
  107914. OPACITYRGB: boolean;
  107915. REFLECTION: boolean;
  107916. EMISSIVE: boolean;
  107917. EMISSIVEDIRECTUV: number;
  107918. SPECULAR: boolean;
  107919. SPECULARDIRECTUV: number;
  107920. BUMP: boolean;
  107921. BUMPDIRECTUV: number;
  107922. PARALLAX: boolean;
  107923. PARALLAXOCCLUSION: boolean;
  107924. SPECULAROVERALPHA: boolean;
  107925. CLIPPLANE: boolean;
  107926. CLIPPLANE2: boolean;
  107927. CLIPPLANE3: boolean;
  107928. CLIPPLANE4: boolean;
  107929. ALPHATEST: boolean;
  107930. DEPTHPREPASS: boolean;
  107931. ALPHAFROMDIFFUSE: boolean;
  107932. POINTSIZE: boolean;
  107933. FOG: boolean;
  107934. SPECULARTERM: boolean;
  107935. DIFFUSEFRESNEL: boolean;
  107936. OPACITYFRESNEL: boolean;
  107937. REFLECTIONFRESNEL: boolean;
  107938. REFRACTIONFRESNEL: boolean;
  107939. EMISSIVEFRESNEL: boolean;
  107940. FRESNEL: boolean;
  107941. NORMAL: boolean;
  107942. UV1: boolean;
  107943. UV2: boolean;
  107944. VERTEXCOLOR: boolean;
  107945. VERTEXALPHA: boolean;
  107946. NUM_BONE_INFLUENCERS: number;
  107947. BonesPerMesh: number;
  107948. BONETEXTURE: boolean;
  107949. INSTANCES: boolean;
  107950. GLOSSINESS: boolean;
  107951. ROUGHNESS: boolean;
  107952. EMISSIVEASILLUMINATION: boolean;
  107953. LINKEMISSIVEWITHDIFFUSE: boolean;
  107954. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107955. LIGHTMAP: boolean;
  107956. LIGHTMAPDIRECTUV: number;
  107957. OBJECTSPACE_NORMALMAP: boolean;
  107958. USELIGHTMAPASSHADOWMAP: boolean;
  107959. REFLECTIONMAP_3D: boolean;
  107960. REFLECTIONMAP_SPHERICAL: boolean;
  107961. REFLECTIONMAP_PLANAR: boolean;
  107962. REFLECTIONMAP_CUBIC: boolean;
  107963. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107964. REFLECTIONMAP_PROJECTION: boolean;
  107965. REFLECTIONMAP_SKYBOX: boolean;
  107966. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107967. REFLECTIONMAP_EXPLICIT: boolean;
  107968. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107969. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107970. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107971. INVERTCUBICMAP: boolean;
  107972. LOGARITHMICDEPTH: boolean;
  107973. REFRACTION: boolean;
  107974. REFRACTIONMAP_3D: boolean;
  107975. REFLECTIONOVERALPHA: boolean;
  107976. TWOSIDEDLIGHTING: boolean;
  107977. SHADOWFLOAT: boolean;
  107978. MORPHTARGETS: boolean;
  107979. MORPHTARGETS_NORMAL: boolean;
  107980. MORPHTARGETS_TANGENT: boolean;
  107981. MORPHTARGETS_UV: boolean;
  107982. NUM_MORPH_INFLUENCERS: number;
  107983. NONUNIFORMSCALING: boolean;
  107984. PREMULTIPLYALPHA: boolean;
  107985. IMAGEPROCESSING: boolean;
  107986. VIGNETTE: boolean;
  107987. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107988. VIGNETTEBLENDMODEOPAQUE: boolean;
  107989. TONEMAPPING: boolean;
  107990. TONEMAPPING_ACES: boolean;
  107991. CONTRAST: boolean;
  107992. COLORCURVES: boolean;
  107993. COLORGRADING: boolean;
  107994. COLORGRADING3D: boolean;
  107995. SAMPLER3DGREENDEPTH: boolean;
  107996. SAMPLER3DBGRMAP: boolean;
  107997. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107998. MULTIVIEW: boolean;
  107999. /**
  108000. * If the reflection texture on this material is in linear color space
  108001. * @hidden
  108002. */
  108003. IS_REFLECTION_LINEAR: boolean;
  108004. /**
  108005. * If the refraction texture on this material is in linear color space
  108006. * @hidden
  108007. */
  108008. IS_REFRACTION_LINEAR: boolean;
  108009. EXPOSURE: boolean;
  108010. constructor();
  108011. setReflectionMode(modeToEnable: string): void;
  108012. }
  108013. /**
  108014. * This is the default material used in Babylon. It is the best trade off between quality
  108015. * and performances.
  108016. * @see http://doc.babylonjs.com/babylon101/materials
  108017. */
  108018. export class StandardMaterial extends PushMaterial {
  108019. private _diffuseTexture;
  108020. /**
  108021. * The basic texture of the material as viewed under a light.
  108022. */
  108023. diffuseTexture: Nullable<BaseTexture>;
  108024. private _ambientTexture;
  108025. /**
  108026. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108027. */
  108028. ambientTexture: Nullable<BaseTexture>;
  108029. private _opacityTexture;
  108030. /**
  108031. * Define the transparency of the material from a texture.
  108032. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108033. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108034. */
  108035. opacityTexture: Nullable<BaseTexture>;
  108036. private _reflectionTexture;
  108037. /**
  108038. * Define the texture used to display the reflection.
  108039. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108040. */
  108041. reflectionTexture: Nullable<BaseTexture>;
  108042. private _emissiveTexture;
  108043. /**
  108044. * Define texture of the material as if self lit.
  108045. * This will be mixed in the final result even in the absence of light.
  108046. */
  108047. emissiveTexture: Nullable<BaseTexture>;
  108048. private _specularTexture;
  108049. /**
  108050. * Define how the color and intensity of the highlight given by the light in the material.
  108051. */
  108052. specularTexture: Nullable<BaseTexture>;
  108053. private _bumpTexture;
  108054. /**
  108055. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108056. * 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.
  108057. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  108058. */
  108059. bumpTexture: Nullable<BaseTexture>;
  108060. private _lightmapTexture;
  108061. /**
  108062. * Complex lighting can be computationally expensive to compute at runtime.
  108063. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108064. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  108065. */
  108066. lightmapTexture: Nullable<BaseTexture>;
  108067. private _refractionTexture;
  108068. /**
  108069. * Define the texture used to display the refraction.
  108070. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108071. */
  108072. refractionTexture: Nullable<BaseTexture>;
  108073. /**
  108074. * The color of the material lit by the environmental background lighting.
  108075. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108076. */
  108077. ambientColor: Color3;
  108078. /**
  108079. * The basic color of the material as viewed under a light.
  108080. */
  108081. diffuseColor: Color3;
  108082. /**
  108083. * Define how the color and intensity of the highlight given by the light in the material.
  108084. */
  108085. specularColor: Color3;
  108086. /**
  108087. * Define the color of the material as if self lit.
  108088. * This will be mixed in the final result even in the absence of light.
  108089. */
  108090. emissiveColor: Color3;
  108091. /**
  108092. * Defines how sharp are the highlights in the material.
  108093. * The bigger the value the sharper giving a more glossy feeling to the result.
  108094. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108095. */
  108096. specularPower: number;
  108097. private _useAlphaFromDiffuseTexture;
  108098. /**
  108099. * Does the transparency come from the diffuse texture alpha channel.
  108100. */
  108101. useAlphaFromDiffuseTexture: boolean;
  108102. private _useEmissiveAsIllumination;
  108103. /**
  108104. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108105. */
  108106. useEmissiveAsIllumination: boolean;
  108107. private _linkEmissiveWithDiffuse;
  108108. /**
  108109. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108110. * the emissive level when the final color is close to one.
  108111. */
  108112. linkEmissiveWithDiffuse: boolean;
  108113. private _useSpecularOverAlpha;
  108114. /**
  108115. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108116. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108117. */
  108118. useSpecularOverAlpha: boolean;
  108119. private _useReflectionOverAlpha;
  108120. /**
  108121. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108122. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108123. */
  108124. useReflectionOverAlpha: boolean;
  108125. private _disableLighting;
  108126. /**
  108127. * Does lights from the scene impacts this material.
  108128. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108129. */
  108130. disableLighting: boolean;
  108131. private _useObjectSpaceNormalMap;
  108132. /**
  108133. * Allows using an object space normal map (instead of tangent space).
  108134. */
  108135. useObjectSpaceNormalMap: boolean;
  108136. private _useParallax;
  108137. /**
  108138. * Is parallax enabled or not.
  108139. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108140. */
  108141. useParallax: boolean;
  108142. private _useParallaxOcclusion;
  108143. /**
  108144. * Is parallax occlusion enabled or not.
  108145. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108146. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  108147. */
  108148. useParallaxOcclusion: boolean;
  108149. /**
  108150. * 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.
  108151. */
  108152. parallaxScaleBias: number;
  108153. private _roughness;
  108154. /**
  108155. * Helps to define how blurry the reflections should appears in the material.
  108156. */
  108157. roughness: number;
  108158. /**
  108159. * In case of refraction, define the value of the index of refraction.
  108160. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108161. */
  108162. indexOfRefraction: number;
  108163. /**
  108164. * Invert the refraction texture alongside the y axis.
  108165. * It can be useful with procedural textures or probe for instance.
  108166. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108167. */
  108168. invertRefractionY: boolean;
  108169. /**
  108170. * Defines the alpha limits in alpha test mode.
  108171. */
  108172. alphaCutOff: number;
  108173. private _useLightmapAsShadowmap;
  108174. /**
  108175. * In case of light mapping, define whether the map contains light or shadow informations.
  108176. */
  108177. useLightmapAsShadowmap: boolean;
  108178. private _diffuseFresnelParameters;
  108179. /**
  108180. * Define the diffuse fresnel parameters of the material.
  108181. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108182. */
  108183. diffuseFresnelParameters: FresnelParameters;
  108184. private _opacityFresnelParameters;
  108185. /**
  108186. * Define the opacity fresnel parameters of the material.
  108187. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108188. */
  108189. opacityFresnelParameters: FresnelParameters;
  108190. private _reflectionFresnelParameters;
  108191. /**
  108192. * Define the reflection fresnel parameters of the material.
  108193. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108194. */
  108195. reflectionFresnelParameters: FresnelParameters;
  108196. private _refractionFresnelParameters;
  108197. /**
  108198. * Define the refraction fresnel parameters of the material.
  108199. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108200. */
  108201. refractionFresnelParameters: FresnelParameters;
  108202. private _emissiveFresnelParameters;
  108203. /**
  108204. * Define the emissive fresnel parameters of the material.
  108205. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108206. */
  108207. emissiveFresnelParameters: FresnelParameters;
  108208. private _useReflectionFresnelFromSpecular;
  108209. /**
  108210. * If true automatically deducts the fresnels values from the material specularity.
  108211. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108212. */
  108213. useReflectionFresnelFromSpecular: boolean;
  108214. private _useGlossinessFromSpecularMapAlpha;
  108215. /**
  108216. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108217. */
  108218. useGlossinessFromSpecularMapAlpha: boolean;
  108219. private _maxSimultaneousLights;
  108220. /**
  108221. * Defines the maximum number of lights that can be used in the material
  108222. */
  108223. maxSimultaneousLights: number;
  108224. private _invertNormalMapX;
  108225. /**
  108226. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108227. */
  108228. invertNormalMapX: boolean;
  108229. private _invertNormalMapY;
  108230. /**
  108231. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108232. */
  108233. invertNormalMapY: boolean;
  108234. private _twoSidedLighting;
  108235. /**
  108236. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108237. */
  108238. twoSidedLighting: boolean;
  108239. /**
  108240. * Default configuration related to image processing available in the standard Material.
  108241. */
  108242. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108243. /**
  108244. * Gets the image processing configuration used either in this material.
  108245. */
  108246. /**
  108247. * Sets the Default image processing configuration used either in the this material.
  108248. *
  108249. * If sets to null, the scene one is in use.
  108250. */
  108251. imageProcessingConfiguration: ImageProcessingConfiguration;
  108252. /**
  108253. * Keep track of the image processing observer to allow dispose and replace.
  108254. */
  108255. private _imageProcessingObserver;
  108256. /**
  108257. * Attaches a new image processing configuration to the Standard Material.
  108258. * @param configuration
  108259. */
  108260. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108261. /**
  108262. * Gets wether the color curves effect is enabled.
  108263. */
  108264. /**
  108265. * Sets wether the color curves effect is enabled.
  108266. */
  108267. cameraColorCurvesEnabled: boolean;
  108268. /**
  108269. * Gets wether the color grading effect is enabled.
  108270. */
  108271. /**
  108272. * Gets wether the color grading effect is enabled.
  108273. */
  108274. cameraColorGradingEnabled: boolean;
  108275. /**
  108276. * Gets wether tonemapping is enabled or not.
  108277. */
  108278. /**
  108279. * Sets wether tonemapping is enabled or not
  108280. */
  108281. cameraToneMappingEnabled: boolean;
  108282. /**
  108283. * The camera exposure used on this material.
  108284. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108285. * This corresponds to a photographic exposure.
  108286. */
  108287. /**
  108288. * The camera exposure used on this material.
  108289. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108290. * This corresponds to a photographic exposure.
  108291. */
  108292. cameraExposure: number;
  108293. /**
  108294. * Gets The camera contrast used on this material.
  108295. */
  108296. /**
  108297. * Sets The camera contrast used on this material.
  108298. */
  108299. cameraContrast: number;
  108300. /**
  108301. * Gets the Color Grading 2D Lookup Texture.
  108302. */
  108303. /**
  108304. * Sets the Color Grading 2D Lookup Texture.
  108305. */
  108306. cameraColorGradingTexture: Nullable<BaseTexture>;
  108307. /**
  108308. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108309. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108310. * 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;
  108311. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108312. */
  108313. /**
  108314. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108315. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108316. * 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;
  108317. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108318. */
  108319. cameraColorCurves: Nullable<ColorCurves>;
  108320. /**
  108321. * Custom callback helping to override the default shader used in the material.
  108322. */
  108323. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  108324. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108325. protected _worldViewProjectionMatrix: Matrix;
  108326. protected _globalAmbientColor: Color3;
  108327. protected _useLogarithmicDepth: boolean;
  108328. protected _rebuildInParallel: boolean;
  108329. /**
  108330. * Instantiates a new standard material.
  108331. * This is the default material used in Babylon. It is the best trade off between quality
  108332. * and performances.
  108333. * @see http://doc.babylonjs.com/babylon101/materials
  108334. * @param name Define the name of the material in the scene
  108335. * @param scene Define the scene the material belong to
  108336. */
  108337. constructor(name: string, scene: Scene);
  108338. /**
  108339. * Gets a boolean indicating that current material needs to register RTT
  108340. */
  108341. readonly hasRenderTargetTextures: boolean;
  108342. /**
  108343. * Gets the current class name of the material e.g. "StandardMaterial"
  108344. * Mainly use in serialization.
  108345. * @returns the class name
  108346. */
  108347. getClassName(): string;
  108348. /**
  108349. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108350. * You can try switching to logarithmic depth.
  108351. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108352. */
  108353. useLogarithmicDepth: boolean;
  108354. /**
  108355. * Specifies if the material will require alpha blending
  108356. * @returns a boolean specifying if alpha blending is needed
  108357. */
  108358. needAlphaBlending(): boolean;
  108359. /**
  108360. * Specifies if this material should be rendered in alpha test mode
  108361. * @returns a boolean specifying if an alpha test is needed.
  108362. */
  108363. needAlphaTesting(): boolean;
  108364. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108365. /**
  108366. * Get the texture used for alpha test purpose.
  108367. * @returns the diffuse texture in case of the standard material.
  108368. */
  108369. getAlphaTestTexture(): Nullable<BaseTexture>;
  108370. /**
  108371. * Get if the submesh is ready to be used and all its information available.
  108372. * Child classes can use it to update shaders
  108373. * @param mesh defines the mesh to check
  108374. * @param subMesh defines which submesh to check
  108375. * @param useInstances specifies that instances should be used
  108376. * @returns a boolean indicating that the submesh is ready or not
  108377. */
  108378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108379. /**
  108380. * Builds the material UBO layouts.
  108381. * Used internally during the effect preparation.
  108382. */
  108383. buildUniformLayout(): void;
  108384. /**
  108385. * Unbinds the material from the mesh
  108386. */
  108387. unbind(): void;
  108388. /**
  108389. * Binds the submesh to this material by preparing the effect and shader to draw
  108390. * @param world defines the world transformation matrix
  108391. * @param mesh defines the mesh containing the submesh
  108392. * @param subMesh defines the submesh to bind the material to
  108393. */
  108394. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108395. /**
  108396. * Get the list of animatables in the material.
  108397. * @returns the list of animatables object used in the material
  108398. */
  108399. getAnimatables(): IAnimatable[];
  108400. /**
  108401. * Gets the active textures from the material
  108402. * @returns an array of textures
  108403. */
  108404. getActiveTextures(): BaseTexture[];
  108405. /**
  108406. * Specifies if the material uses a texture
  108407. * @param texture defines the texture to check against the material
  108408. * @returns a boolean specifying if the material uses the texture
  108409. */
  108410. hasTexture(texture: BaseTexture): boolean;
  108411. /**
  108412. * Disposes the material
  108413. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108414. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108415. */
  108416. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108417. /**
  108418. * Makes a duplicate of the material, and gives it a new name
  108419. * @param name defines the new name for the duplicated material
  108420. * @returns the cloned material
  108421. */
  108422. clone(name: string): StandardMaterial;
  108423. /**
  108424. * Serializes this material in a JSON representation
  108425. * @returns the serialized material object
  108426. */
  108427. serialize(): any;
  108428. /**
  108429. * Creates a standard material from parsed material data
  108430. * @param source defines the JSON representation of the material
  108431. * @param scene defines the hosting scene
  108432. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108433. * @returns a new standard material
  108434. */
  108435. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108436. /**
  108437. * Are diffuse textures enabled in the application.
  108438. */
  108439. static DiffuseTextureEnabled: boolean;
  108440. /**
  108441. * Are ambient textures enabled in the application.
  108442. */
  108443. static AmbientTextureEnabled: boolean;
  108444. /**
  108445. * Are opacity textures enabled in the application.
  108446. */
  108447. static OpacityTextureEnabled: boolean;
  108448. /**
  108449. * Are reflection textures enabled in the application.
  108450. */
  108451. static ReflectionTextureEnabled: boolean;
  108452. /**
  108453. * Are emissive textures enabled in the application.
  108454. */
  108455. static EmissiveTextureEnabled: boolean;
  108456. /**
  108457. * Are specular textures enabled in the application.
  108458. */
  108459. static SpecularTextureEnabled: boolean;
  108460. /**
  108461. * Are bump textures enabled in the application.
  108462. */
  108463. static BumpTextureEnabled: boolean;
  108464. /**
  108465. * Are lightmap textures enabled in the application.
  108466. */
  108467. static LightmapTextureEnabled: boolean;
  108468. /**
  108469. * Are refraction textures enabled in the application.
  108470. */
  108471. static RefractionTextureEnabled: boolean;
  108472. /**
  108473. * Are color grading textures enabled in the application.
  108474. */
  108475. static ColorGradingTextureEnabled: boolean;
  108476. /**
  108477. * Are fresnels enabled in the application.
  108478. */
  108479. static FresnelEnabled: boolean;
  108480. }
  108481. }
  108482. declare module BABYLON {
  108483. /** @hidden */
  108484. export var imageProcessingPixelShader: {
  108485. name: string;
  108486. shader: string;
  108487. };
  108488. }
  108489. declare module BABYLON {
  108490. /**
  108491. * ImageProcessingPostProcess
  108492. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  108493. */
  108494. export class ImageProcessingPostProcess extends PostProcess {
  108495. /**
  108496. * Default configuration related to image processing available in the PBR Material.
  108497. */
  108498. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108499. /**
  108500. * Gets the image processing configuration used either in this material.
  108501. */
  108502. /**
  108503. * Sets the Default image processing configuration used either in the this material.
  108504. *
  108505. * If sets to null, the scene one is in use.
  108506. */
  108507. imageProcessingConfiguration: ImageProcessingConfiguration;
  108508. /**
  108509. * Keep track of the image processing observer to allow dispose and replace.
  108510. */
  108511. private _imageProcessingObserver;
  108512. /**
  108513. * Attaches a new image processing configuration to the PBR Material.
  108514. * @param configuration
  108515. */
  108516. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  108517. /**
  108518. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108519. */
  108520. /**
  108521. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  108522. */
  108523. colorCurves: Nullable<ColorCurves>;
  108524. /**
  108525. * Gets wether the color curves effect is enabled.
  108526. */
  108527. /**
  108528. * Sets wether the color curves effect is enabled.
  108529. */
  108530. colorCurvesEnabled: boolean;
  108531. /**
  108532. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108533. */
  108534. /**
  108535. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  108536. */
  108537. colorGradingTexture: Nullable<BaseTexture>;
  108538. /**
  108539. * Gets wether the color grading effect is enabled.
  108540. */
  108541. /**
  108542. * Gets wether the color grading effect is enabled.
  108543. */
  108544. colorGradingEnabled: boolean;
  108545. /**
  108546. * Gets exposure used in the effect.
  108547. */
  108548. /**
  108549. * Sets exposure used in the effect.
  108550. */
  108551. exposure: number;
  108552. /**
  108553. * Gets wether tonemapping is enabled or not.
  108554. */
  108555. /**
  108556. * Sets wether tonemapping is enabled or not
  108557. */
  108558. toneMappingEnabled: boolean;
  108559. /**
  108560. * Gets the type of tone mapping effect.
  108561. */
  108562. /**
  108563. * Sets the type of tone mapping effect.
  108564. */
  108565. toneMappingType: number;
  108566. /**
  108567. * Gets contrast used in the effect.
  108568. */
  108569. /**
  108570. * Sets contrast used in the effect.
  108571. */
  108572. contrast: number;
  108573. /**
  108574. * Gets Vignette stretch size.
  108575. */
  108576. /**
  108577. * Sets Vignette stretch size.
  108578. */
  108579. vignetteStretch: number;
  108580. /**
  108581. * Gets Vignette centre X Offset.
  108582. */
  108583. /**
  108584. * Sets Vignette centre X Offset.
  108585. */
  108586. vignetteCentreX: number;
  108587. /**
  108588. * Gets Vignette centre Y Offset.
  108589. */
  108590. /**
  108591. * Sets Vignette centre Y Offset.
  108592. */
  108593. vignetteCentreY: number;
  108594. /**
  108595. * Gets Vignette weight or intensity of the vignette effect.
  108596. */
  108597. /**
  108598. * Sets Vignette weight or intensity of the vignette effect.
  108599. */
  108600. vignetteWeight: number;
  108601. /**
  108602. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108603. * if vignetteEnabled is set to true.
  108604. */
  108605. /**
  108606. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  108607. * if vignetteEnabled is set to true.
  108608. */
  108609. vignetteColor: Color4;
  108610. /**
  108611. * Gets Camera field of view used by the Vignette effect.
  108612. */
  108613. /**
  108614. * Sets Camera field of view used by the Vignette effect.
  108615. */
  108616. vignetteCameraFov: number;
  108617. /**
  108618. * Gets the vignette blend mode allowing different kind of effect.
  108619. */
  108620. /**
  108621. * Sets the vignette blend mode allowing different kind of effect.
  108622. */
  108623. vignetteBlendMode: number;
  108624. /**
  108625. * Gets wether the vignette effect is enabled.
  108626. */
  108627. /**
  108628. * Sets wether the vignette effect is enabled.
  108629. */
  108630. vignetteEnabled: boolean;
  108631. private _fromLinearSpace;
  108632. /**
  108633. * Gets wether the input of the processing is in Gamma or Linear Space.
  108634. */
  108635. /**
  108636. * Sets wether the input of the processing is in Gamma or Linear Space.
  108637. */
  108638. fromLinearSpace: boolean;
  108639. /**
  108640. * Defines cache preventing GC.
  108641. */
  108642. private _defines;
  108643. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  108644. /**
  108645. * "ImageProcessingPostProcess"
  108646. * @returns "ImageProcessingPostProcess"
  108647. */
  108648. getClassName(): string;
  108649. protected _updateParameters(): void;
  108650. dispose(camera?: Camera): void;
  108651. }
  108652. }
  108653. declare module BABYLON {
  108654. /**
  108655. * Class containing static functions to help procedurally build meshes
  108656. */
  108657. export class GroundBuilder {
  108658. /**
  108659. * Creates a ground mesh
  108660. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  108661. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  108662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108663. * @param name defines the name of the mesh
  108664. * @param options defines the options used to create the mesh
  108665. * @param scene defines the hosting scene
  108666. * @returns the ground mesh
  108667. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  108668. */
  108669. static CreateGround(name: string, options: {
  108670. width?: number;
  108671. height?: number;
  108672. subdivisions?: number;
  108673. subdivisionsX?: number;
  108674. subdivisionsY?: number;
  108675. updatable?: boolean;
  108676. }, scene: any): Mesh;
  108677. /**
  108678. * Creates a tiled ground mesh
  108679. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  108680. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  108681. * * 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
  108682. * * 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
  108683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108684. * @param name defines the name of the mesh
  108685. * @param options defines the options used to create the mesh
  108686. * @param scene defines the hosting scene
  108687. * @returns the tiled ground mesh
  108688. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  108689. */
  108690. static CreateTiledGround(name: string, options: {
  108691. xmin: number;
  108692. zmin: number;
  108693. xmax: number;
  108694. zmax: number;
  108695. subdivisions?: {
  108696. w: number;
  108697. h: number;
  108698. };
  108699. precision?: {
  108700. w: number;
  108701. h: number;
  108702. };
  108703. updatable?: boolean;
  108704. }, scene?: Nullable<Scene>): Mesh;
  108705. /**
  108706. * Creates a ground mesh from a height map
  108707. * * The parameter `url` sets the URL of the height map image resource.
  108708. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  108709. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  108710. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  108711. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  108712. * * 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.
  108713. * * 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).
  108714. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108716. * @param name defines the name of the mesh
  108717. * @param url defines the url to the height map
  108718. * @param options defines the options used to create the mesh
  108719. * @param scene defines the hosting scene
  108720. * @returns the ground mesh
  108721. * @see https://doc.babylonjs.com/babylon101/height_map
  108722. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  108723. */
  108724. static CreateGroundFromHeightMap(name: string, url: string, options: {
  108725. width?: number;
  108726. height?: number;
  108727. subdivisions?: number;
  108728. minHeight?: number;
  108729. maxHeight?: number;
  108730. colorFilter?: Color3;
  108731. alphaFilter?: number;
  108732. updatable?: boolean;
  108733. onReady?: (mesh: GroundMesh) => void;
  108734. }, scene?: Nullable<Scene>): GroundMesh;
  108735. }
  108736. }
  108737. declare module BABYLON {
  108738. /**
  108739. * Class containing static functions to help procedurally build meshes
  108740. */
  108741. export class TorusBuilder {
  108742. /**
  108743. * Creates a torus mesh
  108744. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  108745. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  108746. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  108747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108750. * @param name defines the name of the mesh
  108751. * @param options defines the options used to create the mesh
  108752. * @param scene defines the hosting scene
  108753. * @returns the torus mesh
  108754. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  108755. */
  108756. static CreateTorus(name: string, options: {
  108757. diameter?: number;
  108758. thickness?: number;
  108759. tessellation?: number;
  108760. updatable?: boolean;
  108761. sideOrientation?: number;
  108762. frontUVs?: Vector4;
  108763. backUVs?: Vector4;
  108764. }, scene: any): Mesh;
  108765. }
  108766. }
  108767. declare module BABYLON {
  108768. /**
  108769. * Class containing static functions to help procedurally build meshes
  108770. */
  108771. export class CylinderBuilder {
  108772. /**
  108773. * Creates a cylinder or a cone mesh
  108774. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  108775. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  108776. * * 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.
  108777. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  108778. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  108779. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  108780. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  108781. * * 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).
  108782. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  108783. * * 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).
  108784. * * 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
  108785. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  108786. * * 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
  108787. * * 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.
  108788. * * If `enclose` is false, a ring surface is one element.
  108789. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  108790. * * 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
  108791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108794. * @param name defines the name of the mesh
  108795. * @param options defines the options used to create the mesh
  108796. * @param scene defines the hosting scene
  108797. * @returns the cylinder mesh
  108798. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  108799. */
  108800. static CreateCylinder(name: string, options: {
  108801. height?: number;
  108802. diameterTop?: number;
  108803. diameterBottom?: number;
  108804. diameter?: number;
  108805. tessellation?: number;
  108806. subdivisions?: number;
  108807. arc?: number;
  108808. faceColors?: Color4[];
  108809. faceUV?: Vector4[];
  108810. updatable?: boolean;
  108811. hasRings?: boolean;
  108812. enclose?: boolean;
  108813. cap?: number;
  108814. sideOrientation?: number;
  108815. frontUVs?: Vector4;
  108816. backUVs?: Vector4;
  108817. }, scene: any): Mesh;
  108818. }
  108819. }
  108820. declare module BABYLON {
  108821. /**
  108822. * Options to modify the vr teleportation behavior.
  108823. */
  108824. export interface VRTeleportationOptions {
  108825. /**
  108826. * The name of the mesh which should be used as the teleportation floor. (default: null)
  108827. */
  108828. floorMeshName?: string;
  108829. /**
  108830. * A list of meshes to be used as the teleportation floor. (default: empty)
  108831. */
  108832. floorMeshes?: Mesh[];
  108833. }
  108834. /**
  108835. * Options to modify the vr experience helper's behavior.
  108836. */
  108837. export interface VRExperienceHelperOptions extends WebVROptions {
  108838. /**
  108839. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  108840. */
  108841. createDeviceOrientationCamera?: boolean;
  108842. /**
  108843. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  108844. */
  108845. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  108846. /**
  108847. * Uses the main button on the controller to toggle the laser casted. (default: true)
  108848. */
  108849. laserToggle?: boolean;
  108850. /**
  108851. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  108852. */
  108853. floorMeshes?: Mesh[];
  108854. /**
  108855. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  108856. */
  108857. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  108858. }
  108859. /**
  108860. * Event containing information after VR has been entered
  108861. */
  108862. export class OnAfterEnteringVRObservableEvent {
  108863. /**
  108864. * If entering vr was successful
  108865. */
  108866. success: boolean;
  108867. }
  108868. /**
  108869. * Helps to quickly add VR support to an existing scene.
  108870. * See http://doc.babylonjs.com/how_to/webvr_helper
  108871. */
  108872. export class VRExperienceHelper {
  108873. /** Options to modify the vr experience helper's behavior. */
  108874. webVROptions: VRExperienceHelperOptions;
  108875. private _scene;
  108876. private _position;
  108877. private _btnVR;
  108878. private _btnVRDisplayed;
  108879. private _webVRsupported;
  108880. private _webVRready;
  108881. private _webVRrequesting;
  108882. private _webVRpresenting;
  108883. private _hasEnteredVR;
  108884. private _fullscreenVRpresenting;
  108885. private _canvas;
  108886. private _webVRCamera;
  108887. private _vrDeviceOrientationCamera;
  108888. private _deviceOrientationCamera;
  108889. private _existingCamera;
  108890. private _onKeyDown;
  108891. private _onVrDisplayPresentChange;
  108892. private _onVRDisplayChanged;
  108893. private _onVRRequestPresentStart;
  108894. private _onVRRequestPresentComplete;
  108895. /**
  108896. * 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)
  108897. */
  108898. enableGazeEvenWhenNoPointerLock: boolean;
  108899. /**
  108900. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  108901. */
  108902. exitVROnDoubleTap: boolean;
  108903. /**
  108904. * Observable raised right before entering VR.
  108905. */
  108906. onEnteringVRObservable: Observable<VRExperienceHelper>;
  108907. /**
  108908. * Observable raised when entering VR has completed.
  108909. */
  108910. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  108911. /**
  108912. * Observable raised when exiting VR.
  108913. */
  108914. onExitingVRObservable: Observable<VRExperienceHelper>;
  108915. /**
  108916. * Observable raised when controller mesh is loaded.
  108917. */
  108918. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108919. /** Return this.onEnteringVRObservable
  108920. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  108921. */
  108922. readonly onEnteringVR: Observable<VRExperienceHelper>;
  108923. /** Return this.onExitingVRObservable
  108924. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  108925. */
  108926. readonly onExitingVR: Observable<VRExperienceHelper>;
  108927. /** Return this.onControllerMeshLoadedObservable
  108928. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  108929. */
  108930. readonly onControllerMeshLoaded: Observable<WebVRController>;
  108931. private _rayLength;
  108932. private _useCustomVRButton;
  108933. private _teleportationRequested;
  108934. private _teleportActive;
  108935. private _floorMeshName;
  108936. private _floorMeshesCollection;
  108937. private _rotationAllowed;
  108938. private _teleportBackwardsVector;
  108939. private _teleportationTarget;
  108940. private _isDefaultTeleportationTarget;
  108941. private _postProcessMove;
  108942. private _teleportationFillColor;
  108943. private _teleportationBorderColor;
  108944. private _rotationAngle;
  108945. private _haloCenter;
  108946. private _cameraGazer;
  108947. private _padSensibilityUp;
  108948. private _padSensibilityDown;
  108949. private _leftController;
  108950. private _rightController;
  108951. /**
  108952. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  108953. */
  108954. onNewMeshSelected: Observable<AbstractMesh>;
  108955. /**
  108956. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  108957. * This observable will provide the mesh and the controller used to select the mesh
  108958. */
  108959. onMeshSelectedWithController: Observable<{
  108960. mesh: AbstractMesh;
  108961. controller: WebVRController;
  108962. }>;
  108963. /**
  108964. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  108965. */
  108966. onNewMeshPicked: Observable<PickingInfo>;
  108967. private _circleEase;
  108968. /**
  108969. * Observable raised before camera teleportation
  108970. */
  108971. onBeforeCameraTeleport: Observable<Vector3>;
  108972. /**
  108973. * Observable raised after camera teleportation
  108974. */
  108975. onAfterCameraTeleport: Observable<Vector3>;
  108976. /**
  108977. * Observable raised when current selected mesh gets unselected
  108978. */
  108979. onSelectedMeshUnselected: Observable<AbstractMesh>;
  108980. private _raySelectionPredicate;
  108981. /**
  108982. * To be optionaly changed by user to define custom ray selection
  108983. */
  108984. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108985. /**
  108986. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108987. */
  108988. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108989. /**
  108990. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108991. */
  108992. teleportationEnabled: boolean;
  108993. private _defaultHeight;
  108994. private _teleportationInitialized;
  108995. private _interactionsEnabled;
  108996. private _interactionsRequested;
  108997. private _displayGaze;
  108998. private _displayLaserPointer;
  108999. /**
  109000. * The mesh used to display where the user is going to teleport.
  109001. */
  109002. /**
  109003. * Sets the mesh to be used to display where the user is going to teleport.
  109004. */
  109005. teleportationTarget: Mesh;
  109006. /**
  109007. * 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
  109008. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  109009. * See http://doc.babylonjs.com/resources/baking_transformations
  109010. */
  109011. gazeTrackerMesh: Mesh;
  109012. /**
  109013. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  109014. */
  109015. updateGazeTrackerScale: boolean;
  109016. /**
  109017. * If the gaze trackers color should be updated when selecting meshes
  109018. */
  109019. updateGazeTrackerColor: boolean;
  109020. /**
  109021. * If the controller laser color should be updated when selecting meshes
  109022. */
  109023. updateControllerLaserColor: boolean;
  109024. /**
  109025. * The gaze tracking mesh corresponding to the left controller
  109026. */
  109027. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  109028. /**
  109029. * The gaze tracking mesh corresponding to the right controller
  109030. */
  109031. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  109032. /**
  109033. * If the ray of the gaze should be displayed.
  109034. */
  109035. /**
  109036. * Sets if the ray of the gaze should be displayed.
  109037. */
  109038. displayGaze: boolean;
  109039. /**
  109040. * If the ray of the LaserPointer should be displayed.
  109041. */
  109042. /**
  109043. * Sets if the ray of the LaserPointer should be displayed.
  109044. */
  109045. displayLaserPointer: boolean;
  109046. /**
  109047. * The deviceOrientationCamera used as the camera when not in VR.
  109048. */
  109049. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  109050. /**
  109051. * Based on the current WebVR support, returns the current VR camera used.
  109052. */
  109053. readonly currentVRCamera: Nullable<Camera>;
  109054. /**
  109055. * The webVRCamera which is used when in VR.
  109056. */
  109057. readonly webVRCamera: WebVRFreeCamera;
  109058. /**
  109059. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  109060. */
  109061. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  109062. /**
  109063. * The html button that is used to trigger entering into VR.
  109064. */
  109065. readonly vrButton: Nullable<HTMLButtonElement>;
  109066. private readonly _teleportationRequestInitiated;
  109067. /**
  109068. * Defines wether or not Pointer lock should be requested when switching to
  109069. * full screen.
  109070. */
  109071. requestPointerLockOnFullScreen: boolean;
  109072. /**
  109073. * Instantiates a VRExperienceHelper.
  109074. * Helps to quickly add VR support to an existing scene.
  109075. * @param scene The scene the VRExperienceHelper belongs to.
  109076. * @param webVROptions Options to modify the vr experience helper's behavior.
  109077. */
  109078. constructor(scene: Scene,
  109079. /** Options to modify the vr experience helper's behavior. */
  109080. webVROptions?: VRExperienceHelperOptions);
  109081. private _onDefaultMeshLoaded;
  109082. private _onResize;
  109083. private _onFullscreenChange;
  109084. /**
  109085. * Gets a value indicating if we are currently in VR mode.
  109086. */
  109087. readonly isInVRMode: boolean;
  109088. private onVrDisplayPresentChange;
  109089. private onVRDisplayChanged;
  109090. private moveButtonToBottomRight;
  109091. private displayVRButton;
  109092. private updateButtonVisibility;
  109093. private _cachedAngularSensibility;
  109094. /**
  109095. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  109096. * Otherwise, will use the fullscreen API.
  109097. */
  109098. enterVR(): void;
  109099. /**
  109100. * Attempt to exit VR, or fullscreen.
  109101. */
  109102. exitVR(): void;
  109103. /**
  109104. * The position of the vr experience helper.
  109105. */
  109106. /**
  109107. * Sets the position of the vr experience helper.
  109108. */
  109109. position: Vector3;
  109110. /**
  109111. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  109112. */
  109113. enableInteractions(): void;
  109114. private readonly _noControllerIsActive;
  109115. private beforeRender;
  109116. private _isTeleportationFloor;
  109117. /**
  109118. * Adds a floor mesh to be used for teleportation.
  109119. * @param floorMesh the mesh to be used for teleportation.
  109120. */
  109121. addFloorMesh(floorMesh: Mesh): void;
  109122. /**
  109123. * Removes a floor mesh from being used for teleportation.
  109124. * @param floorMesh the mesh to be removed.
  109125. */
  109126. removeFloorMesh(floorMesh: Mesh): void;
  109127. /**
  109128. * Enables interactions and teleportation using the VR controllers and gaze.
  109129. * @param vrTeleportationOptions options to modify teleportation behavior.
  109130. */
  109131. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  109132. private _onNewGamepadConnected;
  109133. private _tryEnableInteractionOnController;
  109134. private _onNewGamepadDisconnected;
  109135. private _enableInteractionOnController;
  109136. private _checkTeleportWithRay;
  109137. private _checkRotate;
  109138. private _checkTeleportBackwards;
  109139. private _enableTeleportationOnController;
  109140. private _createTeleportationCircles;
  109141. private _displayTeleportationTarget;
  109142. private _hideTeleportationTarget;
  109143. private _rotateCamera;
  109144. private _moveTeleportationSelectorTo;
  109145. private _workingVector;
  109146. private _workingQuaternion;
  109147. private _workingMatrix;
  109148. /**
  109149. * Teleports the users feet to the desired location
  109150. * @param location The location where the user's feet should be placed
  109151. */
  109152. teleportCamera(location: Vector3): void;
  109153. private _convertNormalToDirectionOfRay;
  109154. private _castRayAndSelectObject;
  109155. private _notifySelectedMeshUnselected;
  109156. /**
  109157. * Sets the color of the laser ray from the vr controllers.
  109158. * @param color new color for the ray.
  109159. */
  109160. changeLaserColor(color: Color3): void;
  109161. /**
  109162. * Sets the color of the ray from the vr headsets gaze.
  109163. * @param color new color for the ray.
  109164. */
  109165. changeGazeColor(color: Color3): void;
  109166. /**
  109167. * Exits VR and disposes of the vr experience helper
  109168. */
  109169. dispose(): void;
  109170. /**
  109171. * Gets the name of the VRExperienceHelper class
  109172. * @returns "VRExperienceHelper"
  109173. */
  109174. getClassName(): string;
  109175. }
  109176. }
  109177. declare module BABYLON {
  109178. /**
  109179. * States of the webXR experience
  109180. */
  109181. export enum WebXRState {
  109182. /**
  109183. * Transitioning to being in XR mode
  109184. */
  109185. ENTERING_XR = 0,
  109186. /**
  109187. * Transitioning to non XR mode
  109188. */
  109189. EXITING_XR = 1,
  109190. /**
  109191. * In XR mode and presenting
  109192. */
  109193. IN_XR = 2,
  109194. /**
  109195. * Not entered XR mode
  109196. */
  109197. NOT_IN_XR = 3
  109198. }
  109199. /**
  109200. * Abstraction of the XR render target
  109201. */
  109202. export interface WebXRRenderTarget extends IDisposable {
  109203. /**
  109204. * xrpresent context of the canvas which can be used to display/mirror xr content
  109205. */
  109206. canvasContext: WebGLRenderingContext;
  109207. /**
  109208. * xr layer for the canvas
  109209. */
  109210. xrLayer: Nullable<XRWebGLLayer>;
  109211. /**
  109212. * Initializes the xr layer for the session
  109213. * @param xrSession xr session
  109214. * @returns a promise that will resolve once the XR Layer has been created
  109215. */
  109216. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  109217. }
  109218. }
  109219. declare module BABYLON {
  109220. /**
  109221. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  109222. */
  109223. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  109224. private _engine;
  109225. private _canvas;
  109226. /**
  109227. * xrpresent context of the canvas which can be used to display/mirror xr content
  109228. */
  109229. canvasContext: WebGLRenderingContext;
  109230. /**
  109231. * xr layer for the canvas
  109232. */
  109233. xrLayer: Nullable<XRWebGLLayer>;
  109234. /**
  109235. * Initializes the xr layer for the session
  109236. * @param xrSession xr session
  109237. * @returns a promise that will resolve once the XR Layer has been created
  109238. */
  109239. initializeXRLayerAsync(xrSession: any): any;
  109240. /**
  109241. * Initializes the canvas to be added/removed upon entering/exiting xr
  109242. * @param engine the Babylon engine
  109243. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  109244. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  109245. */
  109246. constructor(engine: ThinEngine, onStateChangedObservable: Observable<WebXRState>, canvas?: HTMLCanvasElement);
  109247. /**
  109248. * Disposes of the object
  109249. */
  109250. dispose(): void;
  109251. private _setManagedOutputCanvas;
  109252. private _addCanvas;
  109253. private _removeCanvas;
  109254. }
  109255. }
  109256. declare module BABYLON {
  109257. /**
  109258. * Manages an XRSession to work with Babylon's engine
  109259. * @see https://doc.babylonjs.com/how_to/webxr
  109260. */
  109261. export class WebXRSessionManager implements IDisposable {
  109262. private scene;
  109263. /**
  109264. * Fires every time a new xrFrame arrives which can be used to update the camera
  109265. */
  109266. onXRFrameObservable: Observable<any>;
  109267. /**
  109268. * Fires when the xr session is ended either by the device or manually done
  109269. */
  109270. onXRSessionEnded: Observable<any>;
  109271. /**
  109272. * Underlying xr session
  109273. */
  109274. session: XRSession;
  109275. /**
  109276. * Type of reference space used when creating the session
  109277. */
  109278. referenceSpace: XRReferenceSpace;
  109279. /**
  109280. * Current XR frame
  109281. */
  109282. currentFrame: Nullable<XRFrame>;
  109283. private _xrNavigator;
  109284. private baseLayer;
  109285. private _rttProvider;
  109286. private _sessionEnded;
  109287. /**
  109288. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  109289. * @param scene The scene which the session should be created for
  109290. */
  109291. constructor(scene: Scene);
  109292. /**
  109293. * Initializes the manager
  109294. * After initialization enterXR can be called to start an XR session
  109295. * @returns Promise which resolves after it is initialized
  109296. */
  109297. initializeAsync(): Promise<void>;
  109298. /**
  109299. * Initializes an xr session
  109300. * @param xrSessionMode mode to initialize
  109301. * @returns a promise which will resolve once the session has been initialized
  109302. */
  109303. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  109304. /**
  109305. * Sets the reference space on the xr session
  109306. * @param referenceSpace space to set
  109307. * @returns a promise that will resolve once the reference space has been set
  109308. */
  109309. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  109310. /**
  109311. * Updates the render state of the session
  109312. * @param state state to set
  109313. * @returns a promise that resolves once the render state has been updated
  109314. */
  109315. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  109316. /**
  109317. * Starts rendering to the xr layer
  109318. * @returns a promise that will resolve once rendering has started
  109319. */
  109320. startRenderingToXRAsync(): Promise<void>;
  109321. /**
  109322. * Gets the correct render target texture to be rendered this frame for this eye
  109323. * @param eye the eye for which to get the render target
  109324. * @returns the render target for the specified eye
  109325. */
  109326. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  109327. /**
  109328. * Stops the xrSession and restores the renderloop
  109329. * @returns Promise which resolves after it exits XR
  109330. */
  109331. exitXRAsync(): Promise<void>;
  109332. /**
  109333. * Checks if a session would be supported for the creation options specified
  109334. * @param sessionMode session mode to check if supported eg. immersive-vr
  109335. * @returns true if supported
  109336. */
  109337. supportsSessionAsync(sessionMode: XRSessionMode): any;
  109338. /**
  109339. * Creates a WebXRRenderTarget object for the XR session
  109340. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  109341. * @returns a WebXR render target to which the session can render
  109342. */
  109343. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>): WebXRRenderTarget;
  109344. /**
  109345. * @hidden
  109346. * Converts the render layer of xrSession to a render target
  109347. * @param session session to create render target for
  109348. * @param scene scene the new render target should be created for
  109349. */
  109350. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  109351. /**
  109352. * Disposes of the session manager
  109353. */
  109354. dispose(): void;
  109355. }
  109356. }
  109357. declare module BABYLON {
  109358. /**
  109359. * WebXR Camera which holds the views for the xrSession
  109360. * @see https://doc.babylonjs.com/how_to/webxr
  109361. */
  109362. export class WebXRCamera extends FreeCamera {
  109363. private static _TmpMatrix;
  109364. /**
  109365. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  109366. * @param name the name of the camera
  109367. * @param scene the scene to add the camera to
  109368. */
  109369. constructor(name: string, scene: Scene);
  109370. private _updateNumberOfRigCameras;
  109371. /** @hidden */
  109372. _updateForDualEyeDebugging(): void;
  109373. /**
  109374. * Updates the cameras position from the current pose information of the XR session
  109375. * @param xrSessionManager the session containing pose information
  109376. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  109377. */
  109378. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  109379. }
  109380. }
  109381. declare module BABYLON {
  109382. /**
  109383. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  109384. * @see https://doc.babylonjs.com/how_to/webxr
  109385. */
  109386. export class WebXRExperienceHelper implements IDisposable {
  109387. private scene;
  109388. /**
  109389. * 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
  109390. */
  109391. container: AbstractMesh;
  109392. /**
  109393. * Camera used to render xr content
  109394. */
  109395. camera: WebXRCamera;
  109396. /**
  109397. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  109398. */
  109399. state: WebXRState;
  109400. private _setState;
  109401. private static _TmpVector;
  109402. /**
  109403. * Fires when the state of the experience helper has changed
  109404. */
  109405. onStateChangedObservable: Observable<WebXRState>;
  109406. /** Session manager used to keep track of xr session */
  109407. sessionManager: WebXRSessionManager;
  109408. private _nonVRCamera;
  109409. private _originalSceneAutoClear;
  109410. private _supported;
  109411. /**
  109412. * Creates the experience helper
  109413. * @param scene the scene to attach the experience helper to
  109414. * @returns a promise for the experience helper
  109415. */
  109416. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  109417. /**
  109418. * Creates a WebXRExperienceHelper
  109419. * @param scene The scene the helper should be created in
  109420. */
  109421. private constructor();
  109422. /**
  109423. * Exits XR mode and returns the scene to its original state
  109424. * @returns promise that resolves after xr mode has exited
  109425. */
  109426. exitXRAsync(): Promise<void>;
  109427. /**
  109428. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  109429. * @param sessionCreationOptions options for the XR session
  109430. * @param referenceSpaceType frame of reference of the XR session
  109431. * @param renderTarget the output canvas that will be used to enter XR mode
  109432. * @returns promise that resolves after xr mode has entered
  109433. */
  109434. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): any;
  109435. /**
  109436. * Updates the global position of the camera by moving the camera's container
  109437. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  109438. * @param position The desired global position of the camera
  109439. */
  109440. setPositionOfCameraUsingContainer(position: Vector3): void;
  109441. /**
  109442. * Rotates the xr camera by rotating the camera's container around the camera's position
  109443. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  109444. * @param rotation the desired quaternion rotation to apply to the camera
  109445. */
  109446. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  109447. /**
  109448. * Disposes of the experience helper
  109449. */
  109450. dispose(): void;
  109451. }
  109452. }
  109453. declare module BABYLON {
  109454. /**
  109455. * Button which can be used to enter a different mode of XR
  109456. */
  109457. export class WebXREnterExitUIButton {
  109458. /** button element */
  109459. element: HTMLElement;
  109460. /** XR initialization options for the button */
  109461. sessionMode: XRSessionMode;
  109462. /** Reference space type */
  109463. referenceSpaceType: XRReferenceSpaceType;
  109464. /**
  109465. * Creates a WebXREnterExitUIButton
  109466. * @param element button element
  109467. * @param sessionMode XR initialization session mode
  109468. * @param referenceSpaceType the type of reference space to be used
  109469. */
  109470. constructor(
  109471. /** button element */
  109472. element: HTMLElement,
  109473. /** XR initialization options for the button */
  109474. sessionMode: XRSessionMode,
  109475. /** Reference space type */
  109476. referenceSpaceType: XRReferenceSpaceType);
  109477. /**
  109478. * Overwritable function which can be used to update the button's visuals when the state changes
  109479. * @param activeButton the current active button in the UI
  109480. */
  109481. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  109482. }
  109483. /**
  109484. * Options to create the webXR UI
  109485. */
  109486. export class WebXREnterExitUIOptions {
  109487. /**
  109488. * Context to enter xr with
  109489. */
  109490. renderTarget?: Nullable<WebXRRenderTarget>;
  109491. /**
  109492. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  109493. */
  109494. customButtons?: Array<WebXREnterExitUIButton>;
  109495. }
  109496. /**
  109497. * UI to allow the user to enter/exit XR mode
  109498. */
  109499. export class WebXREnterExitUI implements IDisposable {
  109500. private scene;
  109501. private _overlay;
  109502. private _buttons;
  109503. private _activeButton;
  109504. /**
  109505. * Fired every time the active button is changed.
  109506. *
  109507. * When xr is entered via a button that launches xr that button will be the callback parameter
  109508. *
  109509. * When exiting xr the callback parameter will be null)
  109510. */
  109511. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  109512. /**
  109513. * Creates UI to allow the user to enter/exit XR mode
  109514. * @param scene the scene to add the ui to
  109515. * @param helper the xr experience helper to enter/exit xr with
  109516. * @param options options to configure the UI
  109517. * @returns the created ui
  109518. */
  109519. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  109520. private constructor();
  109521. private _updateButtons;
  109522. /**
  109523. * Disposes of the object
  109524. */
  109525. dispose(): void;
  109526. }
  109527. }
  109528. declare module BABYLON {
  109529. /**
  109530. * Represents an XR input
  109531. */
  109532. export class WebXRController {
  109533. private scene;
  109534. /** The underlying input source for the controller */
  109535. inputSource: XRInputSource;
  109536. private parentContainer;
  109537. /**
  109538. * 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
  109539. */
  109540. grip?: AbstractMesh;
  109541. /**
  109542. * Pointer which can be used to select objects or attach a visible laser to
  109543. */
  109544. pointer: AbstractMesh;
  109545. private _gamepadMode;
  109546. /**
  109547. * If available, this is the gamepad object related to this controller.
  109548. * Using this object it is possible to get click events and trackpad changes of the
  109549. * webxr controller that is currently being used.
  109550. */
  109551. gamepadController?: WebVRController;
  109552. /**
  109553. * Event that fires when the controller is removed/disposed
  109554. */
  109555. onDisposeObservable: Observable<{}>;
  109556. private _tmpMatrix;
  109557. private _tmpQuaternion;
  109558. private _tmpVector;
  109559. /**
  109560. * Creates the controller
  109561. * @see https://doc.babylonjs.com/how_to/webxr
  109562. * @param scene the scene which the controller should be associated to
  109563. * @param inputSource the underlying input source for the controller
  109564. * @param parentContainer parent that the controller meshes should be children of
  109565. */
  109566. constructor(scene: Scene,
  109567. /** The underlying input source for the controller */
  109568. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  109569. /**
  109570. * Updates the controller pose based on the given XRFrame
  109571. * @param xrFrame xr frame to update the pose with
  109572. * @param referenceSpace reference space to use
  109573. */
  109574. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  109575. /**
  109576. * Gets a world space ray coming from the controller
  109577. * @param result the resulting ray
  109578. */
  109579. getWorldPointerRayToRef(result: Ray): void;
  109580. /**
  109581. * Get the scene associated with this controller
  109582. * @returns the scene object
  109583. */
  109584. getScene(): Scene;
  109585. /**
  109586. * Disposes of the object
  109587. */
  109588. dispose(): void;
  109589. }
  109590. }
  109591. declare module BABYLON {
  109592. /**
  109593. * XR input used to track XR inputs such as controllers/rays
  109594. */
  109595. export class WebXRInput implements IDisposable {
  109596. /**
  109597. * Base experience the input listens to
  109598. */
  109599. baseExperience: WebXRExperienceHelper;
  109600. /**
  109601. * XR controllers being tracked
  109602. */
  109603. controllers: Array<WebXRController>;
  109604. private _frameObserver;
  109605. private _stateObserver;
  109606. /**
  109607. * Event when a controller has been connected/added
  109608. */
  109609. onControllerAddedObservable: Observable<WebXRController>;
  109610. /**
  109611. * Event when a controller has been removed/disconnected
  109612. */
  109613. onControllerRemovedObservable: Observable<WebXRController>;
  109614. /**
  109615. * Initializes the WebXRInput
  109616. * @param baseExperience experience helper which the input should be created for
  109617. */
  109618. constructor(
  109619. /**
  109620. * Base experience the input listens to
  109621. */
  109622. baseExperience: WebXRExperienceHelper);
  109623. private _onInputSourcesChange;
  109624. private _addAndRemoveControllers;
  109625. /**
  109626. * Disposes of the object
  109627. */
  109628. dispose(): void;
  109629. }
  109630. }
  109631. declare module BABYLON {
  109632. /**
  109633. * Enables teleportation
  109634. */
  109635. export class WebXRControllerTeleportation {
  109636. private _teleportationFillColor;
  109637. private _teleportationBorderColor;
  109638. private _tmpRay;
  109639. private _tmpVector;
  109640. /**
  109641. * Creates a WebXRControllerTeleportation
  109642. * @param input input manager to add teleportation to
  109643. * @param floorMeshes floormeshes which can be teleported to
  109644. */
  109645. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  109646. }
  109647. }
  109648. declare module BABYLON {
  109649. /**
  109650. * Handles pointer input automatically for the pointer of XR controllers
  109651. */
  109652. export class WebXRControllerPointerSelection {
  109653. private static _idCounter;
  109654. private _tmpRay;
  109655. /**
  109656. * Creates a WebXRControllerPointerSelection
  109657. * @param input input manager to setup pointer selection
  109658. */
  109659. constructor(input: WebXRInput);
  109660. private _convertNormalToDirectionOfRay;
  109661. private _updatePointerDistance;
  109662. }
  109663. }
  109664. declare module BABYLON {
  109665. /**
  109666. * Class used to represent data loading progression
  109667. */
  109668. export class SceneLoaderProgressEvent {
  109669. /** defines if data length to load can be evaluated */
  109670. readonly lengthComputable: boolean;
  109671. /** defines the loaded data length */
  109672. readonly loaded: number;
  109673. /** defines the data length to load */
  109674. readonly total: number;
  109675. /**
  109676. * Create a new progress event
  109677. * @param lengthComputable defines if data length to load can be evaluated
  109678. * @param loaded defines the loaded data length
  109679. * @param total defines the data length to load
  109680. */
  109681. constructor(
  109682. /** defines if data length to load can be evaluated */
  109683. lengthComputable: boolean,
  109684. /** defines the loaded data length */
  109685. loaded: number,
  109686. /** defines the data length to load */
  109687. total: number);
  109688. /**
  109689. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  109690. * @param event defines the source event
  109691. * @returns a new SceneLoaderProgressEvent
  109692. */
  109693. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  109694. }
  109695. /**
  109696. * Interface used by SceneLoader plugins to define supported file extensions
  109697. */
  109698. export interface ISceneLoaderPluginExtensions {
  109699. /**
  109700. * Defines the list of supported extensions
  109701. */
  109702. [extension: string]: {
  109703. isBinary: boolean;
  109704. };
  109705. }
  109706. /**
  109707. * Interface used by SceneLoader plugin factory
  109708. */
  109709. export interface ISceneLoaderPluginFactory {
  109710. /**
  109711. * Defines the name of the factory
  109712. */
  109713. name: string;
  109714. /**
  109715. * Function called to create a new plugin
  109716. * @return the new plugin
  109717. */
  109718. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  109719. /**
  109720. * The callback that returns true if the data can be directly loaded.
  109721. * @param data string containing the file data
  109722. * @returns if the data can be loaded directly
  109723. */
  109724. canDirectLoad?(data: string): boolean;
  109725. }
  109726. /**
  109727. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  109728. */
  109729. export interface ISceneLoaderPluginBase {
  109730. /**
  109731. * The friendly name of this plugin.
  109732. */
  109733. name: string;
  109734. /**
  109735. * The file extensions supported by this plugin.
  109736. */
  109737. extensions: string | ISceneLoaderPluginExtensions;
  109738. /**
  109739. * The callback called when loading from a url.
  109740. * @param scene scene loading this url
  109741. * @param url url to load
  109742. * @param onSuccess callback called when the file successfully loads
  109743. * @param onProgress callback called while file is loading (if the server supports this mode)
  109744. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  109745. * @param onError callback called when the file fails to load
  109746. * @returns a file request object
  109747. */
  109748. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109749. /**
  109750. * The callback called when loading from a file object.
  109751. * @param scene scene loading this file
  109752. * @param file defines the file to load
  109753. * @param onSuccess defines the callback to call when data is loaded
  109754. * @param onProgress defines the callback to call during loading process
  109755. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  109756. * @param onError defines the callback to call when an error occurs
  109757. * @returns a file request object
  109758. */
  109759. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  109760. /**
  109761. * The callback that returns true if the data can be directly loaded.
  109762. * @param data string containing the file data
  109763. * @returns if the data can be loaded directly
  109764. */
  109765. canDirectLoad?(data: string): boolean;
  109766. /**
  109767. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  109768. * @param scene scene loading this data
  109769. * @param data string containing the data
  109770. * @returns data to pass to the plugin
  109771. */
  109772. directLoad?(scene: Scene, data: string): any;
  109773. /**
  109774. * The callback that allows custom handling of the root url based on the response url.
  109775. * @param rootUrl the original root url
  109776. * @param responseURL the response url if available
  109777. * @returns the new root url
  109778. */
  109779. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  109780. }
  109781. /**
  109782. * Interface used to define a SceneLoader plugin
  109783. */
  109784. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  109785. /**
  109786. * Import meshes into a scene.
  109787. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109788. * @param scene The scene to import into
  109789. * @param data The data to import
  109790. * @param rootUrl The root url for scene and resources
  109791. * @param meshes The meshes array to import into
  109792. * @param particleSystems The particle systems array to import into
  109793. * @param skeletons The skeletons array to import into
  109794. * @param onError The callback when import fails
  109795. * @returns True if successful or false otherwise
  109796. */
  109797. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  109798. /**
  109799. * Load into a scene.
  109800. * @param scene The scene to load into
  109801. * @param data The data to import
  109802. * @param rootUrl The root url for scene and resources
  109803. * @param onError The callback when import fails
  109804. * @returns True if successful or false otherwise
  109805. */
  109806. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  109807. /**
  109808. * Load into an asset container.
  109809. * @param scene The scene to load into
  109810. * @param data The data to import
  109811. * @param rootUrl The root url for scene and resources
  109812. * @param onError The callback when import fails
  109813. * @returns The loaded asset container
  109814. */
  109815. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  109816. }
  109817. /**
  109818. * Interface used to define an async SceneLoader plugin
  109819. */
  109820. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  109821. /**
  109822. * Import meshes into a scene.
  109823. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109824. * @param scene The scene to import into
  109825. * @param data The data to import
  109826. * @param rootUrl The root url for scene and resources
  109827. * @param onProgress The callback when the load progresses
  109828. * @param fileName Defines the name of the file to load
  109829. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  109830. */
  109831. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  109832. meshes: AbstractMesh[];
  109833. particleSystems: IParticleSystem[];
  109834. skeletons: Skeleton[];
  109835. animationGroups: AnimationGroup[];
  109836. }>;
  109837. /**
  109838. * Load into a scene.
  109839. * @param scene The scene to load into
  109840. * @param data The data to import
  109841. * @param rootUrl The root url for scene and resources
  109842. * @param onProgress The callback when the load progresses
  109843. * @param fileName Defines the name of the file to load
  109844. * @returns Nothing
  109845. */
  109846. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  109847. /**
  109848. * Load into an asset container.
  109849. * @param scene The scene to load into
  109850. * @param data The data to import
  109851. * @param rootUrl The root url for scene and resources
  109852. * @param onProgress The callback when the load progresses
  109853. * @param fileName Defines the name of the file to load
  109854. * @returns The loaded asset container
  109855. */
  109856. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  109857. }
  109858. /**
  109859. * Class used to load scene from various file formats using registered plugins
  109860. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  109861. */
  109862. export class SceneLoader {
  109863. /**
  109864. * No logging while loading
  109865. */
  109866. static readonly NO_LOGGING: number;
  109867. /**
  109868. * Minimal logging while loading
  109869. */
  109870. static readonly MINIMAL_LOGGING: number;
  109871. /**
  109872. * Summary logging while loading
  109873. */
  109874. static readonly SUMMARY_LOGGING: number;
  109875. /**
  109876. * Detailled logging while loading
  109877. */
  109878. static readonly DETAILED_LOGGING: number;
  109879. /**
  109880. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  109881. */
  109882. static ForceFullSceneLoadingForIncremental: boolean;
  109883. /**
  109884. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  109885. */
  109886. static ShowLoadingScreen: boolean;
  109887. /**
  109888. * Defines the current logging level (while loading the scene)
  109889. * @ignorenaming
  109890. */
  109891. static loggingLevel: number;
  109892. /**
  109893. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  109894. */
  109895. static CleanBoneMatrixWeights: boolean;
  109896. /**
  109897. * Event raised when a plugin is used to load a scene
  109898. */
  109899. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  109900. private static _registeredPlugins;
  109901. private static _getDefaultPlugin;
  109902. private static _getPluginForExtension;
  109903. private static _getPluginForDirectLoad;
  109904. private static _getPluginForFilename;
  109905. private static _getDirectLoad;
  109906. private static _loadData;
  109907. private static _getFileInfo;
  109908. /**
  109909. * Gets a plugin that can load the given extension
  109910. * @param extension defines the extension to load
  109911. * @returns a plugin or null if none works
  109912. */
  109913. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  109914. /**
  109915. * Gets a boolean indicating that the given extension can be loaded
  109916. * @param extension defines the extension to load
  109917. * @returns true if the extension is supported
  109918. */
  109919. static IsPluginForExtensionAvailable(extension: string): boolean;
  109920. /**
  109921. * Adds a new plugin to the list of registered plugins
  109922. * @param plugin defines the plugin to add
  109923. */
  109924. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  109925. /**
  109926. * Import meshes into a scene
  109927. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109928. * @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)
  109929. * @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)
  109930. * @param scene the instance of BABYLON.Scene to append to
  109931. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  109932. * @param onProgress a callback with a progress event for each file being loaded
  109933. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109934. * @param pluginExtension the extension used to determine the plugin
  109935. * @returns The loaded plugin
  109936. */
  109937. 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>;
  109938. /**
  109939. * Import meshes into a scene
  109940. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  109941. * @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)
  109942. * @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)
  109943. * @param scene the instance of BABYLON.Scene to append to
  109944. * @param onProgress a callback with a progress event for each file being loaded
  109945. * @param pluginExtension the extension used to determine the plugin
  109946. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  109947. */
  109948. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  109949. meshes: AbstractMesh[];
  109950. particleSystems: IParticleSystem[];
  109951. skeletons: Skeleton[];
  109952. animationGroups: AnimationGroup[];
  109953. }>;
  109954. /**
  109955. * Load a scene
  109956. * @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)
  109957. * @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)
  109958. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109959. * @param onSuccess a callback with the scene when import succeeds
  109960. * @param onProgress a callback with a progress event for each file being loaded
  109961. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109962. * @param pluginExtension the extension used to determine the plugin
  109963. * @returns The loaded plugin
  109964. */
  109965. 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>;
  109966. /**
  109967. * Load a scene
  109968. * @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)
  109969. * @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)
  109970. * @param engine is the instance of BABYLON.Engine to use to create the scene
  109971. * @param onProgress a callback with a progress event for each file being loaded
  109972. * @param pluginExtension the extension used to determine the plugin
  109973. * @returns The loaded scene
  109974. */
  109975. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109976. /**
  109977. * Append a scene
  109978. * @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)
  109979. * @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)
  109980. * @param scene is the instance of BABYLON.Scene to append to
  109981. * @param onSuccess a callback with the scene when import succeeds
  109982. * @param onProgress a callback with a progress event for each file being loaded
  109983. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  109984. * @param pluginExtension the extension used to determine the plugin
  109985. * @returns The loaded plugin
  109986. */
  109987. 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>;
  109988. /**
  109989. * Append a scene
  109990. * @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)
  109991. * @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)
  109992. * @param scene is the instance of BABYLON.Scene to append to
  109993. * @param onProgress a callback with a progress event for each file being loaded
  109994. * @param pluginExtension the extension used to determine the plugin
  109995. * @returns The given scene
  109996. */
  109997. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  109998. /**
  109999. * Load a scene into an asset container
  110000. * @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)
  110001. * @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)
  110002. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110003. * @param onSuccess a callback with the scene when import succeeds
  110004. * @param onProgress a callback with a progress event for each file being loaded
  110005. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  110006. * @param pluginExtension the extension used to determine the plugin
  110007. * @returns The loaded plugin
  110008. */
  110009. 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>;
  110010. /**
  110011. * Load a scene into an asset container
  110012. * @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)
  110013. * @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)
  110014. * @param scene is the instance of Scene to append to
  110015. * @param onProgress a callback with a progress event for each file being loaded
  110016. * @param pluginExtension the extension used to determine the plugin
  110017. * @returns The loaded asset container
  110018. */
  110019. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  110020. }
  110021. }
  110022. declare module BABYLON {
  110023. /**
  110024. * Generic Controller
  110025. */
  110026. export class GenericController extends WebVRController {
  110027. /**
  110028. * Base Url for the controller model.
  110029. */
  110030. static readonly MODEL_BASE_URL: string;
  110031. /**
  110032. * File name for the controller model.
  110033. */
  110034. static readonly MODEL_FILENAME: string;
  110035. /**
  110036. * Creates a new GenericController from a gamepad
  110037. * @param vrGamepad the gamepad that the controller should be created from
  110038. */
  110039. constructor(vrGamepad: any);
  110040. /**
  110041. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110042. * @param scene scene in which to add meshes
  110043. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110044. */
  110045. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110046. /**
  110047. * Called once for each button that changed state since the last frame
  110048. * @param buttonIdx Which button index changed
  110049. * @param state New state of the button
  110050. * @param changes Which properties on the state changed since last frame
  110051. */
  110052. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110053. }
  110054. }
  110055. declare module BABYLON {
  110056. /**
  110057. * Defines the WindowsMotionController object that the state of the windows motion controller
  110058. */
  110059. export class WindowsMotionController extends WebVRController {
  110060. /**
  110061. * The base url used to load the left and right controller models
  110062. */
  110063. static MODEL_BASE_URL: string;
  110064. /**
  110065. * The name of the left controller model file
  110066. */
  110067. static MODEL_LEFT_FILENAME: string;
  110068. /**
  110069. * The name of the right controller model file
  110070. */
  110071. static MODEL_RIGHT_FILENAME: string;
  110072. /**
  110073. * The controller name prefix for this controller type
  110074. */
  110075. static readonly GAMEPAD_ID_PREFIX: string;
  110076. /**
  110077. * The controller id pattern for this controller type
  110078. */
  110079. private static readonly GAMEPAD_ID_PATTERN;
  110080. private _loadedMeshInfo;
  110081. private readonly _mapping;
  110082. /**
  110083. * Fired when the trackpad on this controller is clicked
  110084. */
  110085. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  110086. /**
  110087. * Fired when the trackpad on this controller is modified
  110088. */
  110089. onTrackpadValuesChangedObservable: Observable<StickValues>;
  110090. /**
  110091. * The current x and y values of this controller's trackpad
  110092. */
  110093. trackpad: StickValues;
  110094. /**
  110095. * Creates a new WindowsMotionController from a gamepad
  110096. * @param vrGamepad the gamepad that the controller should be created from
  110097. */
  110098. constructor(vrGamepad: any);
  110099. /**
  110100. * Fired when the trigger on this controller is modified
  110101. */
  110102. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110103. /**
  110104. * Fired when the menu button on this controller is modified
  110105. */
  110106. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110107. /**
  110108. * Fired when the grip button on this controller is modified
  110109. */
  110110. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110111. /**
  110112. * Fired when the thumbstick button on this controller is modified
  110113. */
  110114. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110115. /**
  110116. * Fired when the touchpad button on this controller is modified
  110117. */
  110118. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110119. /**
  110120. * Fired when the touchpad values on this controller are modified
  110121. */
  110122. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  110123. private _updateTrackpad;
  110124. /**
  110125. * Called once per frame by the engine.
  110126. */
  110127. update(): void;
  110128. /**
  110129. * Called once for each button that changed state since the last frame
  110130. * @param buttonIdx Which button index changed
  110131. * @param state New state of the button
  110132. * @param changes Which properties on the state changed since last frame
  110133. */
  110134. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110135. /**
  110136. * Moves the buttons on the controller mesh based on their current state
  110137. * @param buttonName the name of the button to move
  110138. * @param buttonValue the value of the button which determines the buttons new position
  110139. */
  110140. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  110141. /**
  110142. * Moves the axis on the controller mesh based on its current state
  110143. * @param axis the index of the axis
  110144. * @param axisValue the value of the axis which determines the meshes new position
  110145. * @hidden
  110146. */
  110147. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  110148. /**
  110149. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110150. * @param scene scene in which to add meshes
  110151. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110152. */
  110153. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  110154. /**
  110155. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  110156. * can be transformed by button presses and axes values, based on this._mapping.
  110157. *
  110158. * @param scene scene in which the meshes exist
  110159. * @param meshes list of meshes that make up the controller model to process
  110160. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  110161. */
  110162. private processModel;
  110163. private createMeshInfo;
  110164. /**
  110165. * Gets the ray of the controller in the direction the controller is pointing
  110166. * @param length the length the resulting ray should be
  110167. * @returns a ray in the direction the controller is pointing
  110168. */
  110169. getForwardRay(length?: number): Ray;
  110170. /**
  110171. * Disposes of the controller
  110172. */
  110173. dispose(): void;
  110174. }
  110175. }
  110176. declare module BABYLON {
  110177. /**
  110178. * Oculus Touch Controller
  110179. */
  110180. export class OculusTouchController extends WebVRController {
  110181. /**
  110182. * Base Url for the controller model.
  110183. */
  110184. static MODEL_BASE_URL: string;
  110185. /**
  110186. * File name for the left controller model.
  110187. */
  110188. static MODEL_LEFT_FILENAME: string;
  110189. /**
  110190. * File name for the right controller model.
  110191. */
  110192. static MODEL_RIGHT_FILENAME: string;
  110193. /**
  110194. * Base Url for the Quest controller model.
  110195. */
  110196. static QUEST_MODEL_BASE_URL: string;
  110197. /**
  110198. * @hidden
  110199. * If the controllers are running on a device that needs the updated Quest controller models
  110200. */
  110201. static _IsQuest: boolean;
  110202. /**
  110203. * Fired when the secondary trigger on this controller is modified
  110204. */
  110205. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  110206. /**
  110207. * Fired when the thumb rest on this controller is modified
  110208. */
  110209. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  110210. /**
  110211. * Creates a new OculusTouchController from a gamepad
  110212. * @param vrGamepad the gamepad that the controller should be created from
  110213. */
  110214. constructor(vrGamepad: any);
  110215. /**
  110216. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110217. * @param scene scene in which to add meshes
  110218. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110219. */
  110220. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110221. /**
  110222. * Fired when the A button on this controller is modified
  110223. */
  110224. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110225. /**
  110226. * Fired when the B button on this controller is modified
  110227. */
  110228. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110229. /**
  110230. * Fired when the X button on this controller is modified
  110231. */
  110232. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110233. /**
  110234. * Fired when the Y button on this controller is modified
  110235. */
  110236. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110237. /**
  110238. * Called once for each button that changed state since the last frame
  110239. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  110240. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  110241. * 2) secondary trigger (same)
  110242. * 3) A (right) X (left), touch, pressed = value
  110243. * 4) B / Y
  110244. * 5) thumb rest
  110245. * @param buttonIdx Which button index changed
  110246. * @param state New state of the button
  110247. * @param changes Which properties on the state changed since last frame
  110248. */
  110249. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110250. }
  110251. }
  110252. declare module BABYLON {
  110253. /**
  110254. * Vive Controller
  110255. */
  110256. export class ViveController extends WebVRController {
  110257. /**
  110258. * Base Url for the controller model.
  110259. */
  110260. static MODEL_BASE_URL: string;
  110261. /**
  110262. * File name for the controller model.
  110263. */
  110264. static MODEL_FILENAME: string;
  110265. /**
  110266. * Creates a new ViveController from a gamepad
  110267. * @param vrGamepad the gamepad that the controller should be created from
  110268. */
  110269. constructor(vrGamepad: any);
  110270. /**
  110271. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110272. * @param scene scene in which to add meshes
  110273. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110274. */
  110275. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110276. /**
  110277. * Fired when the left button on this controller is modified
  110278. */
  110279. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110280. /**
  110281. * Fired when the right button on this controller is modified
  110282. */
  110283. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110284. /**
  110285. * Fired when the menu button on this controller is modified
  110286. */
  110287. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  110288. /**
  110289. * Called once for each button that changed state since the last frame
  110290. * Vive mapping:
  110291. * 0: touchpad
  110292. * 1: trigger
  110293. * 2: left AND right buttons
  110294. * 3: menu button
  110295. * @param buttonIdx Which button index changed
  110296. * @param state New state of the button
  110297. * @param changes Which properties on the state changed since last frame
  110298. */
  110299. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110300. }
  110301. }
  110302. declare module BABYLON {
  110303. /**
  110304. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  110305. */
  110306. export class WebXRControllerModelLoader {
  110307. /**
  110308. * Creates the WebXRControllerModelLoader
  110309. * @param input xr input that creates the controllers
  110310. */
  110311. constructor(input: WebXRInput);
  110312. }
  110313. }
  110314. declare module BABYLON {
  110315. /**
  110316. * Contains an array of blocks representing the octree
  110317. */
  110318. export interface IOctreeContainer<T> {
  110319. /**
  110320. * Blocks within the octree
  110321. */
  110322. blocks: Array<OctreeBlock<T>>;
  110323. }
  110324. /**
  110325. * Class used to store a cell in an octree
  110326. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110327. */
  110328. export class OctreeBlock<T> {
  110329. /**
  110330. * Gets the content of the current block
  110331. */
  110332. entries: T[];
  110333. /**
  110334. * Gets the list of block children
  110335. */
  110336. blocks: Array<OctreeBlock<T>>;
  110337. private _depth;
  110338. private _maxDepth;
  110339. private _capacity;
  110340. private _minPoint;
  110341. private _maxPoint;
  110342. private _boundingVectors;
  110343. private _creationFunc;
  110344. /**
  110345. * Creates a new block
  110346. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  110347. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  110348. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110349. * @param depth defines the current depth of this block in the octree
  110350. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  110351. * @param creationFunc defines a callback to call when an element is added to the block
  110352. */
  110353. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  110354. /**
  110355. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  110356. */
  110357. readonly capacity: number;
  110358. /**
  110359. * Gets the minimum vector (in world space) of the block's bounding box
  110360. */
  110361. readonly minPoint: Vector3;
  110362. /**
  110363. * Gets the maximum vector (in world space) of the block's bounding box
  110364. */
  110365. readonly maxPoint: Vector3;
  110366. /**
  110367. * Add a new element to this block
  110368. * @param entry defines the element to add
  110369. */
  110370. addEntry(entry: T): void;
  110371. /**
  110372. * Remove an element from this block
  110373. * @param entry defines the element to remove
  110374. */
  110375. removeEntry(entry: T): void;
  110376. /**
  110377. * Add an array of elements to this block
  110378. * @param entries defines the array of elements to add
  110379. */
  110380. addEntries(entries: T[]): void;
  110381. /**
  110382. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  110383. * @param frustumPlanes defines the frustum planes to test
  110384. * @param selection defines the array to store current content if selection is positive
  110385. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110386. */
  110387. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110388. /**
  110389. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  110390. * @param sphereCenter defines the bounding sphere center
  110391. * @param sphereRadius defines the bounding sphere radius
  110392. * @param selection defines the array to store current content if selection is positive
  110393. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110394. */
  110395. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  110396. /**
  110397. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  110398. * @param ray defines the ray to test with
  110399. * @param selection defines the array to store current content if selection is positive
  110400. */
  110401. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  110402. /**
  110403. * Subdivide the content into child blocks (this block will then be empty)
  110404. */
  110405. createInnerBlocks(): void;
  110406. /**
  110407. * @hidden
  110408. */
  110409. 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;
  110410. }
  110411. }
  110412. declare module BABYLON {
  110413. /**
  110414. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  110415. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110416. */
  110417. export class Octree<T> {
  110418. /** 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.) */
  110419. maxDepth: number;
  110420. /**
  110421. * Blocks within the octree containing objects
  110422. */
  110423. blocks: Array<OctreeBlock<T>>;
  110424. /**
  110425. * Content stored in the octree
  110426. */
  110427. dynamicContent: T[];
  110428. private _maxBlockCapacity;
  110429. private _selectionContent;
  110430. private _creationFunc;
  110431. /**
  110432. * Creates a octree
  110433. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110434. * @param creationFunc function to be used to instatiate the octree
  110435. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  110436. * @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.)
  110437. */
  110438. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  110439. /** 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.) */
  110440. maxDepth?: number);
  110441. /**
  110442. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  110443. * @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);
  110444. * @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);
  110445. * @param entries meshes to be added to the octree blocks
  110446. */
  110447. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  110448. /**
  110449. * Adds a mesh to the octree
  110450. * @param entry Mesh to add to the octree
  110451. */
  110452. addMesh(entry: T): void;
  110453. /**
  110454. * Remove an element from the octree
  110455. * @param entry defines the element to remove
  110456. */
  110457. removeMesh(entry: T): void;
  110458. /**
  110459. * Selects an array of meshes within the frustum
  110460. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  110461. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  110462. * @returns array of meshes within the frustum
  110463. */
  110464. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  110465. /**
  110466. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  110467. * @param sphereCenter defines the bounding sphere center
  110468. * @param sphereRadius defines the bounding sphere radius
  110469. * @param allowDuplicate defines if the selection array can contains duplicated entries
  110470. * @returns an array of objects that intersect the sphere
  110471. */
  110472. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  110473. /**
  110474. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  110475. * @param ray defines the ray to test with
  110476. * @returns array of intersected objects
  110477. */
  110478. intersectsRay(ray: Ray): SmartArray<T>;
  110479. /**
  110480. * Adds a mesh into the octree block if it intersects the block
  110481. */
  110482. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  110483. /**
  110484. * Adds a submesh into the octree block if it intersects the block
  110485. */
  110486. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  110487. }
  110488. }
  110489. declare module BABYLON {
  110490. interface Scene {
  110491. /**
  110492. * @hidden
  110493. * Backing Filed
  110494. */
  110495. _selectionOctree: Octree<AbstractMesh>;
  110496. /**
  110497. * Gets the octree used to boost mesh selection (picking)
  110498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110499. */
  110500. selectionOctree: Octree<AbstractMesh>;
  110501. /**
  110502. * Creates or updates the octree used to boost selection (picking)
  110503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110504. * @param maxCapacity defines the maximum capacity per leaf
  110505. * @param maxDepth defines the maximum depth of the octree
  110506. * @returns an octree of AbstractMesh
  110507. */
  110508. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  110509. }
  110510. interface AbstractMesh {
  110511. /**
  110512. * @hidden
  110513. * Backing Field
  110514. */
  110515. _submeshesOctree: Octree<SubMesh>;
  110516. /**
  110517. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  110518. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  110519. * @param maxCapacity defines the maximum size of each block (64 by default)
  110520. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  110521. * @returns the new octree
  110522. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  110523. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  110524. */
  110525. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  110526. }
  110527. /**
  110528. * Defines the octree scene component responsible to manage any octrees
  110529. * in a given scene.
  110530. */
  110531. export class OctreeSceneComponent {
  110532. /**
  110533. * The component name help to identify the component in the list of scene components.
  110534. */
  110535. readonly name: string;
  110536. /**
  110537. * The scene the component belongs to.
  110538. */
  110539. scene: Scene;
  110540. /**
  110541. * Indicates if the meshes have been checked to make sure they are isEnabled()
  110542. */
  110543. readonly checksIsEnabled: boolean;
  110544. /**
  110545. * Creates a new instance of the component for the given scene
  110546. * @param scene Defines the scene to register the component in
  110547. */
  110548. constructor(scene: Scene);
  110549. /**
  110550. * Registers the component in a given scene
  110551. */
  110552. register(): void;
  110553. /**
  110554. * Return the list of active meshes
  110555. * @returns the list of active meshes
  110556. */
  110557. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110558. /**
  110559. * Return the list of active sub meshes
  110560. * @param mesh The mesh to get the candidates sub meshes from
  110561. * @returns the list of active sub meshes
  110562. */
  110563. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110564. private _tempRay;
  110565. /**
  110566. * Return the list of sub meshes intersecting with a given local ray
  110567. * @param mesh defines the mesh to find the submesh for
  110568. * @param localRay defines the ray in local space
  110569. * @returns the list of intersecting sub meshes
  110570. */
  110571. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  110572. /**
  110573. * Return the list of sub meshes colliding with a collider
  110574. * @param mesh defines the mesh to find the submesh for
  110575. * @param collider defines the collider to evaluate the collision against
  110576. * @returns the list of colliding sub meshes
  110577. */
  110578. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  110579. /**
  110580. * Rebuilds the elements related to this component in case of
  110581. * context lost for instance.
  110582. */
  110583. rebuild(): void;
  110584. /**
  110585. * Disposes the component and the associated ressources.
  110586. */
  110587. dispose(): void;
  110588. }
  110589. }
  110590. declare module BABYLON {
  110591. /**
  110592. * Renders a layer on top of an existing scene
  110593. */
  110594. export class UtilityLayerRenderer implements IDisposable {
  110595. /** the original scene that will be rendered on top of */
  110596. originalScene: Scene;
  110597. private _pointerCaptures;
  110598. private _lastPointerEvents;
  110599. private static _DefaultUtilityLayer;
  110600. private static _DefaultKeepDepthUtilityLayer;
  110601. private _sharedGizmoLight;
  110602. private _renderCamera;
  110603. /**
  110604. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  110605. * @returns the camera that is used when rendering the utility layer
  110606. */
  110607. getRenderCamera(): Nullable<Camera>;
  110608. /**
  110609. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  110610. * @param cam the camera that should be used when rendering the utility layer
  110611. */
  110612. setRenderCamera(cam: Nullable<Camera>): void;
  110613. /**
  110614. * @hidden
  110615. * Light which used by gizmos to get light shading
  110616. */
  110617. _getSharedGizmoLight(): HemisphericLight;
  110618. /**
  110619. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  110620. */
  110621. pickUtilitySceneFirst: boolean;
  110622. /**
  110623. * 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)
  110624. */
  110625. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  110626. /**
  110627. * 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)
  110628. */
  110629. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  110630. /**
  110631. * The scene that is rendered on top of the original scene
  110632. */
  110633. utilityLayerScene: Scene;
  110634. /**
  110635. * If the utility layer should automatically be rendered on top of existing scene
  110636. */
  110637. shouldRender: boolean;
  110638. /**
  110639. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  110640. */
  110641. onlyCheckPointerDownEvents: boolean;
  110642. /**
  110643. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  110644. */
  110645. processAllEvents: boolean;
  110646. /**
  110647. * Observable raised when the pointer move from the utility layer scene to the main scene
  110648. */
  110649. onPointerOutObservable: Observable<number>;
  110650. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  110651. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  110652. private _afterRenderObserver;
  110653. private _sceneDisposeObserver;
  110654. private _originalPointerObserver;
  110655. /**
  110656. * Instantiates a UtilityLayerRenderer
  110657. * @param originalScene the original scene that will be rendered on top of
  110658. * @param handleEvents boolean indicating if the utility layer should handle events
  110659. */
  110660. constructor(
  110661. /** the original scene that will be rendered on top of */
  110662. originalScene: Scene, handleEvents?: boolean);
  110663. private _notifyObservers;
  110664. /**
  110665. * Renders the utility layers scene on top of the original scene
  110666. */
  110667. render(): void;
  110668. /**
  110669. * Disposes of the renderer
  110670. */
  110671. dispose(): void;
  110672. private _updateCamera;
  110673. }
  110674. }
  110675. declare module BABYLON {
  110676. /**
  110677. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  110678. */
  110679. export class Gizmo implements IDisposable {
  110680. /** The utility layer the gizmo will be added to */
  110681. gizmoLayer: UtilityLayerRenderer;
  110682. /**
  110683. * The root mesh of the gizmo
  110684. */
  110685. _rootMesh: Mesh;
  110686. private _attachedMesh;
  110687. /**
  110688. * Ratio for the scale of the gizmo (Default: 1)
  110689. */
  110690. scaleRatio: number;
  110691. /**
  110692. * If a custom mesh has been set (Default: false)
  110693. */
  110694. protected _customMeshSet: boolean;
  110695. /**
  110696. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  110697. * * When set, interactions will be enabled
  110698. */
  110699. attachedMesh: Nullable<AbstractMesh>;
  110700. /**
  110701. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110702. * @param mesh The mesh to replace the default mesh of the gizmo
  110703. */
  110704. setCustomMesh(mesh: Mesh): void;
  110705. /**
  110706. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  110707. */
  110708. updateGizmoRotationToMatchAttachedMesh: boolean;
  110709. /**
  110710. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  110711. */
  110712. updateGizmoPositionToMatchAttachedMesh: boolean;
  110713. /**
  110714. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  110715. */
  110716. updateScale: boolean;
  110717. protected _interactionsEnabled: boolean;
  110718. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110719. private _beforeRenderObserver;
  110720. private _tempVector;
  110721. /**
  110722. * Creates a gizmo
  110723. * @param gizmoLayer The utility layer the gizmo will be added to
  110724. */
  110725. constructor(
  110726. /** The utility layer the gizmo will be added to */
  110727. gizmoLayer?: UtilityLayerRenderer);
  110728. /**
  110729. * Updates the gizmo to match the attached mesh's position/rotation
  110730. */
  110731. protected _update(): void;
  110732. /**
  110733. * Disposes of the gizmo
  110734. */
  110735. dispose(): void;
  110736. }
  110737. }
  110738. declare module BABYLON {
  110739. /**
  110740. * Single plane drag gizmo
  110741. */
  110742. export class PlaneDragGizmo extends Gizmo {
  110743. /**
  110744. * Drag behavior responsible for the gizmos dragging interactions
  110745. */
  110746. dragBehavior: PointerDragBehavior;
  110747. private _pointerObserver;
  110748. /**
  110749. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110750. */
  110751. snapDistance: number;
  110752. /**
  110753. * Event that fires each time the gizmo snaps to a new location.
  110754. * * snapDistance is the the change in distance
  110755. */
  110756. onSnapObservable: Observable<{
  110757. snapDistance: number;
  110758. }>;
  110759. private _plane;
  110760. private _coloredMaterial;
  110761. private _hoverMaterial;
  110762. private _isEnabled;
  110763. private _parent;
  110764. /** @hidden */
  110765. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  110766. /** @hidden */
  110767. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110768. /**
  110769. * Creates a PlaneDragGizmo
  110770. * @param gizmoLayer The utility layer the gizmo will be added to
  110771. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  110772. * @param color The color of the gizmo
  110773. */
  110774. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110775. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110776. /**
  110777. * If the gizmo is enabled
  110778. */
  110779. isEnabled: boolean;
  110780. /**
  110781. * Disposes of the gizmo
  110782. */
  110783. dispose(): void;
  110784. }
  110785. }
  110786. declare module BABYLON {
  110787. /**
  110788. * Gizmo that enables dragging a mesh along 3 axis
  110789. */
  110790. export class PositionGizmo extends Gizmo {
  110791. /**
  110792. * Internal gizmo used for interactions on the x axis
  110793. */
  110794. xGizmo: AxisDragGizmo;
  110795. /**
  110796. * Internal gizmo used for interactions on the y axis
  110797. */
  110798. yGizmo: AxisDragGizmo;
  110799. /**
  110800. * Internal gizmo used for interactions on the z axis
  110801. */
  110802. zGizmo: AxisDragGizmo;
  110803. /**
  110804. * Internal gizmo used for interactions on the yz plane
  110805. */
  110806. xPlaneGizmo: PlaneDragGizmo;
  110807. /**
  110808. * Internal gizmo used for interactions on the xz plane
  110809. */
  110810. yPlaneGizmo: PlaneDragGizmo;
  110811. /**
  110812. * Internal gizmo used for interactions on the xy plane
  110813. */
  110814. zPlaneGizmo: PlaneDragGizmo;
  110815. /**
  110816. * private variables
  110817. */
  110818. private _meshAttached;
  110819. private _updateGizmoRotationToMatchAttachedMesh;
  110820. private _snapDistance;
  110821. private _scaleRatio;
  110822. /** Fires an event when any of it's sub gizmos are dragged */
  110823. onDragStartObservable: Observable<unknown>;
  110824. /** Fires an event when any of it's sub gizmos are released from dragging */
  110825. onDragEndObservable: Observable<unknown>;
  110826. /**
  110827. * If set to true, planar drag is enabled
  110828. */
  110829. private _planarGizmoEnabled;
  110830. attachedMesh: Nullable<AbstractMesh>;
  110831. /**
  110832. * Creates a PositionGizmo
  110833. * @param gizmoLayer The utility layer the gizmo will be added to
  110834. */
  110835. constructor(gizmoLayer?: UtilityLayerRenderer);
  110836. /**
  110837. * If the planar drag gizmo is enabled
  110838. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  110839. */
  110840. planarGizmoEnabled: boolean;
  110841. updateGizmoRotationToMatchAttachedMesh: boolean;
  110842. /**
  110843. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110844. */
  110845. snapDistance: number;
  110846. /**
  110847. * Ratio for the scale of the gizmo (Default: 1)
  110848. */
  110849. scaleRatio: number;
  110850. /**
  110851. * Disposes of the gizmo
  110852. */
  110853. dispose(): void;
  110854. /**
  110855. * CustomMeshes are not supported by this gizmo
  110856. * @param mesh The mesh to replace the default mesh of the gizmo
  110857. */
  110858. setCustomMesh(mesh: Mesh): void;
  110859. }
  110860. }
  110861. declare module BABYLON {
  110862. /**
  110863. * Single axis drag gizmo
  110864. */
  110865. export class AxisDragGizmo extends Gizmo {
  110866. /**
  110867. * Drag behavior responsible for the gizmos dragging interactions
  110868. */
  110869. dragBehavior: PointerDragBehavior;
  110870. private _pointerObserver;
  110871. /**
  110872. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110873. */
  110874. snapDistance: number;
  110875. /**
  110876. * Event that fires each time the gizmo snaps to a new location.
  110877. * * snapDistance is the the change in distance
  110878. */
  110879. onSnapObservable: Observable<{
  110880. snapDistance: number;
  110881. }>;
  110882. private _isEnabled;
  110883. private _parent;
  110884. private _arrow;
  110885. private _coloredMaterial;
  110886. private _hoverMaterial;
  110887. /** @hidden */
  110888. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  110889. /** @hidden */
  110890. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  110891. /**
  110892. * Creates an AxisDragGizmo
  110893. * @param gizmoLayer The utility layer the gizmo will be added to
  110894. * @param dragAxis The axis which the gizmo will be able to drag on
  110895. * @param color The color of the gizmo
  110896. */
  110897. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  110898. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110899. /**
  110900. * If the gizmo is enabled
  110901. */
  110902. isEnabled: boolean;
  110903. /**
  110904. * Disposes of the gizmo
  110905. */
  110906. dispose(): void;
  110907. }
  110908. }
  110909. declare module BABYLON.Debug {
  110910. /**
  110911. * The Axes viewer will show 3 axes in a specific point in space
  110912. */
  110913. export class AxesViewer {
  110914. private _xAxis;
  110915. private _yAxis;
  110916. private _zAxis;
  110917. private _scaleLinesFactor;
  110918. private _instanced;
  110919. /**
  110920. * Gets the hosting scene
  110921. */
  110922. scene: Scene;
  110923. /**
  110924. * Gets or sets a number used to scale line length
  110925. */
  110926. scaleLines: number;
  110927. /** Gets the node hierarchy used to render x-axis */
  110928. readonly xAxis: TransformNode;
  110929. /** Gets the node hierarchy used to render y-axis */
  110930. readonly yAxis: TransformNode;
  110931. /** Gets the node hierarchy used to render z-axis */
  110932. readonly zAxis: TransformNode;
  110933. /**
  110934. * Creates a new AxesViewer
  110935. * @param scene defines the hosting scene
  110936. * @param scaleLines defines a number used to scale line length (1 by default)
  110937. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  110938. * @param xAxis defines the node hierarchy used to render the x-axis
  110939. * @param yAxis defines the node hierarchy used to render the y-axis
  110940. * @param zAxis defines the node hierarchy used to render the z-axis
  110941. */
  110942. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  110943. /**
  110944. * Force the viewer to update
  110945. * @param position defines the position of the viewer
  110946. * @param xaxis defines the x axis of the viewer
  110947. * @param yaxis defines the y axis of the viewer
  110948. * @param zaxis defines the z axis of the viewer
  110949. */
  110950. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  110951. /**
  110952. * Creates an instance of this axes viewer.
  110953. * @returns a new axes viewer with instanced meshes
  110954. */
  110955. createInstance(): AxesViewer;
  110956. /** Releases resources */
  110957. dispose(): void;
  110958. private static _SetRenderingGroupId;
  110959. }
  110960. }
  110961. declare module BABYLON.Debug {
  110962. /**
  110963. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  110964. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  110965. */
  110966. export class BoneAxesViewer extends AxesViewer {
  110967. /**
  110968. * Gets or sets the target mesh where to display the axes viewer
  110969. */
  110970. mesh: Nullable<Mesh>;
  110971. /**
  110972. * Gets or sets the target bone where to display the axes viewer
  110973. */
  110974. bone: Nullable<Bone>;
  110975. /** Gets current position */
  110976. pos: Vector3;
  110977. /** Gets direction of X axis */
  110978. xaxis: Vector3;
  110979. /** Gets direction of Y axis */
  110980. yaxis: Vector3;
  110981. /** Gets direction of Z axis */
  110982. zaxis: Vector3;
  110983. /**
  110984. * Creates a new BoneAxesViewer
  110985. * @param scene defines the hosting scene
  110986. * @param bone defines the target bone
  110987. * @param mesh defines the target mesh
  110988. * @param scaleLines defines a scaling factor for line length (1 by default)
  110989. */
  110990. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  110991. /**
  110992. * Force the viewer to update
  110993. */
  110994. update(): void;
  110995. /** Releases resources */
  110996. dispose(): void;
  110997. }
  110998. }
  110999. declare module BABYLON {
  111000. /**
  111001. * Interface used to define scene explorer extensibility option
  111002. */
  111003. export interface IExplorerExtensibilityOption {
  111004. /**
  111005. * Define the option label
  111006. */
  111007. label: string;
  111008. /**
  111009. * Defines the action to execute on click
  111010. */
  111011. action: (entity: any) => void;
  111012. }
  111013. /**
  111014. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  111015. */
  111016. export interface IExplorerExtensibilityGroup {
  111017. /**
  111018. * Defines a predicate to test if a given type mut be extended
  111019. */
  111020. predicate: (entity: any) => boolean;
  111021. /**
  111022. * Gets the list of options added to a type
  111023. */
  111024. entries: IExplorerExtensibilityOption[];
  111025. }
  111026. /**
  111027. * Interface used to define the options to use to create the Inspector
  111028. */
  111029. export interface IInspectorOptions {
  111030. /**
  111031. * Display in overlay mode (default: false)
  111032. */
  111033. overlay?: boolean;
  111034. /**
  111035. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  111036. */
  111037. globalRoot?: HTMLElement;
  111038. /**
  111039. * Display the Scene explorer
  111040. */
  111041. showExplorer?: boolean;
  111042. /**
  111043. * Display the property inspector
  111044. */
  111045. showInspector?: boolean;
  111046. /**
  111047. * Display in embed mode (both panes on the right)
  111048. */
  111049. embedMode?: boolean;
  111050. /**
  111051. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  111052. */
  111053. handleResize?: boolean;
  111054. /**
  111055. * Allow the panes to popup (default: true)
  111056. */
  111057. enablePopup?: boolean;
  111058. /**
  111059. * Allow the panes to be closed by users (default: true)
  111060. */
  111061. enableClose?: boolean;
  111062. /**
  111063. * Optional list of extensibility entries
  111064. */
  111065. explorerExtensibility?: IExplorerExtensibilityGroup[];
  111066. /**
  111067. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  111068. */
  111069. inspectorURL?: string;
  111070. }
  111071. interface Scene {
  111072. /**
  111073. * @hidden
  111074. * Backing field
  111075. */
  111076. _debugLayer: DebugLayer;
  111077. /**
  111078. * Gets the debug layer (aka Inspector) associated with the scene
  111079. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111080. */
  111081. debugLayer: DebugLayer;
  111082. }
  111083. /**
  111084. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111085. * what is happening in your scene
  111086. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111087. */
  111088. export class DebugLayer {
  111089. /**
  111090. * Define the url to get the inspector script from.
  111091. * By default it uses the babylonjs CDN.
  111092. * @ignoreNaming
  111093. */
  111094. static InspectorURL: string;
  111095. private _scene;
  111096. private BJSINSPECTOR;
  111097. private _onPropertyChangedObservable?;
  111098. /**
  111099. * Observable triggered when a property is changed through the inspector.
  111100. */
  111101. readonly onPropertyChangedObservable: any;
  111102. /**
  111103. * Instantiates a new debug layer.
  111104. * The debug layer (aka Inspector) is the go to tool in order to better understand
  111105. * what is happening in your scene
  111106. * @see http://doc.babylonjs.com/features/playground_debuglayer
  111107. * @param scene Defines the scene to inspect
  111108. */
  111109. constructor(scene: Scene);
  111110. /** Creates the inspector window. */
  111111. private _createInspector;
  111112. /**
  111113. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  111114. * @param entity defines the entity to select
  111115. * @param lineContainerTitle defines the specific block to highlight
  111116. */
  111117. select(entity: any, lineContainerTitle?: string): void;
  111118. /** Get the inspector from bundle or global */
  111119. private _getGlobalInspector;
  111120. /**
  111121. * Get if the inspector is visible or not.
  111122. * @returns true if visible otherwise, false
  111123. */
  111124. isVisible(): boolean;
  111125. /**
  111126. * Hide the inspector and close its window.
  111127. */
  111128. hide(): void;
  111129. /**
  111130. * Launch the debugLayer.
  111131. * @param config Define the configuration of the inspector
  111132. * @return a promise fulfilled when the debug layer is visible
  111133. */
  111134. show(config?: IInspectorOptions): Promise<DebugLayer>;
  111135. }
  111136. }
  111137. declare module BABYLON {
  111138. /**
  111139. * Class containing static functions to help procedurally build meshes
  111140. */
  111141. export class BoxBuilder {
  111142. /**
  111143. * Creates a box mesh
  111144. * * The parameter `size` sets the size (float) of each box side (default 1)
  111145. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  111146. * * 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)
  111147. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  111148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111151. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  111152. * @param name defines the name of the mesh
  111153. * @param options defines the options used to create the mesh
  111154. * @param scene defines the hosting scene
  111155. * @returns the box mesh
  111156. */
  111157. static CreateBox(name: string, options: {
  111158. size?: number;
  111159. width?: number;
  111160. height?: number;
  111161. depth?: number;
  111162. faceUV?: Vector4[];
  111163. faceColors?: Color4[];
  111164. sideOrientation?: number;
  111165. frontUVs?: Vector4;
  111166. backUVs?: Vector4;
  111167. wrap?: boolean;
  111168. topBaseAt?: number;
  111169. bottomBaseAt?: number;
  111170. updatable?: boolean;
  111171. }, scene?: Nullable<Scene>): Mesh;
  111172. }
  111173. }
  111174. declare module BABYLON {
  111175. /**
  111176. * Class containing static functions to help procedurally build meshes
  111177. */
  111178. export class SphereBuilder {
  111179. /**
  111180. * Creates a sphere mesh
  111181. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  111182. * * 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`)
  111183. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  111184. * * 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
  111185. * * 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)
  111186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111187. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111189. * @param name defines the name of the mesh
  111190. * @param options defines the options used to create the mesh
  111191. * @param scene defines the hosting scene
  111192. * @returns the sphere mesh
  111193. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  111194. */
  111195. static CreateSphere(name: string, options: {
  111196. segments?: number;
  111197. diameter?: number;
  111198. diameterX?: number;
  111199. diameterY?: number;
  111200. diameterZ?: number;
  111201. arc?: number;
  111202. slice?: number;
  111203. sideOrientation?: number;
  111204. frontUVs?: Vector4;
  111205. backUVs?: Vector4;
  111206. updatable?: boolean;
  111207. }, scene?: Nullable<Scene>): Mesh;
  111208. }
  111209. }
  111210. declare module BABYLON.Debug {
  111211. /**
  111212. * Used to show the physics impostor around the specific mesh
  111213. */
  111214. export class PhysicsViewer {
  111215. /** @hidden */
  111216. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  111217. /** @hidden */
  111218. protected _meshes: Array<Nullable<AbstractMesh>>;
  111219. /** @hidden */
  111220. protected _scene: Nullable<Scene>;
  111221. /** @hidden */
  111222. protected _numMeshes: number;
  111223. /** @hidden */
  111224. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  111225. private _renderFunction;
  111226. private _utilityLayer;
  111227. private _debugBoxMesh;
  111228. private _debugSphereMesh;
  111229. private _debugCylinderMesh;
  111230. private _debugMaterial;
  111231. private _debugMeshMeshes;
  111232. /**
  111233. * Creates a new PhysicsViewer
  111234. * @param scene defines the hosting scene
  111235. */
  111236. constructor(scene: Scene);
  111237. /** @hidden */
  111238. protected _updateDebugMeshes(): void;
  111239. /**
  111240. * Renders a specified physic impostor
  111241. * @param impostor defines the impostor to render
  111242. * @param targetMesh defines the mesh represented by the impostor
  111243. * @returns the new debug mesh used to render the impostor
  111244. */
  111245. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  111246. /**
  111247. * Hides a specified physic impostor
  111248. * @param impostor defines the impostor to hide
  111249. */
  111250. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  111251. private _getDebugMaterial;
  111252. private _getDebugBoxMesh;
  111253. private _getDebugSphereMesh;
  111254. private _getDebugCylinderMesh;
  111255. private _getDebugMeshMesh;
  111256. private _getDebugMesh;
  111257. /** Releases all resources */
  111258. dispose(): void;
  111259. }
  111260. }
  111261. declare module BABYLON {
  111262. /**
  111263. * Class containing static functions to help procedurally build meshes
  111264. */
  111265. export class LinesBuilder {
  111266. /**
  111267. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  111268. * * 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
  111269. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  111270. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  111271. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  111272. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  111273. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  111274. * * 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
  111275. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  111276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  111278. * @param name defines the name of the new line system
  111279. * @param options defines the options used to create the line system
  111280. * @param scene defines the hosting scene
  111281. * @returns a new line system mesh
  111282. */
  111283. static CreateLineSystem(name: string, options: {
  111284. lines: Vector3[][];
  111285. updatable?: boolean;
  111286. instance?: Nullable<LinesMesh>;
  111287. colors?: Nullable<Color4[][]>;
  111288. useVertexAlpha?: boolean;
  111289. }, scene: Nullable<Scene>): LinesMesh;
  111290. /**
  111291. * Creates a line mesh
  111292. * 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
  111293. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111294. * * The parameter `points` is an array successive Vector3
  111295. * * 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
  111296. * * The optional parameter `colors` is an array of successive Color4, one per line point
  111297. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  111298. * * When updating an instance, remember that only point positions can change, not the number of points
  111299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  111301. * @param name defines the name of the new line system
  111302. * @param options defines the options used to create the line system
  111303. * @param scene defines the hosting scene
  111304. * @returns a new line mesh
  111305. */
  111306. static CreateLines(name: string, options: {
  111307. points: Vector3[];
  111308. updatable?: boolean;
  111309. instance?: Nullable<LinesMesh>;
  111310. colors?: Color4[];
  111311. useVertexAlpha?: boolean;
  111312. }, scene?: Nullable<Scene>): LinesMesh;
  111313. /**
  111314. * Creates a dashed line mesh
  111315. * * 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
  111316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  111317. * * The parameter `points` is an array successive Vector3
  111318. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  111319. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  111320. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  111321. * * 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
  111322. * * When updating an instance, remember that only point positions can change, not the number of points
  111323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111324. * @param name defines the name of the mesh
  111325. * @param options defines the options used to create the mesh
  111326. * @param scene defines the hosting scene
  111327. * @returns the dashed line mesh
  111328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  111329. */
  111330. static CreateDashedLines(name: string, options: {
  111331. points: Vector3[];
  111332. dashSize?: number;
  111333. gapSize?: number;
  111334. dashNb?: number;
  111335. updatable?: boolean;
  111336. instance?: LinesMesh;
  111337. }, scene?: Nullable<Scene>): LinesMesh;
  111338. }
  111339. }
  111340. declare module BABYLON {
  111341. /**
  111342. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111343. * in order to better appreciate the issue one might have.
  111344. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111345. */
  111346. export class RayHelper {
  111347. /**
  111348. * Defines the ray we are currently tryin to visualize.
  111349. */
  111350. ray: Nullable<Ray>;
  111351. private _renderPoints;
  111352. private _renderLine;
  111353. private _renderFunction;
  111354. private _scene;
  111355. private _updateToMeshFunction;
  111356. private _attachedToMesh;
  111357. private _meshSpaceDirection;
  111358. private _meshSpaceOrigin;
  111359. /**
  111360. * Helper function to create a colored helper in a scene in one line.
  111361. * @param ray Defines the ray we are currently tryin to visualize
  111362. * @param scene Defines the scene the ray is used in
  111363. * @param color Defines the color we want to see the ray in
  111364. * @returns The newly created ray helper.
  111365. */
  111366. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  111367. /**
  111368. * Instantiate a new ray helper.
  111369. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  111370. * in order to better appreciate the issue one might have.
  111371. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  111372. * @param ray Defines the ray we are currently tryin to visualize
  111373. */
  111374. constructor(ray: Ray);
  111375. /**
  111376. * Shows the ray we are willing to debug.
  111377. * @param scene Defines the scene the ray needs to be rendered in
  111378. * @param color Defines the color the ray needs to be rendered in
  111379. */
  111380. show(scene: Scene, color?: Color3): void;
  111381. /**
  111382. * Hides the ray we are debugging.
  111383. */
  111384. hide(): void;
  111385. private _render;
  111386. /**
  111387. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  111388. * @param mesh Defines the mesh we want the helper attached to
  111389. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  111390. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  111391. * @param length Defines the length of the ray
  111392. */
  111393. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  111394. /**
  111395. * Detach the ray helper from the mesh it has previously been attached to.
  111396. */
  111397. detachFromMesh(): void;
  111398. private _updateToMesh;
  111399. /**
  111400. * Dispose the helper and release its associated resources.
  111401. */
  111402. dispose(): void;
  111403. }
  111404. }
  111405. declare module BABYLON.Debug {
  111406. /**
  111407. * Class used to render a debug view of a given skeleton
  111408. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  111409. */
  111410. export class SkeletonViewer {
  111411. /** defines the skeleton to render */
  111412. skeleton: Skeleton;
  111413. /** defines the mesh attached to the skeleton */
  111414. mesh: AbstractMesh;
  111415. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111416. autoUpdateBonesMatrices: boolean;
  111417. /** defines the rendering group id to use with the viewer */
  111418. renderingGroupId: number;
  111419. /** Gets or sets the color used to render the skeleton */
  111420. color: Color3;
  111421. private _scene;
  111422. private _debugLines;
  111423. private _debugMesh;
  111424. private _isEnabled;
  111425. private _renderFunction;
  111426. private _utilityLayer;
  111427. /**
  111428. * Returns the mesh used to render the bones
  111429. */
  111430. readonly debugMesh: Nullable<LinesMesh>;
  111431. /**
  111432. * Creates a new SkeletonViewer
  111433. * @param skeleton defines the skeleton to render
  111434. * @param mesh defines the mesh attached to the skeleton
  111435. * @param scene defines the hosting scene
  111436. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  111437. * @param renderingGroupId defines the rendering group id to use with the viewer
  111438. */
  111439. constructor(
  111440. /** defines the skeleton to render */
  111441. skeleton: Skeleton,
  111442. /** defines the mesh attached to the skeleton */
  111443. mesh: AbstractMesh, scene: Scene,
  111444. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  111445. autoUpdateBonesMatrices?: boolean,
  111446. /** defines the rendering group id to use with the viewer */
  111447. renderingGroupId?: number);
  111448. /** Gets or sets a boolean indicating if the viewer is enabled */
  111449. isEnabled: boolean;
  111450. private _getBonePosition;
  111451. private _getLinesForBonesWithLength;
  111452. private _getLinesForBonesNoLength;
  111453. /** Update the viewer to sync with current skeleton state */
  111454. update(): void;
  111455. /** Release associated resources */
  111456. dispose(): void;
  111457. }
  111458. }
  111459. declare module BABYLON {
  111460. /**
  111461. * Options to create the null engine
  111462. */
  111463. export class NullEngineOptions {
  111464. /**
  111465. * Render width (Default: 512)
  111466. */
  111467. renderWidth: number;
  111468. /**
  111469. * Render height (Default: 256)
  111470. */
  111471. renderHeight: number;
  111472. /**
  111473. * Texture size (Default: 512)
  111474. */
  111475. textureSize: number;
  111476. /**
  111477. * If delta time between frames should be constant
  111478. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111479. */
  111480. deterministicLockstep: boolean;
  111481. /**
  111482. * Maximum about of steps between frames (Default: 4)
  111483. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111484. */
  111485. lockstepMaxSteps: number;
  111486. }
  111487. /**
  111488. * The null engine class provides support for headless version of babylon.js.
  111489. * This can be used in server side scenario or for testing purposes
  111490. */
  111491. export class NullEngine extends Engine {
  111492. private _options;
  111493. /**
  111494. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  111495. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111496. * @returns true if engine is in deterministic lock step mode
  111497. */
  111498. isDeterministicLockStep(): boolean;
  111499. /**
  111500. * Gets the max steps when engine is running in deterministic lock step
  111501. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111502. * @returns the max steps
  111503. */
  111504. getLockstepMaxSteps(): number;
  111505. /**
  111506. * Gets the current hardware scaling level.
  111507. * By default the hardware scaling level is computed from the window device ratio.
  111508. * 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.
  111509. * @returns a number indicating the current hardware scaling level
  111510. */
  111511. getHardwareScalingLevel(): number;
  111512. constructor(options?: NullEngineOptions);
  111513. /**
  111514. * Creates a vertex buffer
  111515. * @param vertices the data for the vertex buffer
  111516. * @returns the new WebGL static buffer
  111517. */
  111518. createVertexBuffer(vertices: FloatArray): DataBuffer;
  111519. /**
  111520. * Creates a new index buffer
  111521. * @param indices defines the content of the index buffer
  111522. * @param updatable defines if the index buffer must be updatable
  111523. * @returns a new webGL buffer
  111524. */
  111525. createIndexBuffer(indices: IndicesArray): DataBuffer;
  111526. /**
  111527. * Clear the current render buffer or the current render target (if any is set up)
  111528. * @param color defines the color to use
  111529. * @param backBuffer defines if the back buffer must be cleared
  111530. * @param depth defines if the depth buffer must be cleared
  111531. * @param stencil defines if the stencil buffer must be cleared
  111532. */
  111533. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111534. /**
  111535. * Gets the current render width
  111536. * @param useScreen defines if screen size must be used (or the current render target if any)
  111537. * @returns a number defining the current render width
  111538. */
  111539. getRenderWidth(useScreen?: boolean): number;
  111540. /**
  111541. * Gets the current render height
  111542. * @param useScreen defines if screen size must be used (or the current render target if any)
  111543. * @returns a number defining the current render height
  111544. */
  111545. getRenderHeight(useScreen?: boolean): number;
  111546. /**
  111547. * Set the WebGL's viewport
  111548. * @param viewport defines the viewport element to be used
  111549. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  111550. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  111551. */
  111552. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  111553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  111554. /**
  111555. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  111556. * @param pipelineContext defines the pipeline context to use
  111557. * @param uniformsNames defines the list of uniform names
  111558. * @returns an array of webGL uniform locations
  111559. */
  111560. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  111561. /**
  111562. * Gets the lsit of active attributes for a given webGL program
  111563. * @param pipelineContext defines the pipeline context to use
  111564. * @param attributesNames defines the list of attribute names to get
  111565. * @returns an array of indices indicating the offset of each attribute
  111566. */
  111567. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111568. /**
  111569. * Binds an effect to the webGL context
  111570. * @param effect defines the effect to bind
  111571. */
  111572. bindSamplers(effect: Effect): void;
  111573. /**
  111574. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  111575. * @param effect defines the effect to activate
  111576. */
  111577. enableEffect(effect: Effect): void;
  111578. /**
  111579. * Set various states to the webGL context
  111580. * @param culling defines backface culling state
  111581. * @param zOffset defines the value to apply to zOffset (0 by default)
  111582. * @param force defines if states must be applied even if cache is up to date
  111583. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  111584. */
  111585. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111586. /**
  111587. * Set the value of an uniform to an array of int32
  111588. * @param uniform defines the webGL uniform location where to store the value
  111589. * @param array defines the array of int32 to store
  111590. */
  111591. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111592. /**
  111593. * Set the value of an uniform to an array of int32 (stored as vec2)
  111594. * @param uniform defines the webGL uniform location where to store the value
  111595. * @param array defines the array of int32 to store
  111596. */
  111597. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111598. /**
  111599. * Set the value of an uniform to an array of int32 (stored as vec3)
  111600. * @param uniform defines the webGL uniform location where to store the value
  111601. * @param array defines the array of int32 to store
  111602. */
  111603. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111604. /**
  111605. * Set the value of an uniform to an array of int32 (stored as vec4)
  111606. * @param uniform defines the webGL uniform location where to store the value
  111607. * @param array defines the array of int32 to store
  111608. */
  111609. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111610. /**
  111611. * Set the value of an uniform to an array of float32
  111612. * @param uniform defines the webGL uniform location where to store the value
  111613. * @param array defines the array of float32 to store
  111614. */
  111615. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111616. /**
  111617. * Set the value of an uniform to an array of float32 (stored as vec2)
  111618. * @param uniform defines the webGL uniform location where to store the value
  111619. * @param array defines the array of float32 to store
  111620. */
  111621. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111622. /**
  111623. * Set the value of an uniform to an array of float32 (stored as vec3)
  111624. * @param uniform defines the webGL uniform location where to store the value
  111625. * @param array defines the array of float32 to store
  111626. */
  111627. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111628. /**
  111629. * Set the value of an uniform to an array of float32 (stored as vec4)
  111630. * @param uniform defines the webGL uniform location where to store the value
  111631. * @param array defines the array of float32 to store
  111632. */
  111633. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111634. /**
  111635. * Set the value of an uniform to an array of number
  111636. * @param uniform defines the webGL uniform location where to store the value
  111637. * @param array defines the array of number to store
  111638. */
  111639. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111640. /**
  111641. * Set the value of an uniform to an array of number (stored as vec2)
  111642. * @param uniform defines the webGL uniform location where to store the value
  111643. * @param array defines the array of number to store
  111644. */
  111645. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111646. /**
  111647. * Set the value of an uniform to an array of number (stored as vec3)
  111648. * @param uniform defines the webGL uniform location where to store the value
  111649. * @param array defines the array of number to store
  111650. */
  111651. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111652. /**
  111653. * Set the value of an uniform to an array of number (stored as vec4)
  111654. * @param uniform defines the webGL uniform location where to store the value
  111655. * @param array defines the array of number to store
  111656. */
  111657. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111658. /**
  111659. * Set the value of an uniform to an array of float32 (stored as matrices)
  111660. * @param uniform defines the webGL uniform location where to store the value
  111661. * @param matrices defines the array of float32 to store
  111662. */
  111663. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111664. /**
  111665. * Set the value of an uniform to a matrix (3x3)
  111666. * @param uniform defines the webGL uniform location where to store the value
  111667. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  111668. */
  111669. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111670. /**
  111671. * Set the value of an uniform to a matrix (2x2)
  111672. * @param uniform defines the webGL uniform location where to store the value
  111673. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  111674. */
  111675. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111676. /**
  111677. * Set the value of an uniform to a number (float)
  111678. * @param uniform defines the webGL uniform location where to store the value
  111679. * @param value defines the float number to store
  111680. */
  111681. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111682. /**
  111683. * Set the value of an uniform to a vec2
  111684. * @param uniform defines the webGL uniform location where to store the value
  111685. * @param x defines the 1st component of the value
  111686. * @param y defines the 2nd component of the value
  111687. */
  111688. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111689. /**
  111690. * Set the value of an uniform to a vec3
  111691. * @param uniform defines the webGL uniform location where to store the value
  111692. * @param x defines the 1st component of the value
  111693. * @param y defines the 2nd component of the value
  111694. * @param z defines the 3rd component of the value
  111695. */
  111696. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111697. /**
  111698. * Set the value of an uniform to a boolean
  111699. * @param uniform defines the webGL uniform location where to store the value
  111700. * @param bool defines the boolean to store
  111701. */
  111702. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111703. /**
  111704. * Set the value of an uniform to a vec4
  111705. * @param uniform defines the webGL uniform location where to store the value
  111706. * @param x defines the 1st component of the value
  111707. * @param y defines the 2nd component of the value
  111708. * @param z defines the 3rd component of the value
  111709. * @param w defines the 4th component of the value
  111710. */
  111711. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111712. /**
  111713. * Sets the current alpha mode
  111714. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  111715. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111716. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111717. */
  111718. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111719. /**
  111720. * Bind webGl buffers directly to the webGL context
  111721. * @param vertexBuffers defines the vertex buffer to bind
  111722. * @param indexBuffer defines the index buffer to bind
  111723. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  111724. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  111725. * @param effect defines the effect associated with the vertex buffer
  111726. */
  111727. bindBuffers(vertexBuffers: {
  111728. [key: string]: VertexBuffer;
  111729. }, indexBuffer: DataBuffer, effect: Effect): void;
  111730. /**
  111731. * Force the entire cache to be cleared
  111732. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  111733. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  111734. */
  111735. wipeCaches(bruteForce?: boolean): void;
  111736. /**
  111737. * Send a draw order
  111738. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  111739. * @param indexStart defines the starting index
  111740. * @param indexCount defines the number of index to draw
  111741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111742. */
  111743. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  111744. /**
  111745. * Draw a list of indexed primitives
  111746. * @param fillMode defines the primitive to use
  111747. * @param indexStart defines the starting index
  111748. * @param indexCount defines the number of index to draw
  111749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111750. */
  111751. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111752. /**
  111753. * Draw a list of unindexed primitives
  111754. * @param fillMode defines the primitive to use
  111755. * @param verticesStart defines the index of first vertex to draw
  111756. * @param verticesCount defines the count of vertices to draw
  111757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111758. */
  111759. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111760. /** @hidden */
  111761. _createTexture(): WebGLTexture;
  111762. /** @hidden */
  111763. _releaseTexture(texture: InternalTexture): void;
  111764. /**
  111765. * Usually called from Texture.ts.
  111766. * Passed information to create a WebGLTexture
  111767. * @param urlArg defines a value which contains one of the following:
  111768. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111769. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111770. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111772. * @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)
  111773. * @param scene needed for loading to the correct scene
  111774. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  111775. * @param onLoad optional callback to be called upon successful completion
  111776. * @param onError optional callback to be called upon failure
  111777. * @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
  111778. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111779. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111780. * @param forcedExtension defines the extension to use to pick the right loader
  111781. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  111782. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111783. */
  111784. 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;
  111785. /**
  111786. * Creates a new render target texture
  111787. * @param size defines the size of the texture
  111788. * @param options defines the options used to create the texture
  111789. * @returns a new render target texture stored in an InternalTexture
  111790. */
  111791. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111792. /**
  111793. * Update the sampling mode of a given texture
  111794. * @param samplingMode defines the required sampling mode
  111795. * @param texture defines the texture to update
  111796. */
  111797. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111798. /**
  111799. * Binds the frame buffer to the specified texture.
  111800. * @param texture The texture to render to or null for the default canvas
  111801. * @param faceIndex The face of the texture to render to in case of cube texture
  111802. * @param requiredWidth The width of the target to render to
  111803. * @param requiredHeight The height of the target to render to
  111804. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  111805. * @param depthStencilTexture The depth stencil texture to use to render
  111806. * @param lodLevel defines le lod level to bind to the frame buffer
  111807. */
  111808. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111809. /**
  111810. * Unbind the current render target texture from the webGL context
  111811. * @param texture defines the render target texture to unbind
  111812. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111813. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111814. */
  111815. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111816. /**
  111817. * Creates a dynamic vertex buffer
  111818. * @param vertices the data for the dynamic vertex buffer
  111819. * @returns the new WebGL dynamic buffer
  111820. */
  111821. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  111822. /**
  111823. * Update the content of a dynamic texture
  111824. * @param texture defines the texture to update
  111825. * @param canvas defines the canvas containing the source
  111826. * @param invertY defines if data must be stored with Y axis inverted
  111827. * @param premulAlpha defines if alpha is stored as premultiplied
  111828. * @param format defines the format of the data
  111829. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111830. */
  111831. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  111832. /**
  111833. * Gets a boolean indicating if all created effects are ready
  111834. * @returns true if all effects are ready
  111835. */
  111836. areAllEffectsReady(): boolean;
  111837. /**
  111838. * @hidden
  111839. * Get the current error code of the webGL context
  111840. * @returns the error code
  111841. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  111842. */
  111843. getError(): number;
  111844. /** @hidden */
  111845. _getUnpackAlignement(): number;
  111846. /** @hidden */
  111847. _unpackFlipY(value: boolean): void;
  111848. /**
  111849. * Update a dynamic index buffer
  111850. * @param indexBuffer defines the target index buffer
  111851. * @param indices defines the data to update
  111852. * @param offset defines the offset in the target index buffer where update should start
  111853. */
  111854. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  111855. /**
  111856. * Updates a dynamic vertex buffer.
  111857. * @param vertexBuffer the vertex buffer to update
  111858. * @param vertices the data used to update the vertex buffer
  111859. * @param byteOffset the byte offset of the data (optional)
  111860. * @param byteLength the byte length of the data (optional)
  111861. */
  111862. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  111863. /** @hidden */
  111864. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  111865. /** @hidden */
  111866. _bindTexture(channel: number, texture: InternalTexture): void;
  111867. protected _deleteBuffer(buffer: WebGLBuffer): void;
  111868. /**
  111869. * 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
  111870. */
  111871. releaseEffects(): void;
  111872. displayLoadingUI(): void;
  111873. hideLoadingUI(): void;
  111874. /** @hidden */
  111875. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111876. /** @hidden */
  111877. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111878. /** @hidden */
  111879. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111880. /** @hidden */
  111881. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111882. }
  111883. }
  111884. declare module BABYLON {
  111885. /** @hidden */
  111886. export class _OcclusionDataStorage {
  111887. /** @hidden */
  111888. occlusionInternalRetryCounter: number;
  111889. /** @hidden */
  111890. isOcclusionQueryInProgress: boolean;
  111891. /** @hidden */
  111892. isOccluded: boolean;
  111893. /** @hidden */
  111894. occlusionRetryCount: number;
  111895. /** @hidden */
  111896. occlusionType: number;
  111897. /** @hidden */
  111898. occlusionQueryAlgorithmType: number;
  111899. }
  111900. interface Engine {
  111901. /**
  111902. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  111903. * @return the new query
  111904. */
  111905. createQuery(): WebGLQuery;
  111906. /**
  111907. * Delete and release a webGL query
  111908. * @param query defines the query to delete
  111909. * @return the current engine
  111910. */
  111911. deleteQuery(query: WebGLQuery): Engine;
  111912. /**
  111913. * Check if a given query has resolved and got its value
  111914. * @param query defines the query to check
  111915. * @returns true if the query got its value
  111916. */
  111917. isQueryResultAvailable(query: WebGLQuery): boolean;
  111918. /**
  111919. * Gets the value of a given query
  111920. * @param query defines the query to check
  111921. * @returns the value of the query
  111922. */
  111923. getQueryResult(query: WebGLQuery): number;
  111924. /**
  111925. * Initiates an occlusion query
  111926. * @param algorithmType defines the algorithm to use
  111927. * @param query defines the query to use
  111928. * @returns the current engine
  111929. * @see http://doc.babylonjs.com/features/occlusionquery
  111930. */
  111931. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  111932. /**
  111933. * Ends an occlusion query
  111934. * @see http://doc.babylonjs.com/features/occlusionquery
  111935. * @param algorithmType defines the algorithm to use
  111936. * @returns the current engine
  111937. */
  111938. endOcclusionQuery(algorithmType: number): Engine;
  111939. /**
  111940. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  111941. * Please note that only one query can be issued at a time
  111942. * @returns a time token used to track the time span
  111943. */
  111944. startTimeQuery(): Nullable<_TimeToken>;
  111945. /**
  111946. * Ends a time query
  111947. * @param token defines the token used to measure the time span
  111948. * @returns the time spent (in ns)
  111949. */
  111950. endTimeQuery(token: _TimeToken): int;
  111951. /** @hidden */
  111952. _currentNonTimestampToken: Nullable<_TimeToken>;
  111953. /** @hidden */
  111954. _createTimeQuery(): WebGLQuery;
  111955. /** @hidden */
  111956. _deleteTimeQuery(query: WebGLQuery): void;
  111957. /** @hidden */
  111958. _getGlAlgorithmType(algorithmType: number): number;
  111959. /** @hidden */
  111960. _getTimeQueryResult(query: WebGLQuery): any;
  111961. /** @hidden */
  111962. _getTimeQueryAvailability(query: WebGLQuery): any;
  111963. }
  111964. interface AbstractMesh {
  111965. /**
  111966. * Backing filed
  111967. * @hidden
  111968. */
  111969. __occlusionDataStorage: _OcclusionDataStorage;
  111970. /**
  111971. * Access property
  111972. * @hidden
  111973. */
  111974. _occlusionDataStorage: _OcclusionDataStorage;
  111975. /**
  111976. * 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.
  111977. * The default value is -1 which means don't break the query and wait till the result
  111978. * @see http://doc.babylonjs.com/features/occlusionquery
  111979. */
  111980. occlusionRetryCount: number;
  111981. /**
  111982. * 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:
  111983. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  111984. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  111985. * * 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.
  111986. * @see http://doc.babylonjs.com/features/occlusionquery
  111987. */
  111988. occlusionType: number;
  111989. /**
  111990. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  111991. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  111992. * * 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.
  111993. * @see http://doc.babylonjs.com/features/occlusionquery
  111994. */
  111995. occlusionQueryAlgorithmType: number;
  111996. /**
  111997. * 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
  111998. * @see http://doc.babylonjs.com/features/occlusionquery
  111999. */
  112000. isOccluded: boolean;
  112001. /**
  112002. * Flag to check the progress status of the query
  112003. * @see http://doc.babylonjs.com/features/occlusionquery
  112004. */
  112005. isOcclusionQueryInProgress: boolean;
  112006. }
  112007. }
  112008. declare module BABYLON {
  112009. /** @hidden */
  112010. export var _forceTransformFeedbackToBundle: boolean;
  112011. interface Engine {
  112012. /**
  112013. * Creates a webGL transform feedback object
  112014. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  112015. * @returns the webGL transform feedback object
  112016. */
  112017. createTransformFeedback(): WebGLTransformFeedback;
  112018. /**
  112019. * Delete a webGL transform feedback object
  112020. * @param value defines the webGL transform feedback object to delete
  112021. */
  112022. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  112023. /**
  112024. * Bind a webGL transform feedback object to the webgl context
  112025. * @param value defines the webGL transform feedback object to bind
  112026. */
  112027. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  112028. /**
  112029. * Begins a transform feedback operation
  112030. * @param usePoints defines if points or triangles must be used
  112031. */
  112032. beginTransformFeedback(usePoints: boolean): void;
  112033. /**
  112034. * Ends a transform feedback operation
  112035. */
  112036. endTransformFeedback(): void;
  112037. /**
  112038. * Specify the varyings to use with transform feedback
  112039. * @param program defines the associated webGL program
  112040. * @param value defines the list of strings representing the varying names
  112041. */
  112042. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  112043. /**
  112044. * Bind a webGL buffer for a transform feedback operation
  112045. * @param value defines the webGL buffer to bind
  112046. */
  112047. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  112048. }
  112049. }
  112050. declare module BABYLON {
  112051. /**
  112052. * Creation options of the multi render target texture.
  112053. */
  112054. export interface IMultiRenderTargetOptions {
  112055. /**
  112056. * Define if the texture needs to create mip maps after render.
  112057. */
  112058. generateMipMaps?: boolean;
  112059. /**
  112060. * Define the types of all the draw buffers we want to create
  112061. */
  112062. types?: number[];
  112063. /**
  112064. * Define the sampling modes of all the draw buffers we want to create
  112065. */
  112066. samplingModes?: number[];
  112067. /**
  112068. * Define if a depth buffer is required
  112069. */
  112070. generateDepthBuffer?: boolean;
  112071. /**
  112072. * Define if a stencil buffer is required
  112073. */
  112074. generateStencilBuffer?: boolean;
  112075. /**
  112076. * Define if a depth texture is required instead of a depth buffer
  112077. */
  112078. generateDepthTexture?: boolean;
  112079. /**
  112080. * Define the number of desired draw buffers
  112081. */
  112082. textureCount?: number;
  112083. /**
  112084. * Define if aspect ratio should be adapted to the texture or stay the scene one
  112085. */
  112086. doNotChangeAspectRatio?: boolean;
  112087. /**
  112088. * Define the default type of the buffers we are creating
  112089. */
  112090. defaultType?: number;
  112091. }
  112092. /**
  112093. * A multi render target, like a render target provides the ability to render to a texture.
  112094. * Unlike the render target, it can render to several draw buffers in one draw.
  112095. * This is specially interesting in deferred rendering or for any effects requiring more than
  112096. * just one color from a single pass.
  112097. */
  112098. export class MultiRenderTarget extends RenderTargetTexture {
  112099. private _internalTextures;
  112100. private _textures;
  112101. private _multiRenderTargetOptions;
  112102. /**
  112103. * Get if draw buffers are currently supported by the used hardware and browser.
  112104. */
  112105. readonly isSupported: boolean;
  112106. /**
  112107. * Get the list of textures generated by the multi render target.
  112108. */
  112109. readonly textures: Texture[];
  112110. /**
  112111. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  112112. */
  112113. readonly depthTexture: Texture;
  112114. /**
  112115. * Set the wrapping mode on U of all the textures we are rendering to.
  112116. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112117. */
  112118. wrapU: number;
  112119. /**
  112120. * Set the wrapping mode on V of all the textures we are rendering to.
  112121. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  112122. */
  112123. wrapV: number;
  112124. /**
  112125. * Instantiate a new multi render target texture.
  112126. * A multi render target, like a render target provides the ability to render to a texture.
  112127. * Unlike the render target, it can render to several draw buffers in one draw.
  112128. * This is specially interesting in deferred rendering or for any effects requiring more than
  112129. * just one color from a single pass.
  112130. * @param name Define the name of the texture
  112131. * @param size Define the size of the buffers to render to
  112132. * @param count Define the number of target we are rendering into
  112133. * @param scene Define the scene the texture belongs to
  112134. * @param options Define the options used to create the multi render target
  112135. */
  112136. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  112137. /** @hidden */
  112138. _rebuild(): void;
  112139. private _createInternalTextures;
  112140. private _createTextures;
  112141. /**
  112142. * Define the number of samples used if MSAA is enabled.
  112143. */
  112144. samples: number;
  112145. /**
  112146. * Resize all the textures in the multi render target.
  112147. * Be carrefull as it will recreate all the data in the new texture.
  112148. * @param size Define the new size
  112149. */
  112150. resize(size: any): void;
  112151. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  112152. /**
  112153. * Dispose the render targets and their associated resources
  112154. */
  112155. dispose(): void;
  112156. /**
  112157. * Release all the underlying texture used as draw buffers.
  112158. */
  112159. releaseInternalTextures(): void;
  112160. }
  112161. }
  112162. declare module BABYLON {
  112163. interface ThinEngine {
  112164. /**
  112165. * Unbind a list of render target textures from the webGL context
  112166. * This is used only when drawBuffer extension or webGL2 are active
  112167. * @param textures defines the render target textures to unbind
  112168. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112169. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112170. */
  112171. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  112172. /**
  112173. * Create a multi render target texture
  112174. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  112175. * @param size defines the size of the texture
  112176. * @param options defines the creation options
  112177. * @returns the cube texture as an InternalTexture
  112178. */
  112179. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  112180. /**
  112181. * Update the sample count for a given multiple render target texture
  112182. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  112183. * @param textures defines the textures to update
  112184. * @param samples defines the sample count to set
  112185. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  112186. */
  112187. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  112188. }
  112189. }
  112190. declare module BABYLON {
  112191. /**
  112192. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  112193. */
  112194. export interface CubeMapInfo {
  112195. /**
  112196. * The pixel array for the front face.
  112197. * This is stored in format, left to right, up to down format.
  112198. */
  112199. front: Nullable<ArrayBufferView>;
  112200. /**
  112201. * The pixel array for the back face.
  112202. * This is stored in format, left to right, up to down format.
  112203. */
  112204. back: Nullable<ArrayBufferView>;
  112205. /**
  112206. * The pixel array for the left face.
  112207. * This is stored in format, left to right, up to down format.
  112208. */
  112209. left: Nullable<ArrayBufferView>;
  112210. /**
  112211. * The pixel array for the right face.
  112212. * This is stored in format, left to right, up to down format.
  112213. */
  112214. right: Nullable<ArrayBufferView>;
  112215. /**
  112216. * The pixel array for the up face.
  112217. * This is stored in format, left to right, up to down format.
  112218. */
  112219. up: Nullable<ArrayBufferView>;
  112220. /**
  112221. * The pixel array for the down face.
  112222. * This is stored in format, left to right, up to down format.
  112223. */
  112224. down: Nullable<ArrayBufferView>;
  112225. /**
  112226. * The size of the cubemap stored.
  112227. *
  112228. * Each faces will be size * size pixels.
  112229. */
  112230. size: number;
  112231. /**
  112232. * The format of the texture.
  112233. *
  112234. * RGBA, RGB.
  112235. */
  112236. format: number;
  112237. /**
  112238. * The type of the texture data.
  112239. *
  112240. * UNSIGNED_INT, FLOAT.
  112241. */
  112242. type: number;
  112243. /**
  112244. * Specifies whether the texture is in gamma space.
  112245. */
  112246. gammaSpace: boolean;
  112247. }
  112248. /**
  112249. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  112250. */
  112251. export class PanoramaToCubeMapTools {
  112252. private static FACE_FRONT;
  112253. private static FACE_BACK;
  112254. private static FACE_RIGHT;
  112255. private static FACE_LEFT;
  112256. private static FACE_DOWN;
  112257. private static FACE_UP;
  112258. /**
  112259. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  112260. *
  112261. * @param float32Array The source data.
  112262. * @param inputWidth The width of the input panorama.
  112263. * @param inputHeight The height of the input panorama.
  112264. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  112265. * @return The cubemap data
  112266. */
  112267. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  112268. private static CreateCubemapTexture;
  112269. private static CalcProjectionSpherical;
  112270. }
  112271. }
  112272. declare module BABYLON {
  112273. /**
  112274. * Helper class dealing with the extraction of spherical polynomial dataArray
  112275. * from a cube map.
  112276. */
  112277. export class CubeMapToSphericalPolynomialTools {
  112278. private static FileFaces;
  112279. /**
  112280. * Converts a texture to the according Spherical Polynomial data.
  112281. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112282. *
  112283. * @param texture The texture to extract the information from.
  112284. * @return The Spherical Polynomial data.
  112285. */
  112286. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  112287. /**
  112288. * Converts a cubemap to the according Spherical Polynomial data.
  112289. * This extracts the first 3 orders only as they are the only one used in the lighting.
  112290. *
  112291. * @param cubeInfo The Cube map to extract the information from.
  112292. * @return The Spherical Polynomial data.
  112293. */
  112294. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  112295. }
  112296. }
  112297. declare module BABYLON {
  112298. interface BaseTexture {
  112299. /**
  112300. * Get the polynomial representation of the texture data.
  112301. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  112302. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  112303. */
  112304. sphericalPolynomial: Nullable<SphericalPolynomial>;
  112305. }
  112306. }
  112307. declare module BABYLON {
  112308. /** @hidden */
  112309. export var rgbdEncodePixelShader: {
  112310. name: string;
  112311. shader: string;
  112312. };
  112313. }
  112314. declare module BABYLON {
  112315. /** @hidden */
  112316. export var rgbdDecodePixelShader: {
  112317. name: string;
  112318. shader: string;
  112319. };
  112320. }
  112321. declare module BABYLON {
  112322. /**
  112323. * Raw texture data and descriptor sufficient for WebGL texture upload
  112324. */
  112325. export interface EnvironmentTextureInfo {
  112326. /**
  112327. * Version of the environment map
  112328. */
  112329. version: number;
  112330. /**
  112331. * Width of image
  112332. */
  112333. width: number;
  112334. /**
  112335. * Irradiance information stored in the file.
  112336. */
  112337. irradiance: any;
  112338. /**
  112339. * Specular information stored in the file.
  112340. */
  112341. specular: any;
  112342. }
  112343. /**
  112344. * Defines One Image in the file. It requires only the position in the file
  112345. * as well as the length.
  112346. */
  112347. interface BufferImageData {
  112348. /**
  112349. * Length of the image data.
  112350. */
  112351. length: number;
  112352. /**
  112353. * Position of the data from the null terminator delimiting the end of the JSON.
  112354. */
  112355. position: number;
  112356. }
  112357. /**
  112358. * Defines the specular data enclosed in the file.
  112359. * This corresponds to the version 1 of the data.
  112360. */
  112361. export interface EnvironmentTextureSpecularInfoV1 {
  112362. /**
  112363. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  112364. */
  112365. specularDataPosition?: number;
  112366. /**
  112367. * This contains all the images data needed to reconstruct the cubemap.
  112368. */
  112369. mipmaps: Array<BufferImageData>;
  112370. /**
  112371. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  112372. */
  112373. lodGenerationScale: number;
  112374. }
  112375. /**
  112376. * Sets of helpers addressing the serialization and deserialization of environment texture
  112377. * stored in a BabylonJS env file.
  112378. * Those files are usually stored as .env files.
  112379. */
  112380. export class EnvironmentTextureTools {
  112381. /**
  112382. * Magic number identifying the env file.
  112383. */
  112384. private static _MagicBytes;
  112385. /**
  112386. * Gets the environment info from an env file.
  112387. * @param data The array buffer containing the .env bytes.
  112388. * @returns the environment file info (the json header) if successfully parsed.
  112389. */
  112390. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  112391. /**
  112392. * Creates an environment texture from a loaded cube texture.
  112393. * @param texture defines the cube texture to convert in env file
  112394. * @return a promise containing the environment data if succesfull.
  112395. */
  112396. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  112397. /**
  112398. * Creates a JSON representation of the spherical data.
  112399. * @param texture defines the texture containing the polynomials
  112400. * @return the JSON representation of the spherical info
  112401. */
  112402. private static _CreateEnvTextureIrradiance;
  112403. /**
  112404. * Creates the ArrayBufferViews used for initializing environment texture image data.
  112405. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  112406. * @param info parameters that determine what views will be created for accessing the underlying buffer
  112407. * @return the views described by info providing access to the underlying buffer
  112408. */
  112409. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  112410. /**
  112411. * Uploads the texture info contained in the env file to the GPU.
  112412. * @param texture defines the internal texture to upload to
  112413. * @param arrayBuffer defines the buffer cotaining the data to load
  112414. * @param info defines the texture info retrieved through the GetEnvInfo method
  112415. * @returns a promise
  112416. */
  112417. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  112418. private static _OnImageReadyAsync;
  112419. /**
  112420. * Uploads the levels of image data to the GPU.
  112421. * @param texture defines the internal texture to upload to
  112422. * @param imageData defines the array buffer views of image data [mipmap][face]
  112423. * @returns a promise
  112424. */
  112425. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  112426. /**
  112427. * Uploads spherical polynomials information to the texture.
  112428. * @param texture defines the texture we are trying to upload the information to
  112429. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  112430. */
  112431. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  112432. /** @hidden */
  112433. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112434. }
  112435. }
  112436. declare module BABYLON {
  112437. /**
  112438. * Contains position and normal vectors for a vertex
  112439. */
  112440. export class PositionNormalVertex {
  112441. /** the position of the vertex (defaut: 0,0,0) */
  112442. position: Vector3;
  112443. /** the normal of the vertex (defaut: 0,1,0) */
  112444. normal: Vector3;
  112445. /**
  112446. * Creates a PositionNormalVertex
  112447. * @param position the position of the vertex (defaut: 0,0,0)
  112448. * @param normal the normal of the vertex (defaut: 0,1,0)
  112449. */
  112450. constructor(
  112451. /** the position of the vertex (defaut: 0,0,0) */
  112452. position?: Vector3,
  112453. /** the normal of the vertex (defaut: 0,1,0) */
  112454. normal?: Vector3);
  112455. /**
  112456. * Clones the PositionNormalVertex
  112457. * @returns the cloned PositionNormalVertex
  112458. */
  112459. clone(): PositionNormalVertex;
  112460. }
  112461. /**
  112462. * Contains position, normal and uv vectors for a vertex
  112463. */
  112464. export class PositionNormalTextureVertex {
  112465. /** the position of the vertex (defaut: 0,0,0) */
  112466. position: Vector3;
  112467. /** the normal of the vertex (defaut: 0,1,0) */
  112468. normal: Vector3;
  112469. /** the uv of the vertex (default: 0,0) */
  112470. uv: Vector2;
  112471. /**
  112472. * Creates a PositionNormalTextureVertex
  112473. * @param position the position of the vertex (defaut: 0,0,0)
  112474. * @param normal the normal of the vertex (defaut: 0,1,0)
  112475. * @param uv the uv of the vertex (default: 0,0)
  112476. */
  112477. constructor(
  112478. /** the position of the vertex (defaut: 0,0,0) */
  112479. position?: Vector3,
  112480. /** the normal of the vertex (defaut: 0,1,0) */
  112481. normal?: Vector3,
  112482. /** the uv of the vertex (default: 0,0) */
  112483. uv?: Vector2);
  112484. /**
  112485. * Clones the PositionNormalTextureVertex
  112486. * @returns the cloned PositionNormalTextureVertex
  112487. */
  112488. clone(): PositionNormalTextureVertex;
  112489. }
  112490. }
  112491. declare module BABYLON {
  112492. /** @hidden */
  112493. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  112494. private _genericAttributeLocation;
  112495. private _varyingLocationCount;
  112496. private _varyingLocationMap;
  112497. private _replacements;
  112498. private _textureCount;
  112499. private _uniforms;
  112500. lineProcessor(line: string): string;
  112501. attributeProcessor(attribute: string): string;
  112502. varyingProcessor(varying: string, isFragment: boolean): string;
  112503. uniformProcessor(uniform: string): string;
  112504. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  112505. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112506. }
  112507. }
  112508. declare module BABYLON {
  112509. /**
  112510. * Container for accessors for natively-stored mesh data buffers.
  112511. */
  112512. class NativeDataBuffer extends DataBuffer {
  112513. /**
  112514. * Accessor value used to identify/retrieve a natively-stored index buffer.
  112515. */
  112516. nativeIndexBuffer?: any;
  112517. /**
  112518. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  112519. */
  112520. nativeVertexBuffer?: any;
  112521. }
  112522. /** @hidden */
  112523. class NativeTexture extends InternalTexture {
  112524. getInternalTexture(): InternalTexture;
  112525. getViewCount(): number;
  112526. }
  112527. /** @hidden */
  112528. export class NativeEngine extends Engine {
  112529. private readonly _native;
  112530. getHardwareScalingLevel(): number;
  112531. constructor();
  112532. /**
  112533. * Can be used to override the current requestAnimationFrame requester.
  112534. * @hidden
  112535. */
  112536. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112537. /**
  112538. * Override default engine behavior.
  112539. * @param color
  112540. * @param backBuffer
  112541. * @param depth
  112542. * @param stencil
  112543. */
  112544. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112545. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112546. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  112547. createVertexBuffer(data: DataArray): NativeDataBuffer;
  112548. recordVertexArrayObject(vertexBuffers: {
  112549. [key: string]: VertexBuffer;
  112550. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112551. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112552. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  112553. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112554. /**
  112555. * Draw a list of indexed primitives
  112556. * @param fillMode defines the primitive to use
  112557. * @param indexStart defines the starting index
  112558. * @param indexCount defines the number of index to draw
  112559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112560. */
  112561. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112562. /**
  112563. * Draw a list of unindexed primitives
  112564. * @param fillMode defines the primitive to use
  112565. * @param verticesStart defines the index of first vertex to draw
  112566. * @param verticesCount defines the count of vertices to draw
  112567. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112568. */
  112569. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112570. createPipelineContext(): IPipelineContext;
  112571. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112572. /** @hidden */
  112573. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112574. /** @hidden */
  112575. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112576. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112577. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  112578. protected _setProgram(program: WebGLProgram): void;
  112579. _releaseEffect(effect: Effect): void;
  112580. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112581. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  112582. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  112583. bindSamplers(effect: Effect): void;
  112584. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  112585. getRenderWidth(useScreen?: boolean): number;
  112586. getRenderHeight(useScreen?: boolean): number;
  112587. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  112588. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112589. /**
  112590. * Set the z offset to apply to current rendering
  112591. * @param value defines the offset to apply
  112592. */
  112593. setZOffset(value: number): void;
  112594. /**
  112595. * Gets the current value of the zOffset
  112596. * @returns the current zOffset state
  112597. */
  112598. getZOffset(): number;
  112599. /**
  112600. * Enable or disable depth buffering
  112601. * @param enable defines the state to set
  112602. */
  112603. setDepthBuffer(enable: boolean): void;
  112604. /**
  112605. * Gets a boolean indicating if depth writing is enabled
  112606. * @returns the current depth writing state
  112607. */
  112608. getDepthWrite(): boolean;
  112609. /**
  112610. * Enable or disable depth writing
  112611. * @param enable defines the state to set
  112612. */
  112613. setDepthWrite(enable: boolean): void;
  112614. /**
  112615. * Enable or disable color writing
  112616. * @param enable defines the state to set
  112617. */
  112618. setColorWrite(enable: boolean): void;
  112619. /**
  112620. * Gets a boolean indicating if color writing is enabled
  112621. * @returns the current color writing state
  112622. */
  112623. getColorWrite(): boolean;
  112624. /**
  112625. * Sets alpha constants used by some alpha blending modes
  112626. * @param r defines the red component
  112627. * @param g defines the green component
  112628. * @param b defines the blue component
  112629. * @param a defines the alpha component
  112630. */
  112631. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  112632. /**
  112633. * Sets the current alpha mode
  112634. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  112635. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112636. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112637. */
  112638. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112639. /**
  112640. * Gets the current alpha mode
  112641. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112642. * @returns the current alpha mode
  112643. */
  112644. getAlphaMode(): number;
  112645. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112646. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112647. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112648. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112649. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112650. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112651. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112652. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112653. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112654. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112655. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112656. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112657. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112658. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112659. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112660. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112661. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112662. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112663. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112664. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112665. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  112666. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  112667. wipeCaches(bruteForce?: boolean): void;
  112668. _createTexture(): WebGLTexture;
  112669. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112670. /**
  112671. * Usually called from BABYLON.Texture.ts.
  112672. * Passed information to create a WebGLTexture
  112673. * @param urlArg defines a value which contains one of the following:
  112674. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112675. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112676. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112677. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112678. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  112679. * @param scene needed for loading to the correct scene
  112680. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  112681. * @param onLoad optional callback to be called upon successful completion
  112682. * @param onError optional callback to be called upon failure
  112683. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  112684. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112685. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112686. * @param forcedExtension defines the extension to use to pick the right loader
  112687. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112688. */
  112689. 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;
  112690. /**
  112691. * Creates a cube texture
  112692. * @param rootUrl defines the url where the files to load is located
  112693. * @param scene defines the current scene
  112694. * @param files defines the list of files to load (1 per face)
  112695. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  112696. * @param onLoad defines an optional callback raised when the texture is loaded
  112697. * @param onError defines an optional callback raised if there is an issue to load the texture
  112698. * @param format defines the format of the data
  112699. * @param forcedExtension defines the extension to use to pick the right loader
  112700. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  112701. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112702. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112703. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  112704. * @returns the cube texture as an InternalTexture
  112705. */
  112706. 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;
  112707. private _getSamplingFilter;
  112708. private static _GetNativeTextureFormat;
  112709. createRenderTargetTexture(size: number | {
  112710. width: number;
  112711. height: number;
  112712. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  112713. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112714. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  112715. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112716. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112717. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  112718. /**
  112719. * Updates a dynamic vertex buffer.
  112720. * @param vertexBuffer the vertex buffer to update
  112721. * @param data the data used to update the vertex buffer
  112722. * @param byteOffset the byte offset of the data (optional)
  112723. * @param byteLength the byte length of the data (optional)
  112724. */
  112725. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  112726. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112727. private _updateAnisotropicLevel;
  112728. private _getAddressMode;
  112729. /** @hidden */
  112730. _bindTexture(channel: number, texture: InternalTexture): void;
  112731. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  112732. releaseEffects(): void;
  112733. /** @hidden */
  112734. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112735. /** @hidden */
  112736. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112737. /** @hidden */
  112738. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112739. /** @hidden */
  112740. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  112741. }
  112742. }
  112743. declare module BABYLON {
  112744. /**
  112745. * Gather the list of clipboard event types as constants.
  112746. */
  112747. export class ClipboardEventTypes {
  112748. /**
  112749. * The clipboard event is fired when a copy command is active (pressed).
  112750. */
  112751. static readonly COPY: number;
  112752. /**
  112753. * The clipboard event is fired when a cut command is active (pressed).
  112754. */
  112755. static readonly CUT: number;
  112756. /**
  112757. * The clipboard event is fired when a paste command is active (pressed).
  112758. */
  112759. static readonly PASTE: number;
  112760. }
  112761. /**
  112762. * This class is used to store clipboard related info for the onClipboardObservable event.
  112763. */
  112764. export class ClipboardInfo {
  112765. /**
  112766. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112767. */
  112768. type: number;
  112769. /**
  112770. * Defines the related dom event
  112771. */
  112772. event: ClipboardEvent;
  112773. /**
  112774. *Creates an instance of ClipboardInfo.
  112775. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  112776. * @param event Defines the related dom event
  112777. */
  112778. constructor(
  112779. /**
  112780. * Defines the type of event (BABYLON.ClipboardEventTypes)
  112781. */
  112782. type: number,
  112783. /**
  112784. * Defines the related dom event
  112785. */
  112786. event: ClipboardEvent);
  112787. /**
  112788. * Get the clipboard event's type from the keycode.
  112789. * @param keyCode Defines the keyCode for the current keyboard event.
  112790. * @return {number}
  112791. */
  112792. static GetTypeFromCharacter(keyCode: number): number;
  112793. }
  112794. }
  112795. declare module BABYLON {
  112796. /**
  112797. * Google Daydream controller
  112798. */
  112799. export class DaydreamController extends WebVRController {
  112800. /**
  112801. * Base Url for the controller model.
  112802. */
  112803. static MODEL_BASE_URL: string;
  112804. /**
  112805. * File name for the controller model.
  112806. */
  112807. static MODEL_FILENAME: string;
  112808. /**
  112809. * Gamepad Id prefix used to identify Daydream Controller.
  112810. */
  112811. static readonly GAMEPAD_ID_PREFIX: string;
  112812. /**
  112813. * Creates a new DaydreamController from a gamepad
  112814. * @param vrGamepad the gamepad that the controller should be created from
  112815. */
  112816. constructor(vrGamepad: any);
  112817. /**
  112818. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112819. * @param scene scene in which to add meshes
  112820. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112821. */
  112822. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112823. /**
  112824. * Called once for each button that changed state since the last frame
  112825. * @param buttonIdx Which button index changed
  112826. * @param state New state of the button
  112827. * @param changes Which properties on the state changed since last frame
  112828. */
  112829. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112830. }
  112831. }
  112832. declare module BABYLON {
  112833. /**
  112834. * Gear VR Controller
  112835. */
  112836. export class GearVRController extends WebVRController {
  112837. /**
  112838. * Base Url for the controller model.
  112839. */
  112840. static MODEL_BASE_URL: string;
  112841. /**
  112842. * File name for the controller model.
  112843. */
  112844. static MODEL_FILENAME: string;
  112845. /**
  112846. * Gamepad Id prefix used to identify this controller.
  112847. */
  112848. static readonly GAMEPAD_ID_PREFIX: string;
  112849. private readonly _buttonIndexToObservableNameMap;
  112850. /**
  112851. * Creates a new GearVRController from a gamepad
  112852. * @param vrGamepad the gamepad that the controller should be created from
  112853. */
  112854. constructor(vrGamepad: any);
  112855. /**
  112856. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112857. * @param scene scene in which to add meshes
  112858. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112859. */
  112860. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112861. /**
  112862. * Called once for each button that changed state since the last frame
  112863. * @param buttonIdx Which button index changed
  112864. * @param state New state of the button
  112865. * @param changes Which properties on the state changed since last frame
  112866. */
  112867. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112868. }
  112869. }
  112870. declare module BABYLON {
  112871. /**
  112872. * Class containing static functions to help procedurally build meshes
  112873. */
  112874. export class PolyhedronBuilder {
  112875. /**
  112876. * Creates a polyhedron mesh
  112877. * * 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
  112878. * * The parameter `size` (positive float, default 1) sets the polygon size
  112879. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  112880. * * 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`
  112881. * * 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
  112882. * * 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)`)
  112883. * * 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
  112884. * * 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
  112885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112888. * @param name defines the name of the mesh
  112889. * @param options defines the options used to create the mesh
  112890. * @param scene defines the hosting scene
  112891. * @returns the polyhedron mesh
  112892. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  112893. */
  112894. static CreatePolyhedron(name: string, options: {
  112895. type?: number;
  112896. size?: number;
  112897. sizeX?: number;
  112898. sizeY?: number;
  112899. sizeZ?: number;
  112900. custom?: any;
  112901. faceUV?: Vector4[];
  112902. faceColors?: Color4[];
  112903. flat?: boolean;
  112904. updatable?: boolean;
  112905. sideOrientation?: number;
  112906. frontUVs?: Vector4;
  112907. backUVs?: Vector4;
  112908. }, scene?: Nullable<Scene>): Mesh;
  112909. }
  112910. }
  112911. declare module BABYLON {
  112912. /**
  112913. * Gizmo that enables scaling a mesh along 3 axis
  112914. */
  112915. export class ScaleGizmo extends Gizmo {
  112916. /**
  112917. * Internal gizmo used for interactions on the x axis
  112918. */
  112919. xGizmo: AxisScaleGizmo;
  112920. /**
  112921. * Internal gizmo used for interactions on the y axis
  112922. */
  112923. yGizmo: AxisScaleGizmo;
  112924. /**
  112925. * Internal gizmo used for interactions on the z axis
  112926. */
  112927. zGizmo: AxisScaleGizmo;
  112928. /**
  112929. * Internal gizmo used to scale all axis equally
  112930. */
  112931. uniformScaleGizmo: AxisScaleGizmo;
  112932. private _meshAttached;
  112933. private _updateGizmoRotationToMatchAttachedMesh;
  112934. private _snapDistance;
  112935. private _scaleRatio;
  112936. private _uniformScalingMesh;
  112937. private _octahedron;
  112938. /** Fires an event when any of it's sub gizmos are dragged */
  112939. onDragStartObservable: Observable<unknown>;
  112940. /** Fires an event when any of it's sub gizmos are released from dragging */
  112941. onDragEndObservable: Observable<unknown>;
  112942. attachedMesh: Nullable<AbstractMesh>;
  112943. /**
  112944. * Creates a ScaleGizmo
  112945. * @param gizmoLayer The utility layer the gizmo will be added to
  112946. */
  112947. constructor(gizmoLayer?: UtilityLayerRenderer);
  112948. updateGizmoRotationToMatchAttachedMesh: boolean;
  112949. /**
  112950. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112951. */
  112952. snapDistance: number;
  112953. /**
  112954. * Ratio for the scale of the gizmo (Default: 1)
  112955. */
  112956. scaleRatio: number;
  112957. /**
  112958. * Disposes of the gizmo
  112959. */
  112960. dispose(): void;
  112961. }
  112962. }
  112963. declare module BABYLON {
  112964. /**
  112965. * Single axis scale gizmo
  112966. */
  112967. export class AxisScaleGizmo extends Gizmo {
  112968. /**
  112969. * Drag behavior responsible for the gizmos dragging interactions
  112970. */
  112971. dragBehavior: PointerDragBehavior;
  112972. private _pointerObserver;
  112973. /**
  112974. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112975. */
  112976. snapDistance: number;
  112977. /**
  112978. * Event that fires each time the gizmo snaps to a new location.
  112979. * * snapDistance is the the change in distance
  112980. */
  112981. onSnapObservable: Observable<{
  112982. snapDistance: number;
  112983. }>;
  112984. /**
  112985. * If the scaling operation should be done on all axis (default: false)
  112986. */
  112987. uniformScaling: boolean;
  112988. private _isEnabled;
  112989. private _parent;
  112990. private _arrow;
  112991. private _coloredMaterial;
  112992. private _hoverMaterial;
  112993. /**
  112994. * Creates an AxisScaleGizmo
  112995. * @param gizmoLayer The utility layer the gizmo will be added to
  112996. * @param dragAxis The axis which the gizmo will be able to scale on
  112997. * @param color The color of the gizmo
  112998. */
  112999. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  113000. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113001. /**
  113002. * If the gizmo is enabled
  113003. */
  113004. isEnabled: boolean;
  113005. /**
  113006. * Disposes of the gizmo
  113007. */
  113008. dispose(): void;
  113009. /**
  113010. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113011. * @param mesh The mesh to replace the default mesh of the gizmo
  113012. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  113013. */
  113014. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  113015. }
  113016. }
  113017. declare module BABYLON {
  113018. /**
  113019. * Bounding box gizmo
  113020. */
  113021. export class BoundingBoxGizmo extends Gizmo {
  113022. private _lineBoundingBox;
  113023. private _rotateSpheresParent;
  113024. private _scaleBoxesParent;
  113025. private _boundingDimensions;
  113026. private _renderObserver;
  113027. private _pointerObserver;
  113028. private _scaleDragSpeed;
  113029. private _tmpQuaternion;
  113030. private _tmpVector;
  113031. private _tmpRotationMatrix;
  113032. /**
  113033. * 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)
  113034. */
  113035. ignoreChildren: boolean;
  113036. /**
  113037. * 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)
  113038. */
  113039. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  113040. /**
  113041. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  113042. */
  113043. rotationSphereSize: number;
  113044. /**
  113045. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  113046. */
  113047. scaleBoxSize: number;
  113048. /**
  113049. * 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)
  113050. */
  113051. fixedDragMeshScreenSize: boolean;
  113052. /**
  113053. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  113054. */
  113055. fixedDragMeshScreenSizeDistanceFactor: number;
  113056. /**
  113057. * Fired when a rotation sphere or scale box is dragged
  113058. */
  113059. onDragStartObservable: Observable<{}>;
  113060. /**
  113061. * Fired when a scale box is dragged
  113062. */
  113063. onScaleBoxDragObservable: Observable<{}>;
  113064. /**
  113065. * Fired when a scale box drag is ended
  113066. */
  113067. onScaleBoxDragEndObservable: Observable<{}>;
  113068. /**
  113069. * Fired when a rotation sphere is dragged
  113070. */
  113071. onRotationSphereDragObservable: Observable<{}>;
  113072. /**
  113073. * Fired when a rotation sphere drag is ended
  113074. */
  113075. onRotationSphereDragEndObservable: Observable<{}>;
  113076. /**
  113077. * 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)
  113078. */
  113079. scalePivot: Nullable<Vector3>;
  113080. /**
  113081. * Mesh used as a pivot to rotate the attached mesh
  113082. */
  113083. private _anchorMesh;
  113084. private _existingMeshScale;
  113085. private _dragMesh;
  113086. private pointerDragBehavior;
  113087. private coloredMaterial;
  113088. private hoverColoredMaterial;
  113089. /**
  113090. * Sets the color of the bounding box gizmo
  113091. * @param color the color to set
  113092. */
  113093. setColor(color: Color3): void;
  113094. /**
  113095. * Creates an BoundingBoxGizmo
  113096. * @param gizmoLayer The utility layer the gizmo will be added to
  113097. * @param color The color of the gizmo
  113098. */
  113099. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  113100. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113101. private _selectNode;
  113102. /**
  113103. * Updates the bounding box information for the Gizmo
  113104. */
  113105. updateBoundingBox(): void;
  113106. private _updateRotationSpheres;
  113107. private _updateScaleBoxes;
  113108. /**
  113109. * Enables rotation on the specified axis and disables rotation on the others
  113110. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  113111. */
  113112. setEnabledRotationAxis(axis: string): void;
  113113. /**
  113114. * Enables/disables scaling
  113115. * @param enable if scaling should be enabled
  113116. */
  113117. setEnabledScaling(enable: boolean): void;
  113118. private _updateDummy;
  113119. /**
  113120. * Enables a pointer drag behavior on the bounding box of the gizmo
  113121. */
  113122. enableDragBehavior(): void;
  113123. /**
  113124. * Disposes of the gizmo
  113125. */
  113126. dispose(): void;
  113127. /**
  113128. * 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)
  113129. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  113130. * @returns the bounding box mesh with the passed in mesh as a child
  113131. */
  113132. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  113133. /**
  113134. * CustomMeshes are not supported by this gizmo
  113135. * @param mesh The mesh to replace the default mesh of the gizmo
  113136. */
  113137. setCustomMesh(mesh: Mesh): void;
  113138. }
  113139. }
  113140. declare module BABYLON {
  113141. /**
  113142. * Single plane rotation gizmo
  113143. */
  113144. export class PlaneRotationGizmo extends Gizmo {
  113145. /**
  113146. * Drag behavior responsible for the gizmos dragging interactions
  113147. */
  113148. dragBehavior: PointerDragBehavior;
  113149. private _pointerObserver;
  113150. /**
  113151. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  113152. */
  113153. snapDistance: number;
  113154. /**
  113155. * Event that fires each time the gizmo snaps to a new location.
  113156. * * snapDistance is the the change in distance
  113157. */
  113158. onSnapObservable: Observable<{
  113159. snapDistance: number;
  113160. }>;
  113161. private _isEnabled;
  113162. private _parent;
  113163. /**
  113164. * Creates a PlaneRotationGizmo
  113165. * @param gizmoLayer The utility layer the gizmo will be added to
  113166. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  113167. * @param color The color of the gizmo
  113168. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113169. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113170. */
  113171. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  113172. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113173. /**
  113174. * If the gizmo is enabled
  113175. */
  113176. isEnabled: boolean;
  113177. /**
  113178. * Disposes of the gizmo
  113179. */
  113180. dispose(): void;
  113181. }
  113182. }
  113183. declare module BABYLON {
  113184. /**
  113185. * Gizmo that enables rotating a mesh along 3 axis
  113186. */
  113187. export class RotationGizmo extends Gizmo {
  113188. /**
  113189. * Internal gizmo used for interactions on the x axis
  113190. */
  113191. xGizmo: PlaneRotationGizmo;
  113192. /**
  113193. * Internal gizmo used for interactions on the y axis
  113194. */
  113195. yGizmo: PlaneRotationGizmo;
  113196. /**
  113197. * Internal gizmo used for interactions on the z axis
  113198. */
  113199. zGizmo: PlaneRotationGizmo;
  113200. /** Fires an event when any of it's sub gizmos are dragged */
  113201. onDragStartObservable: Observable<unknown>;
  113202. /** Fires an event when any of it's sub gizmos are released from dragging */
  113203. onDragEndObservable: Observable<unknown>;
  113204. private _meshAttached;
  113205. attachedMesh: Nullable<AbstractMesh>;
  113206. /**
  113207. * Creates a RotationGizmo
  113208. * @param gizmoLayer The utility layer the gizmo will be added to
  113209. * @param tessellation Amount of tessellation to be used when creating rotation circles
  113210. * @param useEulerRotation Use and update Euler angle instead of quaternion
  113211. */
  113212. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  113213. updateGizmoRotationToMatchAttachedMesh: boolean;
  113214. /**
  113215. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113216. */
  113217. snapDistance: number;
  113218. /**
  113219. * Ratio for the scale of the gizmo (Default: 1)
  113220. */
  113221. scaleRatio: number;
  113222. /**
  113223. * Disposes of the gizmo
  113224. */
  113225. dispose(): void;
  113226. /**
  113227. * CustomMeshes are not supported by this gizmo
  113228. * @param mesh The mesh to replace the default mesh of the gizmo
  113229. */
  113230. setCustomMesh(mesh: Mesh): void;
  113231. }
  113232. }
  113233. declare module BABYLON {
  113234. /**
  113235. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  113236. */
  113237. export class GizmoManager implements IDisposable {
  113238. private scene;
  113239. /**
  113240. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  113241. */
  113242. gizmos: {
  113243. positionGizmo: Nullable<PositionGizmo>;
  113244. rotationGizmo: Nullable<RotationGizmo>;
  113245. scaleGizmo: Nullable<ScaleGizmo>;
  113246. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  113247. };
  113248. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  113249. clearGizmoOnEmptyPointerEvent: boolean;
  113250. /** Fires an event when the manager is attached to a mesh */
  113251. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  113252. private _gizmosEnabled;
  113253. private _pointerObserver;
  113254. private _attachedMesh;
  113255. private _boundingBoxColor;
  113256. private _defaultUtilityLayer;
  113257. private _defaultKeepDepthUtilityLayer;
  113258. /**
  113259. * When bounding box gizmo is enabled, this can be used to track drag/end events
  113260. */
  113261. boundingBoxDragBehavior: SixDofDragBehavior;
  113262. /**
  113263. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  113264. */
  113265. attachableMeshes: Nullable<Array<AbstractMesh>>;
  113266. /**
  113267. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  113268. */
  113269. usePointerToAttachGizmos: boolean;
  113270. /**
  113271. * Utility layer that the bounding box gizmo belongs to
  113272. */
  113273. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  113274. /**
  113275. * Utility layer that all gizmos besides bounding box belong to
  113276. */
  113277. readonly utilityLayer: UtilityLayerRenderer;
  113278. /**
  113279. * Instatiates a gizmo manager
  113280. * @param scene the scene to overlay the gizmos on top of
  113281. */
  113282. constructor(scene: Scene);
  113283. /**
  113284. * Attaches a set of gizmos to the specified mesh
  113285. * @param mesh The mesh the gizmo's should be attached to
  113286. */
  113287. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  113288. /**
  113289. * If the position gizmo is enabled
  113290. */
  113291. positionGizmoEnabled: boolean;
  113292. /**
  113293. * If the rotation gizmo is enabled
  113294. */
  113295. rotationGizmoEnabled: boolean;
  113296. /**
  113297. * If the scale gizmo is enabled
  113298. */
  113299. scaleGizmoEnabled: boolean;
  113300. /**
  113301. * If the boundingBox gizmo is enabled
  113302. */
  113303. boundingBoxGizmoEnabled: boolean;
  113304. /**
  113305. * Disposes of the gizmo manager
  113306. */
  113307. dispose(): void;
  113308. }
  113309. }
  113310. declare module BABYLON {
  113311. /**
  113312. * A directional light is defined by a direction (what a surprise!).
  113313. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  113314. * 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.
  113315. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113316. */
  113317. export class DirectionalLight extends ShadowLight {
  113318. private _shadowFrustumSize;
  113319. /**
  113320. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  113321. */
  113322. /**
  113323. * Specifies a fix frustum size for the shadow generation.
  113324. */
  113325. shadowFrustumSize: number;
  113326. private _shadowOrthoScale;
  113327. /**
  113328. * Gets the shadow projection scale against the optimal computed one.
  113329. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113330. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113331. */
  113332. /**
  113333. * Sets the shadow projection scale against the optimal computed one.
  113334. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  113335. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  113336. */
  113337. shadowOrthoScale: number;
  113338. /**
  113339. * Automatically compute the projection matrix to best fit (including all the casters)
  113340. * on each frame.
  113341. */
  113342. autoUpdateExtends: boolean;
  113343. private _orthoLeft;
  113344. private _orthoRight;
  113345. private _orthoTop;
  113346. private _orthoBottom;
  113347. /**
  113348. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  113349. * The directional light is emitted from everywhere in the given direction.
  113350. * It can cast shadows.
  113351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113352. * @param name The friendly name of the light
  113353. * @param direction The direction of the light
  113354. * @param scene The scene the light belongs to
  113355. */
  113356. constructor(name: string, direction: Vector3, scene: Scene);
  113357. /**
  113358. * Returns the string "DirectionalLight".
  113359. * @return The class name
  113360. */
  113361. getClassName(): string;
  113362. /**
  113363. * Returns the integer 1.
  113364. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113365. */
  113366. getTypeID(): number;
  113367. /**
  113368. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  113369. * Returns the DirectionalLight Shadow projection matrix.
  113370. */
  113371. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113372. /**
  113373. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  113374. * Returns the DirectionalLight Shadow projection matrix.
  113375. */
  113376. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  113377. /**
  113378. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  113379. * Returns the DirectionalLight Shadow projection matrix.
  113380. */
  113381. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113382. protected _buildUniformLayout(): void;
  113383. /**
  113384. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  113385. * @param effect The effect to update
  113386. * @param lightIndex The index of the light in the effect to update
  113387. * @returns The directional light
  113388. */
  113389. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  113390. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  113391. /**
  113392. * Gets the minZ used for shadow according to both the scene and the light.
  113393. *
  113394. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113395. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113396. * @param activeCamera The camera we are returning the min for
  113397. * @returns the depth min z
  113398. */
  113399. getDepthMinZ(activeCamera: Camera): number;
  113400. /**
  113401. * Gets the maxZ used for shadow according to both the scene and the light.
  113402. *
  113403. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  113404. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  113405. * @param activeCamera The camera we are returning the max for
  113406. * @returns the depth max z
  113407. */
  113408. getDepthMaxZ(activeCamera: Camera): number;
  113409. /**
  113410. * Prepares the list of defines specific to the light type.
  113411. * @param defines the list of defines
  113412. * @param lightIndex defines the index of the light for the effect
  113413. */
  113414. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113415. }
  113416. }
  113417. declare module BABYLON {
  113418. /**
  113419. * Class containing static functions to help procedurally build meshes
  113420. */
  113421. export class HemisphereBuilder {
  113422. /**
  113423. * Creates a hemisphere mesh
  113424. * @param name defines the name of the mesh
  113425. * @param options defines the options used to create the mesh
  113426. * @param scene defines the hosting scene
  113427. * @returns the hemisphere mesh
  113428. */
  113429. static CreateHemisphere(name: string, options: {
  113430. segments?: number;
  113431. diameter?: number;
  113432. sideOrientation?: number;
  113433. }, scene: any): Mesh;
  113434. }
  113435. }
  113436. declare module BABYLON {
  113437. /**
  113438. * A spot light is defined by a position, a direction, an angle, and an exponent.
  113439. * These values define a cone of light starting from the position, emitting toward the direction.
  113440. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  113441. * and the exponent defines the speed of the decay of the light with distance (reach).
  113442. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113443. */
  113444. export class SpotLight extends ShadowLight {
  113445. private _angle;
  113446. private _innerAngle;
  113447. private _cosHalfAngle;
  113448. private _lightAngleScale;
  113449. private _lightAngleOffset;
  113450. /**
  113451. * Gets the cone angle of the spot light in Radians.
  113452. */
  113453. /**
  113454. * Sets the cone angle of the spot light in Radians.
  113455. */
  113456. angle: number;
  113457. /**
  113458. * Only used in gltf falloff mode, this defines the angle where
  113459. * the directional falloff will start before cutting at angle which could be seen
  113460. * as outer angle.
  113461. */
  113462. /**
  113463. * Only used in gltf falloff mode, this defines the angle where
  113464. * the directional falloff will start before cutting at angle which could be seen
  113465. * as outer angle.
  113466. */
  113467. innerAngle: number;
  113468. private _shadowAngleScale;
  113469. /**
  113470. * Allows scaling the angle of the light for shadow generation only.
  113471. */
  113472. /**
  113473. * Allows scaling the angle of the light for shadow generation only.
  113474. */
  113475. shadowAngleScale: number;
  113476. /**
  113477. * The light decay speed with the distance from the emission spot.
  113478. */
  113479. exponent: number;
  113480. private _projectionTextureMatrix;
  113481. /**
  113482. * Allows reading the projecton texture
  113483. */
  113484. readonly projectionTextureMatrix: Matrix;
  113485. protected _projectionTextureLightNear: number;
  113486. /**
  113487. * Gets the near clip of the Spotlight for texture projection.
  113488. */
  113489. /**
  113490. * Sets the near clip of the Spotlight for texture projection.
  113491. */
  113492. projectionTextureLightNear: number;
  113493. protected _projectionTextureLightFar: number;
  113494. /**
  113495. * Gets the far clip of the Spotlight for texture projection.
  113496. */
  113497. /**
  113498. * Sets the far clip of the Spotlight for texture projection.
  113499. */
  113500. projectionTextureLightFar: number;
  113501. protected _projectionTextureUpDirection: Vector3;
  113502. /**
  113503. * Gets the Up vector of the Spotlight for texture projection.
  113504. */
  113505. /**
  113506. * Sets the Up vector of the Spotlight for texture projection.
  113507. */
  113508. projectionTextureUpDirection: Vector3;
  113509. private _projectionTexture;
  113510. /**
  113511. * Gets the projection texture of the light.
  113512. */
  113513. /**
  113514. * Sets the projection texture of the light.
  113515. */
  113516. projectionTexture: Nullable<BaseTexture>;
  113517. private _projectionTextureViewLightDirty;
  113518. private _projectionTextureProjectionLightDirty;
  113519. private _projectionTextureDirty;
  113520. private _projectionTextureViewTargetVector;
  113521. private _projectionTextureViewLightMatrix;
  113522. private _projectionTextureProjectionLightMatrix;
  113523. private _projectionTextureScalingMatrix;
  113524. /**
  113525. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  113526. * It can cast shadows.
  113527. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113528. * @param name The light friendly name
  113529. * @param position The position of the spot light in the scene
  113530. * @param direction The direction of the light in the scene
  113531. * @param angle The cone angle of the light in Radians
  113532. * @param exponent The light decay speed with the distance from the emission spot
  113533. * @param scene The scene the lights belongs to
  113534. */
  113535. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  113536. /**
  113537. * Returns the string "SpotLight".
  113538. * @returns the class name
  113539. */
  113540. getClassName(): string;
  113541. /**
  113542. * Returns the integer 2.
  113543. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113544. */
  113545. getTypeID(): number;
  113546. /**
  113547. * Overrides the direction setter to recompute the projection texture view light Matrix.
  113548. */
  113549. protected _setDirection(value: Vector3): void;
  113550. /**
  113551. * Overrides the position setter to recompute the projection texture view light Matrix.
  113552. */
  113553. protected _setPosition(value: Vector3): void;
  113554. /**
  113555. * 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.
  113556. * Returns the SpotLight.
  113557. */
  113558. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113559. protected _computeProjectionTextureViewLightMatrix(): void;
  113560. protected _computeProjectionTextureProjectionLightMatrix(): void;
  113561. /**
  113562. * Main function for light texture projection matrix computing.
  113563. */
  113564. protected _computeProjectionTextureMatrix(): void;
  113565. protected _buildUniformLayout(): void;
  113566. private _computeAngleValues;
  113567. /**
  113568. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  113569. * @param effect The effect to update
  113570. * @param lightIndex The index of the light in the effect to update
  113571. * @returns The spot light
  113572. */
  113573. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  113574. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  113575. /**
  113576. * Disposes the light and the associated resources.
  113577. */
  113578. dispose(): void;
  113579. /**
  113580. * Prepares the list of defines specific to the light type.
  113581. * @param defines the list of defines
  113582. * @param lightIndex defines the index of the light for the effect
  113583. */
  113584. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113585. }
  113586. }
  113587. declare module BABYLON {
  113588. /**
  113589. * Gizmo that enables viewing a light
  113590. */
  113591. export class LightGizmo extends Gizmo {
  113592. private _lightMesh;
  113593. private _material;
  113594. private cachedPosition;
  113595. private cachedForward;
  113596. /**
  113597. * Creates a LightGizmo
  113598. * @param gizmoLayer The utility layer the gizmo will be added to
  113599. */
  113600. constructor(gizmoLayer?: UtilityLayerRenderer);
  113601. private _light;
  113602. /**
  113603. * The light that the gizmo is attached to
  113604. */
  113605. light: Nullable<Light>;
  113606. /**
  113607. * Gets the material used to render the light gizmo
  113608. */
  113609. readonly material: StandardMaterial;
  113610. /**
  113611. * @hidden
  113612. * Updates the gizmo to match the attached mesh's position/rotation
  113613. */
  113614. protected _update(): void;
  113615. private static _Scale;
  113616. /**
  113617. * Creates the lines for a light mesh
  113618. */
  113619. private static _createLightLines;
  113620. /**
  113621. * Disposes of the light gizmo
  113622. */
  113623. dispose(): void;
  113624. private static _CreateHemisphericLightMesh;
  113625. private static _CreatePointLightMesh;
  113626. private static _CreateSpotLightMesh;
  113627. private static _CreateDirectionalLightMesh;
  113628. }
  113629. }
  113630. declare module BABYLON {
  113631. /** @hidden */
  113632. export var backgroundFragmentDeclaration: {
  113633. name: string;
  113634. shader: string;
  113635. };
  113636. }
  113637. declare module BABYLON {
  113638. /** @hidden */
  113639. export var backgroundUboDeclaration: {
  113640. name: string;
  113641. shader: string;
  113642. };
  113643. }
  113644. declare module BABYLON {
  113645. /** @hidden */
  113646. export var backgroundPixelShader: {
  113647. name: string;
  113648. shader: string;
  113649. };
  113650. }
  113651. declare module BABYLON {
  113652. /** @hidden */
  113653. export var backgroundVertexDeclaration: {
  113654. name: string;
  113655. shader: string;
  113656. };
  113657. }
  113658. declare module BABYLON {
  113659. /** @hidden */
  113660. export var backgroundVertexShader: {
  113661. name: string;
  113662. shader: string;
  113663. };
  113664. }
  113665. declare module BABYLON {
  113666. /**
  113667. * Background material used to create an efficient environement around your scene.
  113668. */
  113669. export class BackgroundMaterial extends PushMaterial {
  113670. /**
  113671. * Standard reflectance value at parallel view angle.
  113672. */
  113673. static StandardReflectance0: number;
  113674. /**
  113675. * Standard reflectance value at grazing angle.
  113676. */
  113677. static StandardReflectance90: number;
  113678. protected _primaryColor: Color3;
  113679. /**
  113680. * Key light Color (multiply against the environement texture)
  113681. */
  113682. primaryColor: Color3;
  113683. protected __perceptualColor: Nullable<Color3>;
  113684. /**
  113685. * Experimental Internal Use Only.
  113686. *
  113687. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  113688. * This acts as a helper to set the primary color to a more "human friendly" value.
  113689. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  113690. * output color as close as possible from the chosen value.
  113691. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  113692. * part of lighting setup.)
  113693. */
  113694. _perceptualColor: Nullable<Color3>;
  113695. protected _primaryColorShadowLevel: float;
  113696. /**
  113697. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  113698. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  113699. */
  113700. primaryColorShadowLevel: float;
  113701. protected _primaryColorHighlightLevel: float;
  113702. /**
  113703. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  113704. * The primary color is used at the level chosen to define what the white area would look.
  113705. */
  113706. primaryColorHighlightLevel: float;
  113707. protected _reflectionTexture: Nullable<BaseTexture>;
  113708. /**
  113709. * Reflection Texture used in the material.
  113710. * Should be author in a specific way for the best result (refer to the documentation).
  113711. */
  113712. reflectionTexture: Nullable<BaseTexture>;
  113713. protected _reflectionBlur: float;
  113714. /**
  113715. * Reflection Texture level of blur.
  113716. *
  113717. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  113718. * texture twice.
  113719. */
  113720. reflectionBlur: float;
  113721. protected _diffuseTexture: Nullable<BaseTexture>;
  113722. /**
  113723. * Diffuse Texture used in the material.
  113724. * Should be author in a specific way for the best result (refer to the documentation).
  113725. */
  113726. diffuseTexture: Nullable<BaseTexture>;
  113727. protected _shadowLights: Nullable<IShadowLight[]>;
  113728. /**
  113729. * Specify the list of lights casting shadow on the material.
  113730. * All scene shadow lights will be included if null.
  113731. */
  113732. shadowLights: Nullable<IShadowLight[]>;
  113733. protected _shadowLevel: float;
  113734. /**
  113735. * Helps adjusting the shadow to a softer level if required.
  113736. * 0 means black shadows and 1 means no shadows.
  113737. */
  113738. shadowLevel: float;
  113739. protected _sceneCenter: Vector3;
  113740. /**
  113741. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  113742. * It is usually zero but might be interesting to modify according to your setup.
  113743. */
  113744. sceneCenter: Vector3;
  113745. protected _opacityFresnel: boolean;
  113746. /**
  113747. * This helps specifying that the material is falling off to the sky box at grazing angle.
  113748. * This helps ensuring a nice transition when the camera goes under the ground.
  113749. */
  113750. opacityFresnel: boolean;
  113751. protected _reflectionFresnel: boolean;
  113752. /**
  113753. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  113754. * This helps adding a mirror texture on the ground.
  113755. */
  113756. reflectionFresnel: boolean;
  113757. protected _reflectionFalloffDistance: number;
  113758. /**
  113759. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  113760. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  113761. */
  113762. reflectionFalloffDistance: number;
  113763. protected _reflectionAmount: number;
  113764. /**
  113765. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  113766. */
  113767. reflectionAmount: number;
  113768. protected _reflectionReflectance0: number;
  113769. /**
  113770. * This specifies the weight of the reflection at grazing angle.
  113771. */
  113772. reflectionReflectance0: number;
  113773. protected _reflectionReflectance90: number;
  113774. /**
  113775. * This specifies the weight of the reflection at a perpendicular point of view.
  113776. */
  113777. reflectionReflectance90: number;
  113778. /**
  113779. * Sets the reflection reflectance fresnel values according to the default standard
  113780. * empirically know to work well :-)
  113781. */
  113782. reflectionStandardFresnelWeight: number;
  113783. protected _useRGBColor: boolean;
  113784. /**
  113785. * Helps to directly use the maps channels instead of their level.
  113786. */
  113787. useRGBColor: boolean;
  113788. protected _enableNoise: boolean;
  113789. /**
  113790. * This helps reducing the banding effect that could occur on the background.
  113791. */
  113792. enableNoise: boolean;
  113793. /**
  113794. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113795. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  113796. * Recommended to be keep at 1.0 except for special cases.
  113797. */
  113798. fovMultiplier: number;
  113799. private _fovMultiplier;
  113800. /**
  113801. * Enable the FOV adjustment feature controlled by fovMultiplier.
  113802. */
  113803. useEquirectangularFOV: boolean;
  113804. private _maxSimultaneousLights;
  113805. /**
  113806. * Number of Simultaneous lights allowed on the material.
  113807. */
  113808. maxSimultaneousLights: int;
  113809. /**
  113810. * Default configuration related to image processing available in the Background Material.
  113811. */
  113812. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113813. /**
  113814. * Keep track of the image processing observer to allow dispose and replace.
  113815. */
  113816. private _imageProcessingObserver;
  113817. /**
  113818. * Attaches a new image processing configuration to the PBR Material.
  113819. * @param configuration (if null the scene configuration will be use)
  113820. */
  113821. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113822. /**
  113823. * Gets the image processing configuration used either in this material.
  113824. */
  113825. /**
  113826. * Sets the Default image processing configuration used either in the this material.
  113827. *
  113828. * If sets to null, the scene one is in use.
  113829. */
  113830. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  113831. /**
  113832. * Gets wether the color curves effect is enabled.
  113833. */
  113834. /**
  113835. * Sets wether the color curves effect is enabled.
  113836. */
  113837. cameraColorCurvesEnabled: boolean;
  113838. /**
  113839. * Gets wether the color grading effect is enabled.
  113840. */
  113841. /**
  113842. * Gets wether the color grading effect is enabled.
  113843. */
  113844. cameraColorGradingEnabled: boolean;
  113845. /**
  113846. * Gets wether tonemapping is enabled or not.
  113847. */
  113848. /**
  113849. * Sets wether tonemapping is enabled or not
  113850. */
  113851. cameraToneMappingEnabled: boolean;
  113852. /**
  113853. * The camera exposure used on this material.
  113854. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113855. * This corresponds to a photographic exposure.
  113856. */
  113857. /**
  113858. * The camera exposure used on this material.
  113859. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113860. * This corresponds to a photographic exposure.
  113861. */
  113862. cameraExposure: float;
  113863. /**
  113864. * Gets The camera contrast used on this material.
  113865. */
  113866. /**
  113867. * Sets The camera contrast used on this material.
  113868. */
  113869. cameraContrast: float;
  113870. /**
  113871. * Gets the Color Grading 2D Lookup Texture.
  113872. */
  113873. /**
  113874. * Sets the Color Grading 2D Lookup Texture.
  113875. */
  113876. cameraColorGradingTexture: Nullable<BaseTexture>;
  113877. /**
  113878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113880. * 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;
  113881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113882. */
  113883. /**
  113884. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113885. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113886. * 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;
  113887. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113888. */
  113889. cameraColorCurves: Nullable<ColorCurves>;
  113890. /**
  113891. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  113892. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  113893. */
  113894. switchToBGR: boolean;
  113895. private _renderTargets;
  113896. private _reflectionControls;
  113897. private _white;
  113898. private _primaryShadowColor;
  113899. private _primaryHighlightColor;
  113900. /**
  113901. * Instantiates a Background Material in the given scene
  113902. * @param name The friendly name of the material
  113903. * @param scene The scene to add the material to
  113904. */
  113905. constructor(name: string, scene: Scene);
  113906. /**
  113907. * Gets a boolean indicating that current material needs to register RTT
  113908. */
  113909. readonly hasRenderTargetTextures: boolean;
  113910. /**
  113911. * The entire material has been created in order to prevent overdraw.
  113912. * @returns false
  113913. */
  113914. needAlphaTesting(): boolean;
  113915. /**
  113916. * The entire material has been created in order to prevent overdraw.
  113917. * @returns true if blending is enable
  113918. */
  113919. needAlphaBlending(): boolean;
  113920. /**
  113921. * Checks wether the material is ready to be rendered for a given mesh.
  113922. * @param mesh The mesh to render
  113923. * @param subMesh The submesh to check against
  113924. * @param useInstances Specify wether or not the material is used with instances
  113925. * @returns true if all the dependencies are ready (Textures, Effects...)
  113926. */
  113927. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113928. /**
  113929. * Compute the primary color according to the chosen perceptual color.
  113930. */
  113931. private _computePrimaryColorFromPerceptualColor;
  113932. /**
  113933. * Compute the highlights and shadow colors according to their chosen levels.
  113934. */
  113935. private _computePrimaryColors;
  113936. /**
  113937. * Build the uniform buffer used in the material.
  113938. */
  113939. buildUniformLayout(): void;
  113940. /**
  113941. * Unbind the material.
  113942. */
  113943. unbind(): void;
  113944. /**
  113945. * Bind only the world matrix to the material.
  113946. * @param world The world matrix to bind.
  113947. */
  113948. bindOnlyWorldMatrix(world: Matrix): void;
  113949. /**
  113950. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  113951. * @param world The world matrix to bind.
  113952. * @param subMesh The submesh to bind for.
  113953. */
  113954. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113955. /**
  113956. * Checks to see if a texture is used in the material.
  113957. * @param texture - Base texture to use.
  113958. * @returns - Boolean specifying if a texture is used in the material.
  113959. */
  113960. hasTexture(texture: BaseTexture): boolean;
  113961. /**
  113962. * Dispose the material.
  113963. * @param forceDisposeEffect Force disposal of the associated effect.
  113964. * @param forceDisposeTextures Force disposal of the associated textures.
  113965. */
  113966. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113967. /**
  113968. * Clones the material.
  113969. * @param name The cloned name.
  113970. * @returns The cloned material.
  113971. */
  113972. clone(name: string): BackgroundMaterial;
  113973. /**
  113974. * Serializes the current material to its JSON representation.
  113975. * @returns The JSON representation.
  113976. */
  113977. serialize(): any;
  113978. /**
  113979. * Gets the class name of the material
  113980. * @returns "BackgroundMaterial"
  113981. */
  113982. getClassName(): string;
  113983. /**
  113984. * Parse a JSON input to create back a background material.
  113985. * @param source The JSON data to parse
  113986. * @param scene The scene to create the parsed material in
  113987. * @param rootUrl The root url of the assets the material depends upon
  113988. * @returns the instantiated BackgroundMaterial.
  113989. */
  113990. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  113991. }
  113992. }
  113993. declare module BABYLON {
  113994. /**
  113995. * Represents the different options available during the creation of
  113996. * a Environment helper.
  113997. *
  113998. * This can control the default ground, skybox and image processing setup of your scene.
  113999. */
  114000. export interface IEnvironmentHelperOptions {
  114001. /**
  114002. * Specifies wether or not to create a ground.
  114003. * True by default.
  114004. */
  114005. createGround: boolean;
  114006. /**
  114007. * Specifies the ground size.
  114008. * 15 by default.
  114009. */
  114010. groundSize: number;
  114011. /**
  114012. * The texture used on the ground for the main color.
  114013. * Comes from the BabylonJS CDN by default.
  114014. *
  114015. * Remarks: Can be either a texture or a url.
  114016. */
  114017. groundTexture: string | BaseTexture;
  114018. /**
  114019. * The color mixed in the ground texture by default.
  114020. * BabylonJS clearColor by default.
  114021. */
  114022. groundColor: Color3;
  114023. /**
  114024. * Specifies the ground opacity.
  114025. * 1 by default.
  114026. */
  114027. groundOpacity: number;
  114028. /**
  114029. * Enables the ground to receive shadows.
  114030. * True by default.
  114031. */
  114032. enableGroundShadow: boolean;
  114033. /**
  114034. * Helps preventing the shadow to be fully black on the ground.
  114035. * 0.5 by default.
  114036. */
  114037. groundShadowLevel: number;
  114038. /**
  114039. * Creates a mirror texture attach to the ground.
  114040. * false by default.
  114041. */
  114042. enableGroundMirror: boolean;
  114043. /**
  114044. * Specifies the ground mirror size ratio.
  114045. * 0.3 by default as the default kernel is 64.
  114046. */
  114047. groundMirrorSizeRatio: number;
  114048. /**
  114049. * Specifies the ground mirror blur kernel size.
  114050. * 64 by default.
  114051. */
  114052. groundMirrorBlurKernel: number;
  114053. /**
  114054. * Specifies the ground mirror visibility amount.
  114055. * 1 by default
  114056. */
  114057. groundMirrorAmount: number;
  114058. /**
  114059. * Specifies the ground mirror reflectance weight.
  114060. * This uses the standard weight of the background material to setup the fresnel effect
  114061. * of the mirror.
  114062. * 1 by default.
  114063. */
  114064. groundMirrorFresnelWeight: number;
  114065. /**
  114066. * Specifies the ground mirror Falloff distance.
  114067. * This can helps reducing the size of the reflection.
  114068. * 0 by Default.
  114069. */
  114070. groundMirrorFallOffDistance: number;
  114071. /**
  114072. * Specifies the ground mirror texture type.
  114073. * Unsigned Int by Default.
  114074. */
  114075. groundMirrorTextureType: number;
  114076. /**
  114077. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  114078. * the shown objects.
  114079. */
  114080. groundYBias: number;
  114081. /**
  114082. * Specifies wether or not to create a skybox.
  114083. * True by default.
  114084. */
  114085. createSkybox: boolean;
  114086. /**
  114087. * Specifies the skybox size.
  114088. * 20 by default.
  114089. */
  114090. skyboxSize: number;
  114091. /**
  114092. * The texture used on the skybox for the main color.
  114093. * Comes from the BabylonJS CDN by default.
  114094. *
  114095. * Remarks: Can be either a texture or a url.
  114096. */
  114097. skyboxTexture: string | BaseTexture;
  114098. /**
  114099. * The color mixed in the skybox texture by default.
  114100. * BabylonJS clearColor by default.
  114101. */
  114102. skyboxColor: Color3;
  114103. /**
  114104. * The background rotation around the Y axis of the scene.
  114105. * This helps aligning the key lights of your scene with the background.
  114106. * 0 by default.
  114107. */
  114108. backgroundYRotation: number;
  114109. /**
  114110. * Compute automatically the size of the elements to best fit with the scene.
  114111. */
  114112. sizeAuto: boolean;
  114113. /**
  114114. * Default position of the rootMesh if autoSize is not true.
  114115. */
  114116. rootPosition: Vector3;
  114117. /**
  114118. * Sets up the image processing in the scene.
  114119. * true by default.
  114120. */
  114121. setupImageProcessing: boolean;
  114122. /**
  114123. * The texture used as your environment texture in the scene.
  114124. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  114125. *
  114126. * Remarks: Can be either a texture or a url.
  114127. */
  114128. environmentTexture: string | BaseTexture;
  114129. /**
  114130. * The value of the exposure to apply to the scene.
  114131. * 0.6 by default if setupImageProcessing is true.
  114132. */
  114133. cameraExposure: number;
  114134. /**
  114135. * The value of the contrast to apply to the scene.
  114136. * 1.6 by default if setupImageProcessing is true.
  114137. */
  114138. cameraContrast: number;
  114139. /**
  114140. * Specifies wether or not tonemapping should be enabled in the scene.
  114141. * true by default if setupImageProcessing is true.
  114142. */
  114143. toneMappingEnabled: boolean;
  114144. }
  114145. /**
  114146. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  114147. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  114148. * It also helps with the default setup of your imageProcessing configuration.
  114149. */
  114150. export class EnvironmentHelper {
  114151. /**
  114152. * Default ground texture URL.
  114153. */
  114154. private static _groundTextureCDNUrl;
  114155. /**
  114156. * Default skybox texture URL.
  114157. */
  114158. private static _skyboxTextureCDNUrl;
  114159. /**
  114160. * Default environment texture URL.
  114161. */
  114162. private static _environmentTextureCDNUrl;
  114163. /**
  114164. * Creates the default options for the helper.
  114165. */
  114166. private static _getDefaultOptions;
  114167. private _rootMesh;
  114168. /**
  114169. * Gets the root mesh created by the helper.
  114170. */
  114171. readonly rootMesh: Mesh;
  114172. private _skybox;
  114173. /**
  114174. * Gets the skybox created by the helper.
  114175. */
  114176. readonly skybox: Nullable<Mesh>;
  114177. private _skyboxTexture;
  114178. /**
  114179. * Gets the skybox texture created by the helper.
  114180. */
  114181. readonly skyboxTexture: Nullable<BaseTexture>;
  114182. private _skyboxMaterial;
  114183. /**
  114184. * Gets the skybox material created by the helper.
  114185. */
  114186. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  114187. private _ground;
  114188. /**
  114189. * Gets the ground mesh created by the helper.
  114190. */
  114191. readonly ground: Nullable<Mesh>;
  114192. private _groundTexture;
  114193. /**
  114194. * Gets the ground texture created by the helper.
  114195. */
  114196. readonly groundTexture: Nullable<BaseTexture>;
  114197. private _groundMirror;
  114198. /**
  114199. * Gets the ground mirror created by the helper.
  114200. */
  114201. readonly groundMirror: Nullable<MirrorTexture>;
  114202. /**
  114203. * Gets the ground mirror render list to helps pushing the meshes
  114204. * you wish in the ground reflection.
  114205. */
  114206. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  114207. private _groundMaterial;
  114208. /**
  114209. * Gets the ground material created by the helper.
  114210. */
  114211. readonly groundMaterial: Nullable<BackgroundMaterial>;
  114212. /**
  114213. * Stores the creation options.
  114214. */
  114215. private readonly _scene;
  114216. private _options;
  114217. /**
  114218. * This observable will be notified with any error during the creation of the environment,
  114219. * mainly texture creation errors.
  114220. */
  114221. onErrorObservable: Observable<{
  114222. message?: string;
  114223. exception?: any;
  114224. }>;
  114225. /**
  114226. * constructor
  114227. * @param options Defines the options we want to customize the helper
  114228. * @param scene The scene to add the material to
  114229. */
  114230. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  114231. /**
  114232. * Updates the background according to the new options
  114233. * @param options
  114234. */
  114235. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  114236. /**
  114237. * Sets the primary color of all the available elements.
  114238. * @param color the main color to affect to the ground and the background
  114239. */
  114240. setMainColor(color: Color3): void;
  114241. /**
  114242. * Setup the image processing according to the specified options.
  114243. */
  114244. private _setupImageProcessing;
  114245. /**
  114246. * Setup the environment texture according to the specified options.
  114247. */
  114248. private _setupEnvironmentTexture;
  114249. /**
  114250. * Setup the background according to the specified options.
  114251. */
  114252. private _setupBackground;
  114253. /**
  114254. * Get the scene sizes according to the setup.
  114255. */
  114256. private _getSceneSize;
  114257. /**
  114258. * Setup the ground according to the specified options.
  114259. */
  114260. private _setupGround;
  114261. /**
  114262. * Setup the ground material according to the specified options.
  114263. */
  114264. private _setupGroundMaterial;
  114265. /**
  114266. * Setup the ground diffuse texture according to the specified options.
  114267. */
  114268. private _setupGroundDiffuseTexture;
  114269. /**
  114270. * Setup the ground mirror texture according to the specified options.
  114271. */
  114272. private _setupGroundMirrorTexture;
  114273. /**
  114274. * Setup the ground to receive the mirror texture.
  114275. */
  114276. private _setupMirrorInGroundMaterial;
  114277. /**
  114278. * Setup the skybox according to the specified options.
  114279. */
  114280. private _setupSkybox;
  114281. /**
  114282. * Setup the skybox material according to the specified options.
  114283. */
  114284. private _setupSkyboxMaterial;
  114285. /**
  114286. * Setup the skybox reflection texture according to the specified options.
  114287. */
  114288. private _setupSkyboxReflectionTexture;
  114289. private _errorHandler;
  114290. /**
  114291. * Dispose all the elements created by the Helper.
  114292. */
  114293. dispose(): void;
  114294. }
  114295. }
  114296. declare module BABYLON {
  114297. /**
  114298. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  114299. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  114300. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  114301. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114302. */
  114303. export class PhotoDome extends TransformNode {
  114304. /**
  114305. * Define the image as a Monoscopic panoramic 360 image.
  114306. */
  114307. static readonly MODE_MONOSCOPIC: number;
  114308. /**
  114309. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114310. */
  114311. static readonly MODE_TOPBOTTOM: number;
  114312. /**
  114313. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114314. */
  114315. static readonly MODE_SIDEBYSIDE: number;
  114316. private _useDirectMapping;
  114317. /**
  114318. * The texture being displayed on the sphere
  114319. */
  114320. protected _photoTexture: Texture;
  114321. /**
  114322. * Gets or sets the texture being displayed on the sphere
  114323. */
  114324. photoTexture: Texture;
  114325. /**
  114326. * Observable raised when an error occured while loading the 360 image
  114327. */
  114328. onLoadErrorObservable: Observable<string>;
  114329. /**
  114330. * The skybox material
  114331. */
  114332. protected _material: BackgroundMaterial;
  114333. /**
  114334. * The surface used for the skybox
  114335. */
  114336. protected _mesh: Mesh;
  114337. /**
  114338. * Gets the mesh used for the skybox.
  114339. */
  114340. readonly mesh: Mesh;
  114341. /**
  114342. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114343. * Also see the options.resolution property.
  114344. */
  114345. fovMultiplier: number;
  114346. private _imageMode;
  114347. /**
  114348. * Gets or set the current video mode for the video. It can be:
  114349. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  114350. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  114351. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  114352. */
  114353. imageMode: number;
  114354. /**
  114355. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  114356. * @param name Element's name, child elements will append suffixes for their own names.
  114357. * @param urlsOfPhoto defines the url of the photo to display
  114358. * @param options defines an object containing optional or exposed sub element properties
  114359. * @param onError defines a callback called when an error occured while loading the texture
  114360. */
  114361. constructor(name: string, urlOfPhoto: string, options: {
  114362. resolution?: number;
  114363. size?: number;
  114364. useDirectMapping?: boolean;
  114365. faceForward?: boolean;
  114366. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  114367. private _onBeforeCameraRenderObserver;
  114368. private _changeImageMode;
  114369. /**
  114370. * Releases resources associated with this node.
  114371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114373. */
  114374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114375. }
  114376. }
  114377. declare module BABYLON {
  114378. /**
  114379. * Class used to host RGBD texture specific utilities
  114380. */
  114381. export class RGBDTextureTools {
  114382. /**
  114383. * Expand the RGBD Texture from RGBD to Half Float if possible.
  114384. * @param texture the texture to expand.
  114385. */
  114386. static ExpandRGBDTexture(texture: Texture): void;
  114387. }
  114388. }
  114389. declare module BABYLON {
  114390. /**
  114391. * Class used to host texture specific utilities
  114392. */
  114393. export class BRDFTextureTools {
  114394. /**
  114395. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  114396. * @param scene defines the hosting scene
  114397. * @returns the environment BRDF texture
  114398. */
  114399. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  114400. private static _environmentBRDFBase64Texture;
  114401. }
  114402. }
  114403. declare module BABYLON {
  114404. /**
  114405. * @hidden
  114406. */
  114407. export interface IMaterialClearCoatDefines {
  114408. CLEARCOAT: boolean;
  114409. CLEARCOAT_DEFAULTIOR: boolean;
  114410. CLEARCOAT_TEXTURE: boolean;
  114411. CLEARCOAT_TEXTUREDIRECTUV: number;
  114412. CLEARCOAT_BUMP: boolean;
  114413. CLEARCOAT_BUMPDIRECTUV: number;
  114414. CLEARCOAT_TINT: boolean;
  114415. CLEARCOAT_TINT_TEXTURE: boolean;
  114416. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114417. /** @hidden */
  114418. _areTexturesDirty: boolean;
  114419. }
  114420. /**
  114421. * Define the code related to the clear coat parameters of the pbr material.
  114422. */
  114423. export class PBRClearCoatConfiguration {
  114424. /**
  114425. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114426. * The default fits with a polyurethane material.
  114427. */
  114428. private static readonly _DefaultIndexOfRefraction;
  114429. private _isEnabled;
  114430. /**
  114431. * Defines if the clear coat is enabled in the material.
  114432. */
  114433. isEnabled: boolean;
  114434. /**
  114435. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  114436. */
  114437. intensity: number;
  114438. /**
  114439. * Defines the clear coat layer roughness.
  114440. */
  114441. roughness: number;
  114442. private _indexOfRefraction;
  114443. /**
  114444. * Defines the index of refraction of the clear coat.
  114445. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  114446. * The default fits with a polyurethane material.
  114447. * Changing the default value is more performance intensive.
  114448. */
  114449. indexOfRefraction: number;
  114450. private _texture;
  114451. /**
  114452. * Stores the clear coat values in a texture.
  114453. */
  114454. texture: Nullable<BaseTexture>;
  114455. private _bumpTexture;
  114456. /**
  114457. * Define the clear coat specific bump texture.
  114458. */
  114459. bumpTexture: Nullable<BaseTexture>;
  114460. private _isTintEnabled;
  114461. /**
  114462. * Defines if the clear coat tint is enabled in the material.
  114463. */
  114464. isTintEnabled: boolean;
  114465. /**
  114466. * Defines the clear coat tint of the material.
  114467. * This is only use if tint is enabled
  114468. */
  114469. tintColor: Color3;
  114470. /**
  114471. * Defines the distance at which the tint color should be found in the
  114472. * clear coat media.
  114473. * This is only use if tint is enabled
  114474. */
  114475. tintColorAtDistance: number;
  114476. /**
  114477. * Defines the clear coat layer thickness.
  114478. * This is only use if tint is enabled
  114479. */
  114480. tintThickness: number;
  114481. private _tintTexture;
  114482. /**
  114483. * Stores the clear tint values in a texture.
  114484. * rgb is tint
  114485. * a is a thickness factor
  114486. */
  114487. tintTexture: Nullable<BaseTexture>;
  114488. /** @hidden */
  114489. private _internalMarkAllSubMeshesAsTexturesDirty;
  114490. /** @hidden */
  114491. _markAllSubMeshesAsTexturesDirty(): void;
  114492. /**
  114493. * Instantiate a new istance of clear coat configuration.
  114494. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114495. */
  114496. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114497. /**
  114498. * Gets wehter the submesh is ready to be used or not.
  114499. * @param defines the list of "defines" to update.
  114500. * @param scene defines the scene the material belongs to.
  114501. * @param engine defines the engine the material belongs to.
  114502. * @param disableBumpMap defines wether the material disables bump or not.
  114503. * @returns - boolean indicating that the submesh is ready or not.
  114504. */
  114505. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  114506. /**
  114507. * Checks to see if a texture is used in the material.
  114508. * @param defines the list of "defines" to update.
  114509. * @param scene defines the scene to the material belongs to.
  114510. */
  114511. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  114512. /**
  114513. * Binds the material data.
  114514. * @param uniformBuffer defines the Uniform buffer to fill in.
  114515. * @param scene defines the scene the material belongs to.
  114516. * @param engine defines the engine the material belongs to.
  114517. * @param disableBumpMap defines wether the material disables bump or not.
  114518. * @param isFrozen defines wether the material is frozen or not.
  114519. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114520. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114521. */
  114522. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  114523. /**
  114524. * Checks to see if a texture is used in the material.
  114525. * @param texture - Base texture to use.
  114526. * @returns - Boolean specifying if a texture is used in the material.
  114527. */
  114528. hasTexture(texture: BaseTexture): boolean;
  114529. /**
  114530. * Returns an array of the actively used textures.
  114531. * @param activeTextures Array of BaseTextures
  114532. */
  114533. getActiveTextures(activeTextures: BaseTexture[]): void;
  114534. /**
  114535. * Returns the animatable textures.
  114536. * @param animatables Array of animatable textures.
  114537. */
  114538. getAnimatables(animatables: IAnimatable[]): void;
  114539. /**
  114540. * Disposes the resources of the material.
  114541. * @param forceDisposeTextures - Forces the disposal of all textures.
  114542. */
  114543. dispose(forceDisposeTextures?: boolean): void;
  114544. /**
  114545. * Get the current class name of the texture useful for serialization or dynamic coding.
  114546. * @returns "PBRClearCoatConfiguration"
  114547. */
  114548. getClassName(): string;
  114549. /**
  114550. * Add fallbacks to the effect fallbacks list.
  114551. * @param defines defines the Base texture to use.
  114552. * @param fallbacks defines the current fallback list.
  114553. * @param currentRank defines the current fallback rank.
  114554. * @returns the new fallback rank.
  114555. */
  114556. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114557. /**
  114558. * Add the required uniforms to the current list.
  114559. * @param uniforms defines the current uniform list.
  114560. */
  114561. static AddUniforms(uniforms: string[]): void;
  114562. /**
  114563. * Add the required samplers to the current list.
  114564. * @param samplers defines the current sampler list.
  114565. */
  114566. static AddSamplers(samplers: string[]): void;
  114567. /**
  114568. * Add the required uniforms to the current buffer.
  114569. * @param uniformBuffer defines the current uniform buffer.
  114570. */
  114571. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114572. /**
  114573. * Makes a duplicate of the current configuration into another one.
  114574. * @param clearCoatConfiguration define the config where to copy the info
  114575. */
  114576. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  114577. /**
  114578. * Serializes this clear coat configuration.
  114579. * @returns - An object with the serialized config.
  114580. */
  114581. serialize(): any;
  114582. /**
  114583. * Parses a anisotropy Configuration from a serialized object.
  114584. * @param source - Serialized object.
  114585. * @param scene Defines the scene we are parsing for
  114586. * @param rootUrl Defines the rootUrl to load from
  114587. */
  114588. parse(source: any, scene: Scene, rootUrl: string): void;
  114589. }
  114590. }
  114591. declare module BABYLON {
  114592. /**
  114593. * @hidden
  114594. */
  114595. export interface IMaterialAnisotropicDefines {
  114596. ANISOTROPIC: boolean;
  114597. ANISOTROPIC_TEXTURE: boolean;
  114598. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114599. MAINUV1: boolean;
  114600. _areTexturesDirty: boolean;
  114601. _needUVs: boolean;
  114602. }
  114603. /**
  114604. * Define the code related to the anisotropic parameters of the pbr material.
  114605. */
  114606. export class PBRAnisotropicConfiguration {
  114607. private _isEnabled;
  114608. /**
  114609. * Defines if the anisotropy is enabled in the material.
  114610. */
  114611. isEnabled: boolean;
  114612. /**
  114613. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  114614. */
  114615. intensity: number;
  114616. /**
  114617. * Defines if the effect is along the tangents, bitangents or in between.
  114618. * By default, the effect is "strectching" the highlights along the tangents.
  114619. */
  114620. direction: Vector2;
  114621. private _texture;
  114622. /**
  114623. * Stores the anisotropy values in a texture.
  114624. * rg is direction (like normal from -1 to 1)
  114625. * b is a intensity
  114626. */
  114627. texture: Nullable<BaseTexture>;
  114628. /** @hidden */
  114629. private _internalMarkAllSubMeshesAsTexturesDirty;
  114630. /** @hidden */
  114631. _markAllSubMeshesAsTexturesDirty(): void;
  114632. /**
  114633. * Instantiate a new istance of anisotropy configuration.
  114634. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114635. */
  114636. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114637. /**
  114638. * Specifies that the submesh is ready to be used.
  114639. * @param defines the list of "defines" to update.
  114640. * @param scene defines the scene the material belongs to.
  114641. * @returns - boolean indicating that the submesh is ready or not.
  114642. */
  114643. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  114644. /**
  114645. * Checks to see if a texture is used in the material.
  114646. * @param defines the list of "defines" to update.
  114647. * @param mesh the mesh we are preparing the defines for.
  114648. * @param scene defines the scene the material belongs to.
  114649. */
  114650. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  114651. /**
  114652. * Binds the material data.
  114653. * @param uniformBuffer defines the Uniform buffer to fill in.
  114654. * @param scene defines the scene the material belongs to.
  114655. * @param isFrozen defines wether the material is frozen or not.
  114656. */
  114657. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114658. /**
  114659. * Checks to see if a texture is used in the material.
  114660. * @param texture - Base texture to use.
  114661. * @returns - Boolean specifying if a texture is used in the material.
  114662. */
  114663. hasTexture(texture: BaseTexture): boolean;
  114664. /**
  114665. * Returns an array of the actively used textures.
  114666. * @param activeTextures Array of BaseTextures
  114667. */
  114668. getActiveTextures(activeTextures: BaseTexture[]): void;
  114669. /**
  114670. * Returns the animatable textures.
  114671. * @param animatables Array of animatable textures.
  114672. */
  114673. getAnimatables(animatables: IAnimatable[]): void;
  114674. /**
  114675. * Disposes the resources of the material.
  114676. * @param forceDisposeTextures - Forces the disposal of all textures.
  114677. */
  114678. dispose(forceDisposeTextures?: boolean): void;
  114679. /**
  114680. * Get the current class name of the texture useful for serialization or dynamic coding.
  114681. * @returns "PBRAnisotropicConfiguration"
  114682. */
  114683. getClassName(): string;
  114684. /**
  114685. * Add fallbacks to the effect fallbacks list.
  114686. * @param defines defines the Base texture to use.
  114687. * @param fallbacks defines the current fallback list.
  114688. * @param currentRank defines the current fallback rank.
  114689. * @returns the new fallback rank.
  114690. */
  114691. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114692. /**
  114693. * Add the required uniforms to the current list.
  114694. * @param uniforms defines the current uniform list.
  114695. */
  114696. static AddUniforms(uniforms: string[]): void;
  114697. /**
  114698. * Add the required uniforms to the current buffer.
  114699. * @param uniformBuffer defines the current uniform buffer.
  114700. */
  114701. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114702. /**
  114703. * Add the required samplers to the current list.
  114704. * @param samplers defines the current sampler list.
  114705. */
  114706. static AddSamplers(samplers: string[]): void;
  114707. /**
  114708. * Makes a duplicate of the current configuration into another one.
  114709. * @param anisotropicConfiguration define the config where to copy the info
  114710. */
  114711. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  114712. /**
  114713. * Serializes this anisotropy configuration.
  114714. * @returns - An object with the serialized config.
  114715. */
  114716. serialize(): any;
  114717. /**
  114718. * Parses a anisotropy Configuration from a serialized object.
  114719. * @param source - Serialized object.
  114720. * @param scene Defines the scene we are parsing for
  114721. * @param rootUrl Defines the rootUrl to load from
  114722. */
  114723. parse(source: any, scene: Scene, rootUrl: string): void;
  114724. }
  114725. }
  114726. declare module BABYLON {
  114727. /**
  114728. * @hidden
  114729. */
  114730. export interface IMaterialBRDFDefines {
  114731. BRDF_V_HEIGHT_CORRELATED: boolean;
  114732. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114733. SPHERICAL_HARMONICS: boolean;
  114734. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114735. /** @hidden */
  114736. _areMiscDirty: boolean;
  114737. }
  114738. /**
  114739. * Define the code related to the BRDF parameters of the pbr material.
  114740. */
  114741. export class PBRBRDFConfiguration {
  114742. /**
  114743. * Default value used for the energy conservation.
  114744. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114745. */
  114746. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  114747. /**
  114748. * Default value used for the Smith Visibility Height Correlated mode.
  114749. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  114750. */
  114751. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  114752. /**
  114753. * Default value used for the IBL diffuse part.
  114754. * This can help switching back to the polynomials mode globally which is a tiny bit
  114755. * less GPU intensive at the drawback of a lower quality.
  114756. */
  114757. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  114758. /**
  114759. * Default value used for activating energy conservation for the specular workflow.
  114760. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114761. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114762. */
  114763. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  114764. private _useEnergyConservation;
  114765. /**
  114766. * Defines if the material uses energy conservation.
  114767. */
  114768. useEnergyConservation: boolean;
  114769. private _useSmithVisibilityHeightCorrelated;
  114770. /**
  114771. * LEGACY Mode set to false
  114772. * Defines if the material uses height smith correlated visibility term.
  114773. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  114774. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  114775. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  114776. * Not relying on height correlated will also disable energy conservation.
  114777. */
  114778. useSmithVisibilityHeightCorrelated: boolean;
  114779. private _useSphericalHarmonics;
  114780. /**
  114781. * LEGACY Mode set to false
  114782. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  114783. * diffuse part of the IBL.
  114784. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  114785. * to the ground truth.
  114786. */
  114787. useSphericalHarmonics: boolean;
  114788. private _useSpecularGlossinessInputEnergyConservation;
  114789. /**
  114790. * Defines if the material uses energy conservation, when the specular workflow is active.
  114791. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  114792. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  114793. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  114794. */
  114795. useSpecularGlossinessInputEnergyConservation: boolean;
  114796. /** @hidden */
  114797. private _internalMarkAllSubMeshesAsMiscDirty;
  114798. /** @hidden */
  114799. _markAllSubMeshesAsMiscDirty(): void;
  114800. /**
  114801. * Instantiate a new istance of clear coat configuration.
  114802. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  114803. */
  114804. constructor(markAllSubMeshesAsMiscDirty: () => void);
  114805. /**
  114806. * Checks to see if a texture is used in the material.
  114807. * @param defines the list of "defines" to update.
  114808. */
  114809. prepareDefines(defines: IMaterialBRDFDefines): void;
  114810. /**
  114811. * Get the current class name of the texture useful for serialization or dynamic coding.
  114812. * @returns "PBRClearCoatConfiguration"
  114813. */
  114814. getClassName(): string;
  114815. /**
  114816. * Makes a duplicate of the current configuration into another one.
  114817. * @param brdfConfiguration define the config where to copy the info
  114818. */
  114819. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  114820. /**
  114821. * Serializes this BRDF configuration.
  114822. * @returns - An object with the serialized config.
  114823. */
  114824. serialize(): any;
  114825. /**
  114826. * Parses a anisotropy Configuration from a serialized object.
  114827. * @param source - Serialized object.
  114828. * @param scene Defines the scene we are parsing for
  114829. * @param rootUrl Defines the rootUrl to load from
  114830. */
  114831. parse(source: any, scene: Scene, rootUrl: string): void;
  114832. }
  114833. }
  114834. declare module BABYLON {
  114835. /**
  114836. * @hidden
  114837. */
  114838. export interface IMaterialSheenDefines {
  114839. SHEEN: boolean;
  114840. SHEEN_TEXTURE: boolean;
  114841. SHEEN_TEXTUREDIRECTUV: number;
  114842. SHEEN_LINKWITHALBEDO: boolean;
  114843. /** @hidden */
  114844. _areTexturesDirty: boolean;
  114845. }
  114846. /**
  114847. * Define the code related to the Sheen parameters of the pbr material.
  114848. */
  114849. export class PBRSheenConfiguration {
  114850. private _isEnabled;
  114851. /**
  114852. * Defines if the material uses sheen.
  114853. */
  114854. isEnabled: boolean;
  114855. private _linkSheenWithAlbedo;
  114856. /**
  114857. * Defines if the sheen is linked to the sheen color.
  114858. */
  114859. linkSheenWithAlbedo: boolean;
  114860. /**
  114861. * Defines the sheen intensity.
  114862. */
  114863. intensity: number;
  114864. /**
  114865. * Defines the sheen color.
  114866. */
  114867. color: Color3;
  114868. private _texture;
  114869. /**
  114870. * Stores the sheen tint values in a texture.
  114871. * rgb is tint
  114872. * a is a intensity
  114873. */
  114874. texture: Nullable<BaseTexture>;
  114875. /** @hidden */
  114876. private _internalMarkAllSubMeshesAsTexturesDirty;
  114877. /** @hidden */
  114878. _markAllSubMeshesAsTexturesDirty(): void;
  114879. /**
  114880. * Instantiate a new istance of clear coat configuration.
  114881. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114882. */
  114883. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114884. /**
  114885. * Specifies that the submesh is ready to be used.
  114886. * @param defines the list of "defines" to update.
  114887. * @param scene defines the scene the material belongs to.
  114888. * @returns - boolean indicating that the submesh is ready or not.
  114889. */
  114890. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  114891. /**
  114892. * Checks to see if a texture is used in the material.
  114893. * @param defines the list of "defines" to update.
  114894. * @param scene defines the scene the material belongs to.
  114895. */
  114896. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  114897. /**
  114898. * Binds the material data.
  114899. * @param uniformBuffer defines the Uniform buffer to fill in.
  114900. * @param scene defines the scene the material belongs to.
  114901. * @param isFrozen defines wether the material is frozen or not.
  114902. */
  114903. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  114904. /**
  114905. * Checks to see if a texture is used in the material.
  114906. * @param texture - Base texture to use.
  114907. * @returns - Boolean specifying if a texture is used in the material.
  114908. */
  114909. hasTexture(texture: BaseTexture): boolean;
  114910. /**
  114911. * Returns an array of the actively used textures.
  114912. * @param activeTextures Array of BaseTextures
  114913. */
  114914. getActiveTextures(activeTextures: BaseTexture[]): void;
  114915. /**
  114916. * Returns the animatable textures.
  114917. * @param animatables Array of animatable textures.
  114918. */
  114919. getAnimatables(animatables: IAnimatable[]): void;
  114920. /**
  114921. * Disposes the resources of the material.
  114922. * @param forceDisposeTextures - Forces the disposal of all textures.
  114923. */
  114924. dispose(forceDisposeTextures?: boolean): void;
  114925. /**
  114926. * Get the current class name of the texture useful for serialization or dynamic coding.
  114927. * @returns "PBRSheenConfiguration"
  114928. */
  114929. getClassName(): string;
  114930. /**
  114931. * Add fallbacks to the effect fallbacks list.
  114932. * @param defines defines the Base texture to use.
  114933. * @param fallbacks defines the current fallback list.
  114934. * @param currentRank defines the current fallback rank.
  114935. * @returns the new fallback rank.
  114936. */
  114937. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114938. /**
  114939. * Add the required uniforms to the current list.
  114940. * @param uniforms defines the current uniform list.
  114941. */
  114942. static AddUniforms(uniforms: string[]): void;
  114943. /**
  114944. * Add the required uniforms to the current buffer.
  114945. * @param uniformBuffer defines the current uniform buffer.
  114946. */
  114947. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114948. /**
  114949. * Add the required samplers to the current list.
  114950. * @param samplers defines the current sampler list.
  114951. */
  114952. static AddSamplers(samplers: string[]): void;
  114953. /**
  114954. * Makes a duplicate of the current configuration into another one.
  114955. * @param sheenConfiguration define the config where to copy the info
  114956. */
  114957. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  114958. /**
  114959. * Serializes this BRDF configuration.
  114960. * @returns - An object with the serialized config.
  114961. */
  114962. serialize(): any;
  114963. /**
  114964. * Parses a anisotropy Configuration from a serialized object.
  114965. * @param source - Serialized object.
  114966. * @param scene Defines the scene we are parsing for
  114967. * @param rootUrl Defines the rootUrl to load from
  114968. */
  114969. parse(source: any, scene: Scene, rootUrl: string): void;
  114970. }
  114971. }
  114972. declare module BABYLON {
  114973. /**
  114974. * @hidden
  114975. */
  114976. export interface IMaterialSubSurfaceDefines {
  114977. SUBSURFACE: boolean;
  114978. SS_REFRACTION: boolean;
  114979. SS_TRANSLUCENCY: boolean;
  114980. SS_SCATERRING: boolean;
  114981. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114982. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114983. SS_REFRACTIONMAP_3D: boolean;
  114984. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114985. SS_LODINREFRACTIONALPHA: boolean;
  114986. SS_GAMMAREFRACTION: boolean;
  114987. SS_RGBDREFRACTION: boolean;
  114988. SS_LINEARSPECULARREFRACTION: boolean;
  114989. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114990. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114991. /** @hidden */
  114992. _areTexturesDirty: boolean;
  114993. }
  114994. /**
  114995. * Define the code related to the sub surface parameters of the pbr material.
  114996. */
  114997. export class PBRSubSurfaceConfiguration {
  114998. private _isRefractionEnabled;
  114999. /**
  115000. * Defines if the refraction is enabled in the material.
  115001. */
  115002. isRefractionEnabled: boolean;
  115003. private _isTranslucencyEnabled;
  115004. /**
  115005. * Defines if the translucency is enabled in the material.
  115006. */
  115007. isTranslucencyEnabled: boolean;
  115008. private _isScatteringEnabled;
  115009. /**
  115010. * Defines the refraction intensity of the material.
  115011. * The refraction when enabled replaces the Diffuse part of the material.
  115012. * The intensity helps transitionning between diffuse and refraction.
  115013. */
  115014. refractionIntensity: number;
  115015. /**
  115016. * Defines the translucency intensity of the material.
  115017. * When translucency has been enabled, this defines how much of the "translucency"
  115018. * is addded to the diffuse part of the material.
  115019. */
  115020. translucencyIntensity: number;
  115021. /**
  115022. * Defines the scattering intensity of the material.
  115023. * When scattering has been enabled, this defines how much of the "scattered light"
  115024. * is addded to the diffuse part of the material.
  115025. */
  115026. scatteringIntensity: number;
  115027. private _thicknessTexture;
  115028. /**
  115029. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  115030. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  115031. * 0 would mean minimumThickness
  115032. * 1 would mean maximumThickness
  115033. * The other channels might be use as a mask to vary the different effects intensity.
  115034. */
  115035. thicknessTexture: Nullable<BaseTexture>;
  115036. private _refractionTexture;
  115037. /**
  115038. * Defines the texture to use for refraction.
  115039. */
  115040. refractionTexture: Nullable<BaseTexture>;
  115041. private _indexOfRefraction;
  115042. /**
  115043. * Defines the index of refraction used in the material.
  115044. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  115045. */
  115046. indexOfRefraction: number;
  115047. private _invertRefractionY;
  115048. /**
  115049. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115050. */
  115051. invertRefractionY: boolean;
  115052. private _linkRefractionWithTransparency;
  115053. /**
  115054. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115055. * Materials half opaque for instance using refraction could benefit from this control.
  115056. */
  115057. linkRefractionWithTransparency: boolean;
  115058. /**
  115059. * Defines the minimum thickness stored in the thickness map.
  115060. * If no thickness map is defined, this value will be used to simulate thickness.
  115061. */
  115062. minimumThickness: number;
  115063. /**
  115064. * Defines the maximum thickness stored in the thickness map.
  115065. */
  115066. maximumThickness: number;
  115067. /**
  115068. * Defines the volume tint of the material.
  115069. * This is used for both translucency and scattering.
  115070. */
  115071. tintColor: Color3;
  115072. /**
  115073. * Defines the distance at which the tint color should be found in the media.
  115074. * This is used for refraction only.
  115075. */
  115076. tintColorAtDistance: number;
  115077. /**
  115078. * Defines how far each channel transmit through the media.
  115079. * It is defined as a color to simplify it selection.
  115080. */
  115081. diffusionDistance: Color3;
  115082. private _useMaskFromThicknessTexture;
  115083. /**
  115084. * Stores the intensity of the different subsurface effects in the thickness texture.
  115085. * * the green channel is the translucency intensity.
  115086. * * the blue channel is the scattering intensity.
  115087. * * the alpha channel is the refraction intensity.
  115088. */
  115089. useMaskFromThicknessTexture: boolean;
  115090. /** @hidden */
  115091. private _internalMarkAllSubMeshesAsTexturesDirty;
  115092. /** @hidden */
  115093. _markAllSubMeshesAsTexturesDirty(): void;
  115094. /**
  115095. * Instantiate a new istance of sub surface configuration.
  115096. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115097. */
  115098. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115099. /**
  115100. * Gets wehter the submesh is ready to be used or not.
  115101. * @param defines the list of "defines" to update.
  115102. * @param scene defines the scene the material belongs to.
  115103. * @returns - boolean indicating that the submesh is ready or not.
  115104. */
  115105. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  115106. /**
  115107. * Checks to see if a texture is used in the material.
  115108. * @param defines the list of "defines" to update.
  115109. * @param scene defines the scene to the material belongs to.
  115110. */
  115111. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  115112. /**
  115113. * Binds the material data.
  115114. * @param uniformBuffer defines the Uniform buffer to fill in.
  115115. * @param scene defines the scene the material belongs to.
  115116. * @param engine defines the engine the material belongs to.
  115117. * @param isFrozen defines wether the material is frozen or not.
  115118. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  115119. */
  115120. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  115121. /**
  115122. * Unbinds the material from the mesh.
  115123. * @param activeEffect defines the effect that should be unbound from.
  115124. * @returns true if unbound, otherwise false
  115125. */
  115126. unbind(activeEffect: Effect): boolean;
  115127. /**
  115128. * Returns the texture used for refraction or null if none is used.
  115129. * @param scene defines the scene the material belongs to.
  115130. * @returns - Refraction texture if present. If no refraction texture and refraction
  115131. * is linked with transparency, returns environment texture. Otherwise, returns null.
  115132. */
  115133. private _getRefractionTexture;
  115134. /**
  115135. * Returns true if alpha blending should be disabled.
  115136. */
  115137. readonly disableAlphaBlending: boolean;
  115138. /**
  115139. * Fills the list of render target textures.
  115140. * @param renderTargets the list of render targets to update
  115141. */
  115142. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  115143. /**
  115144. * Checks to see if a texture is used in the material.
  115145. * @param texture - Base texture to use.
  115146. * @returns - Boolean specifying if a texture is used in the material.
  115147. */
  115148. hasTexture(texture: BaseTexture): boolean;
  115149. /**
  115150. * Gets a boolean indicating that current material needs to register RTT
  115151. * @returns true if this uses a render target otherwise false.
  115152. */
  115153. hasRenderTargetTextures(): boolean;
  115154. /**
  115155. * Returns an array of the actively used textures.
  115156. * @param activeTextures Array of BaseTextures
  115157. */
  115158. getActiveTextures(activeTextures: BaseTexture[]): void;
  115159. /**
  115160. * Returns the animatable textures.
  115161. * @param animatables Array of animatable textures.
  115162. */
  115163. getAnimatables(animatables: IAnimatable[]): void;
  115164. /**
  115165. * Disposes the resources of the material.
  115166. * @param forceDisposeTextures - Forces the disposal of all textures.
  115167. */
  115168. dispose(forceDisposeTextures?: boolean): void;
  115169. /**
  115170. * Get the current class name of the texture useful for serialization or dynamic coding.
  115171. * @returns "PBRSubSurfaceConfiguration"
  115172. */
  115173. getClassName(): string;
  115174. /**
  115175. * Add fallbacks to the effect fallbacks list.
  115176. * @param defines defines the Base texture to use.
  115177. * @param fallbacks defines the current fallback list.
  115178. * @param currentRank defines the current fallback rank.
  115179. * @returns the new fallback rank.
  115180. */
  115181. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115182. /**
  115183. * Add the required uniforms to the current list.
  115184. * @param uniforms defines the current uniform list.
  115185. */
  115186. static AddUniforms(uniforms: string[]): void;
  115187. /**
  115188. * Add the required samplers to the current list.
  115189. * @param samplers defines the current sampler list.
  115190. */
  115191. static AddSamplers(samplers: string[]): void;
  115192. /**
  115193. * Add the required uniforms to the current buffer.
  115194. * @param uniformBuffer defines the current uniform buffer.
  115195. */
  115196. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115197. /**
  115198. * Makes a duplicate of the current configuration into another one.
  115199. * @param configuration define the config where to copy the info
  115200. */
  115201. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  115202. /**
  115203. * Serializes this Sub Surface configuration.
  115204. * @returns - An object with the serialized config.
  115205. */
  115206. serialize(): any;
  115207. /**
  115208. * Parses a anisotropy Configuration from a serialized object.
  115209. * @param source - Serialized object.
  115210. * @param scene Defines the scene we are parsing for
  115211. * @param rootUrl Defines the rootUrl to load from
  115212. */
  115213. parse(source: any, scene: Scene, rootUrl: string): void;
  115214. }
  115215. }
  115216. declare module BABYLON {
  115217. /** @hidden */
  115218. export var pbrFragmentDeclaration: {
  115219. name: string;
  115220. shader: string;
  115221. };
  115222. }
  115223. declare module BABYLON {
  115224. /** @hidden */
  115225. export var pbrUboDeclaration: {
  115226. name: string;
  115227. shader: string;
  115228. };
  115229. }
  115230. declare module BABYLON {
  115231. /** @hidden */
  115232. export var pbrFragmentExtraDeclaration: {
  115233. name: string;
  115234. shader: string;
  115235. };
  115236. }
  115237. declare module BABYLON {
  115238. /** @hidden */
  115239. export var pbrFragmentSamplersDeclaration: {
  115240. name: string;
  115241. shader: string;
  115242. };
  115243. }
  115244. declare module BABYLON {
  115245. /** @hidden */
  115246. export var pbrHelperFunctions: {
  115247. name: string;
  115248. shader: string;
  115249. };
  115250. }
  115251. declare module BABYLON {
  115252. /** @hidden */
  115253. export var harmonicsFunctions: {
  115254. name: string;
  115255. shader: string;
  115256. };
  115257. }
  115258. declare module BABYLON {
  115259. /** @hidden */
  115260. export var pbrDirectLightingSetupFunctions: {
  115261. name: string;
  115262. shader: string;
  115263. };
  115264. }
  115265. declare module BABYLON {
  115266. /** @hidden */
  115267. export var pbrDirectLightingFalloffFunctions: {
  115268. name: string;
  115269. shader: string;
  115270. };
  115271. }
  115272. declare module BABYLON {
  115273. /** @hidden */
  115274. export var pbrBRDFFunctions: {
  115275. name: string;
  115276. shader: string;
  115277. };
  115278. }
  115279. declare module BABYLON {
  115280. /** @hidden */
  115281. export var pbrDirectLightingFunctions: {
  115282. name: string;
  115283. shader: string;
  115284. };
  115285. }
  115286. declare module BABYLON {
  115287. /** @hidden */
  115288. export var pbrIBLFunctions: {
  115289. name: string;
  115290. shader: string;
  115291. };
  115292. }
  115293. declare module BABYLON {
  115294. /** @hidden */
  115295. export var pbrDebug: {
  115296. name: string;
  115297. shader: string;
  115298. };
  115299. }
  115300. declare module BABYLON {
  115301. /** @hidden */
  115302. export var pbrPixelShader: {
  115303. name: string;
  115304. shader: string;
  115305. };
  115306. }
  115307. declare module BABYLON {
  115308. /** @hidden */
  115309. export var pbrVertexDeclaration: {
  115310. name: string;
  115311. shader: string;
  115312. };
  115313. }
  115314. declare module BABYLON {
  115315. /** @hidden */
  115316. export var pbrVertexShader: {
  115317. name: string;
  115318. shader: string;
  115319. };
  115320. }
  115321. declare module BABYLON {
  115322. /**
  115323. * Manages the defines for the PBR Material.
  115324. * @hidden
  115325. */
  115326. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  115327. PBR: boolean;
  115328. MAINUV1: boolean;
  115329. MAINUV2: boolean;
  115330. UV1: boolean;
  115331. UV2: boolean;
  115332. ALBEDO: boolean;
  115333. ALBEDODIRECTUV: number;
  115334. VERTEXCOLOR: boolean;
  115335. AMBIENT: boolean;
  115336. AMBIENTDIRECTUV: number;
  115337. AMBIENTINGRAYSCALE: boolean;
  115338. OPACITY: boolean;
  115339. VERTEXALPHA: boolean;
  115340. OPACITYDIRECTUV: number;
  115341. OPACITYRGB: boolean;
  115342. ALPHATEST: boolean;
  115343. DEPTHPREPASS: boolean;
  115344. ALPHABLEND: boolean;
  115345. ALPHAFROMALBEDO: boolean;
  115346. ALPHATESTVALUE: string;
  115347. SPECULAROVERALPHA: boolean;
  115348. RADIANCEOVERALPHA: boolean;
  115349. ALPHAFRESNEL: boolean;
  115350. LINEARALPHAFRESNEL: boolean;
  115351. PREMULTIPLYALPHA: boolean;
  115352. EMISSIVE: boolean;
  115353. EMISSIVEDIRECTUV: number;
  115354. REFLECTIVITY: boolean;
  115355. REFLECTIVITYDIRECTUV: number;
  115356. SPECULARTERM: boolean;
  115357. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  115358. MICROSURFACEAUTOMATIC: boolean;
  115359. LODBASEDMICROSFURACE: boolean;
  115360. MICROSURFACEMAP: boolean;
  115361. MICROSURFACEMAPDIRECTUV: number;
  115362. METALLICWORKFLOW: boolean;
  115363. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  115364. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  115365. METALLNESSSTOREINMETALMAPBLUE: boolean;
  115366. AOSTOREINMETALMAPRED: boolean;
  115367. ENVIRONMENTBRDF: boolean;
  115368. ENVIRONMENTBRDF_RGBD: boolean;
  115369. NORMAL: boolean;
  115370. TANGENT: boolean;
  115371. BUMP: boolean;
  115372. BUMPDIRECTUV: number;
  115373. OBJECTSPACE_NORMALMAP: boolean;
  115374. PARALLAX: boolean;
  115375. PARALLAXOCCLUSION: boolean;
  115376. NORMALXYSCALE: boolean;
  115377. LIGHTMAP: boolean;
  115378. LIGHTMAPDIRECTUV: number;
  115379. USELIGHTMAPASSHADOWMAP: boolean;
  115380. GAMMALIGHTMAP: boolean;
  115381. RGBDLIGHTMAP: boolean;
  115382. REFLECTION: boolean;
  115383. REFLECTIONMAP_3D: boolean;
  115384. REFLECTIONMAP_SPHERICAL: boolean;
  115385. REFLECTIONMAP_PLANAR: boolean;
  115386. REFLECTIONMAP_CUBIC: boolean;
  115387. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  115388. REFLECTIONMAP_PROJECTION: boolean;
  115389. REFLECTIONMAP_SKYBOX: boolean;
  115390. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  115391. REFLECTIONMAP_EXPLICIT: boolean;
  115392. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  115393. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  115394. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  115395. INVERTCUBICMAP: boolean;
  115396. USESPHERICALFROMREFLECTIONMAP: boolean;
  115397. USEIRRADIANCEMAP: boolean;
  115398. SPHERICAL_HARMONICS: boolean;
  115399. USESPHERICALINVERTEX: boolean;
  115400. REFLECTIONMAP_OPPOSITEZ: boolean;
  115401. LODINREFLECTIONALPHA: boolean;
  115402. GAMMAREFLECTION: boolean;
  115403. RGBDREFLECTION: boolean;
  115404. LINEARSPECULARREFLECTION: boolean;
  115405. RADIANCEOCCLUSION: boolean;
  115406. HORIZONOCCLUSION: boolean;
  115407. INSTANCES: boolean;
  115408. NUM_BONE_INFLUENCERS: number;
  115409. BonesPerMesh: number;
  115410. BONETEXTURE: boolean;
  115411. NONUNIFORMSCALING: boolean;
  115412. MORPHTARGETS: boolean;
  115413. MORPHTARGETS_NORMAL: boolean;
  115414. MORPHTARGETS_TANGENT: boolean;
  115415. MORPHTARGETS_UV: boolean;
  115416. NUM_MORPH_INFLUENCERS: number;
  115417. IMAGEPROCESSING: boolean;
  115418. VIGNETTE: boolean;
  115419. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115420. VIGNETTEBLENDMODEOPAQUE: boolean;
  115421. TONEMAPPING: boolean;
  115422. TONEMAPPING_ACES: boolean;
  115423. CONTRAST: boolean;
  115424. COLORCURVES: boolean;
  115425. COLORGRADING: boolean;
  115426. COLORGRADING3D: boolean;
  115427. SAMPLER3DGREENDEPTH: boolean;
  115428. SAMPLER3DBGRMAP: boolean;
  115429. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115430. EXPOSURE: boolean;
  115431. MULTIVIEW: boolean;
  115432. USEPHYSICALLIGHTFALLOFF: boolean;
  115433. USEGLTFLIGHTFALLOFF: boolean;
  115434. TWOSIDEDLIGHTING: boolean;
  115435. SHADOWFLOAT: boolean;
  115436. CLIPPLANE: boolean;
  115437. CLIPPLANE2: boolean;
  115438. CLIPPLANE3: boolean;
  115439. CLIPPLANE4: boolean;
  115440. POINTSIZE: boolean;
  115441. FOG: boolean;
  115442. LOGARITHMICDEPTH: boolean;
  115443. FORCENORMALFORWARD: boolean;
  115444. SPECULARAA: boolean;
  115445. CLEARCOAT: boolean;
  115446. CLEARCOAT_DEFAULTIOR: boolean;
  115447. CLEARCOAT_TEXTURE: boolean;
  115448. CLEARCOAT_TEXTUREDIRECTUV: number;
  115449. CLEARCOAT_BUMP: boolean;
  115450. CLEARCOAT_BUMPDIRECTUV: number;
  115451. CLEARCOAT_TINT: boolean;
  115452. CLEARCOAT_TINT_TEXTURE: boolean;
  115453. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115454. ANISOTROPIC: boolean;
  115455. ANISOTROPIC_TEXTURE: boolean;
  115456. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115457. BRDF_V_HEIGHT_CORRELATED: boolean;
  115458. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115459. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115460. SHEEN: boolean;
  115461. SHEEN_TEXTURE: boolean;
  115462. SHEEN_TEXTUREDIRECTUV: number;
  115463. SHEEN_LINKWITHALBEDO: boolean;
  115464. SUBSURFACE: boolean;
  115465. SS_REFRACTION: boolean;
  115466. SS_TRANSLUCENCY: boolean;
  115467. SS_SCATERRING: boolean;
  115468. SS_THICKNESSANDMASK_TEXTURE: boolean;
  115469. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  115470. SS_REFRACTIONMAP_3D: boolean;
  115471. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  115472. SS_LODINREFRACTIONALPHA: boolean;
  115473. SS_GAMMAREFRACTION: boolean;
  115474. SS_RGBDREFRACTION: boolean;
  115475. SS_LINEARSPECULARREFRACTION: boolean;
  115476. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  115477. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  115478. UNLIT: boolean;
  115479. DEBUGMODE: number;
  115480. /**
  115481. * Initializes the PBR Material defines.
  115482. */
  115483. constructor();
  115484. /**
  115485. * Resets the PBR Material defines.
  115486. */
  115487. reset(): void;
  115488. }
  115489. /**
  115490. * The Physically based material base class of BJS.
  115491. *
  115492. * This offers the main features of a standard PBR material.
  115493. * For more information, please refer to the documentation :
  115494. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115495. */
  115496. export abstract class PBRBaseMaterial extends PushMaterial {
  115497. /**
  115498. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  115499. */
  115500. static readonly PBRMATERIAL_OPAQUE: number;
  115501. /**
  115502. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  115503. */
  115504. static readonly PBRMATERIAL_ALPHATEST: number;
  115505. /**
  115506. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115507. */
  115508. static readonly PBRMATERIAL_ALPHABLEND: number;
  115509. /**
  115510. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  115511. * They are also discarded below the alpha cutoff threshold to improve performances.
  115512. */
  115513. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  115514. /**
  115515. * Defines the default value of how much AO map is occluding the analytical lights
  115516. * (point spot...).
  115517. */
  115518. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  115519. /**
  115520. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  115521. */
  115522. static readonly LIGHTFALLOFF_PHYSICAL: number;
  115523. /**
  115524. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  115525. * to enhance interoperability with other engines.
  115526. */
  115527. static readonly LIGHTFALLOFF_GLTF: number;
  115528. /**
  115529. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  115530. * to enhance interoperability with other materials.
  115531. */
  115532. static readonly LIGHTFALLOFF_STANDARD: number;
  115533. /**
  115534. * Intensity of the direct lights e.g. the four lights available in your scene.
  115535. * This impacts both the direct diffuse and specular highlights.
  115536. */
  115537. protected _directIntensity: number;
  115538. /**
  115539. * Intensity of the emissive part of the material.
  115540. * This helps controlling the emissive effect without modifying the emissive color.
  115541. */
  115542. protected _emissiveIntensity: number;
  115543. /**
  115544. * Intensity of the environment e.g. how much the environment will light the object
  115545. * either through harmonics for rough material or through the refelction for shiny ones.
  115546. */
  115547. protected _environmentIntensity: number;
  115548. /**
  115549. * This is a special control allowing the reduction of the specular highlights coming from the
  115550. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  115551. */
  115552. protected _specularIntensity: number;
  115553. /**
  115554. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  115555. */
  115556. private _lightingInfos;
  115557. /**
  115558. * Debug Control allowing disabling the bump map on this material.
  115559. */
  115560. protected _disableBumpMap: boolean;
  115561. /**
  115562. * AKA Diffuse Texture in standard nomenclature.
  115563. */
  115564. protected _albedoTexture: Nullable<BaseTexture>;
  115565. /**
  115566. * AKA Occlusion Texture in other nomenclature.
  115567. */
  115568. protected _ambientTexture: Nullable<BaseTexture>;
  115569. /**
  115570. * AKA Occlusion Texture Intensity in other nomenclature.
  115571. */
  115572. protected _ambientTextureStrength: number;
  115573. /**
  115574. * Defines how much the AO map is occluding the analytical lights (point spot...).
  115575. * 1 means it completely occludes it
  115576. * 0 mean it has no impact
  115577. */
  115578. protected _ambientTextureImpactOnAnalyticalLights: number;
  115579. /**
  115580. * Stores the alpha values in a texture.
  115581. */
  115582. protected _opacityTexture: Nullable<BaseTexture>;
  115583. /**
  115584. * Stores the reflection values in a texture.
  115585. */
  115586. protected _reflectionTexture: Nullable<BaseTexture>;
  115587. /**
  115588. * Stores the emissive values in a texture.
  115589. */
  115590. protected _emissiveTexture: Nullable<BaseTexture>;
  115591. /**
  115592. * AKA Specular texture in other nomenclature.
  115593. */
  115594. protected _reflectivityTexture: Nullable<BaseTexture>;
  115595. /**
  115596. * Used to switch from specular/glossiness to metallic/roughness workflow.
  115597. */
  115598. protected _metallicTexture: Nullable<BaseTexture>;
  115599. /**
  115600. * Specifies the metallic scalar of the metallic/roughness workflow.
  115601. * Can also be used to scale the metalness values of the metallic texture.
  115602. */
  115603. protected _metallic: Nullable<number>;
  115604. /**
  115605. * Specifies the roughness scalar of the metallic/roughness workflow.
  115606. * Can also be used to scale the roughness values of the metallic texture.
  115607. */
  115608. protected _roughness: Nullable<number>;
  115609. /**
  115610. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115611. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115612. */
  115613. protected _microSurfaceTexture: Nullable<BaseTexture>;
  115614. /**
  115615. * Stores surface normal data used to displace a mesh in a texture.
  115616. */
  115617. protected _bumpTexture: Nullable<BaseTexture>;
  115618. /**
  115619. * Stores the pre-calculated light information of a mesh in a texture.
  115620. */
  115621. protected _lightmapTexture: Nullable<BaseTexture>;
  115622. /**
  115623. * The color of a material in ambient lighting.
  115624. */
  115625. protected _ambientColor: Color3;
  115626. /**
  115627. * AKA Diffuse Color in other nomenclature.
  115628. */
  115629. protected _albedoColor: Color3;
  115630. /**
  115631. * AKA Specular Color in other nomenclature.
  115632. */
  115633. protected _reflectivityColor: Color3;
  115634. /**
  115635. * The color applied when light is reflected from a material.
  115636. */
  115637. protected _reflectionColor: Color3;
  115638. /**
  115639. * The color applied when light is emitted from a material.
  115640. */
  115641. protected _emissiveColor: Color3;
  115642. /**
  115643. * AKA Glossiness in other nomenclature.
  115644. */
  115645. protected _microSurface: number;
  115646. /**
  115647. * Specifies that the material will use the light map as a show map.
  115648. */
  115649. protected _useLightmapAsShadowmap: boolean;
  115650. /**
  115651. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115652. * makes the reflect vector face the model (under horizon).
  115653. */
  115654. protected _useHorizonOcclusion: boolean;
  115655. /**
  115656. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115657. * too much the area relying on ambient texture to define their ambient occlusion.
  115658. */
  115659. protected _useRadianceOcclusion: boolean;
  115660. /**
  115661. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115662. */
  115663. protected _useAlphaFromAlbedoTexture: boolean;
  115664. /**
  115665. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  115666. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115667. */
  115668. protected _useSpecularOverAlpha: boolean;
  115669. /**
  115670. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115671. */
  115672. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115673. /**
  115674. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115675. */
  115676. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  115677. /**
  115678. * Specifies if the metallic texture contains the roughness information in its green channel.
  115679. */
  115680. protected _useRoughnessFromMetallicTextureGreen: boolean;
  115681. /**
  115682. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115683. */
  115684. protected _useMetallnessFromMetallicTextureBlue: boolean;
  115685. /**
  115686. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115687. */
  115688. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  115689. /**
  115690. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115691. */
  115692. protected _useAmbientInGrayScale: boolean;
  115693. /**
  115694. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115695. * The material will try to infer what glossiness each pixel should be.
  115696. */
  115697. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  115698. /**
  115699. * Defines the falloff type used in this material.
  115700. * It by default is Physical.
  115701. */
  115702. protected _lightFalloff: number;
  115703. /**
  115704. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115705. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115706. */
  115707. protected _useRadianceOverAlpha: boolean;
  115708. /**
  115709. * Allows using an object space normal map (instead of tangent space).
  115710. */
  115711. protected _useObjectSpaceNormalMap: boolean;
  115712. /**
  115713. * Allows using the bump map in parallax mode.
  115714. */
  115715. protected _useParallax: boolean;
  115716. /**
  115717. * Allows using the bump map in parallax occlusion mode.
  115718. */
  115719. protected _useParallaxOcclusion: boolean;
  115720. /**
  115721. * Controls the scale bias of the parallax mode.
  115722. */
  115723. protected _parallaxScaleBias: number;
  115724. /**
  115725. * If sets to true, disables all the lights affecting the material.
  115726. */
  115727. protected _disableLighting: boolean;
  115728. /**
  115729. * Number of Simultaneous lights allowed on the material.
  115730. */
  115731. protected _maxSimultaneousLights: number;
  115732. /**
  115733. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115734. */
  115735. protected _invertNormalMapX: boolean;
  115736. /**
  115737. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115738. */
  115739. protected _invertNormalMapY: boolean;
  115740. /**
  115741. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115742. */
  115743. protected _twoSidedLighting: boolean;
  115744. /**
  115745. * Defines the alpha limits in alpha test mode.
  115746. */
  115747. protected _alphaCutOff: number;
  115748. /**
  115749. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115750. */
  115751. protected _forceAlphaTest: boolean;
  115752. /**
  115753. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115754. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115755. */
  115756. protected _useAlphaFresnel: boolean;
  115757. /**
  115758. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115759. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115760. */
  115761. protected _useLinearAlphaFresnel: boolean;
  115762. /**
  115763. * The transparency mode of the material.
  115764. */
  115765. protected _transparencyMode: Nullable<number>;
  115766. /**
  115767. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  115768. * from cos thetav and roughness:
  115769. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  115770. */
  115771. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  115772. /**
  115773. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115774. */
  115775. protected _forceIrradianceInFragment: boolean;
  115776. /**
  115777. * Force normal to face away from face.
  115778. */
  115779. protected _forceNormalForward: boolean;
  115780. /**
  115781. * Enables specular anti aliasing in the PBR shader.
  115782. * It will both interacts on the Geometry for analytical and IBL lighting.
  115783. * It also prefilter the roughness map based on the bump values.
  115784. */
  115785. protected _enableSpecularAntiAliasing: boolean;
  115786. /**
  115787. * Default configuration related to image processing available in the PBR Material.
  115788. */
  115789. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115790. /**
  115791. * Keep track of the image processing observer to allow dispose and replace.
  115792. */
  115793. private _imageProcessingObserver;
  115794. /**
  115795. * Attaches a new image processing configuration to the PBR Material.
  115796. * @param configuration
  115797. */
  115798. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115799. /**
  115800. * Stores the available render targets.
  115801. */
  115802. private _renderTargets;
  115803. /**
  115804. * Sets the global ambient color for the material used in lighting calculations.
  115805. */
  115806. private _globalAmbientColor;
  115807. /**
  115808. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  115809. */
  115810. private _useLogarithmicDepth;
  115811. /**
  115812. * If set to true, no lighting calculations will be applied.
  115813. */
  115814. private _unlit;
  115815. private _debugMode;
  115816. /**
  115817. * @hidden
  115818. * This is reserved for the inspector.
  115819. * Defines the material debug mode.
  115820. * It helps seeing only some components of the material while troubleshooting.
  115821. */
  115822. debugMode: number;
  115823. /**
  115824. * @hidden
  115825. * This is reserved for the inspector.
  115826. * Specify from where on screen the debug mode should start.
  115827. * The value goes from -1 (full screen) to 1 (not visible)
  115828. * It helps with side by side comparison against the final render
  115829. * This defaults to -1
  115830. */
  115831. private debugLimit;
  115832. /**
  115833. * @hidden
  115834. * This is reserved for the inspector.
  115835. * As the default viewing range might not be enough (if the ambient is really small for instance)
  115836. * You can use the factor to better multiply the final value.
  115837. */
  115838. private debugFactor;
  115839. /**
  115840. * Defines the clear coat layer parameters for the material.
  115841. */
  115842. readonly clearCoat: PBRClearCoatConfiguration;
  115843. /**
  115844. * Defines the anisotropic parameters for the material.
  115845. */
  115846. readonly anisotropy: PBRAnisotropicConfiguration;
  115847. /**
  115848. * Defines the BRDF parameters for the material.
  115849. */
  115850. readonly brdf: PBRBRDFConfiguration;
  115851. /**
  115852. * Defines the Sheen parameters for the material.
  115853. */
  115854. readonly sheen: PBRSheenConfiguration;
  115855. /**
  115856. * Defines the SubSurface parameters for the material.
  115857. */
  115858. readonly subSurface: PBRSubSurfaceConfiguration;
  115859. /**
  115860. * Custom callback helping to override the default shader used in the material.
  115861. */
  115862. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  115863. protected _rebuildInParallel: boolean;
  115864. /**
  115865. * Instantiates a new PBRMaterial instance.
  115866. *
  115867. * @param name The material name
  115868. * @param scene The scene the material will be use in.
  115869. */
  115870. constructor(name: string, scene: Scene);
  115871. /**
  115872. * Gets a boolean indicating that current material needs to register RTT
  115873. */
  115874. readonly hasRenderTargetTextures: boolean;
  115875. /**
  115876. * Gets the name of the material class.
  115877. */
  115878. getClassName(): string;
  115879. /**
  115880. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115881. */
  115882. /**
  115883. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  115884. */
  115885. useLogarithmicDepth: boolean;
  115886. /**
  115887. * Gets the current transparency mode.
  115888. */
  115889. /**
  115890. * Sets the transparency mode of the material.
  115891. *
  115892. * | Value | Type | Description |
  115893. * | ----- | ----------------------------------- | ----------- |
  115894. * | 0 | OPAQUE | |
  115895. * | 1 | ALPHATEST | |
  115896. * | 2 | ALPHABLEND | |
  115897. * | 3 | ALPHATESTANDBLEND | |
  115898. *
  115899. */
  115900. transparencyMode: Nullable<number>;
  115901. /**
  115902. * Returns true if alpha blending should be disabled.
  115903. */
  115904. private readonly _disableAlphaBlending;
  115905. /**
  115906. * Specifies whether or not this material should be rendered in alpha blend mode.
  115907. */
  115908. needAlphaBlending(): boolean;
  115909. /**
  115910. * Specifies if the mesh will require alpha blending.
  115911. * @param mesh - BJS mesh.
  115912. */
  115913. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  115914. /**
  115915. * Specifies whether or not this material should be rendered in alpha test mode.
  115916. */
  115917. needAlphaTesting(): boolean;
  115918. /**
  115919. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  115920. */
  115921. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  115922. /**
  115923. * Gets the texture used for the alpha test.
  115924. */
  115925. getAlphaTestTexture(): Nullable<BaseTexture>;
  115926. /**
  115927. * Specifies that the submesh is ready to be used.
  115928. * @param mesh - BJS mesh.
  115929. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  115930. * @param useInstances - Specifies that instances should be used.
  115931. * @returns - boolean indicating that the submesh is ready or not.
  115932. */
  115933. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115934. /**
  115935. * Specifies if the material uses metallic roughness workflow.
  115936. * @returns boolean specifiying if the material uses metallic roughness workflow.
  115937. */
  115938. isMetallicWorkflow(): boolean;
  115939. private _prepareEffect;
  115940. private _prepareDefines;
  115941. /**
  115942. * Force shader compilation
  115943. */
  115944. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  115945. /**
  115946. * Initializes the uniform buffer layout for the shader.
  115947. */
  115948. buildUniformLayout(): void;
  115949. /**
  115950. * Unbinds the material from the mesh
  115951. */
  115952. unbind(): void;
  115953. /**
  115954. * Binds the submesh data.
  115955. * @param world - The world matrix.
  115956. * @param mesh - The BJS mesh.
  115957. * @param subMesh - A submesh of the BJS mesh.
  115958. */
  115959. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115960. /**
  115961. * Returns the animatable textures.
  115962. * @returns - Array of animatable textures.
  115963. */
  115964. getAnimatables(): IAnimatable[];
  115965. /**
  115966. * Returns the texture used for reflections.
  115967. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  115968. */
  115969. private _getReflectionTexture;
  115970. /**
  115971. * Returns an array of the actively used textures.
  115972. * @returns - Array of BaseTextures
  115973. */
  115974. getActiveTextures(): BaseTexture[];
  115975. /**
  115976. * Checks to see if a texture is used in the material.
  115977. * @param texture - Base texture to use.
  115978. * @returns - Boolean specifying if a texture is used in the material.
  115979. */
  115980. hasTexture(texture: BaseTexture): boolean;
  115981. /**
  115982. * Disposes the resources of the material.
  115983. * @param forceDisposeEffect - Forces the disposal of effects.
  115984. * @param forceDisposeTextures - Forces the disposal of all textures.
  115985. */
  115986. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115987. }
  115988. }
  115989. declare module BABYLON {
  115990. /**
  115991. * The Physically based material of BJS.
  115992. *
  115993. * This offers the main features of a standard PBR material.
  115994. * For more information, please refer to the documentation :
  115995. * https://doc.babylonjs.com/how_to/physically_based_rendering
  115996. */
  115997. export class PBRMaterial extends PBRBaseMaterial {
  115998. /**
  115999. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116000. */
  116001. static readonly PBRMATERIAL_OPAQUE: number;
  116002. /**
  116003. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116004. */
  116005. static readonly PBRMATERIAL_ALPHATEST: number;
  116006. /**
  116007. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116008. */
  116009. static readonly PBRMATERIAL_ALPHABLEND: number;
  116010. /**
  116011. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116012. * They are also discarded below the alpha cutoff threshold to improve performances.
  116013. */
  116014. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116015. /**
  116016. * Defines the default value of how much AO map is occluding the analytical lights
  116017. * (point spot...).
  116018. */
  116019. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116020. /**
  116021. * Intensity of the direct lights e.g. the four lights available in your scene.
  116022. * This impacts both the direct diffuse and specular highlights.
  116023. */
  116024. directIntensity: number;
  116025. /**
  116026. * Intensity of the emissive part of the material.
  116027. * This helps controlling the emissive effect without modifying the emissive color.
  116028. */
  116029. emissiveIntensity: number;
  116030. /**
  116031. * Intensity of the environment e.g. how much the environment will light the object
  116032. * either through harmonics for rough material or through the refelction for shiny ones.
  116033. */
  116034. environmentIntensity: number;
  116035. /**
  116036. * This is a special control allowing the reduction of the specular highlights coming from the
  116037. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116038. */
  116039. specularIntensity: number;
  116040. /**
  116041. * Debug Control allowing disabling the bump map on this material.
  116042. */
  116043. disableBumpMap: boolean;
  116044. /**
  116045. * AKA Diffuse Texture in standard nomenclature.
  116046. */
  116047. albedoTexture: BaseTexture;
  116048. /**
  116049. * AKA Occlusion Texture in other nomenclature.
  116050. */
  116051. ambientTexture: BaseTexture;
  116052. /**
  116053. * AKA Occlusion Texture Intensity in other nomenclature.
  116054. */
  116055. ambientTextureStrength: number;
  116056. /**
  116057. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116058. * 1 means it completely occludes it
  116059. * 0 mean it has no impact
  116060. */
  116061. ambientTextureImpactOnAnalyticalLights: number;
  116062. /**
  116063. * Stores the alpha values in a texture.
  116064. */
  116065. opacityTexture: BaseTexture;
  116066. /**
  116067. * Stores the reflection values in a texture.
  116068. */
  116069. reflectionTexture: Nullable<BaseTexture>;
  116070. /**
  116071. * Stores the emissive values in a texture.
  116072. */
  116073. emissiveTexture: BaseTexture;
  116074. /**
  116075. * AKA Specular texture in other nomenclature.
  116076. */
  116077. reflectivityTexture: BaseTexture;
  116078. /**
  116079. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116080. */
  116081. metallicTexture: BaseTexture;
  116082. /**
  116083. * Specifies the metallic scalar of the metallic/roughness workflow.
  116084. * Can also be used to scale the metalness values of the metallic texture.
  116085. */
  116086. metallic: Nullable<number>;
  116087. /**
  116088. * Specifies the roughness scalar of the metallic/roughness workflow.
  116089. * Can also be used to scale the roughness values of the metallic texture.
  116090. */
  116091. roughness: Nullable<number>;
  116092. /**
  116093. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116094. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116095. */
  116096. microSurfaceTexture: BaseTexture;
  116097. /**
  116098. * Stores surface normal data used to displace a mesh in a texture.
  116099. */
  116100. bumpTexture: BaseTexture;
  116101. /**
  116102. * Stores the pre-calculated light information of a mesh in a texture.
  116103. */
  116104. lightmapTexture: BaseTexture;
  116105. /**
  116106. * Stores the refracted light information in a texture.
  116107. */
  116108. refractionTexture: Nullable<BaseTexture>;
  116109. /**
  116110. * The color of a material in ambient lighting.
  116111. */
  116112. ambientColor: Color3;
  116113. /**
  116114. * AKA Diffuse Color in other nomenclature.
  116115. */
  116116. albedoColor: Color3;
  116117. /**
  116118. * AKA Specular Color in other nomenclature.
  116119. */
  116120. reflectivityColor: Color3;
  116121. /**
  116122. * The color reflected from the material.
  116123. */
  116124. reflectionColor: Color3;
  116125. /**
  116126. * The color emitted from the material.
  116127. */
  116128. emissiveColor: Color3;
  116129. /**
  116130. * AKA Glossiness in other nomenclature.
  116131. */
  116132. microSurface: number;
  116133. /**
  116134. * source material index of refraction (IOR)' / 'destination material IOR.
  116135. */
  116136. indexOfRefraction: number;
  116137. /**
  116138. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116139. */
  116140. invertRefractionY: boolean;
  116141. /**
  116142. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116143. * Materials half opaque for instance using refraction could benefit from this control.
  116144. */
  116145. linkRefractionWithTransparency: boolean;
  116146. /**
  116147. * If true, the light map contains occlusion information instead of lighting info.
  116148. */
  116149. useLightmapAsShadowmap: boolean;
  116150. /**
  116151. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116152. */
  116153. useAlphaFromAlbedoTexture: boolean;
  116154. /**
  116155. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  116156. */
  116157. forceAlphaTest: boolean;
  116158. /**
  116159. * Defines the alpha limits in alpha test mode.
  116160. */
  116161. alphaCutOff: number;
  116162. /**
  116163. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  116164. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116165. */
  116166. useSpecularOverAlpha: boolean;
  116167. /**
  116168. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116169. */
  116170. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116171. /**
  116172. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116173. */
  116174. useRoughnessFromMetallicTextureAlpha: boolean;
  116175. /**
  116176. * Specifies if the metallic texture contains the roughness information in its green channel.
  116177. */
  116178. useRoughnessFromMetallicTextureGreen: boolean;
  116179. /**
  116180. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116181. */
  116182. useMetallnessFromMetallicTextureBlue: boolean;
  116183. /**
  116184. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116185. */
  116186. useAmbientOcclusionFromMetallicTextureRed: boolean;
  116187. /**
  116188. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116189. */
  116190. useAmbientInGrayScale: boolean;
  116191. /**
  116192. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116193. * The material will try to infer what glossiness each pixel should be.
  116194. */
  116195. useAutoMicroSurfaceFromReflectivityMap: boolean;
  116196. /**
  116197. * BJS is using an harcoded light falloff based on a manually sets up range.
  116198. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116199. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116200. */
  116201. /**
  116202. * BJS is using an harcoded light falloff based on a manually sets up range.
  116203. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  116204. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  116205. */
  116206. usePhysicalLightFalloff: boolean;
  116207. /**
  116208. * In order to support the falloff compatibility with gltf, a special mode has been added
  116209. * to reproduce the gltf light falloff.
  116210. */
  116211. /**
  116212. * In order to support the falloff compatibility with gltf, a special mode has been added
  116213. * to reproduce the gltf light falloff.
  116214. */
  116215. useGLTFLightFalloff: boolean;
  116216. /**
  116217. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116218. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116219. */
  116220. useRadianceOverAlpha: boolean;
  116221. /**
  116222. * Allows using an object space normal map (instead of tangent space).
  116223. */
  116224. useObjectSpaceNormalMap: boolean;
  116225. /**
  116226. * Allows using the bump map in parallax mode.
  116227. */
  116228. useParallax: boolean;
  116229. /**
  116230. * Allows using the bump map in parallax occlusion mode.
  116231. */
  116232. useParallaxOcclusion: boolean;
  116233. /**
  116234. * Controls the scale bias of the parallax mode.
  116235. */
  116236. parallaxScaleBias: number;
  116237. /**
  116238. * If sets to true, disables all the lights affecting the material.
  116239. */
  116240. disableLighting: boolean;
  116241. /**
  116242. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  116243. */
  116244. forceIrradianceInFragment: boolean;
  116245. /**
  116246. * Number of Simultaneous lights allowed on the material.
  116247. */
  116248. maxSimultaneousLights: number;
  116249. /**
  116250. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116251. */
  116252. invertNormalMapX: boolean;
  116253. /**
  116254. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116255. */
  116256. invertNormalMapY: boolean;
  116257. /**
  116258. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116259. */
  116260. twoSidedLighting: boolean;
  116261. /**
  116262. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116263. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  116264. */
  116265. useAlphaFresnel: boolean;
  116266. /**
  116267. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  116268. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  116269. */
  116270. useLinearAlphaFresnel: boolean;
  116271. /**
  116272. * Let user defines the brdf lookup texture used for IBL.
  116273. * A default 8bit version is embedded but you could point at :
  116274. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  116275. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116276. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  116277. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116278. */
  116279. environmentBRDFTexture: Nullable<BaseTexture>;
  116280. /**
  116281. * Force normal to face away from face.
  116282. */
  116283. forceNormalForward: boolean;
  116284. /**
  116285. * Enables specular anti aliasing in the PBR shader.
  116286. * It will both interacts on the Geometry for analytical and IBL lighting.
  116287. * It also prefilter the roughness map based on the bump values.
  116288. */
  116289. enableSpecularAntiAliasing: boolean;
  116290. /**
  116291. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116292. * makes the reflect vector face the model (under horizon).
  116293. */
  116294. useHorizonOcclusion: boolean;
  116295. /**
  116296. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116297. * too much the area relying on ambient texture to define their ambient occlusion.
  116298. */
  116299. useRadianceOcclusion: boolean;
  116300. /**
  116301. * If set to true, no lighting calculations will be applied.
  116302. */
  116303. unlit: boolean;
  116304. /**
  116305. * Gets the image processing configuration used either in this material.
  116306. */
  116307. /**
  116308. * Sets the Default image processing configuration used either in the this material.
  116309. *
  116310. * If sets to null, the scene one is in use.
  116311. */
  116312. imageProcessingConfiguration: ImageProcessingConfiguration;
  116313. /**
  116314. * Gets wether the color curves effect is enabled.
  116315. */
  116316. /**
  116317. * Sets wether the color curves effect is enabled.
  116318. */
  116319. cameraColorCurvesEnabled: boolean;
  116320. /**
  116321. * Gets wether the color grading effect is enabled.
  116322. */
  116323. /**
  116324. * Gets wether the color grading effect is enabled.
  116325. */
  116326. cameraColorGradingEnabled: boolean;
  116327. /**
  116328. * Gets wether tonemapping is enabled or not.
  116329. */
  116330. /**
  116331. * Sets wether tonemapping is enabled or not
  116332. */
  116333. cameraToneMappingEnabled: boolean;
  116334. /**
  116335. * The camera exposure used on this material.
  116336. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116337. * This corresponds to a photographic exposure.
  116338. */
  116339. /**
  116340. * The camera exposure used on this material.
  116341. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116342. * This corresponds to a photographic exposure.
  116343. */
  116344. cameraExposure: number;
  116345. /**
  116346. * Gets The camera contrast used on this material.
  116347. */
  116348. /**
  116349. * Sets The camera contrast used on this material.
  116350. */
  116351. cameraContrast: number;
  116352. /**
  116353. * Gets the Color Grading 2D Lookup Texture.
  116354. */
  116355. /**
  116356. * Sets the Color Grading 2D Lookup Texture.
  116357. */
  116358. cameraColorGradingTexture: Nullable<BaseTexture>;
  116359. /**
  116360. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116361. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116362. * 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;
  116363. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116364. */
  116365. /**
  116366. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116367. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116368. * 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;
  116369. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116370. */
  116371. cameraColorCurves: Nullable<ColorCurves>;
  116372. /**
  116373. * Instantiates a new PBRMaterial instance.
  116374. *
  116375. * @param name The material name
  116376. * @param scene The scene the material will be use in.
  116377. */
  116378. constructor(name: string, scene: Scene);
  116379. /**
  116380. * Returns the name of this material class.
  116381. */
  116382. getClassName(): string;
  116383. /**
  116384. * Makes a duplicate of the current material.
  116385. * @param name - name to use for the new material.
  116386. */
  116387. clone(name: string): PBRMaterial;
  116388. /**
  116389. * Serializes this PBR Material.
  116390. * @returns - An object with the serialized material.
  116391. */
  116392. serialize(): any;
  116393. /**
  116394. * Parses a PBR Material from a serialized object.
  116395. * @param source - Serialized object.
  116396. * @param scene - BJS scene instance.
  116397. * @param rootUrl - url for the scene object
  116398. * @returns - PBRMaterial
  116399. */
  116400. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  116401. }
  116402. }
  116403. declare module BABYLON {
  116404. /**
  116405. * Direct draw surface info
  116406. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  116407. */
  116408. export interface DDSInfo {
  116409. /**
  116410. * Width of the texture
  116411. */
  116412. width: number;
  116413. /**
  116414. * Width of the texture
  116415. */
  116416. height: number;
  116417. /**
  116418. * Number of Mipmaps for the texture
  116419. * @see https://en.wikipedia.org/wiki/Mipmap
  116420. */
  116421. mipmapCount: number;
  116422. /**
  116423. * If the textures format is a known fourCC format
  116424. * @see https://www.fourcc.org/
  116425. */
  116426. isFourCC: boolean;
  116427. /**
  116428. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  116429. */
  116430. isRGB: boolean;
  116431. /**
  116432. * If the texture is a lumincance format
  116433. */
  116434. isLuminance: boolean;
  116435. /**
  116436. * If this is a cube texture
  116437. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  116438. */
  116439. isCube: boolean;
  116440. /**
  116441. * If the texture is a compressed format eg. FOURCC_DXT1
  116442. */
  116443. isCompressed: boolean;
  116444. /**
  116445. * The dxgiFormat of the texture
  116446. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  116447. */
  116448. dxgiFormat: number;
  116449. /**
  116450. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  116451. */
  116452. textureType: number;
  116453. /**
  116454. * Sphericle polynomial created for the dds texture
  116455. */
  116456. sphericalPolynomial?: SphericalPolynomial;
  116457. }
  116458. /**
  116459. * Class used to provide DDS decompression tools
  116460. */
  116461. export class DDSTools {
  116462. /**
  116463. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  116464. */
  116465. static StoreLODInAlphaChannel: boolean;
  116466. /**
  116467. * Gets DDS information from an array buffer
  116468. * @param arrayBuffer defines the array buffer to read data from
  116469. * @returns the DDS information
  116470. */
  116471. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  116472. private static _FloatView;
  116473. private static _Int32View;
  116474. private static _ToHalfFloat;
  116475. private static _FromHalfFloat;
  116476. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  116477. private static _GetHalfFloatRGBAArrayBuffer;
  116478. private static _GetFloatRGBAArrayBuffer;
  116479. private static _GetFloatAsUIntRGBAArrayBuffer;
  116480. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  116481. private static _GetRGBAArrayBuffer;
  116482. private static _ExtractLongWordOrder;
  116483. private static _GetRGBArrayBuffer;
  116484. private static _GetLuminanceArrayBuffer;
  116485. /**
  116486. * Uploads DDS Levels to a Babylon Texture
  116487. * @hidden
  116488. */
  116489. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  116490. }
  116491. interface ThinEngine {
  116492. /**
  116493. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  116494. * @param rootUrl defines the url where the file to load is located
  116495. * @param scene defines the current scene
  116496. * @param lodScale defines scale to apply to the mip map selection
  116497. * @param lodOffset defines offset to apply to the mip map selection
  116498. * @param onLoad defines an optional callback raised when the texture is loaded
  116499. * @param onError defines an optional callback raised if there is an issue to load the texture
  116500. * @param format defines the format of the data
  116501. * @param forcedExtension defines the extension to use to pick the right loader
  116502. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  116503. * @returns the cube texture as an InternalTexture
  116504. */
  116505. 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;
  116506. }
  116507. }
  116508. declare module BABYLON {
  116509. /**
  116510. * Implementation of the DDS Texture Loader.
  116511. * @hidden
  116512. */
  116513. export class _DDSTextureLoader implements IInternalTextureLoader {
  116514. /**
  116515. * Defines wether the loader supports cascade loading the different faces.
  116516. */
  116517. readonly supportCascades: boolean;
  116518. /**
  116519. * This returns if the loader support the current file information.
  116520. * @param extension defines the file extension of the file being loaded
  116521. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116522. * @param fallback defines the fallback internal texture if any
  116523. * @param isBase64 defines whether the texture is encoded as a base64
  116524. * @param isBuffer defines whether the texture data are stored as a buffer
  116525. * @returns true if the loader can load the specified file
  116526. */
  116527. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116528. /**
  116529. * Transform the url before loading if required.
  116530. * @param rootUrl the url of the texture
  116531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116532. * @returns the transformed texture
  116533. */
  116534. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116535. /**
  116536. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116537. * @param rootUrl the url of the texture
  116538. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116539. * @returns the fallback texture
  116540. */
  116541. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116542. /**
  116543. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116544. * @param data contains the texture data
  116545. * @param texture defines the BabylonJS internal texture
  116546. * @param createPolynomials will be true if polynomials have been requested
  116547. * @param onLoad defines the callback to trigger once the texture is ready
  116548. * @param onError defines the callback to trigger in case of error
  116549. */
  116550. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116551. /**
  116552. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116553. * @param data contains the texture data
  116554. * @param texture defines the BabylonJS internal texture
  116555. * @param callback defines the method to call once ready to upload
  116556. */
  116557. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116558. }
  116559. }
  116560. declare module BABYLON {
  116561. /**
  116562. * Implementation of the ENV Texture Loader.
  116563. * @hidden
  116564. */
  116565. export class _ENVTextureLoader implements IInternalTextureLoader {
  116566. /**
  116567. * Defines wether the loader supports cascade loading the different faces.
  116568. */
  116569. readonly supportCascades: boolean;
  116570. /**
  116571. * This returns if the loader support the current file information.
  116572. * @param extension defines the file extension of the file being loaded
  116573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116574. * @param fallback defines the fallback internal texture if any
  116575. * @param isBase64 defines whether the texture is encoded as a base64
  116576. * @param isBuffer defines whether the texture data are stored as a buffer
  116577. * @returns true if the loader can load the specified file
  116578. */
  116579. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116580. /**
  116581. * Transform the url before loading if required.
  116582. * @param rootUrl the url of the texture
  116583. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116584. * @returns the transformed texture
  116585. */
  116586. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116587. /**
  116588. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116589. * @param rootUrl the url of the texture
  116590. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116591. * @returns the fallback texture
  116592. */
  116593. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116594. /**
  116595. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116596. * @param data contains the texture data
  116597. * @param texture defines the BabylonJS internal texture
  116598. * @param createPolynomials will be true if polynomials have been requested
  116599. * @param onLoad defines the callback to trigger once the texture is ready
  116600. * @param onError defines the callback to trigger in case of error
  116601. */
  116602. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116603. /**
  116604. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116605. * @param data contains the texture data
  116606. * @param texture defines the BabylonJS internal texture
  116607. * @param callback defines the method to call once ready to upload
  116608. */
  116609. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  116610. }
  116611. }
  116612. declare module BABYLON {
  116613. /**
  116614. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  116615. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  116616. */
  116617. export class KhronosTextureContainer {
  116618. /** contents of the KTX container file */
  116619. arrayBuffer: any;
  116620. private static HEADER_LEN;
  116621. private static COMPRESSED_2D;
  116622. private static COMPRESSED_3D;
  116623. private static TEX_2D;
  116624. private static TEX_3D;
  116625. /**
  116626. * Gets the openGL type
  116627. */
  116628. glType: number;
  116629. /**
  116630. * Gets the openGL type size
  116631. */
  116632. glTypeSize: number;
  116633. /**
  116634. * Gets the openGL format
  116635. */
  116636. glFormat: number;
  116637. /**
  116638. * Gets the openGL internal format
  116639. */
  116640. glInternalFormat: number;
  116641. /**
  116642. * Gets the base internal format
  116643. */
  116644. glBaseInternalFormat: number;
  116645. /**
  116646. * Gets image width in pixel
  116647. */
  116648. pixelWidth: number;
  116649. /**
  116650. * Gets image height in pixel
  116651. */
  116652. pixelHeight: number;
  116653. /**
  116654. * Gets image depth in pixels
  116655. */
  116656. pixelDepth: number;
  116657. /**
  116658. * Gets the number of array elements
  116659. */
  116660. numberOfArrayElements: number;
  116661. /**
  116662. * Gets the number of faces
  116663. */
  116664. numberOfFaces: number;
  116665. /**
  116666. * Gets the number of mipmap levels
  116667. */
  116668. numberOfMipmapLevels: number;
  116669. /**
  116670. * Gets the bytes of key value data
  116671. */
  116672. bytesOfKeyValueData: number;
  116673. /**
  116674. * Gets the load type
  116675. */
  116676. loadType: number;
  116677. /**
  116678. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  116679. */
  116680. isInvalid: boolean;
  116681. /**
  116682. * Creates a new KhronosTextureContainer
  116683. * @param arrayBuffer contents of the KTX container file
  116684. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  116685. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  116686. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  116687. */
  116688. constructor(
  116689. /** contents of the KTX container file */
  116690. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  116691. /**
  116692. * Uploads KTX content to a Babylon Texture.
  116693. * It is assumed that the texture has already been created & is currently bound
  116694. * @hidden
  116695. */
  116696. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  116697. private _upload2DCompressedLevels;
  116698. }
  116699. }
  116700. declare module BABYLON {
  116701. /**
  116702. * Implementation of the KTX Texture Loader.
  116703. * @hidden
  116704. */
  116705. export class _KTXTextureLoader implements IInternalTextureLoader {
  116706. /**
  116707. * Defines wether the loader supports cascade loading the different faces.
  116708. */
  116709. readonly supportCascades: boolean;
  116710. /**
  116711. * This returns if the loader support the current file information.
  116712. * @param extension defines the file extension of the file being loaded
  116713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116714. * @param fallback defines the fallback internal texture if any
  116715. * @param isBase64 defines whether the texture is encoded as a base64
  116716. * @param isBuffer defines whether the texture data are stored as a buffer
  116717. * @returns true if the loader can load the specified file
  116718. */
  116719. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  116720. /**
  116721. * Transform the url before loading if required.
  116722. * @param rootUrl the url of the texture
  116723. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116724. * @returns the transformed texture
  116725. */
  116726. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  116727. /**
  116728. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  116729. * @param rootUrl the url of the texture
  116730. * @param textureFormatInUse defines the current compressed format in use iun the engine
  116731. * @returns the fallback texture
  116732. */
  116733. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  116734. /**
  116735. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  116736. * @param data contains the texture data
  116737. * @param texture defines the BabylonJS internal texture
  116738. * @param createPolynomials will be true if polynomials have been requested
  116739. * @param onLoad defines the callback to trigger once the texture is ready
  116740. * @param onError defines the callback to trigger in case of error
  116741. */
  116742. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  116743. /**
  116744. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  116745. * @param data contains the texture data
  116746. * @param texture defines the BabylonJS internal texture
  116747. * @param callback defines the method to call once ready to upload
  116748. */
  116749. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  116750. }
  116751. }
  116752. declare module BABYLON {
  116753. /**
  116754. * Options for the default xr helper
  116755. */
  116756. export class WebXRDefaultExperienceOptions {
  116757. /**
  116758. * Floor meshes that should be used for teleporting
  116759. */
  116760. floorMeshes: Array<AbstractMesh>;
  116761. /**
  116762. * Enable or disable default UI to enter XR
  116763. */
  116764. disableDefaultUI: boolean;
  116765. }
  116766. /**
  116767. * Default experience which provides a similar setup to the previous webVRExperience
  116768. */
  116769. export class WebXRDefaultExperience {
  116770. /**
  116771. * Base experience
  116772. */
  116773. baseExperience: WebXRExperienceHelper;
  116774. /**
  116775. * Input experience extension
  116776. */
  116777. input: WebXRInput;
  116778. /**
  116779. * Loads the controller models
  116780. */
  116781. controllerModelLoader: WebXRControllerModelLoader;
  116782. /**
  116783. * Enables laser pointer and selection
  116784. */
  116785. pointerSelection: WebXRControllerPointerSelection;
  116786. /**
  116787. * Enables teleportation
  116788. */
  116789. teleportation: WebXRControllerTeleportation;
  116790. /**
  116791. * Enables ui for enetering/exiting xr
  116792. */
  116793. enterExitUI: WebXREnterExitUI;
  116794. /**
  116795. * Default target xr should render to
  116796. */
  116797. renderTarget: WebXRRenderTarget;
  116798. /**
  116799. * Creates the default xr experience
  116800. * @param scene scene
  116801. * @param options options for basic configuration
  116802. * @returns resulting WebXRDefaultExperience
  116803. */
  116804. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116805. private constructor();
  116806. /**
  116807. * DIsposes of the experience helper
  116808. */
  116809. dispose(): void;
  116810. }
  116811. }
  116812. declare module BABYLON {
  116813. /** @hidden */
  116814. export var _forceSceneHelpersToBundle: boolean;
  116815. interface Scene {
  116816. /**
  116817. * Creates a default light for the scene.
  116818. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  116819. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  116820. */
  116821. createDefaultLight(replace?: boolean): void;
  116822. /**
  116823. * Creates a default camera for the scene.
  116824. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  116825. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116826. * @param replace has default false, when true replaces the active camera in the scene
  116827. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  116828. */
  116829. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116830. /**
  116831. * Creates a default camera and a default light.
  116832. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  116833. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  116834. * @param replace has the default false, when true replaces the active camera/light in the scene
  116835. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  116836. */
  116837. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  116838. /**
  116839. * Creates a new sky box
  116840. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  116841. * @param environmentTexture defines the texture to use as environment texture
  116842. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  116843. * @param scale defines the overall scale of the skybox
  116844. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  116845. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  116846. * @returns a new mesh holding the sky box
  116847. */
  116848. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  116849. /**
  116850. * Creates a new environment
  116851. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  116852. * @param options defines the options you can use to configure the environment
  116853. * @returns the new EnvironmentHelper
  116854. */
  116855. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  116856. /**
  116857. * Creates a new VREXperienceHelper
  116858. * @see http://doc.babylonjs.com/how_to/webvr_helper
  116859. * @param webVROptions defines the options used to create the new VREXperienceHelper
  116860. * @returns a new VREXperienceHelper
  116861. */
  116862. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  116863. /**
  116864. * Creates a new WebXRDefaultExperience
  116865. * @see http://doc.babylonjs.com/how_to/webxr
  116866. * @param options experience options
  116867. * @returns a promise for a new WebXRDefaultExperience
  116868. */
  116869. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  116870. }
  116871. }
  116872. declare module BABYLON {
  116873. /**
  116874. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  116875. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  116876. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  116877. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116878. */
  116879. export class VideoDome extends TransformNode {
  116880. /**
  116881. * Define the video source as a Monoscopic panoramic 360 video.
  116882. */
  116883. static readonly MODE_MONOSCOPIC: number;
  116884. /**
  116885. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116886. */
  116887. static readonly MODE_TOPBOTTOM: number;
  116888. /**
  116889. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116890. */
  116891. static readonly MODE_SIDEBYSIDE: number;
  116892. private _halfDome;
  116893. private _useDirectMapping;
  116894. /**
  116895. * The video texture being displayed on the sphere
  116896. */
  116897. protected _videoTexture: VideoTexture;
  116898. /**
  116899. * Gets the video texture being displayed on the sphere
  116900. */
  116901. readonly videoTexture: VideoTexture;
  116902. /**
  116903. * The skybox material
  116904. */
  116905. protected _material: BackgroundMaterial;
  116906. /**
  116907. * The surface used for the skybox
  116908. */
  116909. protected _mesh: Mesh;
  116910. /**
  116911. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  116912. */
  116913. private _halfDomeMask;
  116914. /**
  116915. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116916. * Also see the options.resolution property.
  116917. */
  116918. fovMultiplier: number;
  116919. private _videoMode;
  116920. /**
  116921. * Gets or set the current video mode for the video. It can be:
  116922. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  116923. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  116924. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  116925. */
  116926. videoMode: number;
  116927. /**
  116928. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  116929. *
  116930. */
  116931. /**
  116932. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  116933. */
  116934. halfDome: boolean;
  116935. /**
  116936. * Oberserver used in Stereoscopic VR Mode.
  116937. */
  116938. private _onBeforeCameraRenderObserver;
  116939. /**
  116940. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  116941. * @param name Element's name, child elements will append suffixes for their own names.
  116942. * @param urlsOrVideo defines the url(s) or the video element to use
  116943. * @param options An object containing optional or exposed sub element properties
  116944. */
  116945. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  116946. resolution?: number;
  116947. clickToPlay?: boolean;
  116948. autoPlay?: boolean;
  116949. loop?: boolean;
  116950. size?: number;
  116951. poster?: string;
  116952. faceForward?: boolean;
  116953. useDirectMapping?: boolean;
  116954. halfDomeMode?: boolean;
  116955. }, scene: Scene);
  116956. private _changeVideoMode;
  116957. /**
  116958. * Releases resources associated with this node.
  116959. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116960. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116961. */
  116962. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116963. }
  116964. }
  116965. declare module BABYLON {
  116966. /**
  116967. * This class can be used to get instrumentation data from a Babylon engine
  116968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116969. */
  116970. export class EngineInstrumentation implements IDisposable {
  116971. /**
  116972. * Define the instrumented engine.
  116973. */
  116974. engine: Engine;
  116975. private _captureGPUFrameTime;
  116976. private _gpuFrameTimeToken;
  116977. private _gpuFrameTime;
  116978. private _captureShaderCompilationTime;
  116979. private _shaderCompilationTime;
  116980. private _onBeginFrameObserver;
  116981. private _onEndFrameObserver;
  116982. private _onBeforeShaderCompilationObserver;
  116983. private _onAfterShaderCompilationObserver;
  116984. /**
  116985. * Gets the perf counter used for GPU frame time
  116986. */
  116987. readonly gpuFrameTimeCounter: PerfCounter;
  116988. /**
  116989. * Gets the GPU frame time capture status
  116990. */
  116991. /**
  116992. * Enable or disable the GPU frame time capture
  116993. */
  116994. captureGPUFrameTime: boolean;
  116995. /**
  116996. * Gets the perf counter used for shader compilation time
  116997. */
  116998. readonly shaderCompilationTimeCounter: PerfCounter;
  116999. /**
  117000. * Gets the shader compilation time capture status
  117001. */
  117002. /**
  117003. * Enable or disable the shader compilation time capture
  117004. */
  117005. captureShaderCompilationTime: boolean;
  117006. /**
  117007. * Instantiates a new engine instrumentation.
  117008. * This class can be used to get instrumentation data from a Babylon engine
  117009. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117010. * @param engine Defines the engine to instrument
  117011. */
  117012. constructor(
  117013. /**
  117014. * Define the instrumented engine.
  117015. */
  117016. engine: Engine);
  117017. /**
  117018. * Dispose and release associated resources.
  117019. */
  117020. dispose(): void;
  117021. }
  117022. }
  117023. declare module BABYLON {
  117024. /**
  117025. * This class can be used to get instrumentation data from a Babylon engine
  117026. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117027. */
  117028. export class SceneInstrumentation implements IDisposable {
  117029. /**
  117030. * Defines the scene to instrument
  117031. */
  117032. scene: Scene;
  117033. private _captureActiveMeshesEvaluationTime;
  117034. private _activeMeshesEvaluationTime;
  117035. private _captureRenderTargetsRenderTime;
  117036. private _renderTargetsRenderTime;
  117037. private _captureFrameTime;
  117038. private _frameTime;
  117039. private _captureRenderTime;
  117040. private _renderTime;
  117041. private _captureInterFrameTime;
  117042. private _interFrameTime;
  117043. private _captureParticlesRenderTime;
  117044. private _particlesRenderTime;
  117045. private _captureSpritesRenderTime;
  117046. private _spritesRenderTime;
  117047. private _capturePhysicsTime;
  117048. private _physicsTime;
  117049. private _captureAnimationsTime;
  117050. private _animationsTime;
  117051. private _captureCameraRenderTime;
  117052. private _cameraRenderTime;
  117053. private _onBeforeActiveMeshesEvaluationObserver;
  117054. private _onAfterActiveMeshesEvaluationObserver;
  117055. private _onBeforeRenderTargetsRenderObserver;
  117056. private _onAfterRenderTargetsRenderObserver;
  117057. private _onAfterRenderObserver;
  117058. private _onBeforeDrawPhaseObserver;
  117059. private _onAfterDrawPhaseObserver;
  117060. private _onBeforeAnimationsObserver;
  117061. private _onBeforeParticlesRenderingObserver;
  117062. private _onAfterParticlesRenderingObserver;
  117063. private _onBeforeSpritesRenderingObserver;
  117064. private _onAfterSpritesRenderingObserver;
  117065. private _onBeforePhysicsObserver;
  117066. private _onAfterPhysicsObserver;
  117067. private _onAfterAnimationsObserver;
  117068. private _onBeforeCameraRenderObserver;
  117069. private _onAfterCameraRenderObserver;
  117070. /**
  117071. * Gets the perf counter used for active meshes evaluation time
  117072. */
  117073. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  117074. /**
  117075. * Gets the active meshes evaluation time capture status
  117076. */
  117077. /**
  117078. * Enable or disable the active meshes evaluation time capture
  117079. */
  117080. captureActiveMeshesEvaluationTime: boolean;
  117081. /**
  117082. * Gets the perf counter used for render targets render time
  117083. */
  117084. readonly renderTargetsRenderTimeCounter: PerfCounter;
  117085. /**
  117086. * Gets the render targets render time capture status
  117087. */
  117088. /**
  117089. * Enable or disable the render targets render time capture
  117090. */
  117091. captureRenderTargetsRenderTime: boolean;
  117092. /**
  117093. * Gets the perf counter used for particles render time
  117094. */
  117095. readonly particlesRenderTimeCounter: PerfCounter;
  117096. /**
  117097. * Gets the particles render time capture status
  117098. */
  117099. /**
  117100. * Enable or disable the particles render time capture
  117101. */
  117102. captureParticlesRenderTime: boolean;
  117103. /**
  117104. * Gets the perf counter used for sprites render time
  117105. */
  117106. readonly spritesRenderTimeCounter: PerfCounter;
  117107. /**
  117108. * Gets the sprites render time capture status
  117109. */
  117110. /**
  117111. * Enable or disable the sprites render time capture
  117112. */
  117113. captureSpritesRenderTime: boolean;
  117114. /**
  117115. * Gets the perf counter used for physics time
  117116. */
  117117. readonly physicsTimeCounter: PerfCounter;
  117118. /**
  117119. * Gets the physics time capture status
  117120. */
  117121. /**
  117122. * Enable or disable the physics time capture
  117123. */
  117124. capturePhysicsTime: boolean;
  117125. /**
  117126. * Gets the perf counter used for animations time
  117127. */
  117128. readonly animationsTimeCounter: PerfCounter;
  117129. /**
  117130. * Gets the animations time capture status
  117131. */
  117132. /**
  117133. * Enable or disable the animations time capture
  117134. */
  117135. captureAnimationsTime: boolean;
  117136. /**
  117137. * Gets the perf counter used for frame time capture
  117138. */
  117139. readonly frameTimeCounter: PerfCounter;
  117140. /**
  117141. * Gets the frame time capture status
  117142. */
  117143. /**
  117144. * Enable or disable the frame time capture
  117145. */
  117146. captureFrameTime: boolean;
  117147. /**
  117148. * Gets the perf counter used for inter-frames time capture
  117149. */
  117150. readonly interFrameTimeCounter: PerfCounter;
  117151. /**
  117152. * Gets the inter-frames time capture status
  117153. */
  117154. /**
  117155. * Enable or disable the inter-frames time capture
  117156. */
  117157. captureInterFrameTime: boolean;
  117158. /**
  117159. * Gets the perf counter used for render time capture
  117160. */
  117161. readonly renderTimeCounter: PerfCounter;
  117162. /**
  117163. * Gets the render time capture status
  117164. */
  117165. /**
  117166. * Enable or disable the render time capture
  117167. */
  117168. captureRenderTime: boolean;
  117169. /**
  117170. * Gets the perf counter used for camera render time capture
  117171. */
  117172. readonly cameraRenderTimeCounter: PerfCounter;
  117173. /**
  117174. * Gets the camera render time capture status
  117175. */
  117176. /**
  117177. * Enable or disable the camera render time capture
  117178. */
  117179. captureCameraRenderTime: boolean;
  117180. /**
  117181. * Gets the perf counter used for draw calls
  117182. */
  117183. readonly drawCallsCounter: PerfCounter;
  117184. /**
  117185. * Instantiates a new scene instrumentation.
  117186. * This class can be used to get instrumentation data from a Babylon engine
  117187. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  117188. * @param scene Defines the scene to instrument
  117189. */
  117190. constructor(
  117191. /**
  117192. * Defines the scene to instrument
  117193. */
  117194. scene: Scene);
  117195. /**
  117196. * Dispose and release associated resources.
  117197. */
  117198. dispose(): void;
  117199. }
  117200. }
  117201. declare module BABYLON {
  117202. /** @hidden */
  117203. export var glowMapGenerationPixelShader: {
  117204. name: string;
  117205. shader: string;
  117206. };
  117207. }
  117208. declare module BABYLON {
  117209. /** @hidden */
  117210. export var glowMapGenerationVertexShader: {
  117211. name: string;
  117212. shader: string;
  117213. };
  117214. }
  117215. declare module BABYLON {
  117216. /**
  117217. * Effect layer options. This helps customizing the behaviour
  117218. * of the effect layer.
  117219. */
  117220. export interface IEffectLayerOptions {
  117221. /**
  117222. * Multiplication factor apply to the canvas size to compute the render target size
  117223. * used to generated the objects (the smaller the faster).
  117224. */
  117225. mainTextureRatio: number;
  117226. /**
  117227. * Enforces a fixed size texture to ensure effect stability across devices.
  117228. */
  117229. mainTextureFixedSize?: number;
  117230. /**
  117231. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  117232. */
  117233. alphaBlendingMode: number;
  117234. /**
  117235. * The camera attached to the layer.
  117236. */
  117237. camera: Nullable<Camera>;
  117238. /**
  117239. * The rendering group to draw the layer in.
  117240. */
  117241. renderingGroupId: number;
  117242. }
  117243. /**
  117244. * The effect layer Helps adding post process effect blended with the main pass.
  117245. *
  117246. * This can be for instance use to generate glow or higlight effects on the scene.
  117247. *
  117248. * The effect layer class can not be used directly and is intented to inherited from to be
  117249. * customized per effects.
  117250. */
  117251. export abstract class EffectLayer {
  117252. private _vertexBuffers;
  117253. private _indexBuffer;
  117254. private _cachedDefines;
  117255. private _effectLayerMapGenerationEffect;
  117256. private _effectLayerOptions;
  117257. private _mergeEffect;
  117258. protected _scene: Scene;
  117259. protected _engine: Engine;
  117260. protected _maxSize: number;
  117261. protected _mainTextureDesiredSize: ISize;
  117262. protected _mainTexture: RenderTargetTexture;
  117263. protected _shouldRender: boolean;
  117264. protected _postProcesses: PostProcess[];
  117265. protected _textures: BaseTexture[];
  117266. protected _emissiveTextureAndColor: {
  117267. texture: Nullable<BaseTexture>;
  117268. color: Color4;
  117269. };
  117270. /**
  117271. * The name of the layer
  117272. */
  117273. name: string;
  117274. /**
  117275. * The clear color of the texture used to generate the glow map.
  117276. */
  117277. neutralColor: Color4;
  117278. /**
  117279. * Specifies wether the highlight layer is enabled or not.
  117280. */
  117281. isEnabled: boolean;
  117282. /**
  117283. * Gets the camera attached to the layer.
  117284. */
  117285. readonly camera: Nullable<Camera>;
  117286. /**
  117287. * Gets the rendering group id the layer should render in.
  117288. */
  117289. renderingGroupId: number;
  117290. /**
  117291. * An event triggered when the effect layer has been disposed.
  117292. */
  117293. onDisposeObservable: Observable<EffectLayer>;
  117294. /**
  117295. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  117296. */
  117297. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  117298. /**
  117299. * An event triggered when the generated texture is being merged in the scene.
  117300. */
  117301. onBeforeComposeObservable: Observable<EffectLayer>;
  117302. /**
  117303. * An event triggered when the mesh is rendered into the effect render target.
  117304. */
  117305. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  117306. /**
  117307. * An event triggered after the mesh has been rendered into the effect render target.
  117308. */
  117309. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  117310. /**
  117311. * An event triggered when the generated texture has been merged in the scene.
  117312. */
  117313. onAfterComposeObservable: Observable<EffectLayer>;
  117314. /**
  117315. * An event triggered when the efffect layer changes its size.
  117316. */
  117317. onSizeChangedObservable: Observable<EffectLayer>;
  117318. /** @hidden */
  117319. static _SceneComponentInitialization: (scene: Scene) => void;
  117320. /**
  117321. * Instantiates a new effect Layer and references it in the scene.
  117322. * @param name The name of the layer
  117323. * @param scene The scene to use the layer in
  117324. */
  117325. constructor(
  117326. /** The Friendly of the effect in the scene */
  117327. name: string, scene: Scene);
  117328. /**
  117329. * Get the effect name of the layer.
  117330. * @return The effect name
  117331. */
  117332. abstract getEffectName(): string;
  117333. /**
  117334. * Checks for the readiness of the element composing the layer.
  117335. * @param subMesh the mesh to check for
  117336. * @param useInstances specify wether or not to use instances to render the mesh
  117337. * @return true if ready otherwise, false
  117338. */
  117339. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117340. /**
  117341. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117342. * @returns true if the effect requires stencil during the main canvas render pass.
  117343. */
  117344. abstract needStencil(): boolean;
  117345. /**
  117346. * Create the merge effect. This is the shader use to blit the information back
  117347. * to the main canvas at the end of the scene rendering.
  117348. * @returns The effect containing the shader used to merge the effect on the main canvas
  117349. */
  117350. protected abstract _createMergeEffect(): Effect;
  117351. /**
  117352. * Creates the render target textures and post processes used in the effect layer.
  117353. */
  117354. protected abstract _createTextureAndPostProcesses(): void;
  117355. /**
  117356. * Implementation specific of rendering the generating effect on the main canvas.
  117357. * @param effect The effect used to render through
  117358. */
  117359. protected abstract _internalRender(effect: Effect): void;
  117360. /**
  117361. * Sets the required values for both the emissive texture and and the main color.
  117362. */
  117363. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117364. /**
  117365. * Free any resources and references associated to a mesh.
  117366. * Internal use
  117367. * @param mesh The mesh to free.
  117368. */
  117369. abstract _disposeMesh(mesh: Mesh): void;
  117370. /**
  117371. * Serializes this layer (Glow or Highlight for example)
  117372. * @returns a serialized layer object
  117373. */
  117374. abstract serialize?(): any;
  117375. /**
  117376. * Initializes the effect layer with the required options.
  117377. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  117378. */
  117379. protected _init(options: Partial<IEffectLayerOptions>): void;
  117380. /**
  117381. * Generates the index buffer of the full screen quad blending to the main canvas.
  117382. */
  117383. private _generateIndexBuffer;
  117384. /**
  117385. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  117386. */
  117387. private _generateVertexBuffer;
  117388. /**
  117389. * Sets the main texture desired size which is the closest power of two
  117390. * of the engine canvas size.
  117391. */
  117392. private _setMainTextureSize;
  117393. /**
  117394. * Creates the main texture for the effect layer.
  117395. */
  117396. protected _createMainTexture(): void;
  117397. /**
  117398. * Adds specific effects defines.
  117399. * @param defines The defines to add specifics to.
  117400. */
  117401. protected _addCustomEffectDefines(defines: string[]): void;
  117402. /**
  117403. * Checks for the readiness of the element composing the layer.
  117404. * @param subMesh the mesh to check for
  117405. * @param useInstances specify wether or not to use instances to render the mesh
  117406. * @param emissiveTexture the associated emissive texture used to generate the glow
  117407. * @return true if ready otherwise, false
  117408. */
  117409. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  117410. /**
  117411. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  117412. */
  117413. render(): void;
  117414. /**
  117415. * Determine if a given mesh will be used in the current effect.
  117416. * @param mesh mesh to test
  117417. * @returns true if the mesh will be used
  117418. */
  117419. hasMesh(mesh: AbstractMesh): boolean;
  117420. /**
  117421. * Returns true if the layer contains information to display, otherwise false.
  117422. * @returns true if the glow layer should be rendered
  117423. */
  117424. shouldRender(): boolean;
  117425. /**
  117426. * Returns true if the mesh should render, otherwise false.
  117427. * @param mesh The mesh to render
  117428. * @returns true if it should render otherwise false
  117429. */
  117430. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  117431. /**
  117432. * Returns true if the mesh can be rendered, otherwise false.
  117433. * @param mesh The mesh to render
  117434. * @param material The material used on the mesh
  117435. * @returns true if it can be rendered otherwise false
  117436. */
  117437. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117438. /**
  117439. * Returns true if the mesh should render, otherwise false.
  117440. * @param mesh The mesh to render
  117441. * @returns true if it should render otherwise false
  117442. */
  117443. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  117444. /**
  117445. * Renders the submesh passed in parameter to the generation map.
  117446. */
  117447. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  117448. /**
  117449. * Defines wether the current material of the mesh should be use to render the effect.
  117450. * @param mesh defines the current mesh to render
  117451. */
  117452. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  117453. /**
  117454. * Rebuild the required buffers.
  117455. * @hidden Internal use only.
  117456. */
  117457. _rebuild(): void;
  117458. /**
  117459. * Dispose only the render target textures and post process.
  117460. */
  117461. private _disposeTextureAndPostProcesses;
  117462. /**
  117463. * Dispose the highlight layer and free resources.
  117464. */
  117465. dispose(): void;
  117466. /**
  117467. * Gets the class name of the effect layer
  117468. * @returns the string with the class name of the effect layer
  117469. */
  117470. getClassName(): string;
  117471. /**
  117472. * Creates an effect layer from parsed effect layer data
  117473. * @param parsedEffectLayer defines effect layer data
  117474. * @param scene defines the current scene
  117475. * @param rootUrl defines the root URL containing the effect layer information
  117476. * @returns a parsed effect Layer
  117477. */
  117478. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  117479. }
  117480. }
  117481. declare module BABYLON {
  117482. interface AbstractScene {
  117483. /**
  117484. * The list of effect layers (highlights/glow) added to the scene
  117485. * @see http://doc.babylonjs.com/how_to/highlight_layer
  117486. * @see http://doc.babylonjs.com/how_to/glow_layer
  117487. */
  117488. effectLayers: Array<EffectLayer>;
  117489. /**
  117490. * Removes the given effect layer from this scene.
  117491. * @param toRemove defines the effect layer to remove
  117492. * @returns the index of the removed effect layer
  117493. */
  117494. removeEffectLayer(toRemove: EffectLayer): number;
  117495. /**
  117496. * Adds the given effect layer to this scene
  117497. * @param newEffectLayer defines the effect layer to add
  117498. */
  117499. addEffectLayer(newEffectLayer: EffectLayer): void;
  117500. }
  117501. /**
  117502. * Defines the layer scene component responsible to manage any effect layers
  117503. * in a given scene.
  117504. */
  117505. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  117506. /**
  117507. * The component name helpfull to identify the component in the list of scene components.
  117508. */
  117509. readonly name: string;
  117510. /**
  117511. * The scene the component belongs to.
  117512. */
  117513. scene: Scene;
  117514. private _engine;
  117515. private _renderEffects;
  117516. private _needStencil;
  117517. private _previousStencilState;
  117518. /**
  117519. * Creates a new instance of the component for the given scene
  117520. * @param scene Defines the scene to register the component in
  117521. */
  117522. constructor(scene: Scene);
  117523. /**
  117524. * Registers the component in a given scene
  117525. */
  117526. register(): void;
  117527. /**
  117528. * Rebuilds the elements related to this component in case of
  117529. * context lost for instance.
  117530. */
  117531. rebuild(): void;
  117532. /**
  117533. * Serializes the component data to the specified json object
  117534. * @param serializationObject The object to serialize to
  117535. */
  117536. serialize(serializationObject: any): void;
  117537. /**
  117538. * Adds all the elements from the container to the scene
  117539. * @param container the container holding the elements
  117540. */
  117541. addFromContainer(container: AbstractScene): void;
  117542. /**
  117543. * Removes all the elements in the container from the scene
  117544. * @param container contains the elements to remove
  117545. * @param dispose if the removed element should be disposed (default: false)
  117546. */
  117547. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117548. /**
  117549. * Disposes the component and the associated ressources.
  117550. */
  117551. dispose(): void;
  117552. private _isReadyForMesh;
  117553. private _renderMainTexture;
  117554. private _setStencil;
  117555. private _setStencilBack;
  117556. private _draw;
  117557. private _drawCamera;
  117558. private _drawRenderingGroup;
  117559. }
  117560. }
  117561. declare module BABYLON {
  117562. /** @hidden */
  117563. export var glowMapMergePixelShader: {
  117564. name: string;
  117565. shader: string;
  117566. };
  117567. }
  117568. declare module BABYLON {
  117569. /** @hidden */
  117570. export var glowMapMergeVertexShader: {
  117571. name: string;
  117572. shader: string;
  117573. };
  117574. }
  117575. declare module BABYLON {
  117576. interface AbstractScene {
  117577. /**
  117578. * Return a the first highlight layer of the scene with a given name.
  117579. * @param name The name of the highlight layer to look for.
  117580. * @return The highlight layer if found otherwise null.
  117581. */
  117582. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  117583. }
  117584. /**
  117585. * Glow layer options. This helps customizing the behaviour
  117586. * of the glow layer.
  117587. */
  117588. export interface IGlowLayerOptions {
  117589. /**
  117590. * Multiplication factor apply to the canvas size to compute the render target size
  117591. * used to generated the glowing objects (the smaller the faster).
  117592. */
  117593. mainTextureRatio: number;
  117594. /**
  117595. * Enforces a fixed size texture to ensure resize independant blur.
  117596. */
  117597. mainTextureFixedSize?: number;
  117598. /**
  117599. * How big is the kernel of the blur texture.
  117600. */
  117601. blurKernelSize: number;
  117602. /**
  117603. * The camera attached to the layer.
  117604. */
  117605. camera: Nullable<Camera>;
  117606. /**
  117607. * Enable MSAA by chosing the number of samples.
  117608. */
  117609. mainTextureSamples?: number;
  117610. /**
  117611. * The rendering group to draw the layer in.
  117612. */
  117613. renderingGroupId: number;
  117614. }
  117615. /**
  117616. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  117617. *
  117618. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  117619. *
  117620. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  117621. */
  117622. export class GlowLayer extends EffectLayer {
  117623. /**
  117624. * Effect Name of the layer.
  117625. */
  117626. static readonly EffectName: string;
  117627. /**
  117628. * The default blur kernel size used for the glow.
  117629. */
  117630. static DefaultBlurKernelSize: number;
  117631. /**
  117632. * The default texture size ratio used for the glow.
  117633. */
  117634. static DefaultTextureRatio: number;
  117635. /**
  117636. * Sets the kernel size of the blur.
  117637. */
  117638. /**
  117639. * Gets the kernel size of the blur.
  117640. */
  117641. blurKernelSize: number;
  117642. /**
  117643. * Sets the glow intensity.
  117644. */
  117645. /**
  117646. * Gets the glow intensity.
  117647. */
  117648. intensity: number;
  117649. private _options;
  117650. private _intensity;
  117651. private _horizontalBlurPostprocess1;
  117652. private _verticalBlurPostprocess1;
  117653. private _horizontalBlurPostprocess2;
  117654. private _verticalBlurPostprocess2;
  117655. private _blurTexture1;
  117656. private _blurTexture2;
  117657. private _postProcesses1;
  117658. private _postProcesses2;
  117659. private _includedOnlyMeshes;
  117660. private _excludedMeshes;
  117661. private _meshesUsingTheirOwnMaterials;
  117662. /**
  117663. * Callback used to let the user override the color selection on a per mesh basis
  117664. */
  117665. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  117666. /**
  117667. * Callback used to let the user override the texture selection on a per mesh basis
  117668. */
  117669. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  117670. /**
  117671. * Instantiates a new glow Layer and references it to the scene.
  117672. * @param name The name of the layer
  117673. * @param scene The scene to use the layer in
  117674. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  117675. */
  117676. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  117677. /**
  117678. * Get the effect name of the layer.
  117679. * @return The effect name
  117680. */
  117681. getEffectName(): string;
  117682. /**
  117683. * Create the merge effect. This is the shader use to blit the information back
  117684. * to the main canvas at the end of the scene rendering.
  117685. */
  117686. protected _createMergeEffect(): Effect;
  117687. /**
  117688. * Creates the render target textures and post processes used in the glow layer.
  117689. */
  117690. protected _createTextureAndPostProcesses(): void;
  117691. /**
  117692. * Checks for the readiness of the element composing the layer.
  117693. * @param subMesh the mesh to check for
  117694. * @param useInstances specify wether or not to use instances to render the mesh
  117695. * @param emissiveTexture the associated emissive texture used to generate the glow
  117696. * @return true if ready otherwise, false
  117697. */
  117698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117699. /**
  117700. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117701. */
  117702. needStencil(): boolean;
  117703. /**
  117704. * Returns true if the mesh can be rendered, otherwise false.
  117705. * @param mesh The mesh to render
  117706. * @param material The material used on the mesh
  117707. * @returns true if it can be rendered otherwise false
  117708. */
  117709. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  117710. /**
  117711. * Implementation specific of rendering the generating effect on the main canvas.
  117712. * @param effect The effect used to render through
  117713. */
  117714. protected _internalRender(effect: Effect): void;
  117715. /**
  117716. * Sets the required values for both the emissive texture and and the main color.
  117717. */
  117718. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117719. /**
  117720. * Returns true if the mesh should render, otherwise false.
  117721. * @param mesh The mesh to render
  117722. * @returns true if it should render otherwise false
  117723. */
  117724. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117725. /**
  117726. * Adds specific effects defines.
  117727. * @param defines The defines to add specifics to.
  117728. */
  117729. protected _addCustomEffectDefines(defines: string[]): void;
  117730. /**
  117731. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  117732. * @param mesh The mesh to exclude from the glow layer
  117733. */
  117734. addExcludedMesh(mesh: Mesh): void;
  117735. /**
  117736. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  117737. * @param mesh The mesh to remove
  117738. */
  117739. removeExcludedMesh(mesh: Mesh): void;
  117740. /**
  117741. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  117742. * @param mesh The mesh to include in the glow layer
  117743. */
  117744. addIncludedOnlyMesh(mesh: Mesh): void;
  117745. /**
  117746. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  117747. * @param mesh The mesh to remove
  117748. */
  117749. removeIncludedOnlyMesh(mesh: Mesh): void;
  117750. /**
  117751. * Determine if a given mesh will be used in the glow layer
  117752. * @param mesh The mesh to test
  117753. * @returns true if the mesh will be highlighted by the current glow layer
  117754. */
  117755. hasMesh(mesh: AbstractMesh): boolean;
  117756. /**
  117757. * Defines wether the current material of the mesh should be use to render the effect.
  117758. * @param mesh defines the current mesh to render
  117759. */
  117760. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  117761. /**
  117762. * Add a mesh to be rendered through its own material and not with emissive only.
  117763. * @param mesh The mesh for which we need to use its material
  117764. */
  117765. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  117766. /**
  117767. * Remove a mesh from being rendered through its own material and not with emissive only.
  117768. * @param mesh The mesh for which we need to not use its material
  117769. */
  117770. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  117771. /**
  117772. * Free any resources and references associated to a mesh.
  117773. * Internal use
  117774. * @param mesh The mesh to free.
  117775. * @hidden
  117776. */
  117777. _disposeMesh(mesh: Mesh): void;
  117778. /**
  117779. * Gets the class name of the effect layer
  117780. * @returns the string with the class name of the effect layer
  117781. */
  117782. getClassName(): string;
  117783. /**
  117784. * Serializes this glow layer
  117785. * @returns a serialized glow layer object
  117786. */
  117787. serialize(): any;
  117788. /**
  117789. * Creates a Glow Layer from parsed glow layer data
  117790. * @param parsedGlowLayer defines glow layer data
  117791. * @param scene defines the current scene
  117792. * @param rootUrl defines the root URL containing the glow layer information
  117793. * @returns a parsed Glow Layer
  117794. */
  117795. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  117796. }
  117797. }
  117798. declare module BABYLON {
  117799. /** @hidden */
  117800. export var glowBlurPostProcessPixelShader: {
  117801. name: string;
  117802. shader: string;
  117803. };
  117804. }
  117805. declare module BABYLON {
  117806. interface AbstractScene {
  117807. /**
  117808. * Return a the first highlight layer of the scene with a given name.
  117809. * @param name The name of the highlight layer to look for.
  117810. * @return The highlight layer if found otherwise null.
  117811. */
  117812. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  117813. }
  117814. /**
  117815. * Highlight layer options. This helps customizing the behaviour
  117816. * of the highlight layer.
  117817. */
  117818. export interface IHighlightLayerOptions {
  117819. /**
  117820. * Multiplication factor apply to the canvas size to compute the render target size
  117821. * used to generated the glowing objects (the smaller the faster).
  117822. */
  117823. mainTextureRatio: number;
  117824. /**
  117825. * Enforces a fixed size texture to ensure resize independant blur.
  117826. */
  117827. mainTextureFixedSize?: number;
  117828. /**
  117829. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  117830. * of the picture to blur (the smaller the faster).
  117831. */
  117832. blurTextureSizeRatio: number;
  117833. /**
  117834. * How big in texel of the blur texture is the vertical blur.
  117835. */
  117836. blurVerticalSize: number;
  117837. /**
  117838. * How big in texel of the blur texture is the horizontal blur.
  117839. */
  117840. blurHorizontalSize: number;
  117841. /**
  117842. * Alpha blending mode used to apply the blur. Default is combine.
  117843. */
  117844. alphaBlendingMode: number;
  117845. /**
  117846. * The camera attached to the layer.
  117847. */
  117848. camera: Nullable<Camera>;
  117849. /**
  117850. * Should we display highlight as a solid stroke?
  117851. */
  117852. isStroke?: boolean;
  117853. /**
  117854. * The rendering group to draw the layer in.
  117855. */
  117856. renderingGroupId: number;
  117857. }
  117858. /**
  117859. * The highlight layer Helps adding a glow effect around a mesh.
  117860. *
  117861. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  117862. * glowy meshes to your scene.
  117863. *
  117864. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  117865. */
  117866. export class HighlightLayer extends EffectLayer {
  117867. name: string;
  117868. /**
  117869. * Effect Name of the highlight layer.
  117870. */
  117871. static readonly EffectName: string;
  117872. /**
  117873. * The neutral color used during the preparation of the glow effect.
  117874. * This is black by default as the blend operation is a blend operation.
  117875. */
  117876. static NeutralColor: Color4;
  117877. /**
  117878. * Stencil value used for glowing meshes.
  117879. */
  117880. static GlowingMeshStencilReference: number;
  117881. /**
  117882. * Stencil value used for the other meshes in the scene.
  117883. */
  117884. static NormalMeshStencilReference: number;
  117885. /**
  117886. * Specifies whether or not the inner glow is ACTIVE in the layer.
  117887. */
  117888. innerGlow: boolean;
  117889. /**
  117890. * Specifies whether or not the outer glow is ACTIVE in the layer.
  117891. */
  117892. outerGlow: boolean;
  117893. /**
  117894. * Specifies the horizontal size of the blur.
  117895. */
  117896. /**
  117897. * Gets the horizontal size of the blur.
  117898. */
  117899. blurHorizontalSize: number;
  117900. /**
  117901. * Specifies the vertical size of the blur.
  117902. */
  117903. /**
  117904. * Gets the vertical size of the blur.
  117905. */
  117906. blurVerticalSize: number;
  117907. /**
  117908. * An event triggered when the highlight layer is being blurred.
  117909. */
  117910. onBeforeBlurObservable: Observable<HighlightLayer>;
  117911. /**
  117912. * An event triggered when the highlight layer has been blurred.
  117913. */
  117914. onAfterBlurObservable: Observable<HighlightLayer>;
  117915. private _instanceGlowingMeshStencilReference;
  117916. private _options;
  117917. private _downSamplePostprocess;
  117918. private _horizontalBlurPostprocess;
  117919. private _verticalBlurPostprocess;
  117920. private _blurTexture;
  117921. private _meshes;
  117922. private _excludedMeshes;
  117923. /**
  117924. * Instantiates a new highlight Layer and references it to the scene..
  117925. * @param name The name of the layer
  117926. * @param scene The scene to use the layer in
  117927. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  117928. */
  117929. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  117930. /**
  117931. * Get the effect name of the layer.
  117932. * @return The effect name
  117933. */
  117934. getEffectName(): string;
  117935. /**
  117936. * Create the merge effect. This is the shader use to blit the information back
  117937. * to the main canvas at the end of the scene rendering.
  117938. */
  117939. protected _createMergeEffect(): Effect;
  117940. /**
  117941. * Creates the render target textures and post processes used in the highlight layer.
  117942. */
  117943. protected _createTextureAndPostProcesses(): void;
  117944. /**
  117945. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  117946. */
  117947. needStencil(): boolean;
  117948. /**
  117949. * Checks for the readiness of the element composing the layer.
  117950. * @param subMesh the mesh to check for
  117951. * @param useInstances specify wether or not to use instances to render the mesh
  117952. * @param emissiveTexture the associated emissive texture used to generate the glow
  117953. * @return true if ready otherwise, false
  117954. */
  117955. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117956. /**
  117957. * Implementation specific of rendering the generating effect on the main canvas.
  117958. * @param effect The effect used to render through
  117959. */
  117960. protected _internalRender(effect: Effect): void;
  117961. /**
  117962. * Returns true if the layer contains information to display, otherwise false.
  117963. */
  117964. shouldRender(): boolean;
  117965. /**
  117966. * Returns true if the mesh should render, otherwise false.
  117967. * @param mesh The mesh to render
  117968. * @returns true if it should render otherwise false
  117969. */
  117970. protected _shouldRenderMesh(mesh: Mesh): boolean;
  117971. /**
  117972. * Sets the required values for both the emissive texture and and the main color.
  117973. */
  117974. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  117975. /**
  117976. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  117977. * @param mesh The mesh to exclude from the highlight layer
  117978. */
  117979. addExcludedMesh(mesh: Mesh): void;
  117980. /**
  117981. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  117982. * @param mesh The mesh to highlight
  117983. */
  117984. removeExcludedMesh(mesh: Mesh): void;
  117985. /**
  117986. * Determine if a given mesh will be highlighted by the current HighlightLayer
  117987. * @param mesh mesh to test
  117988. * @returns true if the mesh will be highlighted by the current HighlightLayer
  117989. */
  117990. hasMesh(mesh: AbstractMesh): boolean;
  117991. /**
  117992. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  117993. * @param mesh The mesh to highlight
  117994. * @param color The color of the highlight
  117995. * @param glowEmissiveOnly Extract the glow from the emissive texture
  117996. */
  117997. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  117998. /**
  117999. * Remove a mesh from the highlight layer in order to make it stop glowing.
  118000. * @param mesh The mesh to highlight
  118001. */
  118002. removeMesh(mesh: Mesh): void;
  118003. /**
  118004. * Force the stencil to the normal expected value for none glowing parts
  118005. */
  118006. private _defaultStencilReference;
  118007. /**
  118008. * Free any resources and references associated to a mesh.
  118009. * Internal use
  118010. * @param mesh The mesh to free.
  118011. * @hidden
  118012. */
  118013. _disposeMesh(mesh: Mesh): void;
  118014. /**
  118015. * Dispose the highlight layer and free resources.
  118016. */
  118017. dispose(): void;
  118018. /**
  118019. * Gets the class name of the effect layer
  118020. * @returns the string with the class name of the effect layer
  118021. */
  118022. getClassName(): string;
  118023. /**
  118024. * Serializes this Highlight layer
  118025. * @returns a serialized Highlight layer object
  118026. */
  118027. serialize(): any;
  118028. /**
  118029. * Creates a Highlight layer from parsed Highlight layer data
  118030. * @param parsedHightlightLayer defines the Highlight layer data
  118031. * @param scene defines the current scene
  118032. * @param rootUrl defines the root URL containing the Highlight layer information
  118033. * @returns a parsed Highlight layer
  118034. */
  118035. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  118036. }
  118037. }
  118038. declare module BABYLON {
  118039. interface AbstractScene {
  118040. /**
  118041. * The list of layers (background and foreground) of the scene
  118042. */
  118043. layers: Array<Layer>;
  118044. }
  118045. /**
  118046. * Defines the layer scene component responsible to manage any layers
  118047. * in a given scene.
  118048. */
  118049. export class LayerSceneComponent implements ISceneComponent {
  118050. /**
  118051. * The component name helpfull to identify the component in the list of scene components.
  118052. */
  118053. readonly name: string;
  118054. /**
  118055. * The scene the component belongs to.
  118056. */
  118057. scene: Scene;
  118058. private _engine;
  118059. /**
  118060. * Creates a new instance of the component for the given scene
  118061. * @param scene Defines the scene to register the component in
  118062. */
  118063. constructor(scene: Scene);
  118064. /**
  118065. * Registers the component in a given scene
  118066. */
  118067. register(): void;
  118068. /**
  118069. * Rebuilds the elements related to this component in case of
  118070. * context lost for instance.
  118071. */
  118072. rebuild(): void;
  118073. /**
  118074. * Disposes the component and the associated ressources.
  118075. */
  118076. dispose(): void;
  118077. private _draw;
  118078. private _drawCameraPredicate;
  118079. private _drawCameraBackground;
  118080. private _drawCameraForeground;
  118081. private _drawRenderTargetPredicate;
  118082. private _drawRenderTargetBackground;
  118083. private _drawRenderTargetForeground;
  118084. /**
  118085. * Adds all the elements from the container to the scene
  118086. * @param container the container holding the elements
  118087. */
  118088. addFromContainer(container: AbstractScene): void;
  118089. /**
  118090. * Removes all the elements in the container from the scene
  118091. * @param container contains the elements to remove
  118092. * @param dispose if the removed element should be disposed (default: false)
  118093. */
  118094. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118095. }
  118096. }
  118097. declare module BABYLON {
  118098. /** @hidden */
  118099. export var layerPixelShader: {
  118100. name: string;
  118101. shader: string;
  118102. };
  118103. }
  118104. declare module BABYLON {
  118105. /** @hidden */
  118106. export var layerVertexShader: {
  118107. name: string;
  118108. shader: string;
  118109. };
  118110. }
  118111. declare module BABYLON {
  118112. /**
  118113. * This represents a full screen 2d layer.
  118114. * This can be useful to display a picture in the background of your scene for instance.
  118115. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118116. */
  118117. export class Layer {
  118118. /**
  118119. * Define the name of the layer.
  118120. */
  118121. name: string;
  118122. /**
  118123. * Define the texture the layer should display.
  118124. */
  118125. texture: Nullable<Texture>;
  118126. /**
  118127. * Is the layer in background or foreground.
  118128. */
  118129. isBackground: boolean;
  118130. /**
  118131. * Define the color of the layer (instead of texture).
  118132. */
  118133. color: Color4;
  118134. /**
  118135. * Define the scale of the layer in order to zoom in out of the texture.
  118136. */
  118137. scale: Vector2;
  118138. /**
  118139. * Define an offset for the layer in order to shift the texture.
  118140. */
  118141. offset: Vector2;
  118142. /**
  118143. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  118144. */
  118145. alphaBlendingMode: number;
  118146. /**
  118147. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  118148. * Alpha test will not mix with the background color in case of transparency.
  118149. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  118150. */
  118151. alphaTest: boolean;
  118152. /**
  118153. * Define a mask to restrict the layer to only some of the scene cameras.
  118154. */
  118155. layerMask: number;
  118156. /**
  118157. * Define the list of render target the layer is visible into.
  118158. */
  118159. renderTargetTextures: RenderTargetTexture[];
  118160. /**
  118161. * Define if the layer is only used in renderTarget or if it also
  118162. * renders in the main frame buffer of the canvas.
  118163. */
  118164. renderOnlyInRenderTargetTextures: boolean;
  118165. private _scene;
  118166. private _vertexBuffers;
  118167. private _indexBuffer;
  118168. private _effect;
  118169. private _alphaTestEffect;
  118170. /**
  118171. * An event triggered when the layer is disposed.
  118172. */
  118173. onDisposeObservable: Observable<Layer>;
  118174. private _onDisposeObserver;
  118175. /**
  118176. * Back compatibility with callback before the onDisposeObservable existed.
  118177. * The set callback will be triggered when the layer has been disposed.
  118178. */
  118179. onDispose: () => void;
  118180. /**
  118181. * An event triggered before rendering the scene
  118182. */
  118183. onBeforeRenderObservable: Observable<Layer>;
  118184. private _onBeforeRenderObserver;
  118185. /**
  118186. * Back compatibility with callback before the onBeforeRenderObservable existed.
  118187. * The set callback will be triggered just before rendering the layer.
  118188. */
  118189. onBeforeRender: () => void;
  118190. /**
  118191. * An event triggered after rendering the scene
  118192. */
  118193. onAfterRenderObservable: Observable<Layer>;
  118194. private _onAfterRenderObserver;
  118195. /**
  118196. * Back compatibility with callback before the onAfterRenderObservable existed.
  118197. * The set callback will be triggered just after rendering the layer.
  118198. */
  118199. onAfterRender: () => void;
  118200. /**
  118201. * Instantiates a new layer.
  118202. * This represents a full screen 2d layer.
  118203. * This can be useful to display a picture in the background of your scene for instance.
  118204. * @see https://www.babylonjs-playground.com/#08A2BS#1
  118205. * @param name Define the name of the layer in the scene
  118206. * @param imgUrl Define the url of the texture to display in the layer
  118207. * @param scene Define the scene the layer belongs to
  118208. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  118209. * @param color Defines a color for the layer
  118210. */
  118211. constructor(
  118212. /**
  118213. * Define the name of the layer.
  118214. */
  118215. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  118216. private _createIndexBuffer;
  118217. /** @hidden */
  118218. _rebuild(): void;
  118219. /**
  118220. * Renders the layer in the scene.
  118221. */
  118222. render(): void;
  118223. /**
  118224. * Disposes and releases the associated ressources.
  118225. */
  118226. dispose(): void;
  118227. }
  118228. }
  118229. declare module BABYLON {
  118230. /** @hidden */
  118231. export var lensFlarePixelShader: {
  118232. name: string;
  118233. shader: string;
  118234. };
  118235. }
  118236. declare module BABYLON {
  118237. /** @hidden */
  118238. export var lensFlareVertexShader: {
  118239. name: string;
  118240. shader: string;
  118241. };
  118242. }
  118243. declare module BABYLON {
  118244. /**
  118245. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118246. * It is usually composed of several `lensFlare`.
  118247. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118248. */
  118249. export class LensFlareSystem {
  118250. /**
  118251. * Define the name of the lens flare system
  118252. */
  118253. name: string;
  118254. /**
  118255. * List of lens flares used in this system.
  118256. */
  118257. lensFlares: LensFlare[];
  118258. /**
  118259. * Define a limit from the border the lens flare can be visible.
  118260. */
  118261. borderLimit: number;
  118262. /**
  118263. * Define a viewport border we do not want to see the lens flare in.
  118264. */
  118265. viewportBorder: number;
  118266. /**
  118267. * Define a predicate which could limit the list of meshes able to occlude the effect.
  118268. */
  118269. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118270. /**
  118271. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  118272. */
  118273. layerMask: number;
  118274. /**
  118275. * Define the id of the lens flare system in the scene.
  118276. * (equal to name by default)
  118277. */
  118278. id: string;
  118279. private _scene;
  118280. private _emitter;
  118281. private _vertexBuffers;
  118282. private _indexBuffer;
  118283. private _effect;
  118284. private _positionX;
  118285. private _positionY;
  118286. private _isEnabled;
  118287. /** @hidden */
  118288. static _SceneComponentInitialization: (scene: Scene) => void;
  118289. /**
  118290. * Instantiates a lens flare system.
  118291. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  118292. * It is usually composed of several `lensFlare`.
  118293. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118294. * @param name Define the name of the lens flare system in the scene
  118295. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  118296. * @param scene Define the scene the lens flare system belongs to
  118297. */
  118298. constructor(
  118299. /**
  118300. * Define the name of the lens flare system
  118301. */
  118302. name: string, emitter: any, scene: Scene);
  118303. /**
  118304. * Define if the lens flare system is enabled.
  118305. */
  118306. isEnabled: boolean;
  118307. /**
  118308. * Get the scene the effects belongs to.
  118309. * @returns the scene holding the lens flare system
  118310. */
  118311. getScene(): Scene;
  118312. /**
  118313. * Get the emitter of the lens flare system.
  118314. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118315. * @returns the emitter of the lens flare system
  118316. */
  118317. getEmitter(): any;
  118318. /**
  118319. * Set the emitter of the lens flare system.
  118320. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  118321. * @param newEmitter Define the new emitter of the system
  118322. */
  118323. setEmitter(newEmitter: any): void;
  118324. /**
  118325. * Get the lens flare system emitter position.
  118326. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  118327. * @returns the position
  118328. */
  118329. getEmitterPosition(): Vector3;
  118330. /**
  118331. * @hidden
  118332. */
  118333. computeEffectivePosition(globalViewport: Viewport): boolean;
  118334. /** @hidden */
  118335. _isVisible(): boolean;
  118336. /**
  118337. * @hidden
  118338. */
  118339. render(): boolean;
  118340. /**
  118341. * Dispose and release the lens flare with its associated resources.
  118342. */
  118343. dispose(): void;
  118344. /**
  118345. * Parse a lens flare system from a JSON repressentation
  118346. * @param parsedLensFlareSystem Define the JSON to parse
  118347. * @param scene Define the scene the parsed system should be instantiated in
  118348. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  118349. * @returns the parsed system
  118350. */
  118351. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  118352. /**
  118353. * Serialize the current Lens Flare System into a JSON representation.
  118354. * @returns the serialized JSON
  118355. */
  118356. serialize(): any;
  118357. }
  118358. }
  118359. declare module BABYLON {
  118360. /**
  118361. * This represents one of the lens effect in a `lensFlareSystem`.
  118362. * It controls one of the indiviual texture used in the effect.
  118363. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118364. */
  118365. export class LensFlare {
  118366. /**
  118367. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118368. */
  118369. size: number;
  118370. /**
  118371. * 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.
  118372. */
  118373. position: number;
  118374. /**
  118375. * Define the lens color.
  118376. */
  118377. color: Color3;
  118378. /**
  118379. * Define the lens texture.
  118380. */
  118381. texture: Nullable<Texture>;
  118382. /**
  118383. * Define the alpha mode to render this particular lens.
  118384. */
  118385. alphaMode: number;
  118386. private _system;
  118387. /**
  118388. * Creates a new Lens Flare.
  118389. * This represents one of the lens effect in a `lensFlareSystem`.
  118390. * It controls one of the indiviual texture used in the effect.
  118391. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118392. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  118393. * @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.
  118394. * @param color Define the lens color
  118395. * @param imgUrl Define the lens texture url
  118396. * @param system Define the `lensFlareSystem` this flare is part of
  118397. * @returns The newly created Lens Flare
  118398. */
  118399. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  118400. /**
  118401. * Instantiates a new Lens Flare.
  118402. * This represents one of the lens effect in a `lensFlareSystem`.
  118403. * It controls one of the indiviual texture used in the effect.
  118404. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118405. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  118406. * @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.
  118407. * @param color Define the lens color
  118408. * @param imgUrl Define the lens texture url
  118409. * @param system Define the `lensFlareSystem` this flare is part of
  118410. */
  118411. constructor(
  118412. /**
  118413. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  118414. */
  118415. size: number,
  118416. /**
  118417. * 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.
  118418. */
  118419. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  118420. /**
  118421. * Dispose and release the lens flare with its associated resources.
  118422. */
  118423. dispose(): void;
  118424. }
  118425. }
  118426. declare module BABYLON {
  118427. interface AbstractScene {
  118428. /**
  118429. * The list of lens flare system added to the scene
  118430. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  118431. */
  118432. lensFlareSystems: Array<LensFlareSystem>;
  118433. /**
  118434. * Removes the given lens flare system from this scene.
  118435. * @param toRemove The lens flare system to remove
  118436. * @returns The index of the removed lens flare system
  118437. */
  118438. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  118439. /**
  118440. * Adds the given lens flare system to this scene
  118441. * @param newLensFlareSystem The lens flare system to add
  118442. */
  118443. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  118444. /**
  118445. * Gets a lens flare system using its name
  118446. * @param name defines the name to look for
  118447. * @returns the lens flare system or null if not found
  118448. */
  118449. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  118450. /**
  118451. * Gets a lens flare system using its id
  118452. * @param id defines the id to look for
  118453. * @returns the lens flare system or null if not found
  118454. */
  118455. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  118456. }
  118457. /**
  118458. * Defines the lens flare scene component responsible to manage any lens flares
  118459. * in a given scene.
  118460. */
  118461. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  118462. /**
  118463. * The component name helpfull to identify the component in the list of scene components.
  118464. */
  118465. readonly name: string;
  118466. /**
  118467. * The scene the component belongs to.
  118468. */
  118469. scene: Scene;
  118470. /**
  118471. * Creates a new instance of the component for the given scene
  118472. * @param scene Defines the scene to register the component in
  118473. */
  118474. constructor(scene: Scene);
  118475. /**
  118476. * Registers the component in a given scene
  118477. */
  118478. register(): void;
  118479. /**
  118480. * Rebuilds the elements related to this component in case of
  118481. * context lost for instance.
  118482. */
  118483. rebuild(): void;
  118484. /**
  118485. * Adds all the elements from the container to the scene
  118486. * @param container the container holding the elements
  118487. */
  118488. addFromContainer(container: AbstractScene): void;
  118489. /**
  118490. * Removes all the elements in the container from the scene
  118491. * @param container contains the elements to remove
  118492. * @param dispose if the removed element should be disposed (default: false)
  118493. */
  118494. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118495. /**
  118496. * Serializes the component data to the specified json object
  118497. * @param serializationObject The object to serialize to
  118498. */
  118499. serialize(serializationObject: any): void;
  118500. /**
  118501. * Disposes the component and the associated ressources.
  118502. */
  118503. dispose(): void;
  118504. private _draw;
  118505. }
  118506. }
  118507. declare module BABYLON {
  118508. /**
  118509. * Defines the shadow generator component responsible to manage any shadow generators
  118510. * in a given scene.
  118511. */
  118512. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  118513. /**
  118514. * The component name helpfull to identify the component in the list of scene components.
  118515. */
  118516. readonly name: string;
  118517. /**
  118518. * The scene the component belongs to.
  118519. */
  118520. scene: Scene;
  118521. /**
  118522. * Creates a new instance of the component for the given scene
  118523. * @param scene Defines the scene to register the component in
  118524. */
  118525. constructor(scene: Scene);
  118526. /**
  118527. * Registers the component in a given scene
  118528. */
  118529. register(): void;
  118530. /**
  118531. * Rebuilds the elements related to this component in case of
  118532. * context lost for instance.
  118533. */
  118534. rebuild(): void;
  118535. /**
  118536. * Serializes the component data to the specified json object
  118537. * @param serializationObject The object to serialize to
  118538. */
  118539. serialize(serializationObject: any): void;
  118540. /**
  118541. * Adds all the elements from the container to the scene
  118542. * @param container the container holding the elements
  118543. */
  118544. addFromContainer(container: AbstractScene): void;
  118545. /**
  118546. * Removes all the elements in the container from the scene
  118547. * @param container contains the elements to remove
  118548. * @param dispose if the removed element should be disposed (default: false)
  118549. */
  118550. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118551. /**
  118552. * Rebuilds the elements related to this component in case of
  118553. * context lost for instance.
  118554. */
  118555. dispose(): void;
  118556. private _gatherRenderTargets;
  118557. }
  118558. }
  118559. declare module BABYLON {
  118560. /**
  118561. * A point light is a light defined by an unique point in world space.
  118562. * The light is emitted in every direction from this point.
  118563. * A good example of a point light is a standard light bulb.
  118564. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118565. */
  118566. export class PointLight extends ShadowLight {
  118567. private _shadowAngle;
  118568. /**
  118569. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118570. * This specifies what angle the shadow will use to be created.
  118571. *
  118572. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118573. */
  118574. /**
  118575. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118576. * This specifies what angle the shadow will use to be created.
  118577. *
  118578. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  118579. */
  118580. shadowAngle: number;
  118581. /**
  118582. * Gets the direction if it has been set.
  118583. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118584. */
  118585. /**
  118586. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  118587. */
  118588. direction: Vector3;
  118589. /**
  118590. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  118591. * A PointLight emits the light in every direction.
  118592. * It can cast shadows.
  118593. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  118594. * ```javascript
  118595. * var pointLight = new PointLight("pl", camera.position, scene);
  118596. * ```
  118597. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118598. * @param name The light friendly name
  118599. * @param position The position of the point light in the scene
  118600. * @param scene The scene the lights belongs to
  118601. */
  118602. constructor(name: string, position: Vector3, scene: Scene);
  118603. /**
  118604. * Returns the string "PointLight"
  118605. * @returns the class name
  118606. */
  118607. getClassName(): string;
  118608. /**
  118609. * Returns the integer 0.
  118610. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118611. */
  118612. getTypeID(): number;
  118613. /**
  118614. * Specifies wether or not the shadowmap should be a cube texture.
  118615. * @returns true if the shadowmap needs to be a cube texture.
  118616. */
  118617. needCube(): boolean;
  118618. /**
  118619. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  118620. * @param faceIndex The index of the face we are computed the direction to generate shadow
  118621. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  118622. */
  118623. getShadowDirection(faceIndex?: number): Vector3;
  118624. /**
  118625. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  118626. * - fov = PI / 2
  118627. * - aspect ratio : 1.0
  118628. * - z-near and far equal to the active camera minZ and maxZ.
  118629. * Returns the PointLight.
  118630. */
  118631. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118632. protected _buildUniformLayout(): void;
  118633. /**
  118634. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  118635. * @param effect The effect to update
  118636. * @param lightIndex The index of the light in the effect to update
  118637. * @returns The point light
  118638. */
  118639. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  118640. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118641. /**
  118642. * Prepares the list of defines specific to the light type.
  118643. * @param defines the list of defines
  118644. * @param lightIndex defines the index of the light for the effect
  118645. */
  118646. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118647. }
  118648. }
  118649. declare module BABYLON {
  118650. /**
  118651. * Header information of HDR texture files.
  118652. */
  118653. export interface HDRInfo {
  118654. /**
  118655. * The height of the texture in pixels.
  118656. */
  118657. height: number;
  118658. /**
  118659. * The width of the texture in pixels.
  118660. */
  118661. width: number;
  118662. /**
  118663. * The index of the beginning of the data in the binary file.
  118664. */
  118665. dataPosition: number;
  118666. }
  118667. /**
  118668. * This groups tools to convert HDR texture to native colors array.
  118669. */
  118670. export class HDRTools {
  118671. private static Ldexp;
  118672. private static Rgbe2float;
  118673. private static readStringLine;
  118674. /**
  118675. * Reads header information from an RGBE texture stored in a native array.
  118676. * More information on this format are available here:
  118677. * https://en.wikipedia.org/wiki/RGBE_image_format
  118678. *
  118679. * @param uint8array The binary file stored in native array.
  118680. * @return The header information.
  118681. */
  118682. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  118683. /**
  118684. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  118685. * This RGBE texture needs to store the information as a panorama.
  118686. *
  118687. * More information on this format are available here:
  118688. * https://en.wikipedia.org/wiki/RGBE_image_format
  118689. *
  118690. * @param buffer The binary file stored in an array buffer.
  118691. * @param size The expected size of the extracted cubemap.
  118692. * @return The Cube Map information.
  118693. */
  118694. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  118695. /**
  118696. * Returns the pixels data extracted from an RGBE texture.
  118697. * This pixels will be stored left to right up to down in the R G B order in one array.
  118698. *
  118699. * More information on this format are available here:
  118700. * https://en.wikipedia.org/wiki/RGBE_image_format
  118701. *
  118702. * @param uint8array The binary file stored in an array buffer.
  118703. * @param hdrInfo The header information of the file.
  118704. * @return The pixels data in RGB right to left up to down order.
  118705. */
  118706. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  118707. private static RGBE_ReadPixels_RLE;
  118708. }
  118709. }
  118710. declare module BABYLON {
  118711. /**
  118712. * This represents a texture coming from an HDR input.
  118713. *
  118714. * The only supported format is currently panorama picture stored in RGBE format.
  118715. * Example of such files can be found on HDRLib: http://hdrlib.com/
  118716. */
  118717. export class HDRCubeTexture extends BaseTexture {
  118718. private static _facesMapping;
  118719. private _generateHarmonics;
  118720. private _noMipmap;
  118721. private _textureMatrix;
  118722. private _size;
  118723. private _onLoad;
  118724. private _onError;
  118725. /**
  118726. * The texture URL.
  118727. */
  118728. url: string;
  118729. /**
  118730. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  118731. */
  118732. coordinatesMode: number;
  118733. protected _isBlocking: boolean;
  118734. /**
  118735. * Sets wether or not the texture is blocking during loading.
  118736. */
  118737. /**
  118738. * Gets wether or not the texture is blocking during loading.
  118739. */
  118740. isBlocking: boolean;
  118741. protected _rotationY: number;
  118742. /**
  118743. * Sets texture matrix rotation angle around Y axis in radians.
  118744. */
  118745. /**
  118746. * Gets texture matrix rotation angle around Y axis radians.
  118747. */
  118748. rotationY: number;
  118749. /**
  118750. * Gets or sets the center of the bounding box associated with the cube texture
  118751. * It must define where the camera used to render the texture was set
  118752. */
  118753. boundingBoxPosition: Vector3;
  118754. private _boundingBoxSize;
  118755. /**
  118756. * Gets or sets the size of the bounding box associated with the cube texture
  118757. * When defined, the cubemap will switch to local mode
  118758. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  118759. * @example https://www.babylonjs-playground.com/#RNASML
  118760. */
  118761. boundingBoxSize: Vector3;
  118762. /**
  118763. * Instantiates an HDRTexture from the following parameters.
  118764. *
  118765. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  118766. * @param scene The scene the texture will be used in
  118767. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118768. * @param noMipmap Forces to not generate the mipmap if true
  118769. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  118770. * @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)
  118771. * @param reserved Reserved flag for internal use.
  118772. */
  118773. 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>);
  118774. /**
  118775. * Get the current class name of the texture useful for serialization or dynamic coding.
  118776. * @returns "HDRCubeTexture"
  118777. */
  118778. getClassName(): string;
  118779. /**
  118780. * Occurs when the file is raw .hdr file.
  118781. */
  118782. private loadTexture;
  118783. clone(): HDRCubeTexture;
  118784. delayLoad(): void;
  118785. /**
  118786. * Get the texture reflection matrix used to rotate/transform the reflection.
  118787. * @returns the reflection matrix
  118788. */
  118789. getReflectionTextureMatrix(): Matrix;
  118790. /**
  118791. * Set the texture reflection matrix used to rotate/transform the reflection.
  118792. * @param value Define the reflection matrix to set
  118793. */
  118794. setReflectionTextureMatrix(value: Matrix): void;
  118795. /**
  118796. * Parses a JSON representation of an HDR Texture in order to create the texture
  118797. * @param parsedTexture Define the JSON representation
  118798. * @param scene Define the scene the texture should be created in
  118799. * @param rootUrl Define the root url in case we need to load relative dependencies
  118800. * @returns the newly created texture after parsing
  118801. */
  118802. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  118803. serialize(): any;
  118804. }
  118805. }
  118806. declare module BABYLON {
  118807. /**
  118808. * Class used to control physics engine
  118809. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  118810. */
  118811. export class PhysicsEngine implements IPhysicsEngine {
  118812. private _physicsPlugin;
  118813. /**
  118814. * Global value used to control the smallest number supported by the simulation
  118815. */
  118816. static Epsilon: number;
  118817. private _impostors;
  118818. private _joints;
  118819. /**
  118820. * Gets the gravity vector used by the simulation
  118821. */
  118822. gravity: Vector3;
  118823. /**
  118824. * Factory used to create the default physics plugin.
  118825. * @returns The default physics plugin
  118826. */
  118827. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  118828. /**
  118829. * Creates a new Physics Engine
  118830. * @param gravity defines the gravity vector used by the simulation
  118831. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  118832. */
  118833. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  118834. /**
  118835. * Sets the gravity vector used by the simulation
  118836. * @param gravity defines the gravity vector to use
  118837. */
  118838. setGravity(gravity: Vector3): void;
  118839. /**
  118840. * Set the time step of the physics engine.
  118841. * Default is 1/60.
  118842. * To slow it down, enter 1/600 for example.
  118843. * To speed it up, 1/30
  118844. * @param newTimeStep defines the new timestep to apply to this world.
  118845. */
  118846. setTimeStep(newTimeStep?: number): void;
  118847. /**
  118848. * Get the time step of the physics engine.
  118849. * @returns the current time step
  118850. */
  118851. getTimeStep(): number;
  118852. /**
  118853. * Release all resources
  118854. */
  118855. dispose(): void;
  118856. /**
  118857. * Gets the name of the current physics plugin
  118858. * @returns the name of the plugin
  118859. */
  118860. getPhysicsPluginName(): string;
  118861. /**
  118862. * Adding a new impostor for the impostor tracking.
  118863. * This will be done by the impostor itself.
  118864. * @param impostor the impostor to add
  118865. */
  118866. addImpostor(impostor: PhysicsImpostor): void;
  118867. /**
  118868. * Remove an impostor from the engine.
  118869. * This impostor and its mesh will not longer be updated by the physics engine.
  118870. * @param impostor the impostor to remove
  118871. */
  118872. removeImpostor(impostor: PhysicsImpostor): void;
  118873. /**
  118874. * Add a joint to the physics engine
  118875. * @param mainImpostor defines the main impostor to which the joint is added.
  118876. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  118877. * @param joint defines the joint that will connect both impostors.
  118878. */
  118879. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118880. /**
  118881. * Removes a joint from the simulation
  118882. * @param mainImpostor defines the impostor used with the joint
  118883. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  118884. * @param joint defines the joint to remove
  118885. */
  118886. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  118887. /**
  118888. * Called by the scene. No need to call it.
  118889. * @param delta defines the timespam between frames
  118890. */
  118891. _step(delta: number): void;
  118892. /**
  118893. * Gets the current plugin used to run the simulation
  118894. * @returns current plugin
  118895. */
  118896. getPhysicsPlugin(): IPhysicsEnginePlugin;
  118897. /**
  118898. * Gets the list of physic impostors
  118899. * @returns an array of PhysicsImpostor
  118900. */
  118901. getImpostors(): Array<PhysicsImpostor>;
  118902. /**
  118903. * Gets the impostor for a physics enabled object
  118904. * @param object defines the object impersonated by the impostor
  118905. * @returns the PhysicsImpostor or null if not found
  118906. */
  118907. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  118908. /**
  118909. * Gets the impostor for a physics body object
  118910. * @param body defines physics body used by the impostor
  118911. * @returns the PhysicsImpostor or null if not found
  118912. */
  118913. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  118914. /**
  118915. * Does a raycast in the physics world
  118916. * @param from when should the ray start?
  118917. * @param to when should the ray end?
  118918. * @returns PhysicsRaycastResult
  118919. */
  118920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118921. }
  118922. }
  118923. declare module BABYLON {
  118924. /** @hidden */
  118925. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  118926. private _useDeltaForWorldStep;
  118927. world: any;
  118928. name: string;
  118929. private _physicsMaterials;
  118930. private _fixedTimeStep;
  118931. private _cannonRaycastResult;
  118932. private _raycastResult;
  118933. private _physicsBodysToRemoveAfterStep;
  118934. BJSCANNON: any;
  118935. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  118936. setGravity(gravity: Vector3): void;
  118937. setTimeStep(timeStep: number): void;
  118938. getTimeStep(): number;
  118939. executeStep(delta: number): void;
  118940. private _removeMarkedPhysicsBodiesFromWorld;
  118941. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118942. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118943. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118944. private _processChildMeshes;
  118945. removePhysicsBody(impostor: PhysicsImpostor): void;
  118946. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118947. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118948. private _addMaterial;
  118949. private _checkWithEpsilon;
  118950. private _createShape;
  118951. private _createHeightmap;
  118952. private _minus90X;
  118953. private _plus90X;
  118954. private _tmpPosition;
  118955. private _tmpDeltaPosition;
  118956. private _tmpUnityRotation;
  118957. private _updatePhysicsBodyTransformation;
  118958. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118959. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118960. isSupported(): boolean;
  118961. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118962. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118963. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118964. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118965. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118966. getBodyMass(impostor: PhysicsImpostor): number;
  118967. getBodyFriction(impostor: PhysicsImpostor): number;
  118968. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118969. getBodyRestitution(impostor: PhysicsImpostor): number;
  118970. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118971. sleepBody(impostor: PhysicsImpostor): void;
  118972. wakeUpBody(impostor: PhysicsImpostor): void;
  118973. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  118974. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118975. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118976. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118977. getRadius(impostor: PhysicsImpostor): number;
  118978. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118979. dispose(): void;
  118980. private _extendNamespace;
  118981. /**
  118982. * Does a raycast in the physics world
  118983. * @param from when should the ray start?
  118984. * @param to when should the ray end?
  118985. * @returns PhysicsRaycastResult
  118986. */
  118987. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118988. }
  118989. }
  118990. declare module BABYLON {
  118991. /** @hidden */
  118992. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  118993. world: any;
  118994. name: string;
  118995. BJSOIMO: any;
  118996. private _raycastResult;
  118997. constructor(iterations?: number, oimoInjection?: any);
  118998. setGravity(gravity: Vector3): void;
  118999. setTimeStep(timeStep: number): void;
  119000. getTimeStep(): number;
  119001. private _tmpImpostorsArray;
  119002. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119003. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119004. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119005. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119006. private _tmpPositionVector;
  119007. removePhysicsBody(impostor: PhysicsImpostor): void;
  119008. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119009. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119010. isSupported(): boolean;
  119011. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119012. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119013. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119014. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119015. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119016. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119017. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119018. getBodyMass(impostor: PhysicsImpostor): number;
  119019. getBodyFriction(impostor: PhysicsImpostor): number;
  119020. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119021. getBodyRestitution(impostor: PhysicsImpostor): number;
  119022. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119023. sleepBody(impostor: PhysicsImpostor): void;
  119024. wakeUpBody(impostor: PhysicsImpostor): void;
  119025. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119026. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  119027. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  119028. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119029. getRadius(impostor: PhysicsImpostor): number;
  119030. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119031. dispose(): void;
  119032. /**
  119033. * Does a raycast in the physics world
  119034. * @param from when should the ray start?
  119035. * @param to when should the ray end?
  119036. * @returns PhysicsRaycastResult
  119037. */
  119038. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119039. }
  119040. }
  119041. declare module BABYLON {
  119042. /**
  119043. * Class containing static functions to help procedurally build meshes
  119044. */
  119045. export class RibbonBuilder {
  119046. /**
  119047. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  119048. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  119049. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  119050. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  119051. * * 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
  119052. * * 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
  119053. * * 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
  119054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119056. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119057. * * 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
  119058. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  119059. * * 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
  119060. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  119061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119062. * @param name defines the name of the mesh
  119063. * @param options defines the options used to create the mesh
  119064. * @param scene defines the hosting scene
  119065. * @returns the ribbon mesh
  119066. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  119067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119068. */
  119069. static CreateRibbon(name: string, options: {
  119070. pathArray: Vector3[][];
  119071. closeArray?: boolean;
  119072. closePath?: boolean;
  119073. offset?: number;
  119074. updatable?: boolean;
  119075. sideOrientation?: number;
  119076. frontUVs?: Vector4;
  119077. backUVs?: Vector4;
  119078. instance?: Mesh;
  119079. invertUV?: boolean;
  119080. uvs?: Vector2[];
  119081. colors?: Color4[];
  119082. }, scene?: Nullable<Scene>): Mesh;
  119083. }
  119084. }
  119085. declare module BABYLON {
  119086. /**
  119087. * Class containing static functions to help procedurally build meshes
  119088. */
  119089. export class ShapeBuilder {
  119090. /**
  119091. * 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.
  119092. * * 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.
  119093. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119094. * * 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.
  119095. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  119096. * * 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
  119097. * * 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
  119098. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  119099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  119102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  119103. * @param name defines the name of the mesh
  119104. * @param options defines the options used to create the mesh
  119105. * @param scene defines the hosting scene
  119106. * @returns the extruded shape mesh
  119107. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119109. */
  119110. static ExtrudeShape(name: string, options: {
  119111. shape: Vector3[];
  119112. path: Vector3[];
  119113. scale?: number;
  119114. rotation?: number;
  119115. cap?: number;
  119116. updatable?: boolean;
  119117. sideOrientation?: number;
  119118. frontUVs?: Vector4;
  119119. backUVs?: Vector4;
  119120. instance?: Mesh;
  119121. invertUV?: boolean;
  119122. }, scene?: Nullable<Scene>): Mesh;
  119123. /**
  119124. * Creates an custom extruded shape mesh.
  119125. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  119126. * * 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.
  119127. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  119128. * * 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
  119129. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  119130. * * 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
  119131. * * It must returns a float value that will be the scale value applied to the shape on each path point
  119132. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  119133. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  119134. * * 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
  119135. * * 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
  119136. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  119137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119139. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  119140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119141. * @param name defines the name of the mesh
  119142. * @param options defines the options used to create the mesh
  119143. * @param scene defines the hosting scene
  119144. * @returns the custom extruded shape mesh
  119145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  119146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  119147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  119148. */
  119149. static ExtrudeShapeCustom(name: string, options: {
  119150. shape: Vector3[];
  119151. path: Vector3[];
  119152. scaleFunction?: any;
  119153. rotationFunction?: any;
  119154. ribbonCloseArray?: boolean;
  119155. ribbonClosePath?: boolean;
  119156. cap?: number;
  119157. updatable?: boolean;
  119158. sideOrientation?: number;
  119159. frontUVs?: Vector4;
  119160. backUVs?: Vector4;
  119161. instance?: Mesh;
  119162. invertUV?: boolean;
  119163. }, scene?: Nullable<Scene>): Mesh;
  119164. private static _ExtrudeShapeGeneric;
  119165. }
  119166. }
  119167. declare module BABYLON {
  119168. /**
  119169. * AmmoJS Physics plugin
  119170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  119171. * @see https://github.com/kripken/ammo.js/
  119172. */
  119173. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  119174. private _useDeltaForWorldStep;
  119175. /**
  119176. * Reference to the Ammo library
  119177. */
  119178. bjsAMMO: any;
  119179. /**
  119180. * Created ammoJS world which physics bodies are added to
  119181. */
  119182. world: any;
  119183. /**
  119184. * Name of the plugin
  119185. */
  119186. name: string;
  119187. private _timeStep;
  119188. private _fixedTimeStep;
  119189. private _maxSteps;
  119190. private _tmpQuaternion;
  119191. private _tmpAmmoTransform;
  119192. private _tmpAmmoQuaternion;
  119193. private _tmpAmmoConcreteContactResultCallback;
  119194. private _collisionConfiguration;
  119195. private _dispatcher;
  119196. private _overlappingPairCache;
  119197. private _solver;
  119198. private _softBodySolver;
  119199. private _tmpAmmoVectorA;
  119200. private _tmpAmmoVectorB;
  119201. private _tmpAmmoVectorC;
  119202. private _tmpAmmoVectorD;
  119203. private _tmpContactCallbackResult;
  119204. private _tmpAmmoVectorRCA;
  119205. private _tmpAmmoVectorRCB;
  119206. private _raycastResult;
  119207. private static readonly DISABLE_COLLISION_FLAG;
  119208. private static readonly KINEMATIC_FLAG;
  119209. private static readonly DISABLE_DEACTIVATION_FLAG;
  119210. /**
  119211. * Initializes the ammoJS plugin
  119212. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  119213. * @param ammoInjection can be used to inject your own ammo reference
  119214. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  119215. */
  119216. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  119217. /**
  119218. * Sets the gravity of the physics world (m/(s^2))
  119219. * @param gravity Gravity to set
  119220. */
  119221. setGravity(gravity: Vector3): void;
  119222. /**
  119223. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  119224. * @param timeStep timestep to use in seconds
  119225. */
  119226. setTimeStep(timeStep: number): void;
  119227. /**
  119228. * 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)
  119229. * @param fixedTimeStep fixedTimeStep to use in seconds
  119230. */
  119231. setFixedTimeStep(fixedTimeStep: number): void;
  119232. /**
  119233. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  119234. * @param maxSteps the maximum number of steps by the physics engine per frame
  119235. */
  119236. setMaxSteps(maxSteps: number): void;
  119237. /**
  119238. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  119239. * @returns the current timestep in seconds
  119240. */
  119241. getTimeStep(): number;
  119242. private _isImpostorInContact;
  119243. private _isImpostorPairInContact;
  119244. private _stepSimulation;
  119245. /**
  119246. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  119247. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  119248. * After the step the babylon meshes are set to the position of the physics imposters
  119249. * @param delta amount of time to step forward
  119250. * @param impostors array of imposters to update before/after the step
  119251. */
  119252. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  119253. /**
  119254. * Update babylon mesh to match physics world object
  119255. * @param impostor imposter to match
  119256. */
  119257. private _afterSoftStep;
  119258. /**
  119259. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119260. * @param impostor imposter to match
  119261. */
  119262. private _ropeStep;
  119263. /**
  119264. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  119265. * @param impostor imposter to match
  119266. */
  119267. private _softbodyOrClothStep;
  119268. private _tmpVector;
  119269. private _tmpMatrix;
  119270. /**
  119271. * Applies an impulse on the imposter
  119272. * @param impostor imposter to apply impulse to
  119273. * @param force amount of force to be applied to the imposter
  119274. * @param contactPoint the location to apply the impulse on the imposter
  119275. */
  119276. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119277. /**
  119278. * Applies a force on the imposter
  119279. * @param impostor imposter to apply force
  119280. * @param force amount of force to be applied to the imposter
  119281. * @param contactPoint the location to apply the force on the imposter
  119282. */
  119283. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  119284. /**
  119285. * Creates a physics body using the plugin
  119286. * @param impostor the imposter to create the physics body on
  119287. */
  119288. generatePhysicsBody(impostor: PhysicsImpostor): void;
  119289. /**
  119290. * Removes the physics body from the imposter and disposes of the body's memory
  119291. * @param impostor imposter to remove the physics body from
  119292. */
  119293. removePhysicsBody(impostor: PhysicsImpostor): void;
  119294. /**
  119295. * Generates a joint
  119296. * @param impostorJoint the imposter joint to create the joint with
  119297. */
  119298. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  119299. /**
  119300. * Removes a joint
  119301. * @param impostorJoint the imposter joint to remove the joint from
  119302. */
  119303. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  119304. private _addMeshVerts;
  119305. /**
  119306. * Initialise the soft body vertices to match its object's (mesh) vertices
  119307. * Softbody vertices (nodes) are in world space and to match this
  119308. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  119309. * @param impostor to create the softbody for
  119310. */
  119311. private _softVertexData;
  119312. /**
  119313. * Create an impostor's soft body
  119314. * @param impostor to create the softbody for
  119315. */
  119316. private _createSoftbody;
  119317. /**
  119318. * Create cloth for an impostor
  119319. * @param impostor to create the softbody for
  119320. */
  119321. private _createCloth;
  119322. /**
  119323. * Create rope for an impostor
  119324. * @param impostor to create the softbody for
  119325. */
  119326. private _createRope;
  119327. private _addHullVerts;
  119328. private _createShape;
  119329. /**
  119330. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  119331. * @param impostor imposter containing the physics body and babylon object
  119332. */
  119333. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  119334. /**
  119335. * Sets the babylon object's position/rotation from the physics body's position/rotation
  119336. * @param impostor imposter containing the physics body and babylon object
  119337. * @param newPosition new position
  119338. * @param newRotation new rotation
  119339. */
  119340. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  119341. /**
  119342. * If this plugin is supported
  119343. * @returns true if its supported
  119344. */
  119345. isSupported(): boolean;
  119346. /**
  119347. * Sets the linear velocity of the physics body
  119348. * @param impostor imposter to set the velocity on
  119349. * @param velocity velocity to set
  119350. */
  119351. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119352. /**
  119353. * Sets the angular velocity of the physics body
  119354. * @param impostor imposter to set the velocity on
  119355. * @param velocity velocity to set
  119356. */
  119357. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  119358. /**
  119359. * gets the linear velocity
  119360. * @param impostor imposter to get linear velocity from
  119361. * @returns linear velocity
  119362. */
  119363. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119364. /**
  119365. * gets the angular velocity
  119366. * @param impostor imposter to get angular velocity from
  119367. * @returns angular velocity
  119368. */
  119369. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  119370. /**
  119371. * Sets the mass of physics body
  119372. * @param impostor imposter to set the mass on
  119373. * @param mass mass to set
  119374. */
  119375. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  119376. /**
  119377. * Gets the mass of the physics body
  119378. * @param impostor imposter to get the mass from
  119379. * @returns mass
  119380. */
  119381. getBodyMass(impostor: PhysicsImpostor): number;
  119382. /**
  119383. * Gets friction of the impostor
  119384. * @param impostor impostor to get friction from
  119385. * @returns friction value
  119386. */
  119387. getBodyFriction(impostor: PhysicsImpostor): number;
  119388. /**
  119389. * Sets friction of the impostor
  119390. * @param impostor impostor to set friction on
  119391. * @param friction friction value
  119392. */
  119393. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  119394. /**
  119395. * Gets restitution of the impostor
  119396. * @param impostor impostor to get restitution from
  119397. * @returns restitution value
  119398. */
  119399. getBodyRestitution(impostor: PhysicsImpostor): number;
  119400. /**
  119401. * Sets resitution of the impostor
  119402. * @param impostor impostor to set resitution on
  119403. * @param restitution resitution value
  119404. */
  119405. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  119406. /**
  119407. * Gets pressure inside the impostor
  119408. * @param impostor impostor to get pressure from
  119409. * @returns pressure value
  119410. */
  119411. getBodyPressure(impostor: PhysicsImpostor): number;
  119412. /**
  119413. * Sets pressure inside a soft body impostor
  119414. * Cloth and rope must remain 0 pressure
  119415. * @param impostor impostor to set pressure on
  119416. * @param pressure pressure value
  119417. */
  119418. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  119419. /**
  119420. * Gets stiffness of the impostor
  119421. * @param impostor impostor to get stiffness from
  119422. * @returns pressure value
  119423. */
  119424. getBodyStiffness(impostor: PhysicsImpostor): number;
  119425. /**
  119426. * Sets stiffness of the impostor
  119427. * @param impostor impostor to set stiffness on
  119428. * @param stiffness stiffness value from 0 to 1
  119429. */
  119430. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  119431. /**
  119432. * Gets velocityIterations of the impostor
  119433. * @param impostor impostor to get velocity iterations from
  119434. * @returns velocityIterations value
  119435. */
  119436. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  119437. /**
  119438. * Sets velocityIterations of the impostor
  119439. * @param impostor impostor to set velocity iterations on
  119440. * @param velocityIterations velocityIterations value
  119441. */
  119442. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  119443. /**
  119444. * Gets positionIterations of the impostor
  119445. * @param impostor impostor to get position iterations from
  119446. * @returns positionIterations value
  119447. */
  119448. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  119449. /**
  119450. * Sets positionIterations of the impostor
  119451. * @param impostor impostor to set position on
  119452. * @param positionIterations positionIterations value
  119453. */
  119454. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  119455. /**
  119456. * Append an anchor to a cloth object
  119457. * @param impostor is the cloth impostor to add anchor to
  119458. * @param otherImpostor is the rigid impostor to anchor to
  119459. * @param width ratio across width from 0 to 1
  119460. * @param height ratio up height from 0 to 1
  119461. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  119462. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119463. */
  119464. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119465. /**
  119466. * Append an hook to a rope object
  119467. * @param impostor is the rope impostor to add hook to
  119468. * @param otherImpostor is the rigid impostor to hook to
  119469. * @param length ratio along the rope from 0 to 1
  119470. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  119471. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  119472. */
  119473. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  119474. /**
  119475. * Sleeps the physics body and stops it from being active
  119476. * @param impostor impostor to sleep
  119477. */
  119478. sleepBody(impostor: PhysicsImpostor): void;
  119479. /**
  119480. * Activates the physics body
  119481. * @param impostor impostor to activate
  119482. */
  119483. wakeUpBody(impostor: PhysicsImpostor): void;
  119484. /**
  119485. * Updates the distance parameters of the joint
  119486. * @param joint joint to update
  119487. * @param maxDistance maximum distance of the joint
  119488. * @param minDistance minimum distance of the joint
  119489. */
  119490. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  119491. /**
  119492. * Sets a motor on the joint
  119493. * @param joint joint to set motor on
  119494. * @param speed speed of the motor
  119495. * @param maxForce maximum force of the motor
  119496. * @param motorIndex index of the motor
  119497. */
  119498. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  119499. /**
  119500. * Sets the motors limit
  119501. * @param joint joint to set limit on
  119502. * @param upperLimit upper limit
  119503. * @param lowerLimit lower limit
  119504. */
  119505. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  119506. /**
  119507. * Syncs the position and rotation of a mesh with the impostor
  119508. * @param mesh mesh to sync
  119509. * @param impostor impostor to update the mesh with
  119510. */
  119511. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  119512. /**
  119513. * Gets the radius of the impostor
  119514. * @param impostor impostor to get radius from
  119515. * @returns the radius
  119516. */
  119517. getRadius(impostor: PhysicsImpostor): number;
  119518. /**
  119519. * Gets the box size of the impostor
  119520. * @param impostor impostor to get box size from
  119521. * @param result the resulting box size
  119522. */
  119523. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  119524. /**
  119525. * Disposes of the impostor
  119526. */
  119527. dispose(): void;
  119528. /**
  119529. * Does a raycast in the physics world
  119530. * @param from when should the ray start?
  119531. * @param to when should the ray end?
  119532. * @returns PhysicsRaycastResult
  119533. */
  119534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  119535. }
  119536. }
  119537. declare module BABYLON {
  119538. interface AbstractScene {
  119539. /**
  119540. * The list of reflection probes added to the scene
  119541. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119542. */
  119543. reflectionProbes: Array<ReflectionProbe>;
  119544. /**
  119545. * Removes the given reflection probe from this scene.
  119546. * @param toRemove The reflection probe to remove
  119547. * @returns The index of the removed reflection probe
  119548. */
  119549. removeReflectionProbe(toRemove: ReflectionProbe): number;
  119550. /**
  119551. * Adds the given reflection probe to this scene.
  119552. * @param newReflectionProbe The reflection probe to add
  119553. */
  119554. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  119555. }
  119556. /**
  119557. * Class used to generate realtime reflection / refraction cube textures
  119558. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  119559. */
  119560. export class ReflectionProbe {
  119561. /** defines the name of the probe */
  119562. name: string;
  119563. private _scene;
  119564. private _renderTargetTexture;
  119565. private _projectionMatrix;
  119566. private _viewMatrix;
  119567. private _target;
  119568. private _add;
  119569. private _attachedMesh;
  119570. private _invertYAxis;
  119571. /** Gets or sets probe position (center of the cube map) */
  119572. position: Vector3;
  119573. /**
  119574. * Creates a new reflection probe
  119575. * @param name defines the name of the probe
  119576. * @param size defines the texture resolution (for each face)
  119577. * @param scene defines the hosting scene
  119578. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  119579. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  119580. */
  119581. constructor(
  119582. /** defines the name of the probe */
  119583. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  119584. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  119585. samples: number;
  119586. /** Gets or sets the refresh rate to use (on every frame by default) */
  119587. refreshRate: number;
  119588. /**
  119589. * Gets the hosting scene
  119590. * @returns a Scene
  119591. */
  119592. getScene(): Scene;
  119593. /** Gets the internal CubeTexture used to render to */
  119594. readonly cubeTexture: RenderTargetTexture;
  119595. /** Gets the list of meshes to render */
  119596. readonly renderList: Nullable<AbstractMesh[]>;
  119597. /**
  119598. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  119599. * @param mesh defines the mesh to attach to
  119600. */
  119601. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119602. /**
  119603. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  119604. * @param renderingGroupId The rendering group id corresponding to its index
  119605. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119606. */
  119607. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119608. /**
  119609. * Clean all associated resources
  119610. */
  119611. dispose(): void;
  119612. /**
  119613. * Converts the reflection probe information to a readable string for debug purpose.
  119614. * @param fullDetails Supports for multiple levels of logging within scene loading
  119615. * @returns the human readable reflection probe info
  119616. */
  119617. toString(fullDetails?: boolean): string;
  119618. /**
  119619. * Get the class name of the relfection probe.
  119620. * @returns "ReflectionProbe"
  119621. */
  119622. getClassName(): string;
  119623. /**
  119624. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  119625. * @returns The JSON representation of the texture
  119626. */
  119627. serialize(): any;
  119628. /**
  119629. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  119630. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  119631. * @param scene Define the scene the parsed reflection probe should be instantiated in
  119632. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  119633. * @returns The parsed reflection probe if successful
  119634. */
  119635. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  119636. }
  119637. }
  119638. declare module BABYLON {
  119639. /** @hidden */
  119640. export var _BabylonLoaderRegistered: boolean;
  119641. }
  119642. declare module BABYLON {
  119643. /**
  119644. * The Physically based simple base material of BJS.
  119645. *
  119646. * This enables better naming and convention enforcements on top of the pbrMaterial.
  119647. * It is used as the base class for both the specGloss and metalRough conventions.
  119648. */
  119649. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  119650. /**
  119651. * Number of Simultaneous lights allowed on the material.
  119652. */
  119653. maxSimultaneousLights: number;
  119654. /**
  119655. * If sets to true, disables all the lights affecting the material.
  119656. */
  119657. disableLighting: boolean;
  119658. /**
  119659. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  119660. */
  119661. environmentTexture: BaseTexture;
  119662. /**
  119663. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  119664. */
  119665. invertNormalMapX: boolean;
  119666. /**
  119667. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  119668. */
  119669. invertNormalMapY: boolean;
  119670. /**
  119671. * Normal map used in the model.
  119672. */
  119673. normalTexture: BaseTexture;
  119674. /**
  119675. * Emissivie color used to self-illuminate the model.
  119676. */
  119677. emissiveColor: Color3;
  119678. /**
  119679. * Emissivie texture used to self-illuminate the model.
  119680. */
  119681. emissiveTexture: BaseTexture;
  119682. /**
  119683. * Occlusion Channel Strenght.
  119684. */
  119685. occlusionStrength: number;
  119686. /**
  119687. * Occlusion Texture of the material (adding extra occlusion effects).
  119688. */
  119689. occlusionTexture: BaseTexture;
  119690. /**
  119691. * Defines the alpha limits in alpha test mode.
  119692. */
  119693. alphaCutOff: number;
  119694. /**
  119695. * Gets the current double sided mode.
  119696. */
  119697. /**
  119698. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  119699. */
  119700. doubleSided: boolean;
  119701. /**
  119702. * Stores the pre-calculated light information of a mesh in a texture.
  119703. */
  119704. lightmapTexture: BaseTexture;
  119705. /**
  119706. * If true, the light map contains occlusion information instead of lighting info.
  119707. */
  119708. useLightmapAsShadowmap: boolean;
  119709. /**
  119710. * Instantiates a new PBRMaterial instance.
  119711. *
  119712. * @param name The material name
  119713. * @param scene The scene the material will be use in.
  119714. */
  119715. constructor(name: string, scene: Scene);
  119716. getClassName(): string;
  119717. }
  119718. }
  119719. declare module BABYLON {
  119720. /**
  119721. * The PBR material of BJS following the metal roughness convention.
  119722. *
  119723. * This fits to the PBR convention in the GLTF definition:
  119724. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  119725. */
  119726. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  119727. /**
  119728. * The base color has two different interpretations depending on the value of metalness.
  119729. * When the material is a metal, the base color is the specific measured reflectance value
  119730. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  119731. * of the material.
  119732. */
  119733. baseColor: Color3;
  119734. /**
  119735. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  119736. * well as opacity information in the alpha channel.
  119737. */
  119738. baseTexture: BaseTexture;
  119739. /**
  119740. * Specifies the metallic scalar value of the material.
  119741. * Can also be used to scale the metalness values of the metallic texture.
  119742. */
  119743. metallic: number;
  119744. /**
  119745. * Specifies the roughness scalar value of the material.
  119746. * Can also be used to scale the roughness values of the metallic texture.
  119747. */
  119748. roughness: number;
  119749. /**
  119750. * Texture containing both the metallic value in the B channel and the
  119751. * roughness value in the G channel to keep better precision.
  119752. */
  119753. metallicRoughnessTexture: BaseTexture;
  119754. /**
  119755. * Instantiates a new PBRMetalRoughnessMaterial instance.
  119756. *
  119757. * @param name The material name
  119758. * @param scene The scene the material will be use in.
  119759. */
  119760. constructor(name: string, scene: Scene);
  119761. /**
  119762. * Return the currrent class name of the material.
  119763. */
  119764. getClassName(): string;
  119765. /**
  119766. * Makes a duplicate of the current material.
  119767. * @param name - name to use for the new material.
  119768. */
  119769. clone(name: string): PBRMetallicRoughnessMaterial;
  119770. /**
  119771. * Serialize the material to a parsable JSON object.
  119772. */
  119773. serialize(): any;
  119774. /**
  119775. * Parses a JSON object correponding to the serialize function.
  119776. */
  119777. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  119778. }
  119779. }
  119780. declare module BABYLON {
  119781. /**
  119782. * The PBR material of BJS following the specular glossiness convention.
  119783. *
  119784. * This fits to the PBR convention in the GLTF definition:
  119785. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  119786. */
  119787. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  119788. /**
  119789. * Specifies the diffuse color of the material.
  119790. */
  119791. diffuseColor: Color3;
  119792. /**
  119793. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  119794. * channel.
  119795. */
  119796. diffuseTexture: BaseTexture;
  119797. /**
  119798. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  119799. */
  119800. specularColor: Color3;
  119801. /**
  119802. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  119803. */
  119804. glossiness: number;
  119805. /**
  119806. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  119807. */
  119808. specularGlossinessTexture: BaseTexture;
  119809. /**
  119810. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  119811. *
  119812. * @param name The material name
  119813. * @param scene The scene the material will be use in.
  119814. */
  119815. constructor(name: string, scene: Scene);
  119816. /**
  119817. * Return the currrent class name of the material.
  119818. */
  119819. getClassName(): string;
  119820. /**
  119821. * Makes a duplicate of the current material.
  119822. * @param name - name to use for the new material.
  119823. */
  119824. clone(name: string): PBRSpecularGlossinessMaterial;
  119825. /**
  119826. * Serialize the material to a parsable JSON object.
  119827. */
  119828. serialize(): any;
  119829. /**
  119830. * Parses a JSON object correponding to the serialize function.
  119831. */
  119832. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  119833. }
  119834. }
  119835. declare module BABYLON {
  119836. /**
  119837. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  119838. * It can help converting any input color in a desired output one. This can then be used to create effects
  119839. * from sepia, black and white to sixties or futuristic rendering...
  119840. *
  119841. * The only supported format is currently 3dl.
  119842. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  119843. */
  119844. export class ColorGradingTexture extends BaseTexture {
  119845. /**
  119846. * The current texture matrix. (will always be identity in color grading texture)
  119847. */
  119848. private _textureMatrix;
  119849. /**
  119850. * The texture URL.
  119851. */
  119852. url: string;
  119853. /**
  119854. * Empty line regex stored for GC.
  119855. */
  119856. private static _noneEmptyLineRegex;
  119857. private _engine;
  119858. /**
  119859. * Instantiates a ColorGradingTexture from the following parameters.
  119860. *
  119861. * @param url The location of the color gradind data (currently only supporting 3dl)
  119862. * @param scene The scene the texture will be used in
  119863. */
  119864. constructor(url: string, scene: Scene);
  119865. /**
  119866. * Returns the texture matrix used in most of the material.
  119867. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  119868. */
  119869. getTextureMatrix(): Matrix;
  119870. /**
  119871. * Occurs when the file being loaded is a .3dl LUT file.
  119872. */
  119873. private load3dlTexture;
  119874. /**
  119875. * Starts the loading process of the texture.
  119876. */
  119877. private loadTexture;
  119878. /**
  119879. * Clones the color gradind texture.
  119880. */
  119881. clone(): ColorGradingTexture;
  119882. /**
  119883. * Called during delayed load for textures.
  119884. */
  119885. delayLoad(): void;
  119886. /**
  119887. * Parses a color grading texture serialized by Babylon.
  119888. * @param parsedTexture The texture information being parsedTexture
  119889. * @param scene The scene to load the texture in
  119890. * @param rootUrl The root url of the data assets to load
  119891. * @return A color gradind texture
  119892. */
  119893. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  119894. /**
  119895. * Serializes the LUT texture to json format.
  119896. */
  119897. serialize(): any;
  119898. }
  119899. }
  119900. declare module BABYLON {
  119901. /**
  119902. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  119903. */
  119904. export class EquiRectangularCubeTexture extends BaseTexture {
  119905. /** The six faces of the cube. */
  119906. private static _FacesMapping;
  119907. private _noMipmap;
  119908. private _onLoad;
  119909. private _onError;
  119910. /** The size of the cubemap. */
  119911. private _size;
  119912. /** The buffer of the image. */
  119913. private _buffer;
  119914. /** The width of the input image. */
  119915. private _width;
  119916. /** The height of the input image. */
  119917. private _height;
  119918. /** The URL to the image. */
  119919. url: string;
  119920. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  119921. coordinatesMode: number;
  119922. /**
  119923. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  119924. * @param url The location of the image
  119925. * @param scene The scene the texture will be used in
  119926. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119927. * @param noMipmap Forces to not generate the mipmap if true
  119928. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119929. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119930. * @param onLoad — defines a callback called when texture is loaded
  119931. * @param onError — defines a callback called if there is an error
  119932. */
  119933. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  119934. /**
  119935. * Load the image data, by putting the image on a canvas and extracting its buffer.
  119936. */
  119937. private loadImage;
  119938. /**
  119939. * Convert the image buffer into a cubemap and create a CubeTexture.
  119940. */
  119941. private loadTexture;
  119942. /**
  119943. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  119944. * @param buffer The ArrayBuffer that should be converted.
  119945. * @returns The buffer as Float32Array.
  119946. */
  119947. private getFloat32ArrayFromArrayBuffer;
  119948. /**
  119949. * Get the current class name of the texture useful for serialization or dynamic coding.
  119950. * @returns "EquiRectangularCubeTexture"
  119951. */
  119952. getClassName(): string;
  119953. /**
  119954. * Create a clone of the current EquiRectangularCubeTexture and return it.
  119955. * @returns A clone of the current EquiRectangularCubeTexture.
  119956. */
  119957. clone(): EquiRectangularCubeTexture;
  119958. }
  119959. }
  119960. declare module BABYLON {
  119961. /**
  119962. * Based on jsTGALoader - Javascript loader for TGA file
  119963. * By Vincent Thibault
  119964. * @see http://blog.robrowser.com/javascript-tga-loader.html
  119965. */
  119966. export class TGATools {
  119967. private static _TYPE_INDEXED;
  119968. private static _TYPE_RGB;
  119969. private static _TYPE_GREY;
  119970. private static _TYPE_RLE_INDEXED;
  119971. private static _TYPE_RLE_RGB;
  119972. private static _TYPE_RLE_GREY;
  119973. private static _ORIGIN_MASK;
  119974. private static _ORIGIN_SHIFT;
  119975. private static _ORIGIN_BL;
  119976. private static _ORIGIN_BR;
  119977. private static _ORIGIN_UL;
  119978. private static _ORIGIN_UR;
  119979. /**
  119980. * Gets the header of a TGA file
  119981. * @param data defines the TGA data
  119982. * @returns the header
  119983. */
  119984. static GetTGAHeader(data: Uint8Array): any;
  119985. /**
  119986. * Uploads TGA content to a Babylon Texture
  119987. * @hidden
  119988. */
  119989. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  119990. /** @hidden */
  119991. 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;
  119992. /** @hidden */
  119993. 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;
  119994. /** @hidden */
  119995. 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;
  119996. /** @hidden */
  119997. 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;
  119998. /** @hidden */
  119999. 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;
  120000. /** @hidden */
  120001. 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;
  120002. }
  120003. }
  120004. declare module BABYLON {
  120005. /**
  120006. * Implementation of the TGA Texture Loader.
  120007. * @hidden
  120008. */
  120009. export class _TGATextureLoader implements IInternalTextureLoader {
  120010. /**
  120011. * Defines wether the loader supports cascade loading the different faces.
  120012. */
  120013. readonly supportCascades: boolean;
  120014. /**
  120015. * This returns if the loader support the current file information.
  120016. * @param extension defines the file extension of the file being loaded
  120017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120018. * @param fallback defines the fallback internal texture if any
  120019. * @param isBase64 defines whether the texture is encoded as a base64
  120020. * @param isBuffer defines whether the texture data are stored as a buffer
  120021. * @returns true if the loader can load the specified file
  120022. */
  120023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120024. /**
  120025. * Transform the url before loading if required.
  120026. * @param rootUrl the url of the texture
  120027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120028. * @returns the transformed texture
  120029. */
  120030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120031. /**
  120032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120033. * @param rootUrl the url of the texture
  120034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120035. * @returns the fallback texture
  120036. */
  120037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120038. /**
  120039. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  120040. * @param data contains the texture data
  120041. * @param texture defines the BabylonJS internal texture
  120042. * @param createPolynomials will be true if polynomials have been requested
  120043. * @param onLoad defines the callback to trigger once the texture is ready
  120044. * @param onError defines the callback to trigger in case of error
  120045. */
  120046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120047. /**
  120048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120049. * @param data contains the texture data
  120050. * @param texture defines the BabylonJS internal texture
  120051. * @param callback defines the method to call once ready to upload
  120052. */
  120053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120054. }
  120055. }
  120056. declare module BABYLON {
  120057. /**
  120058. * Info about the .basis files
  120059. */
  120060. class BasisFileInfo {
  120061. /**
  120062. * If the file has alpha
  120063. */
  120064. hasAlpha: boolean;
  120065. /**
  120066. * Info about each image of the basis file
  120067. */
  120068. images: Array<{
  120069. levels: Array<{
  120070. width: number;
  120071. height: number;
  120072. transcodedPixels: ArrayBufferView;
  120073. }>;
  120074. }>;
  120075. }
  120076. /**
  120077. * Result of transcoding a basis file
  120078. */
  120079. class TranscodeResult {
  120080. /**
  120081. * Info about the .basis file
  120082. */
  120083. fileInfo: BasisFileInfo;
  120084. /**
  120085. * Format to use when loading the file
  120086. */
  120087. format: number;
  120088. }
  120089. /**
  120090. * Configuration options for the Basis transcoder
  120091. */
  120092. export class BasisTranscodeConfiguration {
  120093. /**
  120094. * Supported compression formats used to determine the supported output format of the transcoder
  120095. */
  120096. supportedCompressionFormats?: {
  120097. /**
  120098. * etc1 compression format
  120099. */
  120100. etc1?: boolean;
  120101. /**
  120102. * s3tc compression format
  120103. */
  120104. s3tc?: boolean;
  120105. /**
  120106. * pvrtc compression format
  120107. */
  120108. pvrtc?: boolean;
  120109. /**
  120110. * etc2 compression format
  120111. */
  120112. etc2?: boolean;
  120113. };
  120114. /**
  120115. * If mipmap levels should be loaded for transcoded images (Default: true)
  120116. */
  120117. loadMipmapLevels?: boolean;
  120118. /**
  120119. * Index of a single image to load (Default: all images)
  120120. */
  120121. loadSingleImage?: number;
  120122. }
  120123. /**
  120124. * Used to load .Basis files
  120125. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  120126. */
  120127. export class BasisTools {
  120128. private static _IgnoreSupportedFormats;
  120129. /**
  120130. * URL to use when loading the basis transcoder
  120131. */
  120132. static JSModuleURL: string;
  120133. /**
  120134. * URL to use when loading the wasm module for the transcoder
  120135. */
  120136. static WasmModuleURL: string;
  120137. /**
  120138. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  120139. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  120140. * @returns internal format corresponding to the Basis format
  120141. */
  120142. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  120143. private static _WorkerPromise;
  120144. private static _Worker;
  120145. private static _actionId;
  120146. private static _CreateWorkerAsync;
  120147. /**
  120148. * Transcodes a loaded image file to compressed pixel data
  120149. * @param imageData image data to transcode
  120150. * @param config configuration options for the transcoding
  120151. * @returns a promise resulting in the transcoded image
  120152. */
  120153. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  120154. /**
  120155. * Loads a texture from the transcode result
  120156. * @param texture texture load to
  120157. * @param transcodeResult the result of transcoding the basis file to load from
  120158. */
  120159. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  120160. }
  120161. }
  120162. declare module BABYLON {
  120163. /**
  120164. * Loader for .basis file format
  120165. */
  120166. export class _BasisTextureLoader implements IInternalTextureLoader {
  120167. /**
  120168. * Defines whether the loader supports cascade loading the different faces.
  120169. */
  120170. readonly supportCascades: boolean;
  120171. /**
  120172. * This returns if the loader support the current file information.
  120173. * @param extension defines the file extension of the file being loaded
  120174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120175. * @param fallback defines the fallback internal texture if any
  120176. * @param isBase64 defines whether the texture is encoded as a base64
  120177. * @param isBuffer defines whether the texture data are stored as a buffer
  120178. * @returns true if the loader can load the specified file
  120179. */
  120180. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  120181. /**
  120182. * Transform the url before loading if required.
  120183. * @param rootUrl the url of the texture
  120184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120185. * @returns the transformed texture
  120186. */
  120187. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  120188. /**
  120189. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  120190. * @param rootUrl the url of the texture
  120191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  120192. * @returns the fallback texture
  120193. */
  120194. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  120195. /**
  120196. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  120197. * @param data contains the texture data
  120198. * @param texture defines the BabylonJS internal texture
  120199. * @param createPolynomials will be true if polynomials have been requested
  120200. * @param onLoad defines the callback to trigger once the texture is ready
  120201. * @param onError defines the callback to trigger in case of error
  120202. */
  120203. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  120204. /**
  120205. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  120206. * @param data contains the texture data
  120207. * @param texture defines the BabylonJS internal texture
  120208. * @param callback defines the method to call once ready to upload
  120209. */
  120210. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  120211. }
  120212. }
  120213. declare module BABYLON {
  120214. /**
  120215. * 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.
  120216. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120217. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120218. */
  120219. export class CustomProceduralTexture extends ProceduralTexture {
  120220. private _animate;
  120221. private _time;
  120222. private _config;
  120223. private _texturePath;
  120224. /**
  120225. * Instantiates a new Custom Procedural Texture.
  120226. * 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.
  120227. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  120228. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  120229. * @param name Define the name of the texture
  120230. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  120231. * @param size Define the size of the texture to create
  120232. * @param scene Define the scene the texture belongs to
  120233. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  120234. * @param generateMipMaps Define if the texture should creates mip maps or not
  120235. */
  120236. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120237. private _loadJson;
  120238. /**
  120239. * Is the texture ready to be used ? (rendered at least once)
  120240. * @returns true if ready, otherwise, false.
  120241. */
  120242. isReady(): boolean;
  120243. /**
  120244. * Render the texture to its associated render target.
  120245. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  120246. */
  120247. render(useCameraPostProcess?: boolean): void;
  120248. /**
  120249. * Update the list of dependant textures samplers in the shader.
  120250. */
  120251. updateTextures(): void;
  120252. /**
  120253. * Update the uniform values of the procedural texture in the shader.
  120254. */
  120255. updateShaderUniforms(): void;
  120256. /**
  120257. * Define if the texture animates or not.
  120258. */
  120259. animate: boolean;
  120260. }
  120261. }
  120262. declare module BABYLON {
  120263. /** @hidden */
  120264. export var noisePixelShader: {
  120265. name: string;
  120266. shader: string;
  120267. };
  120268. }
  120269. declare module BABYLON {
  120270. /**
  120271. * Class used to generate noise procedural textures
  120272. */
  120273. export class NoiseProceduralTexture extends ProceduralTexture {
  120274. private _time;
  120275. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  120276. brightness: number;
  120277. /** Defines the number of octaves to process */
  120278. octaves: number;
  120279. /** Defines the level of persistence (0.8 by default) */
  120280. persistence: number;
  120281. /** Gets or sets animation speed factor (default is 1) */
  120282. animationSpeedFactor: number;
  120283. /**
  120284. * Creates a new NoiseProceduralTexture
  120285. * @param name defines the name fo the texture
  120286. * @param size defines the size of the texture (default is 256)
  120287. * @param scene defines the hosting scene
  120288. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  120289. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  120290. */
  120291. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  120292. private _updateShaderUniforms;
  120293. protected _getDefines(): string;
  120294. /** Generate the current state of the procedural texture */
  120295. render(useCameraPostProcess?: boolean): void;
  120296. /**
  120297. * Serializes this noise procedural texture
  120298. * @returns a serialized noise procedural texture object
  120299. */
  120300. serialize(): any;
  120301. /**
  120302. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  120303. * @param parsedTexture defines parsed texture data
  120304. * @param scene defines the current scene
  120305. * @param rootUrl defines the root URL containing noise procedural texture information
  120306. * @returns a parsed NoiseProceduralTexture
  120307. */
  120308. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  120309. }
  120310. }
  120311. declare module BABYLON {
  120312. /**
  120313. * Raw cube texture where the raw buffers are passed in
  120314. */
  120315. export class RawCubeTexture extends CubeTexture {
  120316. /**
  120317. * Creates a cube texture where the raw buffers are passed in.
  120318. * @param scene defines the scene the texture is attached to
  120319. * @param data defines the array of data to use to create each face
  120320. * @param size defines the size of the textures
  120321. * @param format defines the format of the data
  120322. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  120323. * @param generateMipMaps defines if the engine should generate the mip levels
  120324. * @param invertY defines if data must be stored with Y axis inverted
  120325. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  120326. * @param compression defines the compression used (null by default)
  120327. */
  120328. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  120329. /**
  120330. * Updates the raw cube texture.
  120331. * @param data defines the data to store
  120332. * @param format defines the data format
  120333. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120334. * @param invertY defines if data must be stored with Y axis inverted
  120335. * @param compression defines the compression used (null by default)
  120336. * @param level defines which level of the texture to update
  120337. */
  120338. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  120339. /**
  120340. * Updates a raw cube texture with RGBD encoded data.
  120341. * @param data defines the array of data [mipmap][face] to use to create each face
  120342. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  120343. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120344. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120345. * @returns a promsie that resolves when the operation is complete
  120346. */
  120347. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  120348. /**
  120349. * Clones the raw cube texture.
  120350. * @return a new cube texture
  120351. */
  120352. clone(): CubeTexture;
  120353. /** @hidden */
  120354. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120355. }
  120356. }
  120357. declare module BABYLON {
  120358. /**
  120359. * Class used to store 3D textures containing user data
  120360. */
  120361. export class RawTexture3D extends Texture {
  120362. /** Gets or sets the texture format to use */
  120363. format: number;
  120364. private _engine;
  120365. /**
  120366. * Create a new RawTexture3D
  120367. * @param data defines the data of the texture
  120368. * @param width defines the width of the texture
  120369. * @param height defines the height of the texture
  120370. * @param depth defines the depth of the texture
  120371. * @param format defines the texture format to use
  120372. * @param scene defines the hosting scene
  120373. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  120374. * @param invertY defines if texture must be stored with Y axis inverted
  120375. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120376. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  120377. */
  120378. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  120379. /** Gets or sets the texture format to use */
  120380. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  120381. /**
  120382. * Update the texture with new data
  120383. * @param data defines the data to store in the texture
  120384. */
  120385. update(data: ArrayBufferView): void;
  120386. }
  120387. }
  120388. declare module BABYLON {
  120389. /**
  120390. * Creates a refraction texture used by refraction channel of the standard material.
  120391. * It is like a mirror but to see through a material.
  120392. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120393. */
  120394. export class RefractionTexture extends RenderTargetTexture {
  120395. /**
  120396. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  120397. * 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.
  120398. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120399. */
  120400. refractionPlane: Plane;
  120401. /**
  120402. * Define how deep under the surface we should see.
  120403. */
  120404. depth: number;
  120405. /**
  120406. * Creates a refraction texture used by refraction channel of the standard material.
  120407. * It is like a mirror but to see through a material.
  120408. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  120409. * @param name Define the texture name
  120410. * @param size Define the size of the underlying texture
  120411. * @param scene Define the scene the refraction belongs to
  120412. * @param generateMipMaps Define if we need to generate mips level for the refraction
  120413. */
  120414. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  120415. /**
  120416. * Clone the refraction texture.
  120417. * @returns the cloned texture
  120418. */
  120419. clone(): RefractionTexture;
  120420. /**
  120421. * Serialize the texture to a JSON representation you could use in Parse later on
  120422. * @returns the serialized JSON representation
  120423. */
  120424. serialize(): any;
  120425. }
  120426. }
  120427. declare module BABYLON {
  120428. /**
  120429. * Defines the options related to the creation of an HtmlElementTexture
  120430. */
  120431. export interface IHtmlElementTextureOptions {
  120432. /**
  120433. * Defines wether mip maps should be created or not.
  120434. */
  120435. generateMipMaps?: boolean;
  120436. /**
  120437. * Defines the sampling mode of the texture.
  120438. */
  120439. samplingMode?: number;
  120440. /**
  120441. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  120442. */
  120443. engine: Nullable<ThinEngine>;
  120444. /**
  120445. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  120446. */
  120447. scene: Nullable<Scene>;
  120448. }
  120449. /**
  120450. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  120451. * To be as efficient as possible depending on your constraints nothing aside the first upload
  120452. * is automatically managed.
  120453. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  120454. * in your application.
  120455. *
  120456. * As the update is not automatic, you need to call them manually.
  120457. */
  120458. export class HtmlElementTexture extends BaseTexture {
  120459. /**
  120460. * The texture URL.
  120461. */
  120462. element: HTMLVideoElement | HTMLCanvasElement;
  120463. private static readonly DefaultOptions;
  120464. private _textureMatrix;
  120465. private _engine;
  120466. private _isVideo;
  120467. private _generateMipMaps;
  120468. private _samplingMode;
  120469. /**
  120470. * Instantiates a HtmlElementTexture from the following parameters.
  120471. *
  120472. * @param name Defines the name of the texture
  120473. * @param element Defines the video or canvas the texture is filled with
  120474. * @param options Defines the other none mandatory texture creation options
  120475. */
  120476. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  120477. private _createInternalTexture;
  120478. /**
  120479. * Returns the texture matrix used in most of the material.
  120480. */
  120481. getTextureMatrix(): Matrix;
  120482. /**
  120483. * Updates the content of the texture.
  120484. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  120485. */
  120486. update(invertY?: Nullable<boolean>): void;
  120487. }
  120488. }
  120489. declare module BABYLON {
  120490. /**
  120491. * Enum used to define the target of a block
  120492. */
  120493. export enum NodeMaterialBlockTargets {
  120494. /** Vertex shader */
  120495. Vertex = 1,
  120496. /** Fragment shader */
  120497. Fragment = 2,
  120498. /** Neutral */
  120499. Neutral = 4,
  120500. /** Vertex and Fragment */
  120501. VertexAndFragment = 3
  120502. }
  120503. }
  120504. declare module BABYLON {
  120505. /**
  120506. * Defines the kind of connection point for node based material
  120507. */
  120508. export enum NodeMaterialBlockConnectionPointTypes {
  120509. /** Float */
  120510. Float = 1,
  120511. /** Int */
  120512. Int = 2,
  120513. /** Vector2 */
  120514. Vector2 = 4,
  120515. /** Vector3 */
  120516. Vector3 = 8,
  120517. /** Vector4 */
  120518. Vector4 = 16,
  120519. /** Color3 */
  120520. Color3 = 32,
  120521. /** Color4 */
  120522. Color4 = 64,
  120523. /** Matrix */
  120524. Matrix = 128,
  120525. /** Detect type based on connection */
  120526. AutoDetect = 1024,
  120527. /** Output type that will be defined by input type */
  120528. BasedOnInput = 2048
  120529. }
  120530. }
  120531. declare module BABYLON {
  120532. /**
  120533. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  120534. */
  120535. export enum NodeMaterialBlockConnectionPointMode {
  120536. /** Value is an uniform */
  120537. Uniform = 0,
  120538. /** Value is a mesh attribute */
  120539. Attribute = 1,
  120540. /** Value is a varying between vertex and fragment shaders */
  120541. Varying = 2,
  120542. /** Mode is undefined */
  120543. Undefined = 3
  120544. }
  120545. }
  120546. declare module BABYLON {
  120547. /**
  120548. * Enum used to define system values e.g. values automatically provided by the system
  120549. */
  120550. export enum NodeMaterialSystemValues {
  120551. /** World */
  120552. World = 1,
  120553. /** View */
  120554. View = 2,
  120555. /** Projection */
  120556. Projection = 3,
  120557. /** ViewProjection */
  120558. ViewProjection = 4,
  120559. /** WorldView */
  120560. WorldView = 5,
  120561. /** WorldViewProjection */
  120562. WorldViewProjection = 6,
  120563. /** CameraPosition */
  120564. CameraPosition = 7,
  120565. /** Fog Color */
  120566. FogColor = 8,
  120567. /** Delta time */
  120568. DeltaTime = 9
  120569. }
  120570. }
  120571. declare module BABYLON {
  120572. /**
  120573. * Root class for all node material optimizers
  120574. */
  120575. export class NodeMaterialOptimizer {
  120576. /**
  120577. * Function used to optimize a NodeMaterial graph
  120578. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  120579. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  120580. */
  120581. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  120582. }
  120583. }
  120584. declare module BABYLON {
  120585. /**
  120586. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  120587. */
  120588. export class TransformBlock extends NodeMaterialBlock {
  120589. /**
  120590. * Defines the value to use to complement W value to transform it to a Vector4
  120591. */
  120592. complementW: number;
  120593. /**
  120594. * Defines the value to use to complement z value to transform it to a Vector4
  120595. */
  120596. complementZ: number;
  120597. /**
  120598. * Creates a new TransformBlock
  120599. * @param name defines the block name
  120600. */
  120601. constructor(name: string);
  120602. /**
  120603. * Gets the current class name
  120604. * @returns the class name
  120605. */
  120606. getClassName(): string;
  120607. /**
  120608. * Gets the vector input
  120609. */
  120610. readonly vector: NodeMaterialConnectionPoint;
  120611. /**
  120612. * Gets the output component
  120613. */
  120614. readonly output: NodeMaterialConnectionPoint;
  120615. /**
  120616. * Gets the matrix transform input
  120617. */
  120618. readonly transform: NodeMaterialConnectionPoint;
  120619. protected _buildBlock(state: NodeMaterialBuildState): this;
  120620. serialize(): any;
  120621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120622. protected _dumpPropertiesCode(): string;
  120623. }
  120624. }
  120625. declare module BABYLON {
  120626. /**
  120627. * Block used to output the vertex position
  120628. */
  120629. export class VertexOutputBlock extends NodeMaterialBlock {
  120630. /**
  120631. * Creates a new VertexOutputBlock
  120632. * @param name defines the block name
  120633. */
  120634. constructor(name: string);
  120635. /**
  120636. * Gets the current class name
  120637. * @returns the class name
  120638. */
  120639. getClassName(): string;
  120640. /**
  120641. * Gets the vector input component
  120642. */
  120643. readonly vector: NodeMaterialConnectionPoint;
  120644. protected _buildBlock(state: NodeMaterialBuildState): this;
  120645. }
  120646. }
  120647. declare module BABYLON {
  120648. /**
  120649. * Block used to output the final color
  120650. */
  120651. export class FragmentOutputBlock extends NodeMaterialBlock {
  120652. /**
  120653. * Create a new FragmentOutputBlock
  120654. * @param name defines the block name
  120655. */
  120656. constructor(name: string);
  120657. /**
  120658. * Gets the current class name
  120659. * @returns the class name
  120660. */
  120661. getClassName(): string;
  120662. /**
  120663. * Gets the rgba input component
  120664. */
  120665. readonly rgba: NodeMaterialConnectionPoint;
  120666. /**
  120667. * Gets the rgb input component
  120668. */
  120669. readonly rgb: NodeMaterialConnectionPoint;
  120670. /**
  120671. * Gets the a input component
  120672. */
  120673. readonly a: NodeMaterialConnectionPoint;
  120674. protected _buildBlock(state: NodeMaterialBuildState): this;
  120675. }
  120676. }
  120677. declare module BABYLON {
  120678. /**
  120679. * Block used to read a reflection texture from a sampler
  120680. */
  120681. export class ReflectionTextureBlock extends NodeMaterialBlock {
  120682. private _define3DName;
  120683. private _defineCubicName;
  120684. private _defineExplicitName;
  120685. private _defineProjectionName;
  120686. private _defineLocalCubicName;
  120687. private _defineSphericalName;
  120688. private _definePlanarName;
  120689. private _defineEquirectangularName;
  120690. private _defineMirroredEquirectangularFixedName;
  120691. private _defineEquirectangularFixedName;
  120692. private _defineSkyboxName;
  120693. private _cubeSamplerName;
  120694. private _2DSamplerName;
  120695. private _positionUVWName;
  120696. private _directionWName;
  120697. private _reflectionCoordsName;
  120698. private _reflection2DCoordsName;
  120699. private _reflectionColorName;
  120700. private _reflectionMatrixName;
  120701. /**
  120702. * Gets or sets the texture associated with the node
  120703. */
  120704. texture: Nullable<BaseTexture>;
  120705. /**
  120706. * Create a new TextureBlock
  120707. * @param name defines the block name
  120708. */
  120709. constructor(name: string);
  120710. /**
  120711. * Gets the current class name
  120712. * @returns the class name
  120713. */
  120714. getClassName(): string;
  120715. /**
  120716. * Gets the world position input component
  120717. */
  120718. readonly position: NodeMaterialConnectionPoint;
  120719. /**
  120720. * Gets the world position input component
  120721. */
  120722. readonly worldPosition: NodeMaterialConnectionPoint;
  120723. /**
  120724. * Gets the world normal input component
  120725. */
  120726. readonly worldNormal: NodeMaterialConnectionPoint;
  120727. /**
  120728. * Gets the world input component
  120729. */
  120730. readonly world: NodeMaterialConnectionPoint;
  120731. /**
  120732. * Gets the camera (or eye) position component
  120733. */
  120734. readonly cameraPosition: NodeMaterialConnectionPoint;
  120735. /**
  120736. * Gets the view input component
  120737. */
  120738. readonly view: NodeMaterialConnectionPoint;
  120739. /**
  120740. * Gets the rgb output component
  120741. */
  120742. readonly rgb: NodeMaterialConnectionPoint;
  120743. /**
  120744. * Gets the r output component
  120745. */
  120746. readonly r: NodeMaterialConnectionPoint;
  120747. /**
  120748. * Gets the g output component
  120749. */
  120750. readonly g: NodeMaterialConnectionPoint;
  120751. /**
  120752. * Gets the b output component
  120753. */
  120754. readonly b: NodeMaterialConnectionPoint;
  120755. autoConfigure(material: NodeMaterial): void;
  120756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120757. isReady(): boolean;
  120758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120759. private _injectVertexCode;
  120760. private _writeOutput;
  120761. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120762. serialize(): any;
  120763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120764. }
  120765. }
  120766. declare module BABYLON {
  120767. /**
  120768. * Interface used to configure the node material editor
  120769. */
  120770. export interface INodeMaterialEditorOptions {
  120771. /** Define the URl to load node editor script */
  120772. editorURL?: string;
  120773. }
  120774. /** @hidden */
  120775. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  120776. /** BONES */
  120777. NUM_BONE_INFLUENCERS: number;
  120778. BonesPerMesh: number;
  120779. BONETEXTURE: boolean;
  120780. /** MORPH TARGETS */
  120781. MORPHTARGETS: boolean;
  120782. MORPHTARGETS_NORMAL: boolean;
  120783. MORPHTARGETS_TANGENT: boolean;
  120784. MORPHTARGETS_UV: boolean;
  120785. NUM_MORPH_INFLUENCERS: number;
  120786. /** IMAGE PROCESSING */
  120787. IMAGEPROCESSING: boolean;
  120788. VIGNETTE: boolean;
  120789. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120790. VIGNETTEBLENDMODEOPAQUE: boolean;
  120791. TONEMAPPING: boolean;
  120792. TONEMAPPING_ACES: boolean;
  120793. CONTRAST: boolean;
  120794. EXPOSURE: boolean;
  120795. COLORCURVES: boolean;
  120796. COLORGRADING: boolean;
  120797. COLORGRADING3D: boolean;
  120798. SAMPLER3DGREENDEPTH: boolean;
  120799. SAMPLER3DBGRMAP: boolean;
  120800. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120801. /** MISC. */
  120802. BUMPDIRECTUV: number;
  120803. constructor();
  120804. setValue(name: string, value: boolean): void;
  120805. }
  120806. /**
  120807. * Class used to configure NodeMaterial
  120808. */
  120809. export interface INodeMaterialOptions {
  120810. /**
  120811. * Defines if blocks should emit comments
  120812. */
  120813. emitComments: boolean;
  120814. }
  120815. /**
  120816. * Class used to create a node based material built by assembling shader blocks
  120817. */
  120818. export class NodeMaterial extends PushMaterial {
  120819. private static _BuildIdGenerator;
  120820. private _options;
  120821. private _vertexCompilationState;
  120822. private _fragmentCompilationState;
  120823. private _sharedData;
  120824. private _buildId;
  120825. private _buildWasSuccessful;
  120826. private _cachedWorldViewMatrix;
  120827. private _cachedWorldViewProjectionMatrix;
  120828. private _optimizers;
  120829. private _animationFrame;
  120830. /** Define the URl to load node editor script */
  120831. static EditorURL: string;
  120832. private BJSNODEMATERIALEDITOR;
  120833. /** Get the inspector from bundle or global */
  120834. private _getGlobalNodeMaterialEditor;
  120835. /**
  120836. * 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)
  120837. */
  120838. ignoreAlpha: boolean;
  120839. /**
  120840. * Defines the maximum number of lights that can be used in the material
  120841. */
  120842. maxSimultaneousLights: number;
  120843. /**
  120844. * Observable raised when the material is built
  120845. */
  120846. onBuildObservable: Observable<NodeMaterial>;
  120847. /**
  120848. * Gets or sets the root nodes of the material vertex shader
  120849. */
  120850. _vertexOutputNodes: NodeMaterialBlock[];
  120851. /**
  120852. * Gets or sets the root nodes of the material fragment (pixel) shader
  120853. */
  120854. _fragmentOutputNodes: NodeMaterialBlock[];
  120855. /** Gets or sets options to control the node material overall behavior */
  120856. options: INodeMaterialOptions;
  120857. /**
  120858. * Default configuration related to image processing available in the standard Material.
  120859. */
  120860. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120861. /**
  120862. * Gets the image processing configuration used either in this material.
  120863. */
  120864. /**
  120865. * Sets the Default image processing configuration used either in the this material.
  120866. *
  120867. * If sets to null, the scene one is in use.
  120868. */
  120869. imageProcessingConfiguration: ImageProcessingConfiguration;
  120870. /**
  120871. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  120872. */
  120873. attachedBlocks: NodeMaterialBlock[];
  120874. /**
  120875. * Create a new node based material
  120876. * @param name defines the material name
  120877. * @param scene defines the hosting scene
  120878. * @param options defines creation option
  120879. */
  120880. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  120881. /**
  120882. * Gets the current class name of the material e.g. "NodeMaterial"
  120883. * @returns the class name
  120884. */
  120885. getClassName(): string;
  120886. /**
  120887. * Keep track of the image processing observer to allow dispose and replace.
  120888. */
  120889. private _imageProcessingObserver;
  120890. /**
  120891. * Attaches a new image processing configuration to the Standard Material.
  120892. * @param configuration
  120893. */
  120894. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120895. /**
  120896. * Get a block by its name
  120897. * @param name defines the name of the block to retrieve
  120898. * @returns the required block or null if not found
  120899. */
  120900. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  120901. /**
  120902. * Get a block by its name
  120903. * @param predicate defines the predicate used to find the good candidate
  120904. * @returns the required block or null if not found
  120905. */
  120906. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  120907. /**
  120908. * Get an input block by its name
  120909. * @param predicate defines the predicate used to find the good candidate
  120910. * @returns the required input block or null if not found
  120911. */
  120912. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  120913. /**
  120914. * Gets the list of input blocks attached to this material
  120915. * @returns an array of InputBlocks
  120916. */
  120917. getInputBlocks(): InputBlock[];
  120918. /**
  120919. * Adds a new optimizer to the list of optimizers
  120920. * @param optimizer defines the optimizers to add
  120921. * @returns the current material
  120922. */
  120923. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120924. /**
  120925. * Remove an optimizer from the list of optimizers
  120926. * @param optimizer defines the optimizers to remove
  120927. * @returns the current material
  120928. */
  120929. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  120930. /**
  120931. * Add a new block to the list of output nodes
  120932. * @param node defines the node to add
  120933. * @returns the current material
  120934. */
  120935. addOutputNode(node: NodeMaterialBlock): this;
  120936. /**
  120937. * Remove a block from the list of root nodes
  120938. * @param node defines the node to remove
  120939. * @returns the current material
  120940. */
  120941. removeOutputNode(node: NodeMaterialBlock): this;
  120942. private _addVertexOutputNode;
  120943. private _removeVertexOutputNode;
  120944. private _addFragmentOutputNode;
  120945. private _removeFragmentOutputNode;
  120946. /**
  120947. * Specifies if the material will require alpha blending
  120948. * @returns a boolean specifying if alpha blending is needed
  120949. */
  120950. needAlphaBlending(): boolean;
  120951. /**
  120952. * Specifies if this material should be rendered in alpha test mode
  120953. * @returns a boolean specifying if an alpha test is needed.
  120954. */
  120955. needAlphaTesting(): boolean;
  120956. private _initializeBlock;
  120957. private _resetDualBlocks;
  120958. /**
  120959. * Build the material and generates the inner effect
  120960. * @param verbose defines if the build should log activity
  120961. */
  120962. build(verbose?: boolean): void;
  120963. /**
  120964. * Runs an otpimization phase to try to improve the shader code
  120965. */
  120966. optimize(): void;
  120967. private _prepareDefinesForAttributes;
  120968. /**
  120969. * Get if the submesh is ready to be used and all its information available.
  120970. * Child classes can use it to update shaders
  120971. * @param mesh defines the mesh to check
  120972. * @param subMesh defines which submesh to check
  120973. * @param useInstances specifies that instances should be used
  120974. * @returns a boolean indicating that the submesh is ready or not
  120975. */
  120976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120977. /**
  120978. * Get a string representing the shaders built by the current node graph
  120979. */
  120980. readonly compiledShaders: string;
  120981. /**
  120982. * Binds the world matrix to the material
  120983. * @param world defines the world transformation matrix
  120984. */
  120985. bindOnlyWorldMatrix(world: Matrix): void;
  120986. /**
  120987. * Binds the submesh to this material by preparing the effect and shader to draw
  120988. * @param world defines the world transformation matrix
  120989. * @param mesh defines the mesh containing the submesh
  120990. * @param subMesh defines the submesh to bind the material to
  120991. */
  120992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120993. /**
  120994. * Gets the active textures from the material
  120995. * @returns an array of textures
  120996. */
  120997. getActiveTextures(): BaseTexture[];
  120998. /**
  120999. * Gets the list of texture blocks
  121000. * @returns an array of texture blocks
  121001. */
  121002. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  121003. /**
  121004. * Specifies if the material uses a texture
  121005. * @param texture defines the texture to check against the material
  121006. * @returns a boolean specifying if the material uses the texture
  121007. */
  121008. hasTexture(texture: BaseTexture): boolean;
  121009. /**
  121010. * Disposes the material
  121011. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  121012. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  121013. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  121014. */
  121015. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  121016. /** Creates the node editor window. */
  121017. private _createNodeEditor;
  121018. /**
  121019. * Launch the node material editor
  121020. * @param config Define the configuration of the editor
  121021. * @return a promise fulfilled when the node editor is visible
  121022. */
  121023. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  121024. /**
  121025. * Clear the current material
  121026. */
  121027. clear(): void;
  121028. /**
  121029. * Clear the current material and set it to a default state
  121030. */
  121031. setToDefault(): void;
  121032. /**
  121033. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  121034. * @param url defines the url to load from
  121035. * @returns a promise that will fullfil when the material is fully loaded
  121036. */
  121037. loadAsync(url: string): Promise<void>;
  121038. private _gatherBlocks;
  121039. /**
  121040. * Generate a string containing the code declaration required to create an equivalent of this material
  121041. * @returns a string
  121042. */
  121043. generateCode(): string;
  121044. /**
  121045. * Serializes this material in a JSON representation
  121046. * @returns the serialized material object
  121047. */
  121048. serialize(): any;
  121049. private _restoreConnections;
  121050. /**
  121051. * Clear the current graph and load a new one from a serialization object
  121052. * @param source defines the JSON representation of the material
  121053. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121054. */
  121055. loadFromSerialization(source: any, rootUrl?: string): void;
  121056. /**
  121057. * Creates a node material from parsed material data
  121058. * @param source defines the JSON representation of the material
  121059. * @param scene defines the hosting scene
  121060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121061. * @returns a new node material
  121062. */
  121063. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  121064. /**
  121065. * Creates a new node material set to default basic configuration
  121066. * @param name defines the name of the material
  121067. * @param scene defines the hosting scene
  121068. * @returns a new NodeMaterial
  121069. */
  121070. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  121071. }
  121072. }
  121073. declare module BABYLON {
  121074. /**
  121075. * Block used to read a texture from a sampler
  121076. */
  121077. export class TextureBlock extends NodeMaterialBlock {
  121078. private _defineName;
  121079. private _linearDefineName;
  121080. private _samplerName;
  121081. private _transformedUVName;
  121082. private _textureTransformName;
  121083. private _textureInfoName;
  121084. private _mainUVName;
  121085. private _mainUVDefineName;
  121086. /**
  121087. * Gets or sets the texture associated with the node
  121088. */
  121089. texture: Nullable<Texture>;
  121090. /**
  121091. * Create a new TextureBlock
  121092. * @param name defines the block name
  121093. */
  121094. constructor(name: string);
  121095. /**
  121096. * Gets the current class name
  121097. * @returns the class name
  121098. */
  121099. getClassName(): string;
  121100. /**
  121101. * Gets the uv input component
  121102. */
  121103. readonly uv: NodeMaterialConnectionPoint;
  121104. /**
  121105. * Gets the rgba output component
  121106. */
  121107. readonly rgba: NodeMaterialConnectionPoint;
  121108. /**
  121109. * Gets the rgb output component
  121110. */
  121111. readonly rgb: NodeMaterialConnectionPoint;
  121112. /**
  121113. * Gets the r output component
  121114. */
  121115. readonly r: NodeMaterialConnectionPoint;
  121116. /**
  121117. * Gets the g output component
  121118. */
  121119. readonly g: NodeMaterialConnectionPoint;
  121120. /**
  121121. * Gets the b output component
  121122. */
  121123. readonly b: NodeMaterialConnectionPoint;
  121124. /**
  121125. * Gets the a output component
  121126. */
  121127. readonly a: NodeMaterialConnectionPoint;
  121128. readonly target: NodeMaterialBlockTargets;
  121129. autoConfigure(material: NodeMaterial): void;
  121130. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121132. isReady(): boolean;
  121133. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121134. private readonly _isMixed;
  121135. private _injectVertexCode;
  121136. private _writeOutput;
  121137. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121138. protected _dumpPropertiesCode(): string;
  121139. serialize(): any;
  121140. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121141. }
  121142. }
  121143. declare module BABYLON {
  121144. /**
  121145. * Class used to store shared data between 2 NodeMaterialBuildState
  121146. */
  121147. export class NodeMaterialBuildStateSharedData {
  121148. /**
  121149. * Gets the list of emitted varyings
  121150. */
  121151. temps: string[];
  121152. /**
  121153. * Gets the list of emitted varyings
  121154. */
  121155. varyings: string[];
  121156. /**
  121157. * Gets the varying declaration string
  121158. */
  121159. varyingDeclaration: string;
  121160. /**
  121161. * Input blocks
  121162. */
  121163. inputBlocks: InputBlock[];
  121164. /**
  121165. * Input blocks
  121166. */
  121167. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  121168. /**
  121169. * Bindable blocks (Blocks that need to set data to the effect)
  121170. */
  121171. bindableBlocks: NodeMaterialBlock[];
  121172. /**
  121173. * List of blocks that can provide a compilation fallback
  121174. */
  121175. blocksWithFallbacks: NodeMaterialBlock[];
  121176. /**
  121177. * List of blocks that can provide a define update
  121178. */
  121179. blocksWithDefines: NodeMaterialBlock[];
  121180. /**
  121181. * List of blocks that can provide a repeatable content
  121182. */
  121183. repeatableContentBlocks: NodeMaterialBlock[];
  121184. /**
  121185. * List of blocks that can provide a dynamic list of uniforms
  121186. */
  121187. dynamicUniformBlocks: NodeMaterialBlock[];
  121188. /**
  121189. * List of blocks that can block the isReady function for the material
  121190. */
  121191. blockingBlocks: NodeMaterialBlock[];
  121192. /**
  121193. * Gets the list of animated inputs
  121194. */
  121195. animatedInputs: InputBlock[];
  121196. /**
  121197. * Build Id used to avoid multiple recompilations
  121198. */
  121199. buildId: number;
  121200. /** List of emitted variables */
  121201. variableNames: {
  121202. [key: string]: number;
  121203. };
  121204. /** List of emitted defines */
  121205. defineNames: {
  121206. [key: string]: number;
  121207. };
  121208. /** Should emit comments? */
  121209. emitComments: boolean;
  121210. /** Emit build activity */
  121211. verbose: boolean;
  121212. /** Gets or sets the hosting scene */
  121213. scene: Scene;
  121214. /**
  121215. * Gets the compilation hints emitted at compilation time
  121216. */
  121217. hints: {
  121218. needWorldViewMatrix: boolean;
  121219. needWorldViewProjectionMatrix: boolean;
  121220. needAlphaBlending: boolean;
  121221. needAlphaTesting: boolean;
  121222. };
  121223. /**
  121224. * List of compilation checks
  121225. */
  121226. checks: {
  121227. emitVertex: boolean;
  121228. emitFragment: boolean;
  121229. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  121230. };
  121231. /** Creates a new shared data */
  121232. constructor();
  121233. /**
  121234. * Emits console errors and exceptions if there is a failing check
  121235. */
  121236. emitErrors(): void;
  121237. }
  121238. }
  121239. declare module BABYLON {
  121240. /**
  121241. * Class used to store node based material build state
  121242. */
  121243. export class NodeMaterialBuildState {
  121244. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  121245. supportUniformBuffers: boolean;
  121246. /**
  121247. * Gets the list of emitted attributes
  121248. */
  121249. attributes: string[];
  121250. /**
  121251. * Gets the list of emitted uniforms
  121252. */
  121253. uniforms: string[];
  121254. /**
  121255. * Gets the list of emitted constants
  121256. */
  121257. constants: string[];
  121258. /**
  121259. * Gets the list of emitted samplers
  121260. */
  121261. samplers: string[];
  121262. /**
  121263. * Gets the list of emitted functions
  121264. */
  121265. functions: {
  121266. [key: string]: string;
  121267. };
  121268. /**
  121269. * Gets the list of emitted extensions
  121270. */
  121271. extensions: {
  121272. [key: string]: string;
  121273. };
  121274. /**
  121275. * Gets the target of the compilation state
  121276. */
  121277. target: NodeMaterialBlockTargets;
  121278. /**
  121279. * Gets the list of emitted counters
  121280. */
  121281. counters: {
  121282. [key: string]: number;
  121283. };
  121284. /**
  121285. * Shared data between multiple NodeMaterialBuildState instances
  121286. */
  121287. sharedData: NodeMaterialBuildStateSharedData;
  121288. /** @hidden */
  121289. _vertexState: NodeMaterialBuildState;
  121290. /** @hidden */
  121291. _attributeDeclaration: string;
  121292. /** @hidden */
  121293. _uniformDeclaration: string;
  121294. /** @hidden */
  121295. _constantDeclaration: string;
  121296. /** @hidden */
  121297. _samplerDeclaration: string;
  121298. /** @hidden */
  121299. _varyingTransfer: string;
  121300. private _repeatableContentAnchorIndex;
  121301. /** @hidden */
  121302. _builtCompilationString: string;
  121303. /**
  121304. * Gets the emitted compilation strings
  121305. */
  121306. compilationString: string;
  121307. /**
  121308. * Finalize the compilation strings
  121309. * @param state defines the current compilation state
  121310. */
  121311. finalize(state: NodeMaterialBuildState): void;
  121312. /** @hidden */
  121313. readonly _repeatableContentAnchor: string;
  121314. /** @hidden */
  121315. _getFreeVariableName(prefix: string): string;
  121316. /** @hidden */
  121317. _getFreeDefineName(prefix: string): string;
  121318. /** @hidden */
  121319. _excludeVariableName(name: string): void;
  121320. /** @hidden */
  121321. _emit2DSampler(name: string): void;
  121322. /** @hidden */
  121323. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  121324. /** @hidden */
  121325. _emitExtension(name: string, extension: string): void;
  121326. /** @hidden */
  121327. _emitFunction(name: string, code: string, comments: string): void;
  121328. /** @hidden */
  121329. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  121330. replaceStrings?: {
  121331. search: RegExp;
  121332. replace: string;
  121333. }[];
  121334. repeatKey?: string;
  121335. }): string;
  121336. /** @hidden */
  121337. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  121338. repeatKey?: string;
  121339. removeAttributes?: boolean;
  121340. removeUniforms?: boolean;
  121341. removeVaryings?: boolean;
  121342. removeIfDef?: boolean;
  121343. replaceStrings?: {
  121344. search: RegExp;
  121345. replace: string;
  121346. }[];
  121347. }, storeKey?: string): void;
  121348. /** @hidden */
  121349. _registerTempVariable(name: string): boolean;
  121350. /** @hidden */
  121351. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  121352. /** @hidden */
  121353. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  121354. /** @hidden */
  121355. _emitFloat(value: number): string;
  121356. }
  121357. }
  121358. declare module BABYLON {
  121359. /**
  121360. * Defines a block that can be used inside a node based material
  121361. */
  121362. export class NodeMaterialBlock {
  121363. private _buildId;
  121364. private _buildTarget;
  121365. private _target;
  121366. private _isFinalMerger;
  121367. private _isInput;
  121368. /** @hidden */
  121369. _codeVariableName: string;
  121370. /** @hidden */
  121371. _inputs: NodeMaterialConnectionPoint[];
  121372. /** @hidden */
  121373. _outputs: NodeMaterialConnectionPoint[];
  121374. /** @hidden */
  121375. _preparationId: number;
  121376. /**
  121377. * Gets or sets the name of the block
  121378. */
  121379. name: string;
  121380. /**
  121381. * Gets or sets the unique id of the node
  121382. */
  121383. uniqueId: number;
  121384. /**
  121385. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  121386. */
  121387. readonly isFinalMerger: boolean;
  121388. /**
  121389. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  121390. */
  121391. readonly isInput: boolean;
  121392. /**
  121393. * Gets or sets the build Id
  121394. */
  121395. buildId: number;
  121396. /**
  121397. * Gets or sets the target of the block
  121398. */
  121399. target: NodeMaterialBlockTargets;
  121400. /**
  121401. * Gets the list of input points
  121402. */
  121403. readonly inputs: NodeMaterialConnectionPoint[];
  121404. /** Gets the list of output points */
  121405. readonly outputs: NodeMaterialConnectionPoint[];
  121406. /**
  121407. * Find an input by its name
  121408. * @param name defines the name of the input to look for
  121409. * @returns the input or null if not found
  121410. */
  121411. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121412. /**
  121413. * Find an output by its name
  121414. * @param name defines the name of the outputto look for
  121415. * @returns the output or null if not found
  121416. */
  121417. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  121418. /**
  121419. * Creates a new NodeMaterialBlock
  121420. * @param name defines the block name
  121421. * @param target defines the target of that block (Vertex by default)
  121422. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  121423. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  121424. */
  121425. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  121426. /**
  121427. * Initialize the block and prepare the context for build
  121428. * @param state defines the state that will be used for the build
  121429. */
  121430. initialize(state: NodeMaterialBuildState): void;
  121431. /**
  121432. * Bind data to effect. Will only be called for blocks with isBindable === true
  121433. * @param effect defines the effect to bind data to
  121434. * @param nodeMaterial defines the hosting NodeMaterial
  121435. * @param mesh defines the mesh that will be rendered
  121436. */
  121437. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121438. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  121439. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  121440. protected _writeFloat(value: number): string;
  121441. /**
  121442. * Gets the current class name e.g. "NodeMaterialBlock"
  121443. * @returns the class name
  121444. */
  121445. getClassName(): string;
  121446. /**
  121447. * Register a new input. Must be called inside a block constructor
  121448. * @param name defines the connection point name
  121449. * @param type defines the connection point type
  121450. * @param isOptional defines a boolean indicating that this input can be omitted
  121451. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121452. * @returns the current block
  121453. */
  121454. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  121455. /**
  121456. * Register a new output. Must be called inside a block constructor
  121457. * @param name defines the connection point name
  121458. * @param type defines the connection point type
  121459. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  121460. * @returns the current block
  121461. */
  121462. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  121463. /**
  121464. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  121465. * @param forOutput defines an optional connection point to check compatibility with
  121466. * @returns the first available input or null
  121467. */
  121468. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  121469. /**
  121470. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  121471. * @param forBlock defines an optional block to check compatibility with
  121472. * @returns the first available input or null
  121473. */
  121474. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  121475. /**
  121476. * Gets the sibling of the given output
  121477. * @param current defines the current output
  121478. * @returns the next output in the list or null
  121479. */
  121480. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  121481. /**
  121482. * Connect current block with another block
  121483. * @param other defines the block to connect with
  121484. * @param options define the various options to help pick the right connections
  121485. * @returns the current block
  121486. */
  121487. connectTo(other: NodeMaterialBlock, options?: {
  121488. input?: string;
  121489. output?: string;
  121490. outputSwizzle?: string;
  121491. }): this | undefined;
  121492. protected _buildBlock(state: NodeMaterialBuildState): void;
  121493. /**
  121494. * Add uniforms, samplers and uniform buffers at compilation time
  121495. * @param state defines the state to update
  121496. * @param nodeMaterial defines the node material requesting the update
  121497. * @param defines defines the material defines to update
  121498. * @param uniformBuffers defines the list of uniform buffer names
  121499. */
  121500. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  121501. /**
  121502. * Add potential fallbacks if shader compilation fails
  121503. * @param mesh defines the mesh to be rendered
  121504. * @param fallbacks defines the current prioritized list of fallbacks
  121505. */
  121506. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121507. /**
  121508. * Initialize defines for shader compilation
  121509. * @param mesh defines the mesh to be rendered
  121510. * @param nodeMaterial defines the node material requesting the update
  121511. * @param defines defines the material defines to update
  121512. * @param useInstances specifies that instances should be used
  121513. */
  121514. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121515. /**
  121516. * Update defines for shader compilation
  121517. * @param mesh defines the mesh to be rendered
  121518. * @param nodeMaterial defines the node material requesting the update
  121519. * @param defines defines the material defines to update
  121520. * @param useInstances specifies that instances should be used
  121521. */
  121522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121523. /**
  121524. * Lets the block try to connect some inputs automatically
  121525. * @param material defines the hosting NodeMaterial
  121526. */
  121527. autoConfigure(material: NodeMaterial): void;
  121528. /**
  121529. * Function called when a block is declared as repeatable content generator
  121530. * @param vertexShaderState defines the current compilation state for the vertex shader
  121531. * @param fragmentShaderState defines the current compilation state for the fragment shader
  121532. * @param mesh defines the mesh to be rendered
  121533. * @param defines defines the material defines to update
  121534. */
  121535. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121536. /**
  121537. * Checks if the block is ready
  121538. * @param mesh defines the mesh to be rendered
  121539. * @param nodeMaterial defines the node material requesting the update
  121540. * @param defines defines the material defines to update
  121541. * @param useInstances specifies that instances should be used
  121542. * @returns true if the block is ready
  121543. */
  121544. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  121545. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  121546. private _processBuild;
  121547. /**
  121548. * Compile the current node and generate the shader code
  121549. * @param state defines the current compilation state (uniforms, samplers, current string)
  121550. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  121551. * @returns true if already built
  121552. */
  121553. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  121554. protected _inputRename(name: string): string;
  121555. protected _outputRename(name: string): string;
  121556. protected _dumpPropertiesCode(): string;
  121557. /** @hidden */
  121558. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  121559. /**
  121560. * Clone the current block to a new identical block
  121561. * @param scene defines the hosting scene
  121562. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  121563. * @returns a copy of the current block
  121564. */
  121565. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  121566. /**
  121567. * Serializes this block in a JSON representation
  121568. * @returns the serialized block object
  121569. */
  121570. serialize(): any;
  121571. /** @hidden */
  121572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121573. /**
  121574. * Release resources
  121575. */
  121576. dispose(): void;
  121577. }
  121578. }
  121579. declare module BABYLON {
  121580. /**
  121581. * Enum defining the type of animations supported by InputBlock
  121582. */
  121583. export enum AnimatedInputBlockTypes {
  121584. /** No animation */
  121585. None = 0,
  121586. /** Time based animation. Will only work for floats */
  121587. Time = 1
  121588. }
  121589. }
  121590. declare module BABYLON {
  121591. /**
  121592. * Block used to expose an input value
  121593. */
  121594. export class InputBlock extends NodeMaterialBlock {
  121595. private _mode;
  121596. private _associatedVariableName;
  121597. private _storedValue;
  121598. private _valueCallback;
  121599. private _type;
  121600. private _animationType;
  121601. /** Gets or set a value used to limit the range of float values */
  121602. min: number;
  121603. /** Gets or set a value used to limit the range of float values */
  121604. max: number;
  121605. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  121606. matrixMode: number;
  121607. /** @hidden */
  121608. _systemValue: Nullable<NodeMaterialSystemValues>;
  121609. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  121610. visibleInInspector: boolean;
  121611. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  121612. isConstant: boolean;
  121613. /**
  121614. * Gets or sets the connection point type (default is float)
  121615. */
  121616. readonly type: NodeMaterialBlockConnectionPointTypes;
  121617. /**
  121618. * Creates a new InputBlock
  121619. * @param name defines the block name
  121620. * @param target defines the target of that block (Vertex by default)
  121621. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  121622. */
  121623. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  121624. /**
  121625. * Gets the output component
  121626. */
  121627. readonly output: NodeMaterialConnectionPoint;
  121628. /**
  121629. * Set the source of this connection point to a vertex attribute
  121630. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  121631. * @returns the current connection point
  121632. */
  121633. setAsAttribute(attributeName?: string): InputBlock;
  121634. /**
  121635. * Set the source of this connection point to a system value
  121636. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  121637. * @returns the current connection point
  121638. */
  121639. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  121640. /**
  121641. * Gets or sets the value of that point.
  121642. * Please note that this value will be ignored if valueCallback is defined
  121643. */
  121644. value: any;
  121645. /**
  121646. * Gets or sets a callback used to get the value of that point.
  121647. * Please note that setting this value will force the connection point to ignore the value property
  121648. */
  121649. valueCallback: () => any;
  121650. /**
  121651. * Gets or sets the associated variable name in the shader
  121652. */
  121653. associatedVariableName: string;
  121654. /** Gets or sets the type of animation applied to the input */
  121655. animationType: AnimatedInputBlockTypes;
  121656. /**
  121657. * Gets a boolean indicating that this connection point not defined yet
  121658. */
  121659. readonly isUndefined: boolean;
  121660. /**
  121661. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  121662. * In this case the connection point name must be the name of the uniform to use.
  121663. * Can only be set on inputs
  121664. */
  121665. isUniform: boolean;
  121666. /**
  121667. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  121668. * In this case the connection point name must be the name of the attribute to use
  121669. * Can only be set on inputs
  121670. */
  121671. isAttribute: boolean;
  121672. /**
  121673. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  121674. * Can only be set on exit points
  121675. */
  121676. isVarying: boolean;
  121677. /**
  121678. * Gets a boolean indicating that the current connection point is a system value
  121679. */
  121680. readonly isSystemValue: boolean;
  121681. /**
  121682. * Gets or sets the current well known value or null if not defined as a system value
  121683. */
  121684. systemValue: Nullable<NodeMaterialSystemValues>;
  121685. /**
  121686. * Gets the current class name
  121687. * @returns the class name
  121688. */
  121689. getClassName(): string;
  121690. /**
  121691. * Animate the input if animationType !== None
  121692. * @param scene defines the rendering scene
  121693. */
  121694. animate(scene: Scene): void;
  121695. private _emitDefine;
  121696. initialize(state: NodeMaterialBuildState): void;
  121697. /**
  121698. * Set the input block to its default value (based on its type)
  121699. */
  121700. setDefaultValue(): void;
  121701. private _emitConstant;
  121702. private _emit;
  121703. /** @hidden */
  121704. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  121705. /** @hidden */
  121706. _transmit(effect: Effect, scene: Scene): void;
  121707. protected _buildBlock(state: NodeMaterialBuildState): void;
  121708. protected _dumpPropertiesCode(): string;
  121709. serialize(): any;
  121710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121711. }
  121712. }
  121713. declare module BABYLON {
  121714. /**
  121715. * Defines a connection point for a block
  121716. */
  121717. export class NodeMaterialConnectionPoint {
  121718. /** @hidden */
  121719. _ownerBlock: NodeMaterialBlock;
  121720. /** @hidden */
  121721. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121722. private _endpoints;
  121723. private _associatedVariableName;
  121724. /** @hidden */
  121725. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121726. /** @hidden */
  121727. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  121728. private _type;
  121729. /** @hidden */
  121730. _enforceAssociatedVariableName: boolean;
  121731. /**
  121732. * Gets or sets the additional types supported by this connection point
  121733. */
  121734. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121735. /**
  121736. * Gets or sets the additional types excluded by this connection point
  121737. */
  121738. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  121739. /**
  121740. * Observable triggered when this point is connected
  121741. */
  121742. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  121743. /**
  121744. * Gets or sets the associated variable name in the shader
  121745. */
  121746. associatedVariableName: string;
  121747. /**
  121748. * Gets or sets the connection point type (default is float)
  121749. */
  121750. type: NodeMaterialBlockConnectionPointTypes;
  121751. /**
  121752. * Gets or sets the connection point name
  121753. */
  121754. name: string;
  121755. /**
  121756. * Gets or sets a boolean indicating that this connection point can be omitted
  121757. */
  121758. isOptional: boolean;
  121759. /**
  121760. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  121761. */
  121762. define: string;
  121763. /** @hidden */
  121764. _prioritizeVertex: boolean;
  121765. private _target;
  121766. /** Gets or sets the target of that connection point */
  121767. target: NodeMaterialBlockTargets;
  121768. /**
  121769. * Gets a boolean indicating that the current point is connected
  121770. */
  121771. readonly isConnected: boolean;
  121772. /**
  121773. * Gets a boolean indicating that the current point is connected to an input block
  121774. */
  121775. readonly isConnectedToInputBlock: boolean;
  121776. /**
  121777. * Gets a the connected input block (if any)
  121778. */
  121779. readonly connectInputBlock: Nullable<InputBlock>;
  121780. /** Get the other side of the connection (if any) */
  121781. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  121782. /** Get the block that owns this connection point */
  121783. readonly ownerBlock: NodeMaterialBlock;
  121784. /** Get the block connected on the other side of this connection (if any) */
  121785. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  121786. /** Get the block connected on the endpoints of this connection (if any) */
  121787. readonly connectedBlocks: Array<NodeMaterialBlock>;
  121788. /** Gets the list of connected endpoints */
  121789. readonly endpoints: NodeMaterialConnectionPoint[];
  121790. /** Gets a boolean indicating if that output point is connected to at least one input */
  121791. readonly hasEndpoints: boolean;
  121792. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  121793. readonly isConnectedInVertexShader: boolean;
  121794. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  121795. readonly isConnectedInFragmentShader: boolean;
  121796. /**
  121797. * Creates a new connection point
  121798. * @param name defines the connection point name
  121799. * @param ownerBlock defines the block hosting this connection point
  121800. */
  121801. constructor(name: string, ownerBlock: NodeMaterialBlock);
  121802. /**
  121803. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  121804. * @returns the class name
  121805. */
  121806. getClassName(): string;
  121807. /**
  121808. * Gets an boolean indicating if the current point can be connected to another point
  121809. * @param connectionPoint defines the other connection point
  121810. * @returns true if the connection is possible
  121811. */
  121812. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  121813. /**
  121814. * Connect this point to another connection point
  121815. * @param connectionPoint defines the other connection point
  121816. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  121817. * @returns the current connection point
  121818. */
  121819. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  121820. /**
  121821. * Disconnect this point from one of his endpoint
  121822. * @param endpoint defines the other connection point
  121823. * @returns the current connection point
  121824. */
  121825. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  121826. /**
  121827. * Serializes this point in a JSON representation
  121828. * @returns the serialized point object
  121829. */
  121830. serialize(): any;
  121831. /**
  121832. * Release resources
  121833. */
  121834. dispose(): void;
  121835. }
  121836. }
  121837. declare module BABYLON {
  121838. /**
  121839. * Block used to add support for vertex skinning (bones)
  121840. */
  121841. export class BonesBlock extends NodeMaterialBlock {
  121842. /**
  121843. * Creates a new BonesBlock
  121844. * @param name defines the block name
  121845. */
  121846. constructor(name: string);
  121847. /**
  121848. * Initialize the block and prepare the context for build
  121849. * @param state defines the state that will be used for the build
  121850. */
  121851. initialize(state: NodeMaterialBuildState): void;
  121852. /**
  121853. * Gets the current class name
  121854. * @returns the class name
  121855. */
  121856. getClassName(): string;
  121857. /**
  121858. * Gets the matrix indices input component
  121859. */
  121860. readonly matricesIndices: NodeMaterialConnectionPoint;
  121861. /**
  121862. * Gets the matrix weights input component
  121863. */
  121864. readonly matricesWeights: NodeMaterialConnectionPoint;
  121865. /**
  121866. * Gets the extra matrix indices input component
  121867. */
  121868. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  121869. /**
  121870. * Gets the extra matrix weights input component
  121871. */
  121872. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  121873. /**
  121874. * Gets the world input component
  121875. */
  121876. readonly world: NodeMaterialConnectionPoint;
  121877. /**
  121878. * Gets the output component
  121879. */
  121880. readonly output: NodeMaterialConnectionPoint;
  121881. autoConfigure(material: NodeMaterial): void;
  121882. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  121883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121884. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121885. protected _buildBlock(state: NodeMaterialBuildState): this;
  121886. }
  121887. }
  121888. declare module BABYLON {
  121889. /**
  121890. * Block used to add support for instances
  121891. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  121892. */
  121893. export class InstancesBlock extends NodeMaterialBlock {
  121894. /**
  121895. * Creates a new InstancesBlock
  121896. * @param name defines the block name
  121897. */
  121898. constructor(name: string);
  121899. /**
  121900. * Gets the current class name
  121901. * @returns the class name
  121902. */
  121903. getClassName(): string;
  121904. /**
  121905. * Gets the first world row input component
  121906. */
  121907. readonly world0: NodeMaterialConnectionPoint;
  121908. /**
  121909. * Gets the second world row input component
  121910. */
  121911. readonly world1: NodeMaterialConnectionPoint;
  121912. /**
  121913. * Gets the third world row input component
  121914. */
  121915. readonly world2: NodeMaterialConnectionPoint;
  121916. /**
  121917. * Gets the forth world row input component
  121918. */
  121919. readonly world3: NodeMaterialConnectionPoint;
  121920. /**
  121921. * Gets the world input component
  121922. */
  121923. readonly world: NodeMaterialConnectionPoint;
  121924. /**
  121925. * Gets the output component
  121926. */
  121927. readonly output: NodeMaterialConnectionPoint;
  121928. autoConfigure(material: NodeMaterial): void;
  121929. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  121930. protected _buildBlock(state: NodeMaterialBuildState): this;
  121931. }
  121932. }
  121933. declare module BABYLON {
  121934. /**
  121935. * Block used to add morph targets support to vertex shader
  121936. */
  121937. export class MorphTargetsBlock extends NodeMaterialBlock {
  121938. private _repeatableContentAnchor;
  121939. private _repeatebleContentGenerated;
  121940. /**
  121941. * Create a new MorphTargetsBlock
  121942. * @param name defines the block name
  121943. */
  121944. constructor(name: string);
  121945. /**
  121946. * Gets the current class name
  121947. * @returns the class name
  121948. */
  121949. getClassName(): string;
  121950. /**
  121951. * Gets the position input component
  121952. */
  121953. readonly position: NodeMaterialConnectionPoint;
  121954. /**
  121955. * Gets the normal input component
  121956. */
  121957. readonly normal: NodeMaterialConnectionPoint;
  121958. /**
  121959. * Gets the tangent input component
  121960. */
  121961. readonly tangent: NodeMaterialConnectionPoint;
  121962. /**
  121963. * Gets the tangent input component
  121964. */
  121965. readonly uv: NodeMaterialConnectionPoint;
  121966. /**
  121967. * Gets the position output component
  121968. */
  121969. readonly positionOutput: NodeMaterialConnectionPoint;
  121970. /**
  121971. * Gets the normal output component
  121972. */
  121973. readonly normalOutput: NodeMaterialConnectionPoint;
  121974. /**
  121975. * Gets the tangent output component
  121976. */
  121977. readonly tangentOutput: NodeMaterialConnectionPoint;
  121978. /**
  121979. * Gets the tangent output component
  121980. */
  121981. readonly uvOutput: NodeMaterialConnectionPoint;
  121982. initialize(state: NodeMaterialBuildState): void;
  121983. autoConfigure(material: NodeMaterial): void;
  121984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121985. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121986. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  121987. protected _buildBlock(state: NodeMaterialBuildState): this;
  121988. }
  121989. }
  121990. declare module BABYLON {
  121991. /**
  121992. * Block used to get data information from a light
  121993. */
  121994. export class LightInformationBlock extends NodeMaterialBlock {
  121995. private _lightDataUniformName;
  121996. private _lightColorUniformName;
  121997. private _lightTypeDefineName;
  121998. /**
  121999. * Gets or sets the light associated with this block
  122000. */
  122001. light: Nullable<Light>;
  122002. /**
  122003. * Creates a new LightInformationBlock
  122004. * @param name defines the block name
  122005. */
  122006. constructor(name: string);
  122007. /**
  122008. * Gets the current class name
  122009. * @returns the class name
  122010. */
  122011. getClassName(): string;
  122012. /**
  122013. * Gets the world position input component
  122014. */
  122015. readonly worldPosition: NodeMaterialConnectionPoint;
  122016. /**
  122017. * Gets the direction output component
  122018. */
  122019. readonly direction: NodeMaterialConnectionPoint;
  122020. /**
  122021. * Gets the direction output component
  122022. */
  122023. readonly color: NodeMaterialConnectionPoint;
  122024. /**
  122025. * Gets the direction output component
  122026. */
  122027. readonly intensity: NodeMaterialConnectionPoint;
  122028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122030. protected _buildBlock(state: NodeMaterialBuildState): this;
  122031. serialize(): any;
  122032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122033. }
  122034. }
  122035. declare module BABYLON {
  122036. /**
  122037. * Block used to add image processing support to fragment shader
  122038. */
  122039. export class ImageProcessingBlock extends NodeMaterialBlock {
  122040. /**
  122041. * Create a new ImageProcessingBlock
  122042. * @param name defines the block name
  122043. */
  122044. constructor(name: string);
  122045. /**
  122046. * Gets the current class name
  122047. * @returns the class name
  122048. */
  122049. getClassName(): string;
  122050. /**
  122051. * Gets the color input component
  122052. */
  122053. readonly color: NodeMaterialConnectionPoint;
  122054. /**
  122055. * Gets the output component
  122056. */
  122057. readonly output: NodeMaterialConnectionPoint;
  122058. /**
  122059. * Initialize the block and prepare the context for build
  122060. * @param state defines the state that will be used for the build
  122061. */
  122062. initialize(state: NodeMaterialBuildState): void;
  122063. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  122064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122066. protected _buildBlock(state: NodeMaterialBuildState): this;
  122067. }
  122068. }
  122069. declare module BABYLON {
  122070. /**
  122071. * Block used to pertub normals based on a normal map
  122072. */
  122073. export class PerturbNormalBlock extends NodeMaterialBlock {
  122074. private _tangentSpaceParameterName;
  122075. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  122076. invertX: boolean;
  122077. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  122078. invertY: boolean;
  122079. /**
  122080. * Create a new PerturbNormalBlock
  122081. * @param name defines the block name
  122082. */
  122083. constructor(name: string);
  122084. /**
  122085. * Gets the current class name
  122086. * @returns the class name
  122087. */
  122088. getClassName(): string;
  122089. /**
  122090. * Gets the world position input component
  122091. */
  122092. readonly worldPosition: NodeMaterialConnectionPoint;
  122093. /**
  122094. * Gets the world normal input component
  122095. */
  122096. readonly worldNormal: NodeMaterialConnectionPoint;
  122097. /**
  122098. * Gets the uv input component
  122099. */
  122100. readonly uv: NodeMaterialConnectionPoint;
  122101. /**
  122102. * Gets the normal map color input component
  122103. */
  122104. readonly normalMapColor: NodeMaterialConnectionPoint;
  122105. /**
  122106. * Gets the strength input component
  122107. */
  122108. readonly strength: NodeMaterialConnectionPoint;
  122109. /**
  122110. * Gets the output component
  122111. */
  122112. readonly output: NodeMaterialConnectionPoint;
  122113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122115. autoConfigure(material: NodeMaterial): void;
  122116. protected _buildBlock(state: NodeMaterialBuildState): this;
  122117. protected _dumpPropertiesCode(): string;
  122118. serialize(): any;
  122119. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122120. }
  122121. }
  122122. declare module BABYLON {
  122123. /**
  122124. * Block used to discard a pixel if a value is smaller than a cutoff
  122125. */
  122126. export class DiscardBlock extends NodeMaterialBlock {
  122127. /**
  122128. * Create a new DiscardBlock
  122129. * @param name defines the block name
  122130. */
  122131. constructor(name: string);
  122132. /**
  122133. * Gets the current class name
  122134. * @returns the class name
  122135. */
  122136. getClassName(): string;
  122137. /**
  122138. * Gets the color input component
  122139. */
  122140. readonly value: NodeMaterialConnectionPoint;
  122141. /**
  122142. * Gets the cutoff input component
  122143. */
  122144. readonly cutoff: NodeMaterialConnectionPoint;
  122145. protected _buildBlock(state: NodeMaterialBuildState): this;
  122146. }
  122147. }
  122148. declare module BABYLON {
  122149. /**
  122150. * Block used to add support for scene fog
  122151. */
  122152. export class FogBlock extends NodeMaterialBlock {
  122153. private _fogDistanceName;
  122154. private _fogParameters;
  122155. /**
  122156. * Create a new FogBlock
  122157. * @param name defines the block name
  122158. */
  122159. constructor(name: string);
  122160. /**
  122161. * Gets the current class name
  122162. * @returns the class name
  122163. */
  122164. getClassName(): string;
  122165. /**
  122166. * Gets the world position input component
  122167. */
  122168. readonly worldPosition: NodeMaterialConnectionPoint;
  122169. /**
  122170. * Gets the view input component
  122171. */
  122172. readonly view: NodeMaterialConnectionPoint;
  122173. /**
  122174. * Gets the color input component
  122175. */
  122176. readonly input: NodeMaterialConnectionPoint;
  122177. /**
  122178. * Gets the fog color input component
  122179. */
  122180. readonly fogColor: NodeMaterialConnectionPoint;
  122181. /**
  122182. * Gets the output component
  122183. */
  122184. readonly output: NodeMaterialConnectionPoint;
  122185. autoConfigure(material: NodeMaterial): void;
  122186. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122187. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122188. protected _buildBlock(state: NodeMaterialBuildState): this;
  122189. }
  122190. }
  122191. declare module BABYLON {
  122192. /**
  122193. * Block used to add light in the fragment shader
  122194. */
  122195. export class LightBlock extends NodeMaterialBlock {
  122196. private _lightId;
  122197. /**
  122198. * Gets or sets the light associated with this block
  122199. */
  122200. light: Nullable<Light>;
  122201. /**
  122202. * Create a new LightBlock
  122203. * @param name defines the block name
  122204. */
  122205. constructor(name: string);
  122206. /**
  122207. * Gets the current class name
  122208. * @returns the class name
  122209. */
  122210. getClassName(): string;
  122211. /**
  122212. * Gets the world position input component
  122213. */
  122214. readonly worldPosition: NodeMaterialConnectionPoint;
  122215. /**
  122216. * Gets the world normal input component
  122217. */
  122218. readonly worldNormal: NodeMaterialConnectionPoint;
  122219. /**
  122220. * Gets the camera (or eye) position component
  122221. */
  122222. readonly cameraPosition: NodeMaterialConnectionPoint;
  122223. /**
  122224. * Gets the glossiness component
  122225. */
  122226. readonly glossiness: NodeMaterialConnectionPoint;
  122227. /**
  122228. * Gets the glossinness power component
  122229. */
  122230. readonly glossPower: NodeMaterialConnectionPoint;
  122231. /**
  122232. * Gets the diffuse color component
  122233. */
  122234. readonly diffuseColor: NodeMaterialConnectionPoint;
  122235. /**
  122236. * Gets the specular color component
  122237. */
  122238. readonly specularColor: NodeMaterialConnectionPoint;
  122239. /**
  122240. * Gets the diffuse output component
  122241. */
  122242. readonly diffuseOutput: NodeMaterialConnectionPoint;
  122243. /**
  122244. * Gets the specular output component
  122245. */
  122246. readonly specularOutput: NodeMaterialConnectionPoint;
  122247. autoConfigure(material: NodeMaterial): void;
  122248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122249. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122250. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122251. private _injectVertexCode;
  122252. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122253. serialize(): any;
  122254. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122255. }
  122256. }
  122257. declare module BABYLON {
  122258. /**
  122259. * Block used to multiply 2 values
  122260. */
  122261. export class MultiplyBlock extends NodeMaterialBlock {
  122262. /**
  122263. * Creates a new MultiplyBlock
  122264. * @param name defines the block name
  122265. */
  122266. constructor(name: string);
  122267. /**
  122268. * Gets the current class name
  122269. * @returns the class name
  122270. */
  122271. getClassName(): string;
  122272. /**
  122273. * Gets the left operand input component
  122274. */
  122275. readonly left: NodeMaterialConnectionPoint;
  122276. /**
  122277. * Gets the right operand input component
  122278. */
  122279. readonly right: NodeMaterialConnectionPoint;
  122280. /**
  122281. * Gets the output component
  122282. */
  122283. readonly output: NodeMaterialConnectionPoint;
  122284. protected _buildBlock(state: NodeMaterialBuildState): this;
  122285. }
  122286. }
  122287. declare module BABYLON {
  122288. /**
  122289. * Block used to add 2 vectors
  122290. */
  122291. export class AddBlock extends NodeMaterialBlock {
  122292. /**
  122293. * Creates a new AddBlock
  122294. * @param name defines the block name
  122295. */
  122296. constructor(name: string);
  122297. /**
  122298. * Gets the current class name
  122299. * @returns the class name
  122300. */
  122301. getClassName(): string;
  122302. /**
  122303. * Gets the left operand input component
  122304. */
  122305. readonly left: NodeMaterialConnectionPoint;
  122306. /**
  122307. * Gets the right operand input component
  122308. */
  122309. readonly right: NodeMaterialConnectionPoint;
  122310. /**
  122311. * Gets the output component
  122312. */
  122313. readonly output: NodeMaterialConnectionPoint;
  122314. protected _buildBlock(state: NodeMaterialBuildState): this;
  122315. }
  122316. }
  122317. declare module BABYLON {
  122318. /**
  122319. * Block used to scale a vector by a float
  122320. */
  122321. export class ScaleBlock extends NodeMaterialBlock {
  122322. /**
  122323. * Creates a new ScaleBlock
  122324. * @param name defines the block name
  122325. */
  122326. constructor(name: string);
  122327. /**
  122328. * Gets the current class name
  122329. * @returns the class name
  122330. */
  122331. getClassName(): string;
  122332. /**
  122333. * Gets the input component
  122334. */
  122335. readonly input: NodeMaterialConnectionPoint;
  122336. /**
  122337. * Gets the factor input component
  122338. */
  122339. readonly factor: NodeMaterialConnectionPoint;
  122340. /**
  122341. * Gets the output component
  122342. */
  122343. readonly output: NodeMaterialConnectionPoint;
  122344. protected _buildBlock(state: NodeMaterialBuildState): this;
  122345. }
  122346. }
  122347. declare module BABYLON {
  122348. /**
  122349. * Block used to clamp a float
  122350. */
  122351. export class ClampBlock extends NodeMaterialBlock {
  122352. /** Gets or sets the minimum range */
  122353. minimum: number;
  122354. /** Gets or sets the maximum range */
  122355. maximum: number;
  122356. /**
  122357. * Creates a new ClampBlock
  122358. * @param name defines the block name
  122359. */
  122360. constructor(name: string);
  122361. /**
  122362. * Gets the current class name
  122363. * @returns the class name
  122364. */
  122365. getClassName(): string;
  122366. /**
  122367. * Gets the value input component
  122368. */
  122369. readonly value: NodeMaterialConnectionPoint;
  122370. /**
  122371. * Gets the output component
  122372. */
  122373. readonly output: NodeMaterialConnectionPoint;
  122374. protected _buildBlock(state: NodeMaterialBuildState): this;
  122375. protected _dumpPropertiesCode(): string;
  122376. serialize(): any;
  122377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122378. }
  122379. }
  122380. declare module BABYLON {
  122381. /**
  122382. * Block used to apply a cross product between 2 vectors
  122383. */
  122384. export class CrossBlock extends NodeMaterialBlock {
  122385. /**
  122386. * Creates a new CrossBlock
  122387. * @param name defines the block name
  122388. */
  122389. constructor(name: string);
  122390. /**
  122391. * Gets the current class name
  122392. * @returns the class name
  122393. */
  122394. getClassName(): string;
  122395. /**
  122396. * Gets the left operand input component
  122397. */
  122398. readonly left: NodeMaterialConnectionPoint;
  122399. /**
  122400. * Gets the right operand input component
  122401. */
  122402. readonly right: NodeMaterialConnectionPoint;
  122403. /**
  122404. * Gets the output component
  122405. */
  122406. readonly output: NodeMaterialConnectionPoint;
  122407. protected _buildBlock(state: NodeMaterialBuildState): this;
  122408. }
  122409. }
  122410. declare module BABYLON {
  122411. /**
  122412. * Block used to apply a dot product between 2 vectors
  122413. */
  122414. export class DotBlock extends NodeMaterialBlock {
  122415. /**
  122416. * Creates a new DotBlock
  122417. * @param name defines the block name
  122418. */
  122419. constructor(name: string);
  122420. /**
  122421. * Gets the current class name
  122422. * @returns the class name
  122423. */
  122424. getClassName(): string;
  122425. /**
  122426. * Gets the left operand input component
  122427. */
  122428. readonly left: NodeMaterialConnectionPoint;
  122429. /**
  122430. * Gets the right operand input component
  122431. */
  122432. readonly right: NodeMaterialConnectionPoint;
  122433. /**
  122434. * Gets the output component
  122435. */
  122436. readonly output: NodeMaterialConnectionPoint;
  122437. protected _buildBlock(state: NodeMaterialBuildState): this;
  122438. }
  122439. }
  122440. declare module BABYLON {
  122441. /**
  122442. * Block used to remap a float from a range to a new one
  122443. */
  122444. export class RemapBlock extends NodeMaterialBlock {
  122445. /**
  122446. * Gets or sets the source range
  122447. */
  122448. sourceRange: Vector2;
  122449. /**
  122450. * Gets or sets the target range
  122451. */
  122452. targetRange: Vector2;
  122453. /**
  122454. * Creates a new RemapBlock
  122455. * @param name defines the block name
  122456. */
  122457. constructor(name: string);
  122458. /**
  122459. * Gets the current class name
  122460. * @returns the class name
  122461. */
  122462. getClassName(): string;
  122463. /**
  122464. * Gets the input component
  122465. */
  122466. readonly input: NodeMaterialConnectionPoint;
  122467. /**
  122468. * Gets the source min input component
  122469. */
  122470. readonly sourceMin: NodeMaterialConnectionPoint;
  122471. /**
  122472. * Gets the source max input component
  122473. */
  122474. readonly sourceMax: NodeMaterialConnectionPoint;
  122475. /**
  122476. * Gets the target min input component
  122477. */
  122478. readonly targetMin: NodeMaterialConnectionPoint;
  122479. /**
  122480. * Gets the target max input component
  122481. */
  122482. readonly targetMax: NodeMaterialConnectionPoint;
  122483. /**
  122484. * Gets the output component
  122485. */
  122486. readonly output: NodeMaterialConnectionPoint;
  122487. protected _buildBlock(state: NodeMaterialBuildState): this;
  122488. protected _dumpPropertiesCode(): string;
  122489. serialize(): any;
  122490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122491. }
  122492. }
  122493. declare module BABYLON {
  122494. /**
  122495. * Block used to normalize a vector
  122496. */
  122497. export class NormalizeBlock extends NodeMaterialBlock {
  122498. /**
  122499. * Creates a new NormalizeBlock
  122500. * @param name defines the block name
  122501. */
  122502. constructor(name: string);
  122503. /**
  122504. * Gets the current class name
  122505. * @returns the class name
  122506. */
  122507. getClassName(): string;
  122508. /**
  122509. * Gets the input component
  122510. */
  122511. readonly input: NodeMaterialConnectionPoint;
  122512. /**
  122513. * Gets the output component
  122514. */
  122515. readonly output: NodeMaterialConnectionPoint;
  122516. protected _buildBlock(state: NodeMaterialBuildState): this;
  122517. }
  122518. }
  122519. declare module BABYLON {
  122520. /**
  122521. * Operations supported by the Trigonometry block
  122522. */
  122523. export enum TrigonometryBlockOperations {
  122524. /** Cos */
  122525. Cos = 0,
  122526. /** Sin */
  122527. Sin = 1,
  122528. /** Abs */
  122529. Abs = 2,
  122530. /** Exp */
  122531. Exp = 3,
  122532. /** Exp2 */
  122533. Exp2 = 4,
  122534. /** Round */
  122535. Round = 5,
  122536. /** Floor */
  122537. Floor = 6,
  122538. /** Ceiling */
  122539. Ceiling = 7,
  122540. /** Square root */
  122541. Sqrt = 8,
  122542. /** Log */
  122543. Log = 9,
  122544. /** Tangent */
  122545. Tan = 10,
  122546. /** Arc tangent */
  122547. ArcTan = 11,
  122548. /** Arc cosinus */
  122549. ArcCos = 12,
  122550. /** Arc sinus */
  122551. ArcSin = 13,
  122552. /** Fraction */
  122553. Fract = 14,
  122554. /** Sign */
  122555. Sign = 15,
  122556. /** To radians (from degrees) */
  122557. Radians = 16,
  122558. /** To degrees (from radians) */
  122559. Degrees = 17
  122560. }
  122561. /**
  122562. * Block used to apply trigonometry operation to floats
  122563. */
  122564. export class TrigonometryBlock extends NodeMaterialBlock {
  122565. /**
  122566. * Gets or sets the operation applied by the block
  122567. */
  122568. operation: TrigonometryBlockOperations;
  122569. /**
  122570. * Creates a new TrigonometryBlock
  122571. * @param name defines the block name
  122572. */
  122573. constructor(name: string);
  122574. /**
  122575. * Gets the current class name
  122576. * @returns the class name
  122577. */
  122578. getClassName(): string;
  122579. /**
  122580. * Gets the input component
  122581. */
  122582. readonly input: NodeMaterialConnectionPoint;
  122583. /**
  122584. * Gets the output component
  122585. */
  122586. readonly output: NodeMaterialConnectionPoint;
  122587. protected _buildBlock(state: NodeMaterialBuildState): this;
  122588. serialize(): any;
  122589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122590. }
  122591. }
  122592. declare module BABYLON {
  122593. /**
  122594. * Block used to create a Color3/4 out of individual inputs (one for each component)
  122595. */
  122596. export class ColorMergerBlock extends NodeMaterialBlock {
  122597. /**
  122598. * Create a new ColorMergerBlock
  122599. * @param name defines the block name
  122600. */
  122601. constructor(name: string);
  122602. /**
  122603. * Gets the current class name
  122604. * @returns the class name
  122605. */
  122606. getClassName(): string;
  122607. /**
  122608. * Gets the r component (input)
  122609. */
  122610. readonly r: NodeMaterialConnectionPoint;
  122611. /**
  122612. * Gets the g component (input)
  122613. */
  122614. readonly g: NodeMaterialConnectionPoint;
  122615. /**
  122616. * Gets the b component (input)
  122617. */
  122618. readonly b: NodeMaterialConnectionPoint;
  122619. /**
  122620. * Gets the a component (input)
  122621. */
  122622. readonly a: NodeMaterialConnectionPoint;
  122623. /**
  122624. * Gets the rgba component (output)
  122625. */
  122626. readonly rgba: NodeMaterialConnectionPoint;
  122627. /**
  122628. * Gets the rgb component (output)
  122629. */
  122630. readonly rgb: NodeMaterialConnectionPoint;
  122631. protected _buildBlock(state: NodeMaterialBuildState): this;
  122632. }
  122633. }
  122634. declare module BABYLON {
  122635. /**
  122636. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  122637. */
  122638. export class VectorMergerBlock extends NodeMaterialBlock {
  122639. /**
  122640. * Create a new VectorMergerBlock
  122641. * @param name defines the block name
  122642. */
  122643. constructor(name: string);
  122644. /**
  122645. * Gets the current class name
  122646. * @returns the class name
  122647. */
  122648. getClassName(): string;
  122649. /**
  122650. * Gets the x component (input)
  122651. */
  122652. readonly x: NodeMaterialConnectionPoint;
  122653. /**
  122654. * Gets the y component (input)
  122655. */
  122656. readonly y: NodeMaterialConnectionPoint;
  122657. /**
  122658. * Gets the z component (input)
  122659. */
  122660. readonly z: NodeMaterialConnectionPoint;
  122661. /**
  122662. * Gets the w component (input)
  122663. */
  122664. readonly w: NodeMaterialConnectionPoint;
  122665. /**
  122666. * Gets the xyzw component (output)
  122667. */
  122668. readonly xyzw: NodeMaterialConnectionPoint;
  122669. /**
  122670. * Gets the xyz component (output)
  122671. */
  122672. readonly xyz: NodeMaterialConnectionPoint;
  122673. /**
  122674. * Gets the xy component (output)
  122675. */
  122676. readonly xy: NodeMaterialConnectionPoint;
  122677. protected _buildBlock(state: NodeMaterialBuildState): this;
  122678. }
  122679. }
  122680. declare module BABYLON {
  122681. /**
  122682. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  122683. */
  122684. export class ColorSplitterBlock extends NodeMaterialBlock {
  122685. /**
  122686. * Create a new ColorSplitterBlock
  122687. * @param name defines the block name
  122688. */
  122689. constructor(name: string);
  122690. /**
  122691. * Gets the current class name
  122692. * @returns the class name
  122693. */
  122694. getClassName(): string;
  122695. /**
  122696. * Gets the rgba component (input)
  122697. */
  122698. readonly rgba: NodeMaterialConnectionPoint;
  122699. /**
  122700. * Gets the rgb component (input)
  122701. */
  122702. readonly rgbIn: NodeMaterialConnectionPoint;
  122703. /**
  122704. * Gets the rgb component (output)
  122705. */
  122706. readonly rgbOut: NodeMaterialConnectionPoint;
  122707. /**
  122708. * Gets the r component (output)
  122709. */
  122710. readonly r: NodeMaterialConnectionPoint;
  122711. /**
  122712. * Gets the g component (output)
  122713. */
  122714. readonly g: NodeMaterialConnectionPoint;
  122715. /**
  122716. * Gets the b component (output)
  122717. */
  122718. readonly b: NodeMaterialConnectionPoint;
  122719. /**
  122720. * Gets the a component (output)
  122721. */
  122722. readonly a: NodeMaterialConnectionPoint;
  122723. protected _inputRename(name: string): string;
  122724. protected _outputRename(name: string): string;
  122725. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122726. }
  122727. }
  122728. declare module BABYLON {
  122729. /**
  122730. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  122731. */
  122732. export class VectorSplitterBlock extends NodeMaterialBlock {
  122733. /**
  122734. * Create a new VectorSplitterBlock
  122735. * @param name defines the block name
  122736. */
  122737. constructor(name: string);
  122738. /**
  122739. * Gets the current class name
  122740. * @returns the class name
  122741. */
  122742. getClassName(): string;
  122743. /**
  122744. * Gets the xyzw component (input)
  122745. */
  122746. readonly xyzw: NodeMaterialConnectionPoint;
  122747. /**
  122748. * Gets the xyz component (input)
  122749. */
  122750. readonly xyzIn: NodeMaterialConnectionPoint;
  122751. /**
  122752. * Gets the xy component (input)
  122753. */
  122754. readonly xyIn: NodeMaterialConnectionPoint;
  122755. /**
  122756. * Gets the xyz component (output)
  122757. */
  122758. readonly xyzOut: NodeMaterialConnectionPoint;
  122759. /**
  122760. * Gets the xy component (output)
  122761. */
  122762. readonly xyOut: NodeMaterialConnectionPoint;
  122763. /**
  122764. * Gets the x component (output)
  122765. */
  122766. readonly x: NodeMaterialConnectionPoint;
  122767. /**
  122768. * Gets the y component (output)
  122769. */
  122770. readonly y: NodeMaterialConnectionPoint;
  122771. /**
  122772. * Gets the z component (output)
  122773. */
  122774. readonly z: NodeMaterialConnectionPoint;
  122775. /**
  122776. * Gets the w component (output)
  122777. */
  122778. readonly w: NodeMaterialConnectionPoint;
  122779. protected _inputRename(name: string): string;
  122780. protected _outputRename(name: string): string;
  122781. protected _buildBlock(state: NodeMaterialBuildState): this;
  122782. }
  122783. }
  122784. declare module BABYLON {
  122785. /**
  122786. * Block used to lerp between 2 values
  122787. */
  122788. export class LerpBlock extends NodeMaterialBlock {
  122789. /**
  122790. * Creates a new LerpBlock
  122791. * @param name defines the block name
  122792. */
  122793. constructor(name: string);
  122794. /**
  122795. * Gets the current class name
  122796. * @returns the class name
  122797. */
  122798. getClassName(): string;
  122799. /**
  122800. * Gets the left operand input component
  122801. */
  122802. readonly left: NodeMaterialConnectionPoint;
  122803. /**
  122804. * Gets the right operand input component
  122805. */
  122806. readonly right: NodeMaterialConnectionPoint;
  122807. /**
  122808. * Gets the gradient operand input component
  122809. */
  122810. readonly gradient: NodeMaterialConnectionPoint;
  122811. /**
  122812. * Gets the output component
  122813. */
  122814. readonly output: NodeMaterialConnectionPoint;
  122815. protected _buildBlock(state: NodeMaterialBuildState): this;
  122816. }
  122817. }
  122818. declare module BABYLON {
  122819. /**
  122820. * Block used to divide 2 vectors
  122821. */
  122822. export class DivideBlock extends NodeMaterialBlock {
  122823. /**
  122824. * Creates a new DivideBlock
  122825. * @param name defines the block name
  122826. */
  122827. constructor(name: string);
  122828. /**
  122829. * Gets the current class name
  122830. * @returns the class name
  122831. */
  122832. getClassName(): string;
  122833. /**
  122834. * Gets the left operand input component
  122835. */
  122836. readonly left: NodeMaterialConnectionPoint;
  122837. /**
  122838. * Gets the right operand input component
  122839. */
  122840. readonly right: NodeMaterialConnectionPoint;
  122841. /**
  122842. * Gets the output component
  122843. */
  122844. readonly output: NodeMaterialConnectionPoint;
  122845. protected _buildBlock(state: NodeMaterialBuildState): this;
  122846. }
  122847. }
  122848. declare module BABYLON {
  122849. /**
  122850. * Block used to subtract 2 vectors
  122851. */
  122852. export class SubtractBlock extends NodeMaterialBlock {
  122853. /**
  122854. * Creates a new SubtractBlock
  122855. * @param name defines the block name
  122856. */
  122857. constructor(name: string);
  122858. /**
  122859. * Gets the current class name
  122860. * @returns the class name
  122861. */
  122862. getClassName(): string;
  122863. /**
  122864. * Gets the left operand input component
  122865. */
  122866. readonly left: NodeMaterialConnectionPoint;
  122867. /**
  122868. * Gets the right operand input component
  122869. */
  122870. readonly right: NodeMaterialConnectionPoint;
  122871. /**
  122872. * Gets the output component
  122873. */
  122874. readonly output: NodeMaterialConnectionPoint;
  122875. protected _buildBlock(state: NodeMaterialBuildState): this;
  122876. }
  122877. }
  122878. declare module BABYLON {
  122879. /**
  122880. * Block used to step a value
  122881. */
  122882. export class StepBlock extends NodeMaterialBlock {
  122883. /**
  122884. * Creates a new StepBlock
  122885. * @param name defines the block name
  122886. */
  122887. constructor(name: string);
  122888. /**
  122889. * Gets the current class name
  122890. * @returns the class name
  122891. */
  122892. getClassName(): string;
  122893. /**
  122894. * Gets the value operand input component
  122895. */
  122896. readonly value: NodeMaterialConnectionPoint;
  122897. /**
  122898. * Gets the edge operand input component
  122899. */
  122900. readonly edge: NodeMaterialConnectionPoint;
  122901. /**
  122902. * Gets the output component
  122903. */
  122904. readonly output: NodeMaterialConnectionPoint;
  122905. protected _buildBlock(state: NodeMaterialBuildState): this;
  122906. }
  122907. }
  122908. declare module BABYLON {
  122909. /**
  122910. * Block used to get the opposite (1 - x) of a value
  122911. */
  122912. export class OneMinusBlock extends NodeMaterialBlock {
  122913. /**
  122914. * Creates a new OneMinusBlock
  122915. * @param name defines the block name
  122916. */
  122917. constructor(name: string);
  122918. /**
  122919. * Gets the current class name
  122920. * @returns the class name
  122921. */
  122922. getClassName(): string;
  122923. /**
  122924. * Gets the input component
  122925. */
  122926. readonly input: NodeMaterialConnectionPoint;
  122927. /**
  122928. * Gets the output component
  122929. */
  122930. readonly output: NodeMaterialConnectionPoint;
  122931. protected _buildBlock(state: NodeMaterialBuildState): this;
  122932. }
  122933. }
  122934. declare module BABYLON {
  122935. /**
  122936. * Block used to get the view direction
  122937. */
  122938. export class ViewDirectionBlock extends NodeMaterialBlock {
  122939. /**
  122940. * Creates a new ViewDirectionBlock
  122941. * @param name defines the block name
  122942. */
  122943. constructor(name: string);
  122944. /**
  122945. * Gets the current class name
  122946. * @returns the class name
  122947. */
  122948. getClassName(): string;
  122949. /**
  122950. * Gets the world position component
  122951. */
  122952. readonly worldPosition: NodeMaterialConnectionPoint;
  122953. /**
  122954. * Gets the camera position component
  122955. */
  122956. readonly cameraPosition: NodeMaterialConnectionPoint;
  122957. /**
  122958. * Gets the output component
  122959. */
  122960. readonly output: NodeMaterialConnectionPoint;
  122961. autoConfigure(material: NodeMaterial): void;
  122962. protected _buildBlock(state: NodeMaterialBuildState): this;
  122963. }
  122964. }
  122965. declare module BABYLON {
  122966. /**
  122967. * Block used to compute fresnel value
  122968. */
  122969. export class FresnelBlock extends NodeMaterialBlock {
  122970. /**
  122971. * Create a new FresnelBlock
  122972. * @param name defines the block name
  122973. */
  122974. constructor(name: string);
  122975. /**
  122976. * Gets the current class name
  122977. * @returns the class name
  122978. */
  122979. getClassName(): string;
  122980. /**
  122981. * Gets the world normal input component
  122982. */
  122983. readonly worldNormal: NodeMaterialConnectionPoint;
  122984. /**
  122985. * Gets the view direction input component
  122986. */
  122987. readonly viewDirection: NodeMaterialConnectionPoint;
  122988. /**
  122989. * Gets the bias input component
  122990. */
  122991. readonly bias: NodeMaterialConnectionPoint;
  122992. /**
  122993. * Gets the camera (or eye) position component
  122994. */
  122995. readonly power: NodeMaterialConnectionPoint;
  122996. /**
  122997. * Gets the fresnel output component
  122998. */
  122999. readonly fresnel: NodeMaterialConnectionPoint;
  123000. autoConfigure(material: NodeMaterial): void;
  123001. protected _buildBlock(state: NodeMaterialBuildState): this;
  123002. }
  123003. }
  123004. declare module BABYLON {
  123005. /**
  123006. * Block used to get the max of 2 values
  123007. */
  123008. export class MaxBlock extends NodeMaterialBlock {
  123009. /**
  123010. * Creates a new MaxBlock
  123011. * @param name defines the block name
  123012. */
  123013. constructor(name: string);
  123014. /**
  123015. * Gets the current class name
  123016. * @returns the class name
  123017. */
  123018. getClassName(): string;
  123019. /**
  123020. * Gets the left operand input component
  123021. */
  123022. readonly left: NodeMaterialConnectionPoint;
  123023. /**
  123024. * Gets the right operand input component
  123025. */
  123026. readonly right: NodeMaterialConnectionPoint;
  123027. /**
  123028. * Gets the output component
  123029. */
  123030. readonly output: NodeMaterialConnectionPoint;
  123031. protected _buildBlock(state: NodeMaterialBuildState): this;
  123032. }
  123033. }
  123034. declare module BABYLON {
  123035. /**
  123036. * Block used to get the min of 2 values
  123037. */
  123038. export class MinBlock extends NodeMaterialBlock {
  123039. /**
  123040. * Creates a new MinBlock
  123041. * @param name defines the block name
  123042. */
  123043. constructor(name: string);
  123044. /**
  123045. * Gets the current class name
  123046. * @returns the class name
  123047. */
  123048. getClassName(): string;
  123049. /**
  123050. * Gets the left operand input component
  123051. */
  123052. readonly left: NodeMaterialConnectionPoint;
  123053. /**
  123054. * Gets the right operand input component
  123055. */
  123056. readonly right: NodeMaterialConnectionPoint;
  123057. /**
  123058. * Gets the output component
  123059. */
  123060. readonly output: NodeMaterialConnectionPoint;
  123061. protected _buildBlock(state: NodeMaterialBuildState): this;
  123062. }
  123063. }
  123064. declare module BABYLON {
  123065. /**
  123066. * Block used to get the distance between 2 values
  123067. */
  123068. export class DistanceBlock extends NodeMaterialBlock {
  123069. /**
  123070. * Creates a new DistanceBlock
  123071. * @param name defines the block name
  123072. */
  123073. constructor(name: string);
  123074. /**
  123075. * Gets the current class name
  123076. * @returns the class name
  123077. */
  123078. getClassName(): string;
  123079. /**
  123080. * Gets the left operand input component
  123081. */
  123082. readonly left: NodeMaterialConnectionPoint;
  123083. /**
  123084. * Gets the right operand input component
  123085. */
  123086. readonly right: NodeMaterialConnectionPoint;
  123087. /**
  123088. * Gets the output component
  123089. */
  123090. readonly output: NodeMaterialConnectionPoint;
  123091. protected _buildBlock(state: NodeMaterialBuildState): this;
  123092. }
  123093. }
  123094. declare module BABYLON {
  123095. /**
  123096. * Block used to get the length of a vector
  123097. */
  123098. export class LengthBlock extends NodeMaterialBlock {
  123099. /**
  123100. * Creates a new LengthBlock
  123101. * @param name defines the block name
  123102. */
  123103. constructor(name: string);
  123104. /**
  123105. * Gets the current class name
  123106. * @returns the class name
  123107. */
  123108. getClassName(): string;
  123109. /**
  123110. * Gets the value input component
  123111. */
  123112. readonly value: NodeMaterialConnectionPoint;
  123113. /**
  123114. * Gets the output component
  123115. */
  123116. readonly output: NodeMaterialConnectionPoint;
  123117. protected _buildBlock(state: NodeMaterialBuildState): this;
  123118. }
  123119. }
  123120. declare module BABYLON {
  123121. /**
  123122. * Block used to get negative version of a value (i.e. x * -1)
  123123. */
  123124. export class NegateBlock extends NodeMaterialBlock {
  123125. /**
  123126. * Creates a new NegateBlock
  123127. * @param name defines the block name
  123128. */
  123129. constructor(name: string);
  123130. /**
  123131. * Gets the current class name
  123132. * @returns the class name
  123133. */
  123134. getClassName(): string;
  123135. /**
  123136. * Gets the value input component
  123137. */
  123138. readonly value: NodeMaterialConnectionPoint;
  123139. /**
  123140. * Gets the output component
  123141. */
  123142. readonly output: NodeMaterialConnectionPoint;
  123143. protected _buildBlock(state: NodeMaterialBuildState): this;
  123144. }
  123145. }
  123146. declare module BABYLON {
  123147. /**
  123148. * Block used to get the value of the first parameter raised to the power of the second
  123149. */
  123150. export class PowBlock extends NodeMaterialBlock {
  123151. /**
  123152. * Creates a new PowBlock
  123153. * @param name defines the block name
  123154. */
  123155. constructor(name: string);
  123156. /**
  123157. * Gets the current class name
  123158. * @returns the class name
  123159. */
  123160. getClassName(): string;
  123161. /**
  123162. * Gets the value operand input component
  123163. */
  123164. readonly value: NodeMaterialConnectionPoint;
  123165. /**
  123166. * Gets the power operand input component
  123167. */
  123168. readonly power: NodeMaterialConnectionPoint;
  123169. /**
  123170. * Gets the output component
  123171. */
  123172. readonly output: NodeMaterialConnectionPoint;
  123173. protected _buildBlock(state: NodeMaterialBuildState): this;
  123174. }
  123175. }
  123176. declare module BABYLON {
  123177. /**
  123178. * Block used to get a random number
  123179. */
  123180. export class RandomNumberBlock extends NodeMaterialBlock {
  123181. /**
  123182. * Creates a new RandomNumberBlock
  123183. * @param name defines the block name
  123184. */
  123185. constructor(name: string);
  123186. /**
  123187. * Gets the current class name
  123188. * @returns the class name
  123189. */
  123190. getClassName(): string;
  123191. /**
  123192. * Gets the seed input component
  123193. */
  123194. readonly seed: NodeMaterialConnectionPoint;
  123195. /**
  123196. * Gets the output component
  123197. */
  123198. readonly output: NodeMaterialConnectionPoint;
  123199. protected _buildBlock(state: NodeMaterialBuildState): this;
  123200. }
  123201. }
  123202. declare module BABYLON {
  123203. /**
  123204. * Block used to compute arc tangent of 2 values
  123205. */
  123206. export class ArcTan2Block extends NodeMaterialBlock {
  123207. /**
  123208. * Creates a new ArcTan2Block
  123209. * @param name defines the block name
  123210. */
  123211. constructor(name: string);
  123212. /**
  123213. * Gets the current class name
  123214. * @returns the class name
  123215. */
  123216. getClassName(): string;
  123217. /**
  123218. * Gets the x operand input component
  123219. */
  123220. readonly x: NodeMaterialConnectionPoint;
  123221. /**
  123222. * Gets the y operand input component
  123223. */
  123224. readonly y: NodeMaterialConnectionPoint;
  123225. /**
  123226. * Gets the output component
  123227. */
  123228. readonly output: NodeMaterialConnectionPoint;
  123229. protected _buildBlock(state: NodeMaterialBuildState): this;
  123230. }
  123231. }
  123232. declare module BABYLON {
  123233. /**
  123234. * Block used to smooth step a value
  123235. */
  123236. export class SmoothStepBlock extends NodeMaterialBlock {
  123237. /**
  123238. * Creates a new SmoothStepBlock
  123239. * @param name defines the block name
  123240. */
  123241. constructor(name: string);
  123242. /**
  123243. * Gets the current class name
  123244. * @returns the class name
  123245. */
  123246. getClassName(): string;
  123247. /**
  123248. * Gets the value operand input component
  123249. */
  123250. readonly value: NodeMaterialConnectionPoint;
  123251. /**
  123252. * Gets the first edge operand input component
  123253. */
  123254. readonly edge0: NodeMaterialConnectionPoint;
  123255. /**
  123256. * Gets the second edge operand input component
  123257. */
  123258. readonly edge1: NodeMaterialConnectionPoint;
  123259. /**
  123260. * Gets the output component
  123261. */
  123262. readonly output: NodeMaterialConnectionPoint;
  123263. protected _buildBlock(state: NodeMaterialBuildState): this;
  123264. }
  123265. }
  123266. declare module BABYLON {
  123267. /**
  123268. * Block used to get the reciprocal (1 / x) of a value
  123269. */
  123270. export class ReciprocalBlock extends NodeMaterialBlock {
  123271. /**
  123272. * Creates a new ReciprocalBlock
  123273. * @param name defines the block name
  123274. */
  123275. constructor(name: string);
  123276. /**
  123277. * Gets the current class name
  123278. * @returns the class name
  123279. */
  123280. getClassName(): string;
  123281. /**
  123282. * Gets the input component
  123283. */
  123284. readonly input: NodeMaterialConnectionPoint;
  123285. /**
  123286. * Gets the output component
  123287. */
  123288. readonly output: NodeMaterialConnectionPoint;
  123289. protected _buildBlock(state: NodeMaterialBuildState): this;
  123290. }
  123291. }
  123292. declare module BABYLON {
  123293. /**
  123294. * Block used to replace a color by another one
  123295. */
  123296. export class ReplaceColorBlock extends NodeMaterialBlock {
  123297. /**
  123298. * Creates a new ReplaceColorBlock
  123299. * @param name defines the block name
  123300. */
  123301. constructor(name: string);
  123302. /**
  123303. * Gets the current class name
  123304. * @returns the class name
  123305. */
  123306. getClassName(): string;
  123307. /**
  123308. * Gets the value input component
  123309. */
  123310. readonly value: NodeMaterialConnectionPoint;
  123311. /**
  123312. * Gets the reference input component
  123313. */
  123314. readonly reference: NodeMaterialConnectionPoint;
  123315. /**
  123316. * Gets the distance input component
  123317. */
  123318. readonly distance: NodeMaterialConnectionPoint;
  123319. /**
  123320. * Gets the replacement input component
  123321. */
  123322. readonly replacement: NodeMaterialConnectionPoint;
  123323. /**
  123324. * Gets the output component
  123325. */
  123326. readonly output: NodeMaterialConnectionPoint;
  123327. protected _buildBlock(state: NodeMaterialBuildState): this;
  123328. }
  123329. }
  123330. declare module BABYLON {
  123331. /**
  123332. * Block used to posterize a value
  123333. * @see https://en.wikipedia.org/wiki/Posterization
  123334. */
  123335. export class PosterizeBlock extends NodeMaterialBlock {
  123336. /**
  123337. * Creates a new PosterizeBlock
  123338. * @param name defines the block name
  123339. */
  123340. constructor(name: string);
  123341. /**
  123342. * Gets the current class name
  123343. * @returns the class name
  123344. */
  123345. getClassName(): string;
  123346. /**
  123347. * Gets the value input component
  123348. */
  123349. readonly value: NodeMaterialConnectionPoint;
  123350. /**
  123351. * Gets the steps input component
  123352. */
  123353. readonly steps: NodeMaterialConnectionPoint;
  123354. /**
  123355. * Gets the output component
  123356. */
  123357. readonly output: NodeMaterialConnectionPoint;
  123358. protected _buildBlock(state: NodeMaterialBuildState): this;
  123359. }
  123360. }
  123361. declare module BABYLON {
  123362. /**
  123363. * Operations supported by the Wave block
  123364. */
  123365. export enum WaveBlockKind {
  123366. /** SawTooth */
  123367. SawTooth = 0,
  123368. /** Square */
  123369. Square = 1,
  123370. /** Triangle */
  123371. Triangle = 2
  123372. }
  123373. /**
  123374. * Block used to apply wave operation to floats
  123375. */
  123376. export class WaveBlock extends NodeMaterialBlock {
  123377. /**
  123378. * Gets or sets the kibnd of wave to be applied by the block
  123379. */
  123380. kind: WaveBlockKind;
  123381. /**
  123382. * Creates a new WaveBlock
  123383. * @param name defines the block name
  123384. */
  123385. constructor(name: string);
  123386. /**
  123387. * Gets the current class name
  123388. * @returns the class name
  123389. */
  123390. getClassName(): string;
  123391. /**
  123392. * Gets the input component
  123393. */
  123394. readonly input: NodeMaterialConnectionPoint;
  123395. /**
  123396. * Gets the output component
  123397. */
  123398. readonly output: NodeMaterialConnectionPoint;
  123399. protected _buildBlock(state: NodeMaterialBuildState): this;
  123400. serialize(): any;
  123401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123402. }
  123403. }
  123404. declare module BABYLON {
  123405. /**
  123406. * Class used to store a color step for the GradientBlock
  123407. */
  123408. export class GradientBlockColorStep {
  123409. /**
  123410. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123411. */
  123412. step: number;
  123413. /**
  123414. * Gets or sets the color associated with this step
  123415. */
  123416. color: Color3;
  123417. /**
  123418. * Creates a new GradientBlockColorStep
  123419. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  123420. * @param color defines the color associated with this step
  123421. */
  123422. constructor(
  123423. /**
  123424. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  123425. */
  123426. step: number,
  123427. /**
  123428. * Gets or sets the color associated with this step
  123429. */
  123430. color: Color3);
  123431. }
  123432. /**
  123433. * Block used to return a color from a gradient based on an input value between 0 and 1
  123434. */
  123435. export class GradientBlock extends NodeMaterialBlock {
  123436. /**
  123437. * Gets or sets the list of color steps
  123438. */
  123439. colorSteps: GradientBlockColorStep[];
  123440. /**
  123441. * Creates a new GradientBlock
  123442. * @param name defines the block name
  123443. */
  123444. constructor(name: string);
  123445. /**
  123446. * Gets the current class name
  123447. * @returns the class name
  123448. */
  123449. getClassName(): string;
  123450. /**
  123451. * Gets the gradient input component
  123452. */
  123453. readonly gradient: NodeMaterialConnectionPoint;
  123454. /**
  123455. * Gets the output component
  123456. */
  123457. readonly output: NodeMaterialConnectionPoint;
  123458. private _writeColorConstant;
  123459. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123460. serialize(): any;
  123461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123462. protected _dumpPropertiesCode(): string;
  123463. }
  123464. }
  123465. declare module BABYLON {
  123466. /**
  123467. * Block used to normalize lerp between 2 values
  123468. */
  123469. export class NLerpBlock extends NodeMaterialBlock {
  123470. /**
  123471. * Creates a new NLerpBlock
  123472. * @param name defines the block name
  123473. */
  123474. constructor(name: string);
  123475. /**
  123476. * Gets the current class name
  123477. * @returns the class name
  123478. */
  123479. getClassName(): string;
  123480. /**
  123481. * Gets the left operand input component
  123482. */
  123483. readonly left: NodeMaterialConnectionPoint;
  123484. /**
  123485. * Gets the right operand input component
  123486. */
  123487. readonly right: NodeMaterialConnectionPoint;
  123488. /**
  123489. * Gets the gradient operand input component
  123490. */
  123491. readonly gradient: NodeMaterialConnectionPoint;
  123492. /**
  123493. * Gets the output component
  123494. */
  123495. readonly output: NodeMaterialConnectionPoint;
  123496. protected _buildBlock(state: NodeMaterialBuildState): this;
  123497. }
  123498. }
  123499. declare module BABYLON {
  123500. /**
  123501. * Block used to test if the fragment shader is front facing
  123502. */
  123503. export class FrontFacingBlock extends NodeMaterialBlock {
  123504. /**
  123505. * Creates a new FrontFacingBlock
  123506. * @param name defines the block name
  123507. */
  123508. constructor(name: string);
  123509. /**
  123510. * Gets the current class name
  123511. * @returns the class name
  123512. */
  123513. getClassName(): string;
  123514. /**
  123515. * Gets the world normal component
  123516. */
  123517. readonly worldNormal: NodeMaterialConnectionPoint;
  123518. /**
  123519. * Gets the view direction input component
  123520. */
  123521. readonly viewDirection: NodeMaterialConnectionPoint;
  123522. /**
  123523. * Gets the output component
  123524. */
  123525. readonly output: NodeMaterialConnectionPoint;
  123526. autoConfigure(material: NodeMaterial): void;
  123527. protected _buildBlock(state: NodeMaterialBuildState): this;
  123528. }
  123529. }
  123530. declare module BABYLON {
  123531. /**
  123532. * Effect Render Options
  123533. */
  123534. export interface IEffectRendererOptions {
  123535. /**
  123536. * Defines the vertices positions.
  123537. */
  123538. positions?: number[];
  123539. /**
  123540. * Defines the indices.
  123541. */
  123542. indices?: number[];
  123543. }
  123544. /**
  123545. * Helper class to render one or more effects
  123546. */
  123547. export class EffectRenderer {
  123548. private engine;
  123549. private static _DefaultOptions;
  123550. private _vertexBuffers;
  123551. private _indexBuffer;
  123552. private _ringBufferIndex;
  123553. private _ringScreenBuffer;
  123554. private _fullscreenViewport;
  123555. private _getNextFrameBuffer;
  123556. /**
  123557. * Creates an effect renderer
  123558. * @param engine the engine to use for rendering
  123559. * @param options defines the options of the effect renderer
  123560. */
  123561. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  123562. /**
  123563. * Sets the current viewport in normalized coordinates 0-1
  123564. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  123565. */
  123566. setViewport(viewport?: Viewport): void;
  123567. /**
  123568. * Binds the embedded attributes buffer to the effect.
  123569. * @param effect Defines the effect to bind the attributes for
  123570. */
  123571. bindBuffers(effect: Effect): void;
  123572. /**
  123573. * Sets the current effect wrapper to use during draw.
  123574. * The effect needs to be ready before calling this api.
  123575. * This also sets the default full screen position attribute.
  123576. * @param effectWrapper Defines the effect to draw with
  123577. */
  123578. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  123579. /**
  123580. * Draws a full screen quad.
  123581. */
  123582. draw(): void;
  123583. /**
  123584. * renders one or more effects to a specified texture
  123585. * @param effectWrappers list of effects to renderer
  123586. * @param outputTexture texture to draw to, if null it will render to the screen
  123587. */
  123588. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  123589. /**
  123590. * Disposes of the effect renderer
  123591. */
  123592. dispose(): void;
  123593. }
  123594. /**
  123595. * Options to create an EffectWrapper
  123596. */
  123597. interface EffectWrapperCreationOptions {
  123598. /**
  123599. * Engine to use to create the effect
  123600. */
  123601. engine: ThinEngine;
  123602. /**
  123603. * Fragment shader for the effect
  123604. */
  123605. fragmentShader: string;
  123606. /**
  123607. * Vertex shader for the effect
  123608. */
  123609. vertexShader?: string;
  123610. /**
  123611. * Attributes to use in the shader
  123612. */
  123613. attributeNames?: Array<string>;
  123614. /**
  123615. * Uniforms to use in the shader
  123616. */
  123617. uniformNames?: Array<string>;
  123618. /**
  123619. * Texture sampler names to use in the shader
  123620. */
  123621. samplerNames?: Array<string>;
  123622. /**
  123623. * The friendly name of the effect displayed in Spector.
  123624. */
  123625. name?: string;
  123626. }
  123627. /**
  123628. * Wraps an effect to be used for rendering
  123629. */
  123630. export class EffectWrapper {
  123631. /**
  123632. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  123633. */
  123634. onApplyObservable: Observable<{}>;
  123635. /**
  123636. * The underlying effect
  123637. */
  123638. effect: Effect;
  123639. /**
  123640. * Creates an effect to be renderer
  123641. * @param creationOptions options to create the effect
  123642. */
  123643. constructor(creationOptions: EffectWrapperCreationOptions);
  123644. /**
  123645. * Disposes of the effect wrapper
  123646. */
  123647. dispose(): void;
  123648. }
  123649. }
  123650. declare module BABYLON {
  123651. /**
  123652. * Helper class to push actions to a pool of workers.
  123653. */
  123654. export class WorkerPool implements IDisposable {
  123655. private _workerInfos;
  123656. private _pendingActions;
  123657. /**
  123658. * Constructor
  123659. * @param workers Array of workers to use for actions
  123660. */
  123661. constructor(workers: Array<Worker>);
  123662. /**
  123663. * Terminates all workers and clears any pending actions.
  123664. */
  123665. dispose(): void;
  123666. /**
  123667. * Pushes an action to the worker pool. If all the workers are active, the action will be
  123668. * pended until a worker has completed its action.
  123669. * @param action The action to perform. Call onComplete when the action is complete.
  123670. */
  123671. push(action: (worker: Worker, onComplete: () => void) => void): void;
  123672. private _execute;
  123673. }
  123674. }
  123675. declare module BABYLON {
  123676. /**
  123677. * Configuration for Draco compression
  123678. */
  123679. export interface IDracoCompressionConfiguration {
  123680. /**
  123681. * Configuration for the decoder.
  123682. */
  123683. decoder: {
  123684. /**
  123685. * The url to the WebAssembly module.
  123686. */
  123687. wasmUrl?: string;
  123688. /**
  123689. * The url to the WebAssembly binary.
  123690. */
  123691. wasmBinaryUrl?: string;
  123692. /**
  123693. * The url to the fallback JavaScript module.
  123694. */
  123695. fallbackUrl?: string;
  123696. };
  123697. }
  123698. /**
  123699. * Draco compression (https://google.github.io/draco/)
  123700. *
  123701. * This class wraps the Draco module.
  123702. *
  123703. * **Encoder**
  123704. *
  123705. * The encoder is not currently implemented.
  123706. *
  123707. * **Decoder**
  123708. *
  123709. * 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.
  123710. *
  123711. * To update the configuration, use the following code:
  123712. * ```javascript
  123713. * DracoCompression.Configuration = {
  123714. * decoder: {
  123715. * wasmUrl: "<url to the WebAssembly library>",
  123716. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  123717. * fallbackUrl: "<url to the fallback JavaScript library>",
  123718. * }
  123719. * };
  123720. * ```
  123721. *
  123722. * 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.
  123723. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  123724. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  123725. *
  123726. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  123727. * ```javascript
  123728. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  123729. * ```
  123730. *
  123731. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  123732. */
  123733. export class DracoCompression implements IDisposable {
  123734. private _workerPoolPromise?;
  123735. private _decoderModulePromise?;
  123736. /**
  123737. * The configuration. Defaults to the following urls:
  123738. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  123739. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  123740. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  123741. */
  123742. static Configuration: IDracoCompressionConfiguration;
  123743. /**
  123744. * Returns true if the decoder configuration is available.
  123745. */
  123746. static readonly DecoderAvailable: boolean;
  123747. /**
  123748. * Default number of workers to create when creating the draco compression object.
  123749. */
  123750. static DefaultNumWorkers: number;
  123751. private static GetDefaultNumWorkers;
  123752. private static _Default;
  123753. /**
  123754. * Default instance for the draco compression object.
  123755. */
  123756. static readonly Default: DracoCompression;
  123757. /**
  123758. * Constructor
  123759. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  123760. */
  123761. constructor(numWorkers?: number);
  123762. /**
  123763. * Stop all async operations and release resources.
  123764. */
  123765. dispose(): void;
  123766. /**
  123767. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  123768. * @returns a promise that resolves when ready
  123769. */
  123770. whenReadyAsync(): Promise<void>;
  123771. /**
  123772. * Decode Draco compressed mesh data to vertex data.
  123773. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  123774. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  123775. * @returns A promise that resolves with the decoded vertex data
  123776. */
  123777. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  123778. [kind: string]: number;
  123779. }): Promise<VertexData>;
  123780. }
  123781. }
  123782. declare module BABYLON {
  123783. /**
  123784. * Class for building Constructive Solid Geometry
  123785. */
  123786. export class CSG {
  123787. private polygons;
  123788. /**
  123789. * The world matrix
  123790. */
  123791. matrix: Matrix;
  123792. /**
  123793. * Stores the position
  123794. */
  123795. position: Vector3;
  123796. /**
  123797. * Stores the rotation
  123798. */
  123799. rotation: Vector3;
  123800. /**
  123801. * Stores the rotation quaternion
  123802. */
  123803. rotationQuaternion: Nullable<Quaternion>;
  123804. /**
  123805. * Stores the scaling vector
  123806. */
  123807. scaling: Vector3;
  123808. /**
  123809. * Convert the Mesh to CSG
  123810. * @param mesh The Mesh to convert to CSG
  123811. * @returns A new CSG from the Mesh
  123812. */
  123813. static FromMesh(mesh: Mesh): CSG;
  123814. /**
  123815. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  123816. * @param polygons Polygons used to construct a CSG solid
  123817. */
  123818. private static FromPolygons;
  123819. /**
  123820. * Clones, or makes a deep copy, of the CSG
  123821. * @returns A new CSG
  123822. */
  123823. clone(): CSG;
  123824. /**
  123825. * Unions this CSG with another CSG
  123826. * @param csg The CSG to union against this CSG
  123827. * @returns The unioned CSG
  123828. */
  123829. union(csg: CSG): CSG;
  123830. /**
  123831. * Unions this CSG with another CSG in place
  123832. * @param csg The CSG to union against this CSG
  123833. */
  123834. unionInPlace(csg: CSG): void;
  123835. /**
  123836. * Subtracts this CSG with another CSG
  123837. * @param csg The CSG to subtract against this CSG
  123838. * @returns A new CSG
  123839. */
  123840. subtract(csg: CSG): CSG;
  123841. /**
  123842. * Subtracts this CSG with another CSG in place
  123843. * @param csg The CSG to subtact against this CSG
  123844. */
  123845. subtractInPlace(csg: CSG): void;
  123846. /**
  123847. * Intersect this CSG with another CSG
  123848. * @param csg The CSG to intersect against this CSG
  123849. * @returns A new CSG
  123850. */
  123851. intersect(csg: CSG): CSG;
  123852. /**
  123853. * Intersects this CSG with another CSG in place
  123854. * @param csg The CSG to intersect against this CSG
  123855. */
  123856. intersectInPlace(csg: CSG): void;
  123857. /**
  123858. * Return a new CSG solid with solid and empty space switched. This solid is
  123859. * not modified.
  123860. * @returns A new CSG solid with solid and empty space switched
  123861. */
  123862. inverse(): CSG;
  123863. /**
  123864. * Inverses the CSG in place
  123865. */
  123866. inverseInPlace(): void;
  123867. /**
  123868. * This is used to keep meshes transformations so they can be restored
  123869. * when we build back a Babylon Mesh
  123870. * NB : All CSG operations are performed in world coordinates
  123871. * @param csg The CSG to copy the transform attributes from
  123872. * @returns This CSG
  123873. */
  123874. copyTransformAttributes(csg: CSG): CSG;
  123875. /**
  123876. * Build Raw mesh from CSG
  123877. * Coordinates here are in world space
  123878. * @param name The name of the mesh geometry
  123879. * @param scene The Scene
  123880. * @param keepSubMeshes Specifies if the submeshes should be kept
  123881. * @returns A new Mesh
  123882. */
  123883. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123884. /**
  123885. * Build Mesh from CSG taking material and transforms into account
  123886. * @param name The name of the Mesh
  123887. * @param material The material of the Mesh
  123888. * @param scene The Scene
  123889. * @param keepSubMeshes Specifies if submeshes should be kept
  123890. * @returns The new Mesh
  123891. */
  123892. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  123893. }
  123894. }
  123895. declare module BABYLON {
  123896. /**
  123897. * Class used to create a trail following a mesh
  123898. */
  123899. export class TrailMesh extends Mesh {
  123900. private _generator;
  123901. private _autoStart;
  123902. private _running;
  123903. private _diameter;
  123904. private _length;
  123905. private _sectionPolygonPointsCount;
  123906. private _sectionVectors;
  123907. private _sectionNormalVectors;
  123908. private _beforeRenderObserver;
  123909. /**
  123910. * @constructor
  123911. * @param name The value used by scene.getMeshByName() to do a lookup.
  123912. * @param generator The mesh to generate a trail.
  123913. * @param scene The scene to add this mesh to.
  123914. * @param diameter Diameter of trailing mesh. Default is 1.
  123915. * @param length Length of trailing mesh. Default is 60.
  123916. * @param autoStart Automatically start trailing mesh. Default true.
  123917. */
  123918. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  123919. /**
  123920. * "TrailMesh"
  123921. * @returns "TrailMesh"
  123922. */
  123923. getClassName(): string;
  123924. private _createMesh;
  123925. /**
  123926. * Start trailing mesh.
  123927. */
  123928. start(): void;
  123929. /**
  123930. * Stop trailing mesh.
  123931. */
  123932. stop(): void;
  123933. /**
  123934. * Update trailing mesh geometry.
  123935. */
  123936. update(): void;
  123937. /**
  123938. * Returns a new TrailMesh object.
  123939. * @param name is a string, the name given to the new mesh
  123940. * @param newGenerator use new generator object for cloned trail mesh
  123941. * @returns a new mesh
  123942. */
  123943. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  123944. /**
  123945. * Serializes this trail mesh
  123946. * @param serializationObject object to write serialization to
  123947. */
  123948. serialize(serializationObject: any): void;
  123949. /**
  123950. * Parses a serialized trail mesh
  123951. * @param parsedMesh the serialized mesh
  123952. * @param scene the scene to create the trail mesh in
  123953. * @returns the created trail mesh
  123954. */
  123955. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  123956. }
  123957. }
  123958. declare module BABYLON {
  123959. /**
  123960. * Class containing static functions to help procedurally build meshes
  123961. */
  123962. export class TiledBoxBuilder {
  123963. /**
  123964. * Creates a box mesh
  123965. * 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)
  123966. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123970. * @param name defines the name of the mesh
  123971. * @param options defines the options used to create the mesh
  123972. * @param scene defines the hosting scene
  123973. * @returns the box mesh
  123974. */
  123975. static CreateTiledBox(name: string, options: {
  123976. pattern?: number;
  123977. width?: number;
  123978. height?: number;
  123979. depth?: number;
  123980. tileSize?: number;
  123981. tileWidth?: number;
  123982. tileHeight?: number;
  123983. alignHorizontal?: number;
  123984. alignVertical?: number;
  123985. faceUV?: Vector4[];
  123986. faceColors?: Color4[];
  123987. sideOrientation?: number;
  123988. updatable?: boolean;
  123989. }, scene?: Nullable<Scene>): Mesh;
  123990. }
  123991. }
  123992. declare module BABYLON {
  123993. /**
  123994. * Class containing static functions to help procedurally build meshes
  123995. */
  123996. export class TorusKnotBuilder {
  123997. /**
  123998. * Creates a torus knot mesh
  123999. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124000. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124001. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124002. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124006. * @param name defines the name of the mesh
  124007. * @param options defines the options used to create the mesh
  124008. * @param scene defines the hosting scene
  124009. * @returns the torus knot mesh
  124010. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124011. */
  124012. static CreateTorusKnot(name: string, options: {
  124013. radius?: number;
  124014. tube?: number;
  124015. radialSegments?: number;
  124016. tubularSegments?: number;
  124017. p?: number;
  124018. q?: number;
  124019. updatable?: boolean;
  124020. sideOrientation?: number;
  124021. frontUVs?: Vector4;
  124022. backUVs?: Vector4;
  124023. }, scene: any): Mesh;
  124024. }
  124025. }
  124026. declare module BABYLON {
  124027. /**
  124028. * Polygon
  124029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  124030. */
  124031. export class Polygon {
  124032. /**
  124033. * Creates a rectangle
  124034. * @param xmin bottom X coord
  124035. * @param ymin bottom Y coord
  124036. * @param xmax top X coord
  124037. * @param ymax top Y coord
  124038. * @returns points that make the resulting rectation
  124039. */
  124040. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  124041. /**
  124042. * Creates a circle
  124043. * @param radius radius of circle
  124044. * @param cx scale in x
  124045. * @param cy scale in y
  124046. * @param numberOfSides number of sides that make up the circle
  124047. * @returns points that make the resulting circle
  124048. */
  124049. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  124050. /**
  124051. * Creates a polygon from input string
  124052. * @param input Input polygon data
  124053. * @returns the parsed points
  124054. */
  124055. static Parse(input: string): Vector2[];
  124056. /**
  124057. * Starts building a polygon from x and y coordinates
  124058. * @param x x coordinate
  124059. * @param y y coordinate
  124060. * @returns the started path2
  124061. */
  124062. static StartingAt(x: number, y: number): Path2;
  124063. }
  124064. /**
  124065. * Builds a polygon
  124066. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  124067. */
  124068. export class PolygonMeshBuilder {
  124069. private _points;
  124070. private _outlinepoints;
  124071. private _holes;
  124072. private _name;
  124073. private _scene;
  124074. private _epoints;
  124075. private _eholes;
  124076. private _addToepoint;
  124077. /**
  124078. * Babylon reference to the earcut plugin.
  124079. */
  124080. bjsEarcut: any;
  124081. /**
  124082. * Creates a PolygonMeshBuilder
  124083. * @param name name of the builder
  124084. * @param contours Path of the polygon
  124085. * @param scene scene to add to when creating the mesh
  124086. * @param earcutInjection can be used to inject your own earcut reference
  124087. */
  124088. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  124089. /**
  124090. * Adds a whole within the polygon
  124091. * @param hole Array of points defining the hole
  124092. * @returns this
  124093. */
  124094. addHole(hole: Vector2[]): PolygonMeshBuilder;
  124095. /**
  124096. * Creates the polygon
  124097. * @param updatable If the mesh should be updatable
  124098. * @param depth The depth of the mesh created
  124099. * @returns the created mesh
  124100. */
  124101. build(updatable?: boolean, depth?: number): Mesh;
  124102. /**
  124103. * Creates the polygon
  124104. * @param depth The depth of the mesh created
  124105. * @returns the created VertexData
  124106. */
  124107. buildVertexData(depth?: number): VertexData;
  124108. /**
  124109. * Adds a side to the polygon
  124110. * @param positions points that make the polygon
  124111. * @param normals normals of the polygon
  124112. * @param uvs uvs of the polygon
  124113. * @param indices indices of the polygon
  124114. * @param bounds bounds of the polygon
  124115. * @param points points of the polygon
  124116. * @param depth depth of the polygon
  124117. * @param flip flip of the polygon
  124118. */
  124119. private addSide;
  124120. }
  124121. }
  124122. declare module BABYLON {
  124123. /**
  124124. * Class containing static functions to help procedurally build meshes
  124125. */
  124126. export class PolygonBuilder {
  124127. /**
  124128. * Creates a polygon mesh
  124129. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124130. * * 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
  124131. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124134. * * Remember you can only change the shape positions, not their number when updating a polygon
  124135. * @param name defines the name of the mesh
  124136. * @param options defines the options used to create the mesh
  124137. * @param scene defines the hosting scene
  124138. * @param earcutInjection can be used to inject your own earcut reference
  124139. * @returns the polygon mesh
  124140. */
  124141. static CreatePolygon(name: string, options: {
  124142. shape: Vector3[];
  124143. holes?: Vector3[][];
  124144. depth?: number;
  124145. faceUV?: Vector4[];
  124146. faceColors?: Color4[];
  124147. updatable?: boolean;
  124148. sideOrientation?: number;
  124149. frontUVs?: Vector4;
  124150. backUVs?: Vector4;
  124151. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124152. /**
  124153. * Creates an extruded polygon mesh, with depth in the Y direction.
  124154. * * 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)
  124155. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124156. * @param name defines the name of the mesh
  124157. * @param options defines the options used to create the mesh
  124158. * @param scene defines the hosting scene
  124159. * @param earcutInjection can be used to inject your own earcut reference
  124160. * @returns the polygon mesh
  124161. */
  124162. static ExtrudePolygon(name: string, options: {
  124163. shape: Vector3[];
  124164. holes?: Vector3[][];
  124165. depth?: number;
  124166. faceUV?: Vector4[];
  124167. faceColors?: Color4[];
  124168. updatable?: boolean;
  124169. sideOrientation?: number;
  124170. frontUVs?: Vector4;
  124171. backUVs?: Vector4;
  124172. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124173. }
  124174. }
  124175. declare module BABYLON {
  124176. /**
  124177. * Class containing static functions to help procedurally build meshes
  124178. */
  124179. export class LatheBuilder {
  124180. /**
  124181. * Creates lathe mesh.
  124182. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124183. * * 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
  124184. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124185. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124186. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124187. * * 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
  124188. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124189. * * 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
  124190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124192. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124194. * @param name defines the name of the mesh
  124195. * @param options defines the options used to create the mesh
  124196. * @param scene defines the hosting scene
  124197. * @returns the lathe mesh
  124198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124199. */
  124200. static CreateLathe(name: string, options: {
  124201. shape: Vector3[];
  124202. radius?: number;
  124203. tessellation?: number;
  124204. clip?: number;
  124205. arc?: number;
  124206. closed?: boolean;
  124207. updatable?: boolean;
  124208. sideOrientation?: number;
  124209. frontUVs?: Vector4;
  124210. backUVs?: Vector4;
  124211. cap?: number;
  124212. invertUV?: boolean;
  124213. }, scene?: Nullable<Scene>): Mesh;
  124214. }
  124215. }
  124216. declare module BABYLON {
  124217. /**
  124218. * Class containing static functions to help procedurally build meshes
  124219. */
  124220. export class TiledPlaneBuilder {
  124221. /**
  124222. * Creates a tiled plane mesh
  124223. * * The parameter `pattern` will, depending on value, do nothing or
  124224. * * * flip (reflect about central vertical) alternate tiles across and up
  124225. * * * flip every tile on alternate rows
  124226. * * * rotate (180 degs) alternate tiles across and up
  124227. * * * rotate every tile on alternate rows
  124228. * * * flip and rotate alternate tiles across and up
  124229. * * * flip and rotate every tile on alternate rows
  124230. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  124231. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  124232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124234. * * 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)
  124235. * * 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)
  124236. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124237. * @param name defines the name of the mesh
  124238. * @param options defines the options used to create the mesh
  124239. * @param scene defines the hosting scene
  124240. * @returns the box mesh
  124241. */
  124242. static CreateTiledPlane(name: string, options: {
  124243. pattern?: number;
  124244. tileSize?: number;
  124245. tileWidth?: number;
  124246. tileHeight?: number;
  124247. size?: number;
  124248. width?: number;
  124249. height?: number;
  124250. alignHorizontal?: number;
  124251. alignVertical?: number;
  124252. sideOrientation?: number;
  124253. frontUVs?: Vector4;
  124254. backUVs?: Vector4;
  124255. updatable?: boolean;
  124256. }, scene?: Nullable<Scene>): Mesh;
  124257. }
  124258. }
  124259. declare module BABYLON {
  124260. /**
  124261. * Class containing static functions to help procedurally build meshes
  124262. */
  124263. export class TubeBuilder {
  124264. /**
  124265. * Creates a tube mesh.
  124266. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124267. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124268. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124269. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124270. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124271. * * 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)
  124272. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124273. * * 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
  124274. * * 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
  124275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124277. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124279. * @param name defines the name of the mesh
  124280. * @param options defines the options used to create the mesh
  124281. * @param scene defines the hosting scene
  124282. * @returns the tube mesh
  124283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124284. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  124285. */
  124286. static CreateTube(name: string, options: {
  124287. path: Vector3[];
  124288. radius?: number;
  124289. tessellation?: number;
  124290. radiusFunction?: {
  124291. (i: number, distance: number): number;
  124292. };
  124293. cap?: number;
  124294. arc?: number;
  124295. updatable?: boolean;
  124296. sideOrientation?: number;
  124297. frontUVs?: Vector4;
  124298. backUVs?: Vector4;
  124299. instance?: Mesh;
  124300. invertUV?: boolean;
  124301. }, scene?: Nullable<Scene>): Mesh;
  124302. }
  124303. }
  124304. declare module BABYLON {
  124305. /**
  124306. * Class containing static functions to help procedurally build meshes
  124307. */
  124308. export class IcoSphereBuilder {
  124309. /**
  124310. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124311. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124312. * * 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`)
  124313. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124314. * * 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
  124315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124318. * @param name defines the name of the mesh
  124319. * @param options defines the options used to create the mesh
  124320. * @param scene defines the hosting scene
  124321. * @returns the icosahedron mesh
  124322. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124323. */
  124324. static CreateIcoSphere(name: string, options: {
  124325. radius?: number;
  124326. radiusX?: number;
  124327. radiusY?: number;
  124328. radiusZ?: number;
  124329. flat?: boolean;
  124330. subdivisions?: number;
  124331. sideOrientation?: number;
  124332. frontUVs?: Vector4;
  124333. backUVs?: Vector4;
  124334. updatable?: boolean;
  124335. }, scene?: Nullable<Scene>): Mesh;
  124336. }
  124337. }
  124338. declare module BABYLON {
  124339. /**
  124340. * Class containing static functions to help procedurally build meshes
  124341. */
  124342. export class DecalBuilder {
  124343. /**
  124344. * Creates a decal mesh.
  124345. * 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
  124346. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  124347. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  124348. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  124349. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  124350. * @param name defines the name of the mesh
  124351. * @param sourceMesh defines the mesh where the decal must be applied
  124352. * @param options defines the options used to create the mesh
  124353. * @param scene defines the hosting scene
  124354. * @returns the decal mesh
  124355. * @see https://doc.babylonjs.com/how_to/decals
  124356. */
  124357. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  124358. position?: Vector3;
  124359. normal?: Vector3;
  124360. size?: Vector3;
  124361. angle?: number;
  124362. }): Mesh;
  124363. }
  124364. }
  124365. declare module BABYLON {
  124366. /**
  124367. * Class containing static functions to help procedurally build meshes
  124368. */
  124369. export class MeshBuilder {
  124370. /**
  124371. * Creates a box mesh
  124372. * * The parameter `size` sets the size (float) of each box side (default 1)
  124373. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  124374. * * 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)
  124375. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124379. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  124380. * @param name defines the name of the mesh
  124381. * @param options defines the options used to create the mesh
  124382. * @param scene defines the hosting scene
  124383. * @returns the box mesh
  124384. */
  124385. static CreateBox(name: string, options: {
  124386. size?: number;
  124387. width?: number;
  124388. height?: number;
  124389. depth?: number;
  124390. faceUV?: Vector4[];
  124391. faceColors?: Color4[];
  124392. sideOrientation?: number;
  124393. frontUVs?: Vector4;
  124394. backUVs?: Vector4;
  124395. updatable?: boolean;
  124396. }, scene?: Nullable<Scene>): Mesh;
  124397. /**
  124398. * Creates a tiled box mesh
  124399. * * faceTiles sets the pattern, tile size and number of tiles for a face
  124400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124401. * @param name defines the name of the mesh
  124402. * @param options defines the options used to create the mesh
  124403. * @param scene defines the hosting scene
  124404. * @returns the tiled box mesh
  124405. */
  124406. static CreateTiledBox(name: string, options: {
  124407. pattern?: number;
  124408. size?: number;
  124409. width?: number;
  124410. height?: number;
  124411. depth: number;
  124412. tileSize?: number;
  124413. tileWidth?: number;
  124414. tileHeight?: number;
  124415. faceUV?: Vector4[];
  124416. faceColors?: Color4[];
  124417. alignHorizontal?: number;
  124418. alignVertical?: number;
  124419. sideOrientation?: number;
  124420. updatable?: boolean;
  124421. }, scene?: Nullable<Scene>): Mesh;
  124422. /**
  124423. * Creates a sphere mesh
  124424. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  124425. * * 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`)
  124426. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  124427. * * 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
  124428. * * 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)
  124429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124432. * @param name defines the name of the mesh
  124433. * @param options defines the options used to create the mesh
  124434. * @param scene defines the hosting scene
  124435. * @returns the sphere mesh
  124436. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  124437. */
  124438. static CreateSphere(name: string, options: {
  124439. segments?: number;
  124440. diameter?: number;
  124441. diameterX?: number;
  124442. diameterY?: number;
  124443. diameterZ?: number;
  124444. arc?: number;
  124445. slice?: number;
  124446. sideOrientation?: number;
  124447. frontUVs?: Vector4;
  124448. backUVs?: Vector4;
  124449. updatable?: boolean;
  124450. }, scene?: Nullable<Scene>): Mesh;
  124451. /**
  124452. * Creates a plane polygonal mesh. By default, this is a disc
  124453. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  124454. * * 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
  124455. * * 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
  124456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124459. * @param name defines the name of the mesh
  124460. * @param options defines the options used to create the mesh
  124461. * @param scene defines the hosting scene
  124462. * @returns the plane polygonal mesh
  124463. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  124464. */
  124465. static CreateDisc(name: string, options: {
  124466. radius?: number;
  124467. tessellation?: number;
  124468. arc?: number;
  124469. updatable?: boolean;
  124470. sideOrientation?: number;
  124471. frontUVs?: Vector4;
  124472. backUVs?: Vector4;
  124473. }, scene?: Nullable<Scene>): Mesh;
  124474. /**
  124475. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  124476. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  124477. * * 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`)
  124478. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  124479. * * 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
  124480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124483. * @param name defines the name of the mesh
  124484. * @param options defines the options used to create the mesh
  124485. * @param scene defines the hosting scene
  124486. * @returns the icosahedron mesh
  124487. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  124488. */
  124489. static CreateIcoSphere(name: string, options: {
  124490. radius?: number;
  124491. radiusX?: number;
  124492. radiusY?: number;
  124493. radiusZ?: number;
  124494. flat?: boolean;
  124495. subdivisions?: number;
  124496. sideOrientation?: number;
  124497. frontUVs?: Vector4;
  124498. backUVs?: Vector4;
  124499. updatable?: boolean;
  124500. }, scene?: Nullable<Scene>): Mesh;
  124501. /**
  124502. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124503. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124504. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124505. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124506. * * 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
  124507. * * 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
  124508. * * 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
  124509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124512. * * 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
  124513. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124514. * * 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
  124515. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124517. * @param name defines the name of the mesh
  124518. * @param options defines the options used to create the mesh
  124519. * @param scene defines the hosting scene
  124520. * @returns the ribbon mesh
  124521. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124523. */
  124524. static CreateRibbon(name: string, options: {
  124525. pathArray: Vector3[][];
  124526. closeArray?: boolean;
  124527. closePath?: boolean;
  124528. offset?: number;
  124529. updatable?: boolean;
  124530. sideOrientation?: number;
  124531. frontUVs?: Vector4;
  124532. backUVs?: Vector4;
  124533. instance?: Mesh;
  124534. invertUV?: boolean;
  124535. uvs?: Vector2[];
  124536. colors?: Color4[];
  124537. }, scene?: Nullable<Scene>): Mesh;
  124538. /**
  124539. * Creates a cylinder or a cone mesh
  124540. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124541. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124542. * * 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.
  124543. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124544. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124545. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124546. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124547. * * 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).
  124548. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124549. * * 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).
  124550. * * 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
  124551. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124552. * * 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
  124553. * * 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.
  124554. * * If `enclose` is false, a ring surface is one element.
  124555. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124556. * * 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
  124557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124560. * @param name defines the name of the mesh
  124561. * @param options defines the options used to create the mesh
  124562. * @param scene defines the hosting scene
  124563. * @returns the cylinder mesh
  124564. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124565. */
  124566. static CreateCylinder(name: string, options: {
  124567. height?: number;
  124568. diameterTop?: number;
  124569. diameterBottom?: number;
  124570. diameter?: number;
  124571. tessellation?: number;
  124572. subdivisions?: number;
  124573. arc?: number;
  124574. faceColors?: Color4[];
  124575. faceUV?: Vector4[];
  124576. updatable?: boolean;
  124577. hasRings?: boolean;
  124578. enclose?: boolean;
  124579. cap?: number;
  124580. sideOrientation?: number;
  124581. frontUVs?: Vector4;
  124582. backUVs?: Vector4;
  124583. }, scene?: Nullable<Scene>): Mesh;
  124584. /**
  124585. * Creates a torus mesh
  124586. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124587. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124588. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124592. * @param name defines the name of the mesh
  124593. * @param options defines the options used to create the mesh
  124594. * @param scene defines the hosting scene
  124595. * @returns the torus mesh
  124596. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124597. */
  124598. static CreateTorus(name: string, options: {
  124599. diameter?: number;
  124600. thickness?: number;
  124601. tessellation?: number;
  124602. updatable?: boolean;
  124603. sideOrientation?: number;
  124604. frontUVs?: Vector4;
  124605. backUVs?: Vector4;
  124606. }, scene?: Nullable<Scene>): Mesh;
  124607. /**
  124608. * Creates a torus knot mesh
  124609. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  124610. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  124611. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  124612. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  124613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124616. * @param name defines the name of the mesh
  124617. * @param options defines the options used to create the mesh
  124618. * @param scene defines the hosting scene
  124619. * @returns the torus knot mesh
  124620. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  124621. */
  124622. static CreateTorusKnot(name: string, options: {
  124623. radius?: number;
  124624. tube?: number;
  124625. radialSegments?: number;
  124626. tubularSegments?: number;
  124627. p?: number;
  124628. q?: number;
  124629. updatable?: boolean;
  124630. sideOrientation?: number;
  124631. frontUVs?: Vector4;
  124632. backUVs?: Vector4;
  124633. }, scene?: Nullable<Scene>): Mesh;
  124634. /**
  124635. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  124636. * * 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
  124637. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  124638. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  124639. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  124640. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  124641. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  124642. * * 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
  124643. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  124644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  124646. * @param name defines the name of the new line system
  124647. * @param options defines the options used to create the line system
  124648. * @param scene defines the hosting scene
  124649. * @returns a new line system mesh
  124650. */
  124651. static CreateLineSystem(name: string, options: {
  124652. lines: Vector3[][];
  124653. updatable?: boolean;
  124654. instance?: Nullable<LinesMesh>;
  124655. colors?: Nullable<Color4[][]>;
  124656. useVertexAlpha?: boolean;
  124657. }, scene: Nullable<Scene>): LinesMesh;
  124658. /**
  124659. * Creates a line mesh
  124660. * 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
  124661. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124662. * * The parameter `points` is an array successive Vector3
  124663. * * 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
  124664. * * The optional parameter `colors` is an array of successive Color4, one per line point
  124665. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  124666. * * When updating an instance, remember that only point positions can change, not the number of points
  124667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  124669. * @param name defines the name of the new line system
  124670. * @param options defines the options used to create the line system
  124671. * @param scene defines the hosting scene
  124672. * @returns a new line mesh
  124673. */
  124674. static CreateLines(name: string, options: {
  124675. points: Vector3[];
  124676. updatable?: boolean;
  124677. instance?: Nullable<LinesMesh>;
  124678. colors?: Color4[];
  124679. useVertexAlpha?: boolean;
  124680. }, scene?: Nullable<Scene>): LinesMesh;
  124681. /**
  124682. * Creates a dashed line mesh
  124683. * * 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
  124684. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  124685. * * The parameter `points` is an array successive Vector3
  124686. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  124687. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  124688. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  124689. * * 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
  124690. * * When updating an instance, remember that only point positions can change, not the number of points
  124691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124692. * @param name defines the name of the mesh
  124693. * @param options defines the options used to create the mesh
  124694. * @param scene defines the hosting scene
  124695. * @returns the dashed line mesh
  124696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  124697. */
  124698. static CreateDashedLines(name: string, options: {
  124699. points: Vector3[];
  124700. dashSize?: number;
  124701. gapSize?: number;
  124702. dashNb?: number;
  124703. updatable?: boolean;
  124704. instance?: LinesMesh;
  124705. }, scene?: Nullable<Scene>): LinesMesh;
  124706. /**
  124707. * 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.
  124708. * * 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.
  124709. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124710. * * 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.
  124711. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124712. * * 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
  124713. * * 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
  124714. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124717. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124719. * @param name defines the name of the mesh
  124720. * @param options defines the options used to create the mesh
  124721. * @param scene defines the hosting scene
  124722. * @returns the extruded shape mesh
  124723. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124724. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124725. */
  124726. static ExtrudeShape(name: string, options: {
  124727. shape: Vector3[];
  124728. path: Vector3[];
  124729. scale?: number;
  124730. rotation?: number;
  124731. cap?: number;
  124732. updatable?: boolean;
  124733. sideOrientation?: number;
  124734. frontUVs?: Vector4;
  124735. backUVs?: Vector4;
  124736. instance?: Mesh;
  124737. invertUV?: boolean;
  124738. }, scene?: Nullable<Scene>): Mesh;
  124739. /**
  124740. * Creates an custom extruded shape mesh.
  124741. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124742. * * 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.
  124743. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124744. * * 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
  124745. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124746. * * 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
  124747. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124748. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124749. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124750. * * 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
  124751. * * 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
  124752. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124755. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124757. * @param name defines the name of the mesh
  124758. * @param options defines the options used to create the mesh
  124759. * @param scene defines the hosting scene
  124760. * @returns the custom extruded shape mesh
  124761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124762. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124764. */
  124765. static ExtrudeShapeCustom(name: string, options: {
  124766. shape: Vector3[];
  124767. path: Vector3[];
  124768. scaleFunction?: any;
  124769. rotationFunction?: any;
  124770. ribbonCloseArray?: boolean;
  124771. ribbonClosePath?: boolean;
  124772. cap?: number;
  124773. updatable?: boolean;
  124774. sideOrientation?: number;
  124775. frontUVs?: Vector4;
  124776. backUVs?: Vector4;
  124777. instance?: Mesh;
  124778. invertUV?: boolean;
  124779. }, scene?: Nullable<Scene>): Mesh;
  124780. /**
  124781. * Creates lathe mesh.
  124782. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  124783. * * 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
  124784. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  124785. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  124786. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  124787. * * 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
  124788. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  124789. * * 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
  124790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124794. * @param name defines the name of the mesh
  124795. * @param options defines the options used to create the mesh
  124796. * @param scene defines the hosting scene
  124797. * @returns the lathe mesh
  124798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  124799. */
  124800. static CreateLathe(name: string, options: {
  124801. shape: Vector3[];
  124802. radius?: number;
  124803. tessellation?: number;
  124804. clip?: number;
  124805. arc?: number;
  124806. closed?: boolean;
  124807. updatable?: boolean;
  124808. sideOrientation?: number;
  124809. frontUVs?: Vector4;
  124810. backUVs?: Vector4;
  124811. cap?: number;
  124812. invertUV?: boolean;
  124813. }, scene?: Nullable<Scene>): Mesh;
  124814. /**
  124815. * Creates a tiled plane mesh
  124816. * * You can set a limited pattern arrangement with the tiles
  124817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124820. * @param name defines the name of the mesh
  124821. * @param options defines the options used to create the mesh
  124822. * @param scene defines the hosting scene
  124823. * @returns the plane mesh
  124824. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124825. */
  124826. static CreateTiledPlane(name: string, options: {
  124827. pattern?: number;
  124828. tileSize?: number;
  124829. tileWidth?: number;
  124830. tileHeight?: number;
  124831. size?: number;
  124832. width?: number;
  124833. height?: number;
  124834. alignHorizontal?: number;
  124835. alignVertical?: number;
  124836. sideOrientation?: number;
  124837. frontUVs?: Vector4;
  124838. backUVs?: Vector4;
  124839. updatable?: boolean;
  124840. }, scene?: Nullable<Scene>): Mesh;
  124841. /**
  124842. * Creates a plane mesh
  124843. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124844. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124845. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124849. * @param name defines the name of the mesh
  124850. * @param options defines the options used to create the mesh
  124851. * @param scene defines the hosting scene
  124852. * @returns the plane mesh
  124853. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124854. */
  124855. static CreatePlane(name: string, options: {
  124856. size?: number;
  124857. width?: number;
  124858. height?: number;
  124859. sideOrientation?: number;
  124860. frontUVs?: Vector4;
  124861. backUVs?: Vector4;
  124862. updatable?: boolean;
  124863. sourcePlane?: Plane;
  124864. }, scene?: Nullable<Scene>): Mesh;
  124865. /**
  124866. * Creates a ground mesh
  124867. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124868. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124870. * @param name defines the name of the mesh
  124871. * @param options defines the options used to create the mesh
  124872. * @param scene defines the hosting scene
  124873. * @returns the ground mesh
  124874. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124875. */
  124876. static CreateGround(name: string, options: {
  124877. width?: number;
  124878. height?: number;
  124879. subdivisions?: number;
  124880. subdivisionsX?: number;
  124881. subdivisionsY?: number;
  124882. updatable?: boolean;
  124883. }, scene?: Nullable<Scene>): Mesh;
  124884. /**
  124885. * Creates a tiled ground mesh
  124886. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124887. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124888. * * 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
  124889. * * 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
  124890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124891. * @param name defines the name of the mesh
  124892. * @param options defines the options used to create the mesh
  124893. * @param scene defines the hosting scene
  124894. * @returns the tiled ground mesh
  124895. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124896. */
  124897. static CreateTiledGround(name: string, options: {
  124898. xmin: number;
  124899. zmin: number;
  124900. xmax: number;
  124901. zmax: number;
  124902. subdivisions?: {
  124903. w: number;
  124904. h: number;
  124905. };
  124906. precision?: {
  124907. w: number;
  124908. h: number;
  124909. };
  124910. updatable?: boolean;
  124911. }, scene?: Nullable<Scene>): Mesh;
  124912. /**
  124913. * Creates a ground mesh from a height map
  124914. * * The parameter `url` sets the URL of the height map image resource.
  124915. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124916. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124917. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124918. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124919. * * 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.
  124920. * * 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).
  124921. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124923. * @param name defines the name of the mesh
  124924. * @param url defines the url to the height map
  124925. * @param options defines the options used to create the mesh
  124926. * @param scene defines the hosting scene
  124927. * @returns the ground mesh
  124928. * @see https://doc.babylonjs.com/babylon101/height_map
  124929. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124930. */
  124931. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124932. width?: number;
  124933. height?: number;
  124934. subdivisions?: number;
  124935. minHeight?: number;
  124936. maxHeight?: number;
  124937. colorFilter?: Color3;
  124938. alphaFilter?: number;
  124939. updatable?: boolean;
  124940. onReady?: (mesh: GroundMesh) => void;
  124941. }, scene?: Nullable<Scene>): GroundMesh;
  124942. /**
  124943. * Creates a polygon mesh
  124944. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  124945. * * 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
  124946. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  124947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  124949. * * Remember you can only change the shape positions, not their number when updating a polygon
  124950. * @param name defines the name of the mesh
  124951. * @param options defines the options used to create the mesh
  124952. * @param scene defines the hosting scene
  124953. * @param earcutInjection can be used to inject your own earcut reference
  124954. * @returns the polygon mesh
  124955. */
  124956. static CreatePolygon(name: string, options: {
  124957. shape: Vector3[];
  124958. holes?: Vector3[][];
  124959. depth?: number;
  124960. faceUV?: Vector4[];
  124961. faceColors?: Color4[];
  124962. updatable?: boolean;
  124963. sideOrientation?: number;
  124964. frontUVs?: Vector4;
  124965. backUVs?: Vector4;
  124966. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124967. /**
  124968. * Creates an extruded polygon mesh, with depth in the Y direction.
  124969. * * 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)
  124970. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  124971. * @param name defines the name of the mesh
  124972. * @param options defines the options used to create the mesh
  124973. * @param scene defines the hosting scene
  124974. * @param earcutInjection can be used to inject your own earcut reference
  124975. * @returns the polygon mesh
  124976. */
  124977. static ExtrudePolygon(name: string, options: {
  124978. shape: Vector3[];
  124979. holes?: Vector3[][];
  124980. depth?: number;
  124981. faceUV?: Vector4[];
  124982. faceColors?: Color4[];
  124983. updatable?: boolean;
  124984. sideOrientation?: number;
  124985. frontUVs?: Vector4;
  124986. backUVs?: Vector4;
  124987. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  124988. /**
  124989. * Creates a tube mesh.
  124990. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124991. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  124992. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  124993. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  124994. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  124995. * * 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)
  124996. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  124997. * * 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
  124998. * * 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
  124999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125001. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125003. * @param name defines the name of the mesh
  125004. * @param options defines the options used to create the mesh
  125005. * @param scene defines the hosting scene
  125006. * @returns the tube mesh
  125007. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125008. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125009. */
  125010. static CreateTube(name: string, options: {
  125011. path: Vector3[];
  125012. radius?: number;
  125013. tessellation?: number;
  125014. radiusFunction?: {
  125015. (i: number, distance: number): number;
  125016. };
  125017. cap?: number;
  125018. arc?: number;
  125019. updatable?: boolean;
  125020. sideOrientation?: number;
  125021. frontUVs?: Vector4;
  125022. backUVs?: Vector4;
  125023. instance?: Mesh;
  125024. invertUV?: boolean;
  125025. }, scene?: Nullable<Scene>): Mesh;
  125026. /**
  125027. * Creates a polyhedron mesh
  125028. * * 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
  125029. * * The parameter `size` (positive float, default 1) sets the polygon size
  125030. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  125031. * * 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`
  125032. * * 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
  125033. * * 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)`)
  125034. * * 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
  125035. * * 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
  125036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125039. * @param name defines the name of the mesh
  125040. * @param options defines the options used to create the mesh
  125041. * @param scene defines the hosting scene
  125042. * @returns the polyhedron mesh
  125043. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  125044. */
  125045. static CreatePolyhedron(name: string, options: {
  125046. type?: number;
  125047. size?: number;
  125048. sizeX?: number;
  125049. sizeY?: number;
  125050. sizeZ?: number;
  125051. custom?: any;
  125052. faceUV?: Vector4[];
  125053. faceColors?: Color4[];
  125054. flat?: boolean;
  125055. updatable?: boolean;
  125056. sideOrientation?: number;
  125057. frontUVs?: Vector4;
  125058. backUVs?: Vector4;
  125059. }, scene?: Nullable<Scene>): Mesh;
  125060. /**
  125061. * Creates a decal mesh.
  125062. * 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
  125063. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125064. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125065. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125066. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125067. * @param name defines the name of the mesh
  125068. * @param sourceMesh defines the mesh where the decal must be applied
  125069. * @param options defines the options used to create the mesh
  125070. * @param scene defines the hosting scene
  125071. * @returns the decal mesh
  125072. * @see https://doc.babylonjs.com/how_to/decals
  125073. */
  125074. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125075. position?: Vector3;
  125076. normal?: Vector3;
  125077. size?: Vector3;
  125078. angle?: number;
  125079. }): Mesh;
  125080. }
  125081. }
  125082. declare module BABYLON {
  125083. /**
  125084. * A simplifier interface for future simplification implementations
  125085. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125086. */
  125087. export interface ISimplifier {
  125088. /**
  125089. * Simplification of a given mesh according to the given settings.
  125090. * Since this requires computation, it is assumed that the function runs async.
  125091. * @param settings The settings of the simplification, including quality and distance
  125092. * @param successCallback A callback that will be called after the mesh was simplified.
  125093. * @param errorCallback in case of an error, this callback will be called. optional.
  125094. */
  125095. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  125096. }
  125097. /**
  125098. * Expected simplification settings.
  125099. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  125100. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125101. */
  125102. export interface ISimplificationSettings {
  125103. /**
  125104. * Gets or sets the expected quality
  125105. */
  125106. quality: number;
  125107. /**
  125108. * Gets or sets the distance when this optimized version should be used
  125109. */
  125110. distance: number;
  125111. /**
  125112. * Gets an already optimized mesh
  125113. */
  125114. optimizeMesh?: boolean;
  125115. }
  125116. /**
  125117. * Class used to specify simplification options
  125118. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125119. */
  125120. export class SimplificationSettings implements ISimplificationSettings {
  125121. /** expected quality */
  125122. quality: number;
  125123. /** distance when this optimized version should be used */
  125124. distance: number;
  125125. /** already optimized mesh */
  125126. optimizeMesh?: boolean | undefined;
  125127. /**
  125128. * Creates a SimplificationSettings
  125129. * @param quality expected quality
  125130. * @param distance distance when this optimized version should be used
  125131. * @param optimizeMesh already optimized mesh
  125132. */
  125133. constructor(
  125134. /** expected quality */
  125135. quality: number,
  125136. /** distance when this optimized version should be used */
  125137. distance: number,
  125138. /** already optimized mesh */
  125139. optimizeMesh?: boolean | undefined);
  125140. }
  125141. /**
  125142. * Interface used to define a simplification task
  125143. */
  125144. export interface ISimplificationTask {
  125145. /**
  125146. * Array of settings
  125147. */
  125148. settings: Array<ISimplificationSettings>;
  125149. /**
  125150. * Simplification type
  125151. */
  125152. simplificationType: SimplificationType;
  125153. /**
  125154. * Mesh to simplify
  125155. */
  125156. mesh: Mesh;
  125157. /**
  125158. * Callback called on success
  125159. */
  125160. successCallback?: () => void;
  125161. /**
  125162. * Defines if parallel processing can be used
  125163. */
  125164. parallelProcessing: boolean;
  125165. }
  125166. /**
  125167. * Queue used to order the simplification tasks
  125168. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125169. */
  125170. export class SimplificationQueue {
  125171. private _simplificationArray;
  125172. /**
  125173. * Gets a boolean indicating that the process is still running
  125174. */
  125175. running: boolean;
  125176. /**
  125177. * Creates a new queue
  125178. */
  125179. constructor();
  125180. /**
  125181. * Adds a new simplification task
  125182. * @param task defines a task to add
  125183. */
  125184. addTask(task: ISimplificationTask): void;
  125185. /**
  125186. * Execute next task
  125187. */
  125188. executeNext(): void;
  125189. /**
  125190. * Execute a simplification task
  125191. * @param task defines the task to run
  125192. */
  125193. runSimplification(task: ISimplificationTask): void;
  125194. private getSimplifier;
  125195. }
  125196. /**
  125197. * The implemented types of simplification
  125198. * At the moment only Quadratic Error Decimation is implemented
  125199. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125200. */
  125201. export enum SimplificationType {
  125202. /** Quadratic error decimation */
  125203. QUADRATIC = 0
  125204. }
  125205. }
  125206. declare module BABYLON {
  125207. interface Scene {
  125208. /** @hidden (Backing field) */
  125209. _simplificationQueue: SimplificationQueue;
  125210. /**
  125211. * Gets or sets the simplification queue attached to the scene
  125212. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  125213. */
  125214. simplificationQueue: SimplificationQueue;
  125215. }
  125216. interface Mesh {
  125217. /**
  125218. * Simplify the mesh according to the given array of settings.
  125219. * Function will return immediately and will simplify async
  125220. * @param settings a collection of simplification settings
  125221. * @param parallelProcessing should all levels calculate parallel or one after the other
  125222. * @param simplificationType the type of simplification to run
  125223. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  125224. * @returns the current mesh
  125225. */
  125226. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  125227. }
  125228. /**
  125229. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  125230. * created in a scene
  125231. */
  125232. export class SimplicationQueueSceneComponent implements ISceneComponent {
  125233. /**
  125234. * The component name helpfull to identify the component in the list of scene components.
  125235. */
  125236. readonly name: string;
  125237. /**
  125238. * The scene the component belongs to.
  125239. */
  125240. scene: Scene;
  125241. /**
  125242. * Creates a new instance of the component for the given scene
  125243. * @param scene Defines the scene to register the component in
  125244. */
  125245. constructor(scene: Scene);
  125246. /**
  125247. * Registers the component in a given scene
  125248. */
  125249. register(): void;
  125250. /**
  125251. * Rebuilds the elements related to this component in case of
  125252. * context lost for instance.
  125253. */
  125254. rebuild(): void;
  125255. /**
  125256. * Disposes the component and the associated ressources
  125257. */
  125258. dispose(): void;
  125259. private _beforeCameraUpdate;
  125260. }
  125261. }
  125262. declare module BABYLON {
  125263. /**
  125264. * Navigation plugin interface to add navigation constrained by a navigation mesh
  125265. */
  125266. export interface INavigationEnginePlugin {
  125267. /**
  125268. * plugin name
  125269. */
  125270. name: string;
  125271. /**
  125272. * Creates a navigation mesh
  125273. * @param meshes array of all the geometry used to compute the navigatio mesh
  125274. * @param parameters bunch of parameters used to filter geometry
  125275. */
  125276. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125277. /**
  125278. * Create a navigation mesh debug mesh
  125279. * @param scene is where the mesh will be added
  125280. * @returns debug display mesh
  125281. */
  125282. createDebugNavMesh(scene: Scene): Mesh;
  125283. /**
  125284. * Get a navigation mesh constrained position, closest to the parameter position
  125285. * @param position world position
  125286. * @returns the closest point to position constrained by the navigation mesh
  125287. */
  125288. getClosestPoint(position: Vector3): Vector3;
  125289. /**
  125290. * Get a navigation mesh constrained position, within a particular radius
  125291. * @param position world position
  125292. * @param maxRadius the maximum distance to the constrained world position
  125293. * @returns the closest point to position constrained by the navigation mesh
  125294. */
  125295. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125296. /**
  125297. * Compute the final position from a segment made of destination-position
  125298. * @param position world position
  125299. * @param destination world position
  125300. * @returns the resulting point along the navmesh
  125301. */
  125302. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125303. /**
  125304. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125305. * @param start world position
  125306. * @param end world position
  125307. * @returns array containing world position composing the path
  125308. */
  125309. computePath(start: Vector3, end: Vector3): Vector3[];
  125310. /**
  125311. * If this plugin is supported
  125312. * @returns true if plugin is supported
  125313. */
  125314. isSupported(): boolean;
  125315. /**
  125316. * Create a new Crowd so you can add agents
  125317. * @param maxAgents the maximum agent count in the crowd
  125318. * @param maxAgentRadius the maximum radius an agent can have
  125319. * @param scene to attach the crowd to
  125320. * @returns the crowd you can add agents to
  125321. */
  125322. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125323. /**
  125324. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125325. * The queries will try to find a solution within those bounds
  125326. * default is (1,1,1)
  125327. * @param extent x,y,z value that define the extent around the queries point of reference
  125328. */
  125329. setDefaultQueryExtent(extent: Vector3): void;
  125330. /**
  125331. * Get the Bounding box extent specified by setDefaultQueryExtent
  125332. * @returns the box extent values
  125333. */
  125334. getDefaultQueryExtent(): Vector3;
  125335. /**
  125336. * Release all resources
  125337. */
  125338. dispose(): void;
  125339. }
  125340. /**
  125341. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  125342. */
  125343. export interface ICrowd {
  125344. /**
  125345. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125346. * You can attach anything to that node. The node position is updated in the scene update tick.
  125347. * @param pos world position that will be constrained by the navigation mesh
  125348. * @param parameters agent parameters
  125349. * @param transform hooked to the agent that will be update by the scene
  125350. * @returns agent index
  125351. */
  125352. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125353. /**
  125354. * Returns the agent position in world space
  125355. * @param index agent index returned by addAgent
  125356. * @returns world space position
  125357. */
  125358. getAgentPosition(index: number): Vector3;
  125359. /**
  125360. * Gets the agent velocity in world space
  125361. * @param index agent index returned by addAgent
  125362. * @returns world space velocity
  125363. */
  125364. getAgentVelocity(index: number): Vector3;
  125365. /**
  125366. * remove a particular agent previously created
  125367. * @param index agent index returned by addAgent
  125368. */
  125369. removeAgent(index: number): void;
  125370. /**
  125371. * get the list of all agents attached to this crowd
  125372. * @returns list of agent indices
  125373. */
  125374. getAgents(): number[];
  125375. /**
  125376. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125377. * @param deltaTime in seconds
  125378. */
  125379. update(deltaTime: number): void;
  125380. /**
  125381. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125382. * @param index agent index returned by addAgent
  125383. * @param destination targeted world position
  125384. */
  125385. agentGoto(index: number, destination: Vector3): void;
  125386. /**
  125387. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125388. * The queries will try to find a solution within those bounds
  125389. * default is (1,1,1)
  125390. * @param extent x,y,z value that define the extent around the queries point of reference
  125391. */
  125392. setDefaultQueryExtent(extent: Vector3): void;
  125393. /**
  125394. * Get the Bounding box extent specified by setDefaultQueryExtent
  125395. * @returns the box extent values
  125396. */
  125397. getDefaultQueryExtent(): Vector3;
  125398. /**
  125399. * Release all resources
  125400. */
  125401. dispose(): void;
  125402. }
  125403. /**
  125404. * Configures an agent
  125405. */
  125406. export interface IAgentParameters {
  125407. /**
  125408. * Agent radius. [Limit: >= 0]
  125409. */
  125410. radius: number;
  125411. /**
  125412. * Agent height. [Limit: > 0]
  125413. */
  125414. height: number;
  125415. /**
  125416. * Maximum allowed acceleration. [Limit: >= 0]
  125417. */
  125418. maxAcceleration: number;
  125419. /**
  125420. * Maximum allowed speed. [Limit: >= 0]
  125421. */
  125422. maxSpeed: number;
  125423. /**
  125424. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  125425. */
  125426. collisionQueryRange: number;
  125427. /**
  125428. * The path visibility optimization range. [Limit: > 0]
  125429. */
  125430. pathOptimizationRange: number;
  125431. /**
  125432. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  125433. */
  125434. separationWeight: number;
  125435. }
  125436. /**
  125437. * Configures the navigation mesh creation
  125438. */
  125439. export interface INavMeshParameters {
  125440. /**
  125441. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  125442. */
  125443. cs: number;
  125444. /**
  125445. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  125446. */
  125447. ch: number;
  125448. /**
  125449. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  125450. */
  125451. walkableSlopeAngle: number;
  125452. /**
  125453. * Minimum floor to 'ceiling' height that will still allow the floor area to
  125454. * be considered walkable. [Limit: >= 3] [Units: vx]
  125455. */
  125456. walkableHeight: number;
  125457. /**
  125458. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  125459. */
  125460. walkableClimb: number;
  125461. /**
  125462. * The distance to erode/shrink the walkable area of the heightfield away from
  125463. * obstructions. [Limit: >=0] [Units: vx]
  125464. */
  125465. walkableRadius: number;
  125466. /**
  125467. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  125468. */
  125469. maxEdgeLen: number;
  125470. /**
  125471. * The maximum distance a simplfied contour's border edges should deviate
  125472. * the original raw contour. [Limit: >=0] [Units: vx]
  125473. */
  125474. maxSimplificationError: number;
  125475. /**
  125476. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  125477. */
  125478. minRegionArea: number;
  125479. /**
  125480. * Any regions with a span count smaller than this value will, if possible,
  125481. * be merged with larger regions. [Limit: >=0] [Units: vx]
  125482. */
  125483. mergeRegionArea: number;
  125484. /**
  125485. * The maximum number of vertices allowed for polygons generated during the
  125486. * contour to polygon conversion process. [Limit: >= 3]
  125487. */
  125488. maxVertsPerPoly: number;
  125489. /**
  125490. * Sets the sampling distance to use when generating the detail mesh.
  125491. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  125492. */
  125493. detailSampleDist: number;
  125494. /**
  125495. * The maximum distance the detail mesh surface should deviate from heightfield
  125496. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  125497. */
  125498. detailSampleMaxError: number;
  125499. }
  125500. }
  125501. declare module BABYLON {
  125502. /**
  125503. * RecastJS navigation plugin
  125504. */
  125505. export class RecastJSPlugin implements INavigationEnginePlugin {
  125506. /**
  125507. * Reference to the Recast library
  125508. */
  125509. bjsRECAST: any;
  125510. /**
  125511. * plugin name
  125512. */
  125513. name: string;
  125514. /**
  125515. * the first navmesh created. We might extend this to support multiple navmeshes
  125516. */
  125517. navMesh: any;
  125518. /**
  125519. * Initializes the recastJS plugin
  125520. * @param recastInjection can be used to inject your own recast reference
  125521. */
  125522. constructor(recastInjection?: any);
  125523. /**
  125524. * Creates a navigation mesh
  125525. * @param meshes array of all the geometry used to compute the navigatio mesh
  125526. * @param parameters bunch of parameters used to filter geometry
  125527. */
  125528. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  125529. /**
  125530. * Create a navigation mesh debug mesh
  125531. * @param scene is where the mesh will be added
  125532. * @returns debug display mesh
  125533. */
  125534. createDebugNavMesh(scene: Scene): Mesh;
  125535. /**
  125536. * Get a navigation mesh constrained position, closest to the parameter position
  125537. * @param position world position
  125538. * @returns the closest point to position constrained by the navigation mesh
  125539. */
  125540. getClosestPoint(position: Vector3): Vector3;
  125541. /**
  125542. * Get a navigation mesh constrained position, within a particular radius
  125543. * @param position world position
  125544. * @param maxRadius the maximum distance to the constrained world position
  125545. * @returns the closest point to position constrained by the navigation mesh
  125546. */
  125547. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  125548. /**
  125549. * Compute the final position from a segment made of destination-position
  125550. * @param position world position
  125551. * @param destination world position
  125552. * @returns the resulting point along the navmesh
  125553. */
  125554. moveAlong(position: Vector3, destination: Vector3): Vector3;
  125555. /**
  125556. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  125557. * @param start world position
  125558. * @param end world position
  125559. * @returns array containing world position composing the path
  125560. */
  125561. computePath(start: Vector3, end: Vector3): Vector3[];
  125562. /**
  125563. * Create a new Crowd so you can add agents
  125564. * @param maxAgents the maximum agent count in the crowd
  125565. * @param maxAgentRadius the maximum radius an agent can have
  125566. * @param scene to attach the crowd to
  125567. * @returns the crowd you can add agents to
  125568. */
  125569. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  125570. /**
  125571. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125572. * The queries will try to find a solution within those bounds
  125573. * default is (1,1,1)
  125574. * @param extent x,y,z value that define the extent around the queries point of reference
  125575. */
  125576. setDefaultQueryExtent(extent: Vector3): void;
  125577. /**
  125578. * Get the Bounding box extent specified by setDefaultQueryExtent
  125579. * @returns the box extent values
  125580. */
  125581. getDefaultQueryExtent(): Vector3;
  125582. /**
  125583. * Disposes
  125584. */
  125585. dispose(): void;
  125586. /**
  125587. * If this plugin is supported
  125588. * @returns true if plugin is supported
  125589. */
  125590. isSupported(): boolean;
  125591. }
  125592. /**
  125593. * Recast detour crowd implementation
  125594. */
  125595. export class RecastJSCrowd implements ICrowd {
  125596. /**
  125597. * Recast/detour plugin
  125598. */
  125599. bjsRECASTPlugin: RecastJSPlugin;
  125600. /**
  125601. * Link to the detour crowd
  125602. */
  125603. recastCrowd: any;
  125604. /**
  125605. * One transform per agent
  125606. */
  125607. transforms: TransformNode[];
  125608. /**
  125609. * All agents created
  125610. */
  125611. agents: number[];
  125612. /**
  125613. * Link to the scene is kept to unregister the crowd from the scene
  125614. */
  125615. private _scene;
  125616. /**
  125617. * Observer for crowd updates
  125618. */
  125619. private _onBeforeAnimationsObserver;
  125620. /**
  125621. * Constructor
  125622. * @param plugin recastJS plugin
  125623. * @param maxAgents the maximum agent count in the crowd
  125624. * @param maxAgentRadius the maximum radius an agent can have
  125625. * @param scene to attach the crowd to
  125626. * @returns the crowd you can add agents to
  125627. */
  125628. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  125629. /**
  125630. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  125631. * You can attach anything to that node. The node position is updated in the scene update tick.
  125632. * @param pos world position that will be constrained by the navigation mesh
  125633. * @param parameters agent parameters
  125634. * @param transform hooked to the agent that will be update by the scene
  125635. * @returns agent index
  125636. */
  125637. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  125638. /**
  125639. * Returns the agent position in world space
  125640. * @param index agent index returned by addAgent
  125641. * @returns world space position
  125642. */
  125643. getAgentPosition(index: number): Vector3;
  125644. /**
  125645. * Returns the agent velocity in world space
  125646. * @param index agent index returned by addAgent
  125647. * @returns world space velocity
  125648. */
  125649. getAgentVelocity(index: number): Vector3;
  125650. /**
  125651. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  125652. * @param index agent index returned by addAgent
  125653. * @param destination targeted world position
  125654. */
  125655. agentGoto(index: number, destination: Vector3): void;
  125656. /**
  125657. * remove a particular agent previously created
  125658. * @param index agent index returned by addAgent
  125659. */
  125660. removeAgent(index: number): void;
  125661. /**
  125662. * get the list of all agents attached to this crowd
  125663. * @returns list of agent indices
  125664. */
  125665. getAgents(): number[];
  125666. /**
  125667. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  125668. * @param deltaTime in seconds
  125669. */
  125670. update(deltaTime: number): void;
  125671. /**
  125672. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  125673. * The queries will try to find a solution within those bounds
  125674. * default is (1,1,1)
  125675. * @param extent x,y,z value that define the extent around the queries point of reference
  125676. */
  125677. setDefaultQueryExtent(extent: Vector3): void;
  125678. /**
  125679. * Get the Bounding box extent specified by setDefaultQueryExtent
  125680. * @returns the box extent values
  125681. */
  125682. getDefaultQueryExtent(): Vector3;
  125683. /**
  125684. * Release all resources
  125685. */
  125686. dispose(): void;
  125687. }
  125688. }
  125689. declare module BABYLON {
  125690. /**
  125691. * Class used to enable access to IndexedDB
  125692. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125693. */
  125694. export class Database implements IOfflineProvider {
  125695. private _callbackManifestChecked;
  125696. private _currentSceneUrl;
  125697. private _db;
  125698. private _enableSceneOffline;
  125699. private _enableTexturesOffline;
  125700. private _manifestVersionFound;
  125701. private _mustUpdateRessources;
  125702. private _hasReachedQuota;
  125703. private _isSupported;
  125704. private _idbFactory;
  125705. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  125706. private static IsUASupportingBlobStorage;
  125707. /**
  125708. * Gets a boolean indicating if Database storate is enabled (off by default)
  125709. */
  125710. static IDBStorageEnabled: boolean;
  125711. /**
  125712. * Gets a boolean indicating if scene must be saved in the database
  125713. */
  125714. readonly enableSceneOffline: boolean;
  125715. /**
  125716. * Gets a boolean indicating if textures must be saved in the database
  125717. */
  125718. readonly enableTexturesOffline: boolean;
  125719. /**
  125720. * Creates a new Database
  125721. * @param urlToScene defines the url to load the scene
  125722. * @param callbackManifestChecked defines the callback to use when manifest is checked
  125723. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  125724. */
  125725. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  125726. private static _ParseURL;
  125727. private static _ReturnFullUrlLocation;
  125728. private _checkManifestFile;
  125729. /**
  125730. * Open the database and make it available
  125731. * @param successCallback defines the callback to call on success
  125732. * @param errorCallback defines the callback to call on error
  125733. */
  125734. open(successCallback: () => void, errorCallback: () => void): void;
  125735. /**
  125736. * Loads an image from the database
  125737. * @param url defines the url to load from
  125738. * @param image defines the target DOM image
  125739. */
  125740. loadImage(url: string, image: HTMLImageElement): void;
  125741. private _loadImageFromDBAsync;
  125742. private _saveImageIntoDBAsync;
  125743. private _checkVersionFromDB;
  125744. private _loadVersionFromDBAsync;
  125745. private _saveVersionIntoDBAsync;
  125746. /**
  125747. * Loads a file from database
  125748. * @param url defines the URL to load from
  125749. * @param sceneLoaded defines a callback to call on success
  125750. * @param progressCallBack defines a callback to call when progress changed
  125751. * @param errorCallback defines a callback to call on error
  125752. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  125753. */
  125754. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  125755. private _loadFileAsync;
  125756. private _saveFileAsync;
  125757. /**
  125758. * Validates if xhr data is correct
  125759. * @param xhr defines the request to validate
  125760. * @param dataType defines the expected data type
  125761. * @returns true if data is correct
  125762. */
  125763. private static _ValidateXHRData;
  125764. }
  125765. }
  125766. declare module BABYLON {
  125767. /** @hidden */
  125768. export var gpuUpdateParticlesPixelShader: {
  125769. name: string;
  125770. shader: string;
  125771. };
  125772. }
  125773. declare module BABYLON {
  125774. /** @hidden */
  125775. export var gpuUpdateParticlesVertexShader: {
  125776. name: string;
  125777. shader: string;
  125778. };
  125779. }
  125780. declare module BABYLON {
  125781. /** @hidden */
  125782. export var clipPlaneFragmentDeclaration2: {
  125783. name: string;
  125784. shader: string;
  125785. };
  125786. }
  125787. declare module BABYLON {
  125788. /** @hidden */
  125789. export var gpuRenderParticlesPixelShader: {
  125790. name: string;
  125791. shader: string;
  125792. };
  125793. }
  125794. declare module BABYLON {
  125795. /** @hidden */
  125796. export var clipPlaneVertexDeclaration2: {
  125797. name: string;
  125798. shader: string;
  125799. };
  125800. }
  125801. declare module BABYLON {
  125802. /** @hidden */
  125803. export var gpuRenderParticlesVertexShader: {
  125804. name: string;
  125805. shader: string;
  125806. };
  125807. }
  125808. declare module BABYLON {
  125809. /**
  125810. * This represents a GPU particle system in Babylon
  125811. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  125812. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  125813. */
  125814. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  125815. /**
  125816. * The layer mask we are rendering the particles through.
  125817. */
  125818. layerMask: number;
  125819. private _capacity;
  125820. private _activeCount;
  125821. private _currentActiveCount;
  125822. private _accumulatedCount;
  125823. private _renderEffect;
  125824. private _updateEffect;
  125825. private _buffer0;
  125826. private _buffer1;
  125827. private _spriteBuffer;
  125828. private _updateVAO;
  125829. private _renderVAO;
  125830. private _targetIndex;
  125831. private _sourceBuffer;
  125832. private _targetBuffer;
  125833. private _engine;
  125834. private _currentRenderId;
  125835. private _started;
  125836. private _stopped;
  125837. private _timeDelta;
  125838. private _randomTexture;
  125839. private _randomTexture2;
  125840. private _attributesStrideSize;
  125841. private _updateEffectOptions;
  125842. private _randomTextureSize;
  125843. private _actualFrame;
  125844. private readonly _rawTextureWidth;
  125845. /**
  125846. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  125847. */
  125848. static readonly IsSupported: boolean;
  125849. /**
  125850. * An event triggered when the system is disposed.
  125851. */
  125852. onDisposeObservable: Observable<GPUParticleSystem>;
  125853. /**
  125854. * Gets the maximum number of particles active at the same time.
  125855. * @returns The max number of active particles.
  125856. */
  125857. getCapacity(): number;
  125858. /**
  125859. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  125860. * to override the particles.
  125861. */
  125862. forceDepthWrite: boolean;
  125863. /**
  125864. * Gets or set the number of active particles
  125865. */
  125866. activeParticleCount: number;
  125867. private _preWarmDone;
  125868. /**
  125869. * Is this system ready to be used/rendered
  125870. * @return true if the system is ready
  125871. */
  125872. isReady(): boolean;
  125873. /**
  125874. * Gets if the system has been started. (Note: this will still be true after stop is called)
  125875. * @returns True if it has been started, otherwise false.
  125876. */
  125877. isStarted(): boolean;
  125878. /**
  125879. * Starts the particle system and begins to emit
  125880. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  125881. */
  125882. start(delay?: number): void;
  125883. /**
  125884. * Stops the particle system.
  125885. */
  125886. stop(): void;
  125887. /**
  125888. * Remove all active particles
  125889. */
  125890. reset(): void;
  125891. /**
  125892. * Returns the string "GPUParticleSystem"
  125893. * @returns a string containing the class name
  125894. */
  125895. getClassName(): string;
  125896. private _colorGradientsTexture;
  125897. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  125898. /**
  125899. * Adds a new color gradient
  125900. * @param gradient defines the gradient to use (between 0 and 1)
  125901. * @param color1 defines the color to affect to the specified gradient
  125902. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  125903. * @returns the current particle system
  125904. */
  125905. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  125906. /**
  125907. * Remove a specific color gradient
  125908. * @param gradient defines the gradient to remove
  125909. * @returns the current particle system
  125910. */
  125911. removeColorGradient(gradient: number): GPUParticleSystem;
  125912. private _angularSpeedGradientsTexture;
  125913. private _sizeGradientsTexture;
  125914. private _velocityGradientsTexture;
  125915. private _limitVelocityGradientsTexture;
  125916. private _dragGradientsTexture;
  125917. private _addFactorGradient;
  125918. /**
  125919. * Adds a new size gradient
  125920. * @param gradient defines the gradient to use (between 0 and 1)
  125921. * @param factor defines the size factor to affect to the specified gradient
  125922. * @returns the current particle system
  125923. */
  125924. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  125925. /**
  125926. * Remove a specific size gradient
  125927. * @param gradient defines the gradient to remove
  125928. * @returns the current particle system
  125929. */
  125930. removeSizeGradient(gradient: number): GPUParticleSystem;
  125931. /**
  125932. * Adds a new angular speed gradient
  125933. * @param gradient defines the gradient to use (between 0 and 1)
  125934. * @param factor defines the angular speed to affect to the specified gradient
  125935. * @returns the current particle system
  125936. */
  125937. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  125938. /**
  125939. * Remove a specific angular speed gradient
  125940. * @param gradient defines the gradient to remove
  125941. * @returns the current particle system
  125942. */
  125943. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  125944. /**
  125945. * Adds a new velocity gradient
  125946. * @param gradient defines the gradient to use (between 0 and 1)
  125947. * @param factor defines the velocity to affect to the specified gradient
  125948. * @returns the current particle system
  125949. */
  125950. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125951. /**
  125952. * Remove a specific velocity gradient
  125953. * @param gradient defines the gradient to remove
  125954. * @returns the current particle system
  125955. */
  125956. removeVelocityGradient(gradient: number): GPUParticleSystem;
  125957. /**
  125958. * Adds a new limit velocity gradient
  125959. * @param gradient defines the gradient to use (between 0 and 1)
  125960. * @param factor defines the limit velocity value to affect to the specified gradient
  125961. * @returns the current particle system
  125962. */
  125963. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  125964. /**
  125965. * Remove a specific limit velocity gradient
  125966. * @param gradient defines the gradient to remove
  125967. * @returns the current particle system
  125968. */
  125969. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  125970. /**
  125971. * Adds a new drag gradient
  125972. * @param gradient defines the gradient to use (between 0 and 1)
  125973. * @param factor defines the drag value to affect to the specified gradient
  125974. * @returns the current particle system
  125975. */
  125976. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  125977. /**
  125978. * Remove a specific drag gradient
  125979. * @param gradient defines the gradient to remove
  125980. * @returns the current particle system
  125981. */
  125982. removeDragGradient(gradient: number): GPUParticleSystem;
  125983. /**
  125984. * Not supported by GPUParticleSystem
  125985. * @param gradient defines the gradient to use (between 0 and 1)
  125986. * @param factor defines the emit rate value to affect to the specified gradient
  125987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  125988. * @returns the current particle system
  125989. */
  125990. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  125991. /**
  125992. * Not supported by GPUParticleSystem
  125993. * @param gradient defines the gradient to remove
  125994. * @returns the current particle system
  125995. */
  125996. removeEmitRateGradient(gradient: number): IParticleSystem;
  125997. /**
  125998. * Not supported by GPUParticleSystem
  125999. * @param gradient defines the gradient to use (between 0 and 1)
  126000. * @param factor defines the start size value to affect to the specified gradient
  126001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126002. * @returns the current particle system
  126003. */
  126004. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126005. /**
  126006. * Not supported by GPUParticleSystem
  126007. * @param gradient defines the gradient to remove
  126008. * @returns the current particle system
  126009. */
  126010. removeStartSizeGradient(gradient: number): IParticleSystem;
  126011. /**
  126012. * Not supported by GPUParticleSystem
  126013. * @param gradient defines the gradient to use (between 0 and 1)
  126014. * @param min defines the color remap minimal range
  126015. * @param max defines the color remap maximal range
  126016. * @returns the current particle system
  126017. */
  126018. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126019. /**
  126020. * Not supported by GPUParticleSystem
  126021. * @param gradient defines the gradient to remove
  126022. * @returns the current particle system
  126023. */
  126024. removeColorRemapGradient(): IParticleSystem;
  126025. /**
  126026. * Not supported by GPUParticleSystem
  126027. * @param gradient defines the gradient to use (between 0 and 1)
  126028. * @param min defines the alpha remap minimal range
  126029. * @param max defines the alpha remap maximal range
  126030. * @returns the current particle system
  126031. */
  126032. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  126033. /**
  126034. * Not supported by GPUParticleSystem
  126035. * @param gradient defines the gradient to remove
  126036. * @returns the current particle system
  126037. */
  126038. removeAlphaRemapGradient(): IParticleSystem;
  126039. /**
  126040. * Not supported by GPUParticleSystem
  126041. * @param gradient defines the gradient to use (between 0 and 1)
  126042. * @param color defines the color to affect to the specified gradient
  126043. * @returns the current particle system
  126044. */
  126045. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  126046. /**
  126047. * Not supported by GPUParticleSystem
  126048. * @param gradient defines the gradient to remove
  126049. * @returns the current particle system
  126050. */
  126051. removeRampGradient(): IParticleSystem;
  126052. /**
  126053. * Not supported by GPUParticleSystem
  126054. * @returns the list of ramp gradients
  126055. */
  126056. getRampGradients(): Nullable<Array<Color3Gradient>>;
  126057. /**
  126058. * Not supported by GPUParticleSystem
  126059. * Gets or sets a boolean indicating that ramp gradients must be used
  126060. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  126061. */
  126062. useRampGradients: boolean;
  126063. /**
  126064. * Not supported by GPUParticleSystem
  126065. * @param gradient defines the gradient to use (between 0 and 1)
  126066. * @param factor defines the life time factor to affect to the specified gradient
  126067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  126068. * @returns the current particle system
  126069. */
  126070. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  126071. /**
  126072. * Not supported by GPUParticleSystem
  126073. * @param gradient defines the gradient to remove
  126074. * @returns the current particle system
  126075. */
  126076. removeLifeTimeGradient(gradient: number): IParticleSystem;
  126077. /**
  126078. * Instantiates a GPU particle system.
  126079. * 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.
  126080. * @param name The name of the particle system
  126081. * @param options The options used to create the system
  126082. * @param scene The scene the particle system belongs to
  126083. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  126084. */
  126085. constructor(name: string, options: Partial<{
  126086. capacity: number;
  126087. randomTextureSize: number;
  126088. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  126089. protected _reset(): void;
  126090. private _createUpdateVAO;
  126091. private _createRenderVAO;
  126092. private _initialize;
  126093. /** @hidden */
  126094. _recreateUpdateEffect(): void;
  126095. /** @hidden */
  126096. _recreateRenderEffect(): void;
  126097. /**
  126098. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  126099. * @param preWarm defines if we are in the pre-warmimg phase
  126100. */
  126101. animate(preWarm?: boolean): void;
  126102. private _createFactorGradientTexture;
  126103. private _createSizeGradientTexture;
  126104. private _createAngularSpeedGradientTexture;
  126105. private _createVelocityGradientTexture;
  126106. private _createLimitVelocityGradientTexture;
  126107. private _createDragGradientTexture;
  126108. private _createColorGradientTexture;
  126109. /**
  126110. * Renders the particle system in its current state
  126111. * @param preWarm defines if the system should only update the particles but not render them
  126112. * @returns the current number of particles
  126113. */
  126114. render(preWarm?: boolean): number;
  126115. /**
  126116. * Rebuilds the particle system
  126117. */
  126118. rebuild(): void;
  126119. private _releaseBuffers;
  126120. private _releaseVAOs;
  126121. /**
  126122. * Disposes the particle system and free the associated resources
  126123. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  126124. */
  126125. dispose(disposeTexture?: boolean): void;
  126126. /**
  126127. * Clones the particle system.
  126128. * @param name The name of the cloned object
  126129. * @param newEmitter The new emitter to use
  126130. * @returns the cloned particle system
  126131. */
  126132. clone(name: string, newEmitter: any): GPUParticleSystem;
  126133. /**
  126134. * Serializes the particle system to a JSON object.
  126135. * @returns the JSON object
  126136. */
  126137. serialize(): any;
  126138. /**
  126139. * Parses a JSON object to create a GPU particle system.
  126140. * @param parsedParticleSystem The JSON object to parse
  126141. * @param scene The scene to create the particle system in
  126142. * @param rootUrl The root url to use to load external dependencies like texture
  126143. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  126144. * @returns the parsed GPU particle system
  126145. */
  126146. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  126147. }
  126148. }
  126149. declare module BABYLON {
  126150. /**
  126151. * Represents a set of particle systems working together to create a specific effect
  126152. */
  126153. export class ParticleSystemSet implements IDisposable {
  126154. /**
  126155. * Gets or sets base Assets URL
  126156. */
  126157. static BaseAssetsUrl: string;
  126158. private _emitterCreationOptions;
  126159. private _emitterNode;
  126160. /**
  126161. * Gets the particle system list
  126162. */
  126163. systems: IParticleSystem[];
  126164. /**
  126165. * Gets the emitter node used with this set
  126166. */
  126167. readonly emitterNode: Nullable<TransformNode>;
  126168. /**
  126169. * Creates a new emitter mesh as a sphere
  126170. * @param options defines the options used to create the sphere
  126171. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  126172. * @param scene defines the hosting scene
  126173. */
  126174. setEmitterAsSphere(options: {
  126175. diameter: number;
  126176. segments: number;
  126177. color: Color3;
  126178. }, renderingGroupId: number, scene: Scene): void;
  126179. /**
  126180. * Starts all particle systems of the set
  126181. * @param emitter defines an optional mesh to use as emitter for the particle systems
  126182. */
  126183. start(emitter?: AbstractMesh): void;
  126184. /**
  126185. * Release all associated resources
  126186. */
  126187. dispose(): void;
  126188. /**
  126189. * Serialize the set into a JSON compatible object
  126190. * @returns a JSON compatible representation of the set
  126191. */
  126192. serialize(): any;
  126193. /**
  126194. * Parse a new ParticleSystemSet from a serialized source
  126195. * @param data defines a JSON compatible representation of the set
  126196. * @param scene defines the hosting scene
  126197. * @param gpu defines if we want GPU particles or CPU particles
  126198. * @returns a new ParticleSystemSet
  126199. */
  126200. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  126201. }
  126202. }
  126203. declare module BABYLON {
  126204. /**
  126205. * This class is made for on one-liner static method to help creating particle system set.
  126206. */
  126207. export class ParticleHelper {
  126208. /**
  126209. * Gets or sets base Assets URL
  126210. */
  126211. static BaseAssetsUrl: string;
  126212. /**
  126213. * Create a default particle system that you can tweak
  126214. * @param emitter defines the emitter to use
  126215. * @param capacity defines the system capacity (default is 500 particles)
  126216. * @param scene defines the hosting scene
  126217. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  126218. * @returns the new Particle system
  126219. */
  126220. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  126221. /**
  126222. * This is the main static method (one-liner) of this helper to create different particle systems
  126223. * @param type This string represents the type to the particle system to create
  126224. * @param scene The scene where the particle system should live
  126225. * @param gpu If the system will use gpu
  126226. * @returns the ParticleSystemSet created
  126227. */
  126228. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  126229. /**
  126230. * Static function used to export a particle system to a ParticleSystemSet variable.
  126231. * Please note that the emitter shape is not exported
  126232. * @param systems defines the particle systems to export
  126233. * @returns the created particle system set
  126234. */
  126235. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  126236. }
  126237. }
  126238. declare module BABYLON {
  126239. interface Engine {
  126240. /**
  126241. * Create an effect to use with particle systems.
  126242. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  126243. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  126244. * @param uniformsNames defines a list of attribute names
  126245. * @param samplers defines an array of string used to represent textures
  126246. * @param defines defines the string containing the defines to use to compile the shaders
  126247. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  126248. * @param onCompiled defines a function to call when the effect creation is successful
  126249. * @param onError defines a function to call when the effect creation has failed
  126250. * @returns the new Effect
  126251. */
  126252. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  126253. }
  126254. interface Mesh {
  126255. /**
  126256. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  126257. * @returns an array of IParticleSystem
  126258. */
  126259. getEmittedParticleSystems(): IParticleSystem[];
  126260. /**
  126261. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  126262. * @returns an array of IParticleSystem
  126263. */
  126264. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  126265. }
  126266. /**
  126267. * @hidden
  126268. */
  126269. export var _IDoNeedToBeInTheBuild: number;
  126270. }
  126271. declare module BABYLON {
  126272. /** Defines the 4 color options */
  126273. export enum PointColor {
  126274. /** color value */
  126275. Color = 2,
  126276. /** uv value */
  126277. UV = 1,
  126278. /** random value */
  126279. Random = 0,
  126280. /** stated value */
  126281. Stated = 3
  126282. }
  126283. /**
  126284. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  126285. * As it is just a mesh, the PointCloudSystem has all the same properties as any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  126286. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  126287. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  126288. *
  126289. * Full documentation here : TO BE ENTERED
  126290. */
  126291. export class PointsCloudSystem implements IDisposable {
  126292. /**
  126293. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  126294. * Example : var p = SPS.particles[i];
  126295. */
  126296. particles: CloudPoint[];
  126297. /**
  126298. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  126299. */
  126300. nbParticles: number;
  126301. /**
  126302. * This a counter for your own usage. It's not set by any SPS functions.
  126303. */
  126304. counter: number;
  126305. /**
  126306. * The PCS name. This name is also given to the underlying mesh.
  126307. */
  126308. name: string;
  126309. /**
  126310. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  126311. */
  126312. mesh: Mesh;
  126313. /**
  126314. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  126315. * Please read :
  126316. */
  126317. vars: any;
  126318. /**
  126319. * @hidden
  126320. */
  126321. _size: number;
  126322. private _scene;
  126323. private _promises;
  126324. private _positions;
  126325. private _indices;
  126326. private _normals;
  126327. private _colors;
  126328. private _uvs;
  126329. private _indices32;
  126330. private _positions32;
  126331. private _colors32;
  126332. private _uvs32;
  126333. private _updatable;
  126334. private _isVisibilityBoxLocked;
  126335. private _alwaysVisible;
  126336. private _groups;
  126337. private _groupCounter;
  126338. private _computeParticleColor;
  126339. private _computeParticleTexture;
  126340. private _computeParticleRotation;
  126341. private _computeBoundingBox;
  126342. private _isReady;
  126343. /**
  126344. * Creates a PCS (Points Cloud System) object
  126345. * @param name (String) is the PCS name, this will be the underlying mesh name
  126346. * @param pointSize (number) is the size for each point
  126347. * @param scene (Scene) is the scene in which the PCS is added
  126348. * @param options defines the options of the PCS e.g.
  126349. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  126350. */
  126351. constructor(name: string, pointSize: number, scene: Scene, options?: {
  126352. updatable?: boolean;
  126353. });
  126354. /**
  126355. * Builds the PCS underlying mesh. Returns a standard Mesh.
  126356. * If no points were added to the PCS, the returned mesh is just a single point.
  126357. * @returns a promise for the created mesh
  126358. */
  126359. buildMeshAsync(): Promise<Mesh>;
  126360. /**
  126361. * @hidden
  126362. */
  126363. private _buildMesh;
  126364. private _addParticle;
  126365. private _randomUnitVector;
  126366. private _getColorIndicesForCoord;
  126367. private _setPointsColorOrUV;
  126368. private _colorFromTexture;
  126369. private _calculateDensity;
  126370. /**
  126371. * Adds points to the PCS in random positions within a unit sphere
  126372. * @param nb (positive integer) the number of particles to be created from this model
  126373. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  126374. * @returns the number of groups in the system
  126375. */
  126376. addPoints(nb: number, pointFunction?: any): number;
  126377. /**
  126378. * Adds points to the PCS from the surface of the model shape
  126379. * @param mesh is any Mesh object that will be used as a surface model for the points
  126380. * @param nb (positive integer) the number of particles to be created from this model
  126381. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  126382. * @param color (color3) to be used when colorWith is stated
  126383. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126384. * @returns the number of groups in the system
  126385. */
  126386. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126387. /**
  126388. * Adds points to the PCS inside the model shape
  126389. * @param mesh is any Mesh object that will be used as a surface model for the points
  126390. * @param nb (positive integer) the number of particles to be created from this model
  126391. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible),
  126392. * @param color (color4) to be used when colorWith is stated
  126393. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  126394. * @returns the number of groups in the system
  126395. */
  126396. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4, range?: number): number;
  126397. /**
  126398. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  126399. * This method calls `updateParticle()` for each particle of the SPS.
  126400. * For an animated SPS, it is usually called within the render loop.
  126401. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  126402. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  126403. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  126404. * @returns the PCS.
  126405. */
  126406. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  126407. /**
  126408. * Disposes the PCS.
  126409. */
  126410. dispose(): void;
  126411. /**
  126412. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  126413. * doc :
  126414. * @returns the PCS.
  126415. */
  126416. refreshVisibleSize(): PointsCloudSystem;
  126417. /**
  126418. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  126419. * @param size the size (float) of the visibility box
  126420. * note : this doesn't lock the PCS mesh bounding box.
  126421. * doc :
  126422. */
  126423. setVisibilityBox(size: number): void;
  126424. /**
  126425. * Gets whether the PCS is always visible or not
  126426. * doc :
  126427. */
  126428. /**
  126429. * Sets the PCS as always visible or not
  126430. * doc :
  126431. */
  126432. isAlwaysVisible: boolean;
  126433. /**
  126434. * Tells to `setParticles()` to compute the particle rotations or not
  126435. * Default value : false. The PCS is faster when it's set to false
  126436. * Note : particle rotations are only applied to parent particles
  126437. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  126438. */
  126439. computeParticleRotation: boolean;
  126440. /**
  126441. * Tells to `setParticles()` to compute the particle colors or not.
  126442. * Default value : true. The PCS is faster when it's set to false.
  126443. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126444. */
  126445. /**
  126446. * Gets if `setParticles()` computes the particle colors or not.
  126447. * Default value : false. The PCS is faster when it's set to false.
  126448. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  126449. */
  126450. computeParticleColor: boolean;
  126451. /**
  126452. * Gets if `setParticles()` computes the particle textures or not.
  126453. * Default value : false. The PCS is faster when it's set to false.
  126454. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  126455. */
  126456. computeParticleTexture: boolean;
  126457. /**
  126458. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  126459. */
  126460. /**
  126461. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  126462. */
  126463. computeBoundingBox: boolean;
  126464. /**
  126465. * This function does nothing. It may be overwritten to set all the particle first values.
  126466. * The PCS doesn't call this function, you may have to call it by your own.
  126467. * doc :
  126468. */
  126469. initParticles(): void;
  126470. /**
  126471. * This function does nothing. It may be overwritten to recycle a particle
  126472. * The PCS doesn't call this function, you can to call it
  126473. * doc :
  126474. * @param particle The particle to recycle
  126475. * @returns the recycled particle
  126476. */
  126477. recycleParticle(particle: CloudPoint): CloudPoint;
  126478. /**
  126479. * Updates a particle : this function should be overwritten by the user.
  126480. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  126481. * doc :
  126482. * @example : just set a particle position or velocity and recycle conditions
  126483. * @param particle The particle to update
  126484. * @returns the updated particle
  126485. */
  126486. updateParticle(particle: CloudPoint): CloudPoint;
  126487. /**
  126488. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  126489. * This does nothing and may be overwritten by the user.
  126490. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126491. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126492. * @param update the boolean update value actually passed to setParticles()
  126493. */
  126494. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126495. /**
  126496. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  126497. * This will be passed three parameters.
  126498. * This does nothing and may be overwritten by the user.
  126499. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  126500. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  126501. * @param update the boolean update value actually passed to setParticles()
  126502. */
  126503. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  126504. }
  126505. }
  126506. declare module BABYLON {
  126507. /**
  126508. * Represents one particle of a points cloud system.
  126509. */
  126510. export class CloudPoint {
  126511. /**
  126512. * particle global index
  126513. */
  126514. idx: number;
  126515. /**
  126516. * The color of the particle
  126517. */
  126518. color: Nullable<Color4>;
  126519. /**
  126520. * The world space position of the particle.
  126521. */
  126522. position: Vector3;
  126523. /**
  126524. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  126525. */
  126526. rotation: Vector3;
  126527. /**
  126528. * The world space rotation quaternion of the particle.
  126529. */
  126530. rotationQuaternion: Nullable<Quaternion>;
  126531. /**
  126532. * The uv of the particle.
  126533. */
  126534. uv: Nullable<Vector2>;
  126535. /**
  126536. * The current speed of the particle.
  126537. */
  126538. velocity: Vector3;
  126539. /**
  126540. * The pivot point in the particle local space.
  126541. */
  126542. pivot: Vector3;
  126543. /**
  126544. * Must the particle be translated from its pivot point in its local space ?
  126545. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  126546. * Default : false
  126547. */
  126548. translateFromPivot: boolean;
  126549. /**
  126550. * Index of this particle in the global "positions" array (Internal use)
  126551. * @hidden
  126552. */
  126553. _pos: number;
  126554. /**
  126555. * @hidden Index of this particle in the global "indices" array (Internal use)
  126556. */
  126557. _ind: number;
  126558. /**
  126559. * Group this particle belongs to
  126560. */
  126561. _group: PointsGroup;
  126562. /**
  126563. * Group id of this particle
  126564. */
  126565. groupId: number;
  126566. /**
  126567. * Index of the particle in its group id (Internal use)
  126568. */
  126569. idxInGroup: number;
  126570. /**
  126571. * @hidden Particle BoundingInfo object (Internal use)
  126572. */
  126573. _boundingInfo: BoundingInfo;
  126574. /**
  126575. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  126576. */
  126577. _pcs: PointsCloudSystem;
  126578. /**
  126579. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  126580. */
  126581. _stillInvisible: boolean;
  126582. /**
  126583. * @hidden Last computed particle rotation matrix
  126584. */
  126585. _rotationMatrix: number[];
  126586. /**
  126587. * Parent particle Id, if any.
  126588. * Default null.
  126589. */
  126590. parentId: Nullable<number>;
  126591. /**
  126592. * @hidden Internal global position in the PCS.
  126593. */
  126594. _globalPosition: Vector3;
  126595. /**
  126596. * Creates a Point Cloud object.
  126597. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  126598. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  126599. * @param group (PointsGroup) is the group the particle belongs to
  126600. * @param groupId (integer) is the group identifier in the PCS.
  126601. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  126602. * @param pcs defines the PCS it is associated to
  126603. */
  126604. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  126605. /**
  126606. * get point size
  126607. */
  126608. /**
  126609. * Set point size
  126610. */
  126611. size: Vector3;
  126612. /**
  126613. * Legacy support, changed quaternion to rotationQuaternion
  126614. */
  126615. /**
  126616. * Legacy support, changed quaternion to rotationQuaternion
  126617. */
  126618. quaternion: Nullable<Quaternion>;
  126619. /**
  126620. * Returns a boolean. True if the particle intersects a mesh, else false
  126621. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  126622. * @param target is the object (point or mesh) what the intersection is computed against
  126623. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  126624. * @returns true if it intersects
  126625. */
  126626. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  126627. /**
  126628. * get the rotation matrix of the particle
  126629. * @hidden
  126630. */
  126631. getRotationMatrix(m: Matrix): void;
  126632. }
  126633. /**
  126634. * Represents a group of points in a points cloud system
  126635. * * PCS internal tool, don't use it manually.
  126636. */
  126637. export class PointsGroup {
  126638. /**
  126639. * The group id
  126640. * @hidden
  126641. */
  126642. groupID: number;
  126643. /**
  126644. * image data for group (internal use)
  126645. * @hidden
  126646. */
  126647. _groupImageData: Nullable<ArrayBufferView>;
  126648. /**
  126649. * Image Width (internal use)
  126650. * @hidden
  126651. */
  126652. _groupImgWidth: number;
  126653. /**
  126654. * Image Height (internal use)
  126655. * @hidden
  126656. */
  126657. _groupImgHeight: number;
  126658. /**
  126659. * Custom position function (internal use)
  126660. * @hidden
  126661. */
  126662. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  126663. /**
  126664. * density per facet for surface points
  126665. * @hidden
  126666. */
  126667. _groupDensity: number[];
  126668. /**
  126669. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  126670. * PCS internal tool, don't use it manually.
  126671. * @hidden
  126672. */
  126673. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  126674. }
  126675. }
  126676. declare module BABYLON {
  126677. interface Scene {
  126678. /** @hidden (Backing field) */
  126679. _physicsEngine: Nullable<IPhysicsEngine>;
  126680. /**
  126681. * Gets the current physics engine
  126682. * @returns a IPhysicsEngine or null if none attached
  126683. */
  126684. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  126685. /**
  126686. * Enables physics to the current scene
  126687. * @param gravity defines the scene's gravity for the physics engine
  126688. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  126689. * @return a boolean indicating if the physics engine was initialized
  126690. */
  126691. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  126692. /**
  126693. * Disables and disposes the physics engine associated with the scene
  126694. */
  126695. disablePhysicsEngine(): void;
  126696. /**
  126697. * Gets a boolean indicating if there is an active physics engine
  126698. * @returns a boolean indicating if there is an active physics engine
  126699. */
  126700. isPhysicsEnabled(): boolean;
  126701. /**
  126702. * Deletes a physics compound impostor
  126703. * @param compound defines the compound to delete
  126704. */
  126705. deleteCompoundImpostor(compound: any): void;
  126706. /**
  126707. * An event triggered when physic simulation is about to be run
  126708. */
  126709. onBeforePhysicsObservable: Observable<Scene>;
  126710. /**
  126711. * An event triggered when physic simulation has been done
  126712. */
  126713. onAfterPhysicsObservable: Observable<Scene>;
  126714. }
  126715. interface AbstractMesh {
  126716. /** @hidden */
  126717. _physicsImpostor: Nullable<PhysicsImpostor>;
  126718. /**
  126719. * Gets or sets impostor used for physic simulation
  126720. * @see http://doc.babylonjs.com/features/physics_engine
  126721. */
  126722. physicsImpostor: Nullable<PhysicsImpostor>;
  126723. /**
  126724. * Gets the current physics impostor
  126725. * @see http://doc.babylonjs.com/features/physics_engine
  126726. * @returns a physics impostor or null
  126727. */
  126728. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  126729. /** Apply a physic impulse to the mesh
  126730. * @param force defines the force to apply
  126731. * @param contactPoint defines where to apply the force
  126732. * @returns the current mesh
  126733. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  126734. */
  126735. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  126736. /**
  126737. * Creates a physic joint between two meshes
  126738. * @param otherMesh defines the other mesh to use
  126739. * @param pivot1 defines the pivot to use on this mesh
  126740. * @param pivot2 defines the pivot to use on the other mesh
  126741. * @param options defines additional options (can be plugin dependent)
  126742. * @returns the current mesh
  126743. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  126744. */
  126745. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  126746. /** @hidden */
  126747. _disposePhysicsObserver: Nullable<Observer<Node>>;
  126748. }
  126749. /**
  126750. * Defines the physics engine scene component responsible to manage a physics engine
  126751. */
  126752. export class PhysicsEngineSceneComponent implements ISceneComponent {
  126753. /**
  126754. * The component name helpful to identify the component in the list of scene components.
  126755. */
  126756. readonly name: string;
  126757. /**
  126758. * The scene the component belongs to.
  126759. */
  126760. scene: Scene;
  126761. /**
  126762. * Creates a new instance of the component for the given scene
  126763. * @param scene Defines the scene to register the component in
  126764. */
  126765. constructor(scene: Scene);
  126766. /**
  126767. * Registers the component in a given scene
  126768. */
  126769. register(): void;
  126770. /**
  126771. * Rebuilds the elements related to this component in case of
  126772. * context lost for instance.
  126773. */
  126774. rebuild(): void;
  126775. /**
  126776. * Disposes the component and the associated ressources
  126777. */
  126778. dispose(): void;
  126779. }
  126780. }
  126781. declare module BABYLON {
  126782. /**
  126783. * A helper for physics simulations
  126784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  126785. */
  126786. export class PhysicsHelper {
  126787. private _scene;
  126788. private _physicsEngine;
  126789. /**
  126790. * Initializes the Physics helper
  126791. * @param scene Babylon.js scene
  126792. */
  126793. constructor(scene: Scene);
  126794. /**
  126795. * Applies a radial explosion impulse
  126796. * @param origin the origin of the explosion
  126797. * @param radiusOrEventOptions the radius or the options of radial explosion
  126798. * @param strength the explosion strength
  126799. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126800. * @returns A physics radial explosion event, or null
  126801. */
  126802. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126803. /**
  126804. * Applies a radial explosion force
  126805. * @param origin the origin of the explosion
  126806. * @param radiusOrEventOptions the radius or the options of radial explosion
  126807. * @param strength the explosion strength
  126808. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126809. * @returns A physics radial explosion event, or null
  126810. */
  126811. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  126812. /**
  126813. * Creates a gravitational field
  126814. * @param origin the origin of the explosion
  126815. * @param radiusOrEventOptions the radius or the options of radial explosion
  126816. * @param strength the explosion strength
  126817. * @param falloff possible options: Constant & Linear. Defaults to Constant
  126818. * @returns A physics gravitational field event, or null
  126819. */
  126820. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  126821. /**
  126822. * Creates a physics updraft event
  126823. * @param origin the origin of the updraft
  126824. * @param radiusOrEventOptions the radius or the options of the updraft
  126825. * @param strength the strength of the updraft
  126826. * @param height the height of the updraft
  126827. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  126828. * @returns A physics updraft event, or null
  126829. */
  126830. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  126831. /**
  126832. * Creates a physics vortex event
  126833. * @param origin the of the vortex
  126834. * @param radiusOrEventOptions the radius or the options of the vortex
  126835. * @param strength the strength of the vortex
  126836. * @param height the height of the vortex
  126837. * @returns a Physics vortex event, or null
  126838. * A physics vortex event or null
  126839. */
  126840. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  126841. }
  126842. /**
  126843. * Represents a physics radial explosion event
  126844. */
  126845. class PhysicsRadialExplosionEvent {
  126846. private _scene;
  126847. private _options;
  126848. private _sphere;
  126849. private _dataFetched;
  126850. /**
  126851. * Initializes a radial explosioin event
  126852. * @param _scene BabylonJS scene
  126853. * @param _options The options for the vortex event
  126854. */
  126855. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  126856. /**
  126857. * Returns the data related to the radial explosion event (sphere).
  126858. * @returns The radial explosion event data
  126859. */
  126860. getData(): PhysicsRadialExplosionEventData;
  126861. /**
  126862. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  126863. * @param impostor A physics imposter
  126864. * @param origin the origin of the explosion
  126865. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  126866. */
  126867. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  126868. /**
  126869. * Triggers affecterd impostors callbacks
  126870. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  126871. */
  126872. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  126873. /**
  126874. * Disposes the sphere.
  126875. * @param force Specifies if the sphere should be disposed by force
  126876. */
  126877. dispose(force?: boolean): void;
  126878. /*** Helpers ***/
  126879. private _prepareSphere;
  126880. private _intersectsWithSphere;
  126881. }
  126882. /**
  126883. * Represents a gravitational field event
  126884. */
  126885. class PhysicsGravitationalFieldEvent {
  126886. private _physicsHelper;
  126887. private _scene;
  126888. private _origin;
  126889. private _options;
  126890. private _tickCallback;
  126891. private _sphere;
  126892. private _dataFetched;
  126893. /**
  126894. * Initializes the physics gravitational field event
  126895. * @param _physicsHelper A physics helper
  126896. * @param _scene BabylonJS scene
  126897. * @param _origin The origin position of the gravitational field event
  126898. * @param _options The options for the vortex event
  126899. */
  126900. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  126901. /**
  126902. * Returns the data related to the gravitational field event (sphere).
  126903. * @returns A gravitational field event
  126904. */
  126905. getData(): PhysicsGravitationalFieldEventData;
  126906. /**
  126907. * Enables the gravitational field.
  126908. */
  126909. enable(): void;
  126910. /**
  126911. * Disables the gravitational field.
  126912. */
  126913. disable(): void;
  126914. /**
  126915. * Disposes the sphere.
  126916. * @param force The force to dispose from the gravitational field event
  126917. */
  126918. dispose(force?: boolean): void;
  126919. private _tick;
  126920. }
  126921. /**
  126922. * Represents a physics updraft event
  126923. */
  126924. class PhysicsUpdraftEvent {
  126925. private _scene;
  126926. private _origin;
  126927. private _options;
  126928. private _physicsEngine;
  126929. private _originTop;
  126930. private _originDirection;
  126931. private _tickCallback;
  126932. private _cylinder;
  126933. private _cylinderPosition;
  126934. private _dataFetched;
  126935. /**
  126936. * Initializes the physics updraft event
  126937. * @param _scene BabylonJS scene
  126938. * @param _origin The origin position of the updraft
  126939. * @param _options The options for the updraft event
  126940. */
  126941. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  126942. /**
  126943. * Returns the data related to the updraft event (cylinder).
  126944. * @returns A physics updraft event
  126945. */
  126946. getData(): PhysicsUpdraftEventData;
  126947. /**
  126948. * Enables the updraft.
  126949. */
  126950. enable(): void;
  126951. /**
  126952. * Disables the updraft.
  126953. */
  126954. disable(): void;
  126955. /**
  126956. * Disposes the cylinder.
  126957. * @param force Specifies if the updraft should be disposed by force
  126958. */
  126959. dispose(force?: boolean): void;
  126960. private getImpostorHitData;
  126961. private _tick;
  126962. /*** Helpers ***/
  126963. private _prepareCylinder;
  126964. private _intersectsWithCylinder;
  126965. }
  126966. /**
  126967. * Represents a physics vortex event
  126968. */
  126969. class PhysicsVortexEvent {
  126970. private _scene;
  126971. private _origin;
  126972. private _options;
  126973. private _physicsEngine;
  126974. private _originTop;
  126975. private _tickCallback;
  126976. private _cylinder;
  126977. private _cylinderPosition;
  126978. private _dataFetched;
  126979. /**
  126980. * Initializes the physics vortex event
  126981. * @param _scene The BabylonJS scene
  126982. * @param _origin The origin position of the vortex
  126983. * @param _options The options for the vortex event
  126984. */
  126985. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  126986. /**
  126987. * Returns the data related to the vortex event (cylinder).
  126988. * @returns The physics vortex event data
  126989. */
  126990. getData(): PhysicsVortexEventData;
  126991. /**
  126992. * Enables the vortex.
  126993. */
  126994. enable(): void;
  126995. /**
  126996. * Disables the cortex.
  126997. */
  126998. disable(): void;
  126999. /**
  127000. * Disposes the sphere.
  127001. * @param force
  127002. */
  127003. dispose(force?: boolean): void;
  127004. private getImpostorHitData;
  127005. private _tick;
  127006. /*** Helpers ***/
  127007. private _prepareCylinder;
  127008. private _intersectsWithCylinder;
  127009. }
  127010. /**
  127011. * Options fot the radial explosion event
  127012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127013. */
  127014. export class PhysicsRadialExplosionEventOptions {
  127015. /**
  127016. * The radius of the sphere for the radial explosion.
  127017. */
  127018. radius: number;
  127019. /**
  127020. * The strenth of the explosion.
  127021. */
  127022. strength: number;
  127023. /**
  127024. * The strenght of the force in correspondence to the distance of the affected object
  127025. */
  127026. falloff: PhysicsRadialImpulseFalloff;
  127027. /**
  127028. * Sphere options for the radial explosion.
  127029. */
  127030. sphere: {
  127031. segments: number;
  127032. diameter: number;
  127033. };
  127034. /**
  127035. * Sphere options for the radial explosion.
  127036. */
  127037. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  127038. }
  127039. /**
  127040. * Options fot the updraft event
  127041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127042. */
  127043. export class PhysicsUpdraftEventOptions {
  127044. /**
  127045. * The radius of the cylinder for the vortex
  127046. */
  127047. radius: number;
  127048. /**
  127049. * The strenth of the updraft.
  127050. */
  127051. strength: number;
  127052. /**
  127053. * The height of the cylinder for the updraft.
  127054. */
  127055. height: number;
  127056. /**
  127057. * The mode for the the updraft.
  127058. */
  127059. updraftMode: PhysicsUpdraftMode;
  127060. }
  127061. /**
  127062. * Options fot the vortex event
  127063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127064. */
  127065. export class PhysicsVortexEventOptions {
  127066. /**
  127067. * The radius of the cylinder for the vortex
  127068. */
  127069. radius: number;
  127070. /**
  127071. * The strenth of the vortex.
  127072. */
  127073. strength: number;
  127074. /**
  127075. * The height of the cylinder for the vortex.
  127076. */
  127077. height: number;
  127078. /**
  127079. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  127080. */
  127081. centripetalForceThreshold: number;
  127082. /**
  127083. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  127084. */
  127085. centripetalForceMultiplier: number;
  127086. /**
  127087. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  127088. */
  127089. centrifugalForceMultiplier: number;
  127090. /**
  127091. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  127092. */
  127093. updraftForceMultiplier: number;
  127094. }
  127095. /**
  127096. * The strenght of the force in correspondence to the distance of the affected object
  127097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127098. */
  127099. export enum PhysicsRadialImpulseFalloff {
  127100. /** Defines that impulse is constant in strength across it's whole radius */
  127101. Constant = 0,
  127102. /** Defines that impulse gets weaker if it's further from the origin */
  127103. Linear = 1
  127104. }
  127105. /**
  127106. * The strength of the force in correspondence to the distance of the affected object
  127107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127108. */
  127109. export enum PhysicsUpdraftMode {
  127110. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  127111. Center = 0,
  127112. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  127113. Perpendicular = 1
  127114. }
  127115. /**
  127116. * Interface for a physics hit data
  127117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127118. */
  127119. export interface PhysicsHitData {
  127120. /**
  127121. * The force applied at the contact point
  127122. */
  127123. force: Vector3;
  127124. /**
  127125. * The contact point
  127126. */
  127127. contactPoint: Vector3;
  127128. /**
  127129. * The distance from the origin to the contact point
  127130. */
  127131. distanceFromOrigin: number;
  127132. }
  127133. /**
  127134. * Interface for radial explosion event data
  127135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127136. */
  127137. export interface PhysicsRadialExplosionEventData {
  127138. /**
  127139. * A sphere used for the radial explosion event
  127140. */
  127141. sphere: Mesh;
  127142. }
  127143. /**
  127144. * Interface for gravitational field event data
  127145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127146. */
  127147. export interface PhysicsGravitationalFieldEventData {
  127148. /**
  127149. * A sphere mesh used for the gravitational field event
  127150. */
  127151. sphere: Mesh;
  127152. }
  127153. /**
  127154. * Interface for updraft event data
  127155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127156. */
  127157. export interface PhysicsUpdraftEventData {
  127158. /**
  127159. * A cylinder used for the updraft event
  127160. */
  127161. cylinder: Mesh;
  127162. }
  127163. /**
  127164. * Interface for vortex event data
  127165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127166. */
  127167. export interface PhysicsVortexEventData {
  127168. /**
  127169. * A cylinder used for the vortex event
  127170. */
  127171. cylinder: Mesh;
  127172. }
  127173. /**
  127174. * Interface for an affected physics impostor
  127175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  127176. */
  127177. export interface PhysicsAffectedImpostorWithData {
  127178. /**
  127179. * The impostor affected by the effect
  127180. */
  127181. impostor: PhysicsImpostor;
  127182. /**
  127183. * The data about the hit/horce from the explosion
  127184. */
  127185. hitData: PhysicsHitData;
  127186. }
  127187. }
  127188. declare module BABYLON {
  127189. /** @hidden */
  127190. export var blackAndWhitePixelShader: {
  127191. name: string;
  127192. shader: string;
  127193. };
  127194. }
  127195. declare module BABYLON {
  127196. /**
  127197. * Post process used to render in black and white
  127198. */
  127199. export class BlackAndWhitePostProcess extends PostProcess {
  127200. /**
  127201. * Linear about to convert he result to black and white (default: 1)
  127202. */
  127203. degree: number;
  127204. /**
  127205. * Creates a black and white post process
  127206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  127207. * @param name The name of the effect.
  127208. * @param options The required width/height ratio to downsize to before computing the render pass.
  127209. * @param camera The camera to apply the render pass to.
  127210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127211. * @param engine The engine which the post process will be applied. (default: current engine)
  127212. * @param reusable If the post process can be reused on the same frame. (default: false)
  127213. */
  127214. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127215. }
  127216. }
  127217. declare module BABYLON {
  127218. /**
  127219. * This represents a set of one or more post processes in Babylon.
  127220. * A post process can be used to apply a shader to a texture after it is rendered.
  127221. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  127222. */
  127223. export class PostProcessRenderEffect {
  127224. private _postProcesses;
  127225. private _getPostProcesses;
  127226. private _singleInstance;
  127227. private _cameras;
  127228. private _indicesForCamera;
  127229. /**
  127230. * Name of the effect
  127231. * @hidden
  127232. */
  127233. _name: string;
  127234. /**
  127235. * Instantiates a post process render effect.
  127236. * A post process can be used to apply a shader to a texture after it is rendered.
  127237. * @param engine The engine the effect is tied to
  127238. * @param name The name of the effect
  127239. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  127240. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  127241. */
  127242. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  127243. /**
  127244. * Checks if all the post processes in the effect are supported.
  127245. */
  127246. readonly isSupported: boolean;
  127247. /**
  127248. * Updates the current state of the effect
  127249. * @hidden
  127250. */
  127251. _update(): void;
  127252. /**
  127253. * Attaches the effect on cameras
  127254. * @param cameras The camera to attach to.
  127255. * @hidden
  127256. */
  127257. _attachCameras(cameras: Camera): void;
  127258. /**
  127259. * Attaches the effect on cameras
  127260. * @param cameras The camera to attach to.
  127261. * @hidden
  127262. */
  127263. _attachCameras(cameras: Camera[]): void;
  127264. /**
  127265. * Detaches the effect on cameras
  127266. * @param cameras The camera to detatch from.
  127267. * @hidden
  127268. */
  127269. _detachCameras(cameras: Camera): void;
  127270. /**
  127271. * Detatches the effect on cameras
  127272. * @param cameras The camera to detatch from.
  127273. * @hidden
  127274. */
  127275. _detachCameras(cameras: Camera[]): void;
  127276. /**
  127277. * Enables the effect on given cameras
  127278. * @param cameras The camera to enable.
  127279. * @hidden
  127280. */
  127281. _enable(cameras: Camera): void;
  127282. /**
  127283. * Enables the effect on given cameras
  127284. * @param cameras The camera to enable.
  127285. * @hidden
  127286. */
  127287. _enable(cameras: Nullable<Camera[]>): void;
  127288. /**
  127289. * Disables the effect on the given cameras
  127290. * @param cameras The camera to disable.
  127291. * @hidden
  127292. */
  127293. _disable(cameras: Camera): void;
  127294. /**
  127295. * Disables the effect on the given cameras
  127296. * @param cameras The camera to disable.
  127297. * @hidden
  127298. */
  127299. _disable(cameras: Nullable<Camera[]>): void;
  127300. /**
  127301. * Gets a list of the post processes contained in the effect.
  127302. * @param camera The camera to get the post processes on.
  127303. * @returns The list of the post processes in the effect.
  127304. */
  127305. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  127306. }
  127307. }
  127308. declare module BABYLON {
  127309. /** @hidden */
  127310. export var extractHighlightsPixelShader: {
  127311. name: string;
  127312. shader: string;
  127313. };
  127314. }
  127315. declare module BABYLON {
  127316. /**
  127317. * 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.
  127318. */
  127319. export class ExtractHighlightsPostProcess extends PostProcess {
  127320. /**
  127321. * The luminance threshold, pixels below this value will be set to black.
  127322. */
  127323. threshold: number;
  127324. /** @hidden */
  127325. _exposure: number;
  127326. /**
  127327. * Post process which has the input texture to be used when performing highlight extraction
  127328. * @hidden
  127329. */
  127330. _inputPostProcess: Nullable<PostProcess>;
  127331. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127332. }
  127333. }
  127334. declare module BABYLON {
  127335. /** @hidden */
  127336. export var bloomMergePixelShader: {
  127337. name: string;
  127338. shader: string;
  127339. };
  127340. }
  127341. declare module BABYLON {
  127342. /**
  127343. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127344. */
  127345. export class BloomMergePostProcess extends PostProcess {
  127346. /** Weight of the bloom to be added to the original input. */
  127347. weight: number;
  127348. /**
  127349. * Creates a new instance of @see BloomMergePostProcess
  127350. * @param name The name of the effect.
  127351. * @param originalFromInput Post process which's input will be used for the merge.
  127352. * @param blurred Blurred highlights post process which's output will be used.
  127353. * @param weight Weight of the bloom to be added to the original input.
  127354. * @param options The required width/height ratio to downsize to before computing the render pass.
  127355. * @param camera The camera to apply the render pass to.
  127356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127357. * @param engine The engine which the post process will be applied. (default: current engine)
  127358. * @param reusable If the post process can be reused on the same frame. (default: false)
  127359. * @param textureType Type of textures used when performing the post process. (default: 0)
  127360. * @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)
  127361. */
  127362. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  127363. /** Weight of the bloom to be added to the original input. */
  127364. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127365. }
  127366. }
  127367. declare module BABYLON {
  127368. /**
  127369. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  127370. */
  127371. export class BloomEffect extends PostProcessRenderEffect {
  127372. private bloomScale;
  127373. /**
  127374. * @hidden Internal
  127375. */
  127376. _effects: Array<PostProcess>;
  127377. /**
  127378. * @hidden Internal
  127379. */
  127380. _downscale: ExtractHighlightsPostProcess;
  127381. private _blurX;
  127382. private _blurY;
  127383. private _merge;
  127384. /**
  127385. * The luminance threshold to find bright areas of the image to bloom.
  127386. */
  127387. threshold: number;
  127388. /**
  127389. * The strength of the bloom.
  127390. */
  127391. weight: number;
  127392. /**
  127393. * Specifies the size of the bloom blur kernel, relative to the final output size
  127394. */
  127395. kernel: number;
  127396. /**
  127397. * Creates a new instance of @see BloomEffect
  127398. * @param scene The scene the effect belongs to.
  127399. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  127400. * @param bloomKernel The size of the kernel to be used when applying the blur.
  127401. * @param bloomWeight The the strength of bloom.
  127402. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127403. * @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)
  127404. */
  127405. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  127406. /**
  127407. * Disposes each of the internal effects for a given camera.
  127408. * @param camera The camera to dispose the effect on.
  127409. */
  127410. disposeEffects(camera: Camera): void;
  127411. /**
  127412. * @hidden Internal
  127413. */
  127414. _updateEffects(): void;
  127415. /**
  127416. * Internal
  127417. * @returns if all the contained post processes are ready.
  127418. * @hidden
  127419. */
  127420. _isReady(): boolean;
  127421. }
  127422. }
  127423. declare module BABYLON {
  127424. /** @hidden */
  127425. export var chromaticAberrationPixelShader: {
  127426. name: string;
  127427. shader: string;
  127428. };
  127429. }
  127430. declare module BABYLON {
  127431. /**
  127432. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  127433. */
  127434. export class ChromaticAberrationPostProcess extends PostProcess {
  127435. /**
  127436. * The amount of seperation of rgb channels (default: 30)
  127437. */
  127438. aberrationAmount: number;
  127439. /**
  127440. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  127441. */
  127442. radialIntensity: number;
  127443. /**
  127444. * 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))
  127445. */
  127446. direction: Vector2;
  127447. /**
  127448. * 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))
  127449. */
  127450. centerPosition: Vector2;
  127451. /**
  127452. * Creates a new instance ChromaticAberrationPostProcess
  127453. * @param name The name of the effect.
  127454. * @param screenWidth The width of the screen to apply the effect on.
  127455. * @param screenHeight The height of the screen to apply the effect on.
  127456. * @param options The required width/height ratio to downsize to before computing the render pass.
  127457. * @param camera The camera to apply the render pass to.
  127458. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127459. * @param engine The engine which the post process will be applied. (default: current engine)
  127460. * @param reusable If the post process can be reused on the same frame. (default: false)
  127461. * @param textureType Type of textures used when performing the post process. (default: 0)
  127462. * @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)
  127463. */
  127464. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127465. }
  127466. }
  127467. declare module BABYLON {
  127468. /** @hidden */
  127469. export var circleOfConfusionPixelShader: {
  127470. name: string;
  127471. shader: string;
  127472. };
  127473. }
  127474. declare module BABYLON {
  127475. /**
  127476. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  127477. */
  127478. export class CircleOfConfusionPostProcess extends PostProcess {
  127479. /**
  127480. * 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.
  127481. */
  127482. lensSize: number;
  127483. /**
  127484. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127485. */
  127486. fStop: number;
  127487. /**
  127488. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127489. */
  127490. focusDistance: number;
  127491. /**
  127492. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  127493. */
  127494. focalLength: number;
  127495. private _depthTexture;
  127496. /**
  127497. * Creates a new instance CircleOfConfusionPostProcess
  127498. * @param name The name of the effect.
  127499. * @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.
  127500. * @param options The required width/height ratio to downsize to before computing the render pass.
  127501. * @param camera The camera to apply the render pass to.
  127502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127503. * @param engine The engine which the post process will be applied. (default: current engine)
  127504. * @param reusable If the post process can be reused on the same frame. (default: false)
  127505. * @param textureType Type of textures used when performing the post process. (default: 0)
  127506. * @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)
  127507. */
  127508. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127509. /**
  127510. * 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.
  127511. */
  127512. depthTexture: RenderTargetTexture;
  127513. }
  127514. }
  127515. declare module BABYLON {
  127516. /** @hidden */
  127517. export var colorCorrectionPixelShader: {
  127518. name: string;
  127519. shader: string;
  127520. };
  127521. }
  127522. declare module BABYLON {
  127523. /**
  127524. *
  127525. * This post-process allows the modification of rendered colors by using
  127526. * a 'look-up table' (LUT). This effect is also called Color Grading.
  127527. *
  127528. * The object needs to be provided an url to a texture containing the color
  127529. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  127530. * Use an image editing software to tweak the LUT to match your needs.
  127531. *
  127532. * For an example of a color LUT, see here:
  127533. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  127534. * For explanations on color grading, see here:
  127535. * @see http://udn.epicgames.com/Three/ColorGrading.html
  127536. *
  127537. */
  127538. export class ColorCorrectionPostProcess extends PostProcess {
  127539. private _colorTableTexture;
  127540. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127541. }
  127542. }
  127543. declare module BABYLON {
  127544. /** @hidden */
  127545. export var convolutionPixelShader: {
  127546. name: string;
  127547. shader: string;
  127548. };
  127549. }
  127550. declare module BABYLON {
  127551. /**
  127552. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  127553. * input texture to perform effects such as edge detection or sharpening
  127554. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  127555. */
  127556. export class ConvolutionPostProcess extends PostProcess {
  127557. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127558. kernel: number[];
  127559. /**
  127560. * Creates a new instance ConvolutionPostProcess
  127561. * @param name The name of the effect.
  127562. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  127563. * @param options The required width/height ratio to downsize to before computing the render pass.
  127564. * @param camera The camera to apply the render pass to.
  127565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127566. * @param engine The engine which the post process will be applied. (default: current engine)
  127567. * @param reusable If the post process can be reused on the same frame. (default: false)
  127568. * @param textureType Type of textures used when performing the post process. (default: 0)
  127569. */
  127570. constructor(name: string,
  127571. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  127572. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127573. /**
  127574. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127575. */
  127576. static EdgeDetect0Kernel: number[];
  127577. /**
  127578. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127579. */
  127580. static EdgeDetect1Kernel: number[];
  127581. /**
  127582. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127583. */
  127584. static EdgeDetect2Kernel: number[];
  127585. /**
  127586. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127587. */
  127588. static SharpenKernel: number[];
  127589. /**
  127590. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127591. */
  127592. static EmbossKernel: number[];
  127593. /**
  127594. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  127595. */
  127596. static GaussianKernel: number[];
  127597. }
  127598. }
  127599. declare module BABYLON {
  127600. /**
  127601. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  127602. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  127603. * based on samples that have a large difference in distance than the center pixel.
  127604. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  127605. */
  127606. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  127607. direction: Vector2;
  127608. /**
  127609. * Creates a new instance CircleOfConfusionPostProcess
  127610. * @param name The name of the effect.
  127611. * @param scene The scene the effect belongs to.
  127612. * @param direction The direction the blur should be applied.
  127613. * @param kernel The size of the kernel used to blur.
  127614. * @param options The required width/height ratio to downsize to before computing the render pass.
  127615. * @param camera The camera to apply the render pass to.
  127616. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  127617. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  127618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127619. * @param engine The engine which the post process will be applied. (default: current engine)
  127620. * @param reusable If the post process can be reused on the same frame. (default: false)
  127621. * @param textureType Type of textures used when performing the post process. (default: 0)
  127622. * @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)
  127623. */
  127624. 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);
  127625. }
  127626. }
  127627. declare module BABYLON {
  127628. /** @hidden */
  127629. export var depthOfFieldMergePixelShader: {
  127630. name: string;
  127631. shader: string;
  127632. };
  127633. }
  127634. declare module BABYLON {
  127635. /**
  127636. * Options to be set when merging outputs from the default pipeline.
  127637. */
  127638. export class DepthOfFieldMergePostProcessOptions {
  127639. /**
  127640. * The original image to merge on top of
  127641. */
  127642. originalFromInput: PostProcess;
  127643. /**
  127644. * Parameters to perform the merge of the depth of field effect
  127645. */
  127646. depthOfField?: {
  127647. circleOfConfusion: PostProcess;
  127648. blurSteps: Array<PostProcess>;
  127649. };
  127650. /**
  127651. * Parameters to perform the merge of bloom effect
  127652. */
  127653. bloom?: {
  127654. blurred: PostProcess;
  127655. weight: number;
  127656. };
  127657. }
  127658. /**
  127659. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  127660. */
  127661. export class DepthOfFieldMergePostProcess extends PostProcess {
  127662. private blurSteps;
  127663. /**
  127664. * Creates a new instance of DepthOfFieldMergePostProcess
  127665. * @param name The name of the effect.
  127666. * @param originalFromInput Post process which's input will be used for the merge.
  127667. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  127668. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  127669. * @param options The required width/height ratio to downsize to before computing the render pass.
  127670. * @param camera The camera to apply the render pass to.
  127671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127672. * @param engine The engine which the post process will be applied. (default: current engine)
  127673. * @param reusable If the post process can be reused on the same frame. (default: false)
  127674. * @param textureType Type of textures used when performing the post process. (default: 0)
  127675. * @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)
  127676. */
  127677. 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);
  127678. /**
  127679. * Updates the effect with the current post process compile time values and recompiles the shader.
  127680. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  127681. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  127682. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  127683. * @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
  127684. * @param onCompiled Called when the shader has been compiled.
  127685. * @param onError Called if there is an error when compiling a shader.
  127686. */
  127687. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  127688. }
  127689. }
  127690. declare module BABYLON {
  127691. /**
  127692. * Specifies the level of max blur that should be applied when using the depth of field effect
  127693. */
  127694. export enum DepthOfFieldEffectBlurLevel {
  127695. /**
  127696. * Subtle blur
  127697. */
  127698. Low = 0,
  127699. /**
  127700. * Medium blur
  127701. */
  127702. Medium = 1,
  127703. /**
  127704. * Large blur
  127705. */
  127706. High = 2
  127707. }
  127708. /**
  127709. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  127710. */
  127711. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  127712. private _circleOfConfusion;
  127713. /**
  127714. * @hidden Internal, blurs from high to low
  127715. */
  127716. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  127717. private _depthOfFieldBlurY;
  127718. private _dofMerge;
  127719. /**
  127720. * @hidden Internal post processes in depth of field effect
  127721. */
  127722. _effects: Array<PostProcess>;
  127723. /**
  127724. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  127725. */
  127726. focalLength: number;
  127727. /**
  127728. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  127729. */
  127730. fStop: number;
  127731. /**
  127732. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  127733. */
  127734. focusDistance: number;
  127735. /**
  127736. * 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.
  127737. */
  127738. lensSize: number;
  127739. /**
  127740. * Creates a new instance DepthOfFieldEffect
  127741. * @param scene The scene the effect belongs to.
  127742. * @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.
  127743. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  127744. * @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)
  127745. */
  127746. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  127747. /**
  127748. * Get the current class name of the current effet
  127749. * @returns "DepthOfFieldEffect"
  127750. */
  127751. getClassName(): string;
  127752. /**
  127753. * 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.
  127754. */
  127755. depthTexture: RenderTargetTexture;
  127756. /**
  127757. * Disposes each of the internal effects for a given camera.
  127758. * @param camera The camera to dispose the effect on.
  127759. */
  127760. disposeEffects(camera: Camera): void;
  127761. /**
  127762. * @hidden Internal
  127763. */
  127764. _updateEffects(): void;
  127765. /**
  127766. * Internal
  127767. * @returns if all the contained post processes are ready.
  127768. * @hidden
  127769. */
  127770. _isReady(): boolean;
  127771. }
  127772. }
  127773. declare module BABYLON {
  127774. /** @hidden */
  127775. export var displayPassPixelShader: {
  127776. name: string;
  127777. shader: string;
  127778. };
  127779. }
  127780. declare module BABYLON {
  127781. /**
  127782. * DisplayPassPostProcess which produces an output the same as it's input
  127783. */
  127784. export class DisplayPassPostProcess extends PostProcess {
  127785. /**
  127786. * Creates the DisplayPassPostProcess
  127787. * @param name The name of the effect.
  127788. * @param options The required width/height ratio to downsize to before computing the render pass.
  127789. * @param camera The camera to apply the render pass to.
  127790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127791. * @param engine The engine which the post process will be applied. (default: current engine)
  127792. * @param reusable If the post process can be reused on the same frame. (default: false)
  127793. */
  127794. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127795. }
  127796. }
  127797. declare module BABYLON {
  127798. /** @hidden */
  127799. export var filterPixelShader: {
  127800. name: string;
  127801. shader: string;
  127802. };
  127803. }
  127804. declare module BABYLON {
  127805. /**
  127806. * Applies a kernel filter to the image
  127807. */
  127808. export class FilterPostProcess extends PostProcess {
  127809. /** The matrix to be applied to the image */
  127810. kernelMatrix: Matrix;
  127811. /**
  127812. *
  127813. * @param name The name of the effect.
  127814. * @param kernelMatrix The matrix to be applied to the image
  127815. * @param options The required width/height ratio to downsize to before computing the render pass.
  127816. * @param camera The camera to apply the render pass to.
  127817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127818. * @param engine The engine which the post process will be applied. (default: current engine)
  127819. * @param reusable If the post process can be reused on the same frame. (default: false)
  127820. */
  127821. constructor(name: string,
  127822. /** The matrix to be applied to the image */
  127823. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  127824. }
  127825. }
  127826. declare module BABYLON {
  127827. /** @hidden */
  127828. export var fxaaPixelShader: {
  127829. name: string;
  127830. shader: string;
  127831. };
  127832. }
  127833. declare module BABYLON {
  127834. /** @hidden */
  127835. export var fxaaVertexShader: {
  127836. name: string;
  127837. shader: string;
  127838. };
  127839. }
  127840. declare module BABYLON {
  127841. /**
  127842. * Fxaa post process
  127843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  127844. */
  127845. export class FxaaPostProcess extends PostProcess {
  127846. /** @hidden */
  127847. texelWidth: number;
  127848. /** @hidden */
  127849. texelHeight: number;
  127850. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127851. private _getDefines;
  127852. }
  127853. }
  127854. declare module BABYLON {
  127855. /** @hidden */
  127856. export var grainPixelShader: {
  127857. name: string;
  127858. shader: string;
  127859. };
  127860. }
  127861. declare module BABYLON {
  127862. /**
  127863. * The GrainPostProcess adds noise to the image at mid luminance levels
  127864. */
  127865. export class GrainPostProcess extends PostProcess {
  127866. /**
  127867. * The intensity of the grain added (default: 30)
  127868. */
  127869. intensity: number;
  127870. /**
  127871. * If the grain should be randomized on every frame
  127872. */
  127873. animated: boolean;
  127874. /**
  127875. * Creates a new instance of @see GrainPostProcess
  127876. * @param name The name of the effect.
  127877. * @param options The required width/height ratio to downsize to before computing the render pass.
  127878. * @param camera The camera to apply the render pass to.
  127879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127880. * @param engine The engine which the post process will be applied. (default: current engine)
  127881. * @param reusable If the post process can be reused on the same frame. (default: false)
  127882. * @param textureType Type of textures used when performing the post process. (default: 0)
  127883. * @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)
  127884. */
  127885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  127886. }
  127887. }
  127888. declare module BABYLON {
  127889. /** @hidden */
  127890. export var highlightsPixelShader: {
  127891. name: string;
  127892. shader: string;
  127893. };
  127894. }
  127895. declare module BABYLON {
  127896. /**
  127897. * Extracts highlights from the image
  127898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127899. */
  127900. export class HighlightsPostProcess extends PostProcess {
  127901. /**
  127902. * Extracts highlights from the image
  127903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  127904. * @param name The name of the effect.
  127905. * @param options The required width/height ratio to downsize to before computing the render pass.
  127906. * @param camera The camera to apply the render pass to.
  127907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  127908. * @param engine The engine which the post process will be applied. (default: current engine)
  127909. * @param reusable If the post process can be reused on the same frame. (default: false)
  127910. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  127911. */
  127912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  127913. }
  127914. }
  127915. declare module BABYLON {
  127916. /** @hidden */
  127917. export var mrtFragmentDeclaration: {
  127918. name: string;
  127919. shader: string;
  127920. };
  127921. }
  127922. declare module BABYLON {
  127923. /** @hidden */
  127924. export var geometryPixelShader: {
  127925. name: string;
  127926. shader: string;
  127927. };
  127928. }
  127929. declare module BABYLON {
  127930. /** @hidden */
  127931. export var geometryVertexShader: {
  127932. name: string;
  127933. shader: string;
  127934. };
  127935. }
  127936. declare module BABYLON {
  127937. /** @hidden */
  127938. interface ISavedTransformationMatrix {
  127939. world: Matrix;
  127940. viewProjection: Matrix;
  127941. }
  127942. /**
  127943. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127944. */
  127945. export class GeometryBufferRenderer {
  127946. /**
  127947. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127948. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127949. */
  127950. static readonly POSITION_TEXTURE_TYPE: number;
  127951. /**
  127952. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127953. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127954. */
  127955. static readonly VELOCITY_TEXTURE_TYPE: number;
  127956. /**
  127957. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127958. * in order to compute objects velocities when enableVelocity is set to "true"
  127959. * @hidden
  127960. */
  127961. _previousTransformationMatrices: {
  127962. [index: number]: ISavedTransformationMatrix;
  127963. };
  127964. /**
  127965. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  127966. * in order to compute objects velocities when enableVelocity is set to "true"
  127967. * @hidden
  127968. */
  127969. _previousBonesTransformationMatrices: {
  127970. [index: number]: Float32Array;
  127971. };
  127972. /**
  127973. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  127974. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  127975. */
  127976. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  127977. private _scene;
  127978. private _multiRenderTarget;
  127979. private _ratio;
  127980. private _enablePosition;
  127981. private _enableVelocity;
  127982. private _positionIndex;
  127983. private _velocityIndex;
  127984. protected _effect: Effect;
  127985. protected _cachedDefines: string;
  127986. /**
  127987. * Set the render list (meshes to be rendered) used in the G buffer.
  127988. */
  127989. renderList: Mesh[];
  127990. /**
  127991. * Gets wether or not G buffer are supported by the running hardware.
  127992. * This requires draw buffer supports
  127993. */
  127994. readonly isSupported: boolean;
  127995. /**
  127996. * Returns the index of the given texture type in the G-Buffer textures array
  127997. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127998. * @returns the index of the given texture type in the G-Buffer textures array
  127999. */
  128000. getTextureIndex(textureType: number): number;
  128001. /**
  128002. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  128003. */
  128004. /**
  128005. * Sets whether or not objects positions are enabled for the G buffer.
  128006. */
  128007. enablePosition: boolean;
  128008. /**
  128009. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  128010. */
  128011. /**
  128012. * Sets wether or not objects velocities are enabled for the G buffer.
  128013. */
  128014. enableVelocity: boolean;
  128015. /**
  128016. * Gets the scene associated with the buffer.
  128017. */
  128018. readonly scene: Scene;
  128019. /**
  128020. * Gets the ratio used by the buffer during its creation.
  128021. * How big is the buffer related to the main canvas.
  128022. */
  128023. readonly ratio: number;
  128024. /** @hidden */
  128025. static _SceneComponentInitialization: (scene: Scene) => void;
  128026. /**
  128027. * Creates a new G Buffer for the scene
  128028. * @param scene The scene the buffer belongs to
  128029. * @param ratio How big is the buffer related to the main canvas.
  128030. */
  128031. constructor(scene: Scene, ratio?: number);
  128032. /**
  128033. * Checks wether everything is ready to render a submesh to the G buffer.
  128034. * @param subMesh the submesh to check readiness for
  128035. * @param useInstances is the mesh drawn using instance or not
  128036. * @returns true if ready otherwise false
  128037. */
  128038. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128039. /**
  128040. * Gets the current underlying G Buffer.
  128041. * @returns the buffer
  128042. */
  128043. getGBuffer(): MultiRenderTarget;
  128044. /**
  128045. * Gets the number of samples used to render the buffer (anti aliasing).
  128046. */
  128047. /**
  128048. * Sets the number of samples used to render the buffer (anti aliasing).
  128049. */
  128050. samples: number;
  128051. /**
  128052. * Disposes the renderer and frees up associated resources.
  128053. */
  128054. dispose(): void;
  128055. protected _createRenderTargets(): void;
  128056. private _copyBonesTransformationMatrices;
  128057. }
  128058. }
  128059. declare module BABYLON {
  128060. interface Scene {
  128061. /** @hidden (Backing field) */
  128062. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128063. /**
  128064. * Gets or Sets the current geometry buffer associated to the scene.
  128065. */
  128066. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  128067. /**
  128068. * Enables a GeometryBufferRender and associates it with the scene
  128069. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  128070. * @returns the GeometryBufferRenderer
  128071. */
  128072. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  128073. /**
  128074. * Disables the GeometryBufferRender associated with the scene
  128075. */
  128076. disableGeometryBufferRenderer(): void;
  128077. }
  128078. /**
  128079. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  128080. * in several rendering techniques.
  128081. */
  128082. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  128083. /**
  128084. * The component name helpful to identify the component in the list of scene components.
  128085. */
  128086. readonly name: string;
  128087. /**
  128088. * The scene the component belongs to.
  128089. */
  128090. scene: Scene;
  128091. /**
  128092. * Creates a new instance of the component for the given scene
  128093. * @param scene Defines the scene to register the component in
  128094. */
  128095. constructor(scene: Scene);
  128096. /**
  128097. * Registers the component in a given scene
  128098. */
  128099. register(): void;
  128100. /**
  128101. * Rebuilds the elements related to this component in case of
  128102. * context lost for instance.
  128103. */
  128104. rebuild(): void;
  128105. /**
  128106. * Disposes the component and the associated ressources
  128107. */
  128108. dispose(): void;
  128109. private _gatherRenderTargets;
  128110. }
  128111. }
  128112. declare module BABYLON {
  128113. /** @hidden */
  128114. export var motionBlurPixelShader: {
  128115. name: string;
  128116. shader: string;
  128117. };
  128118. }
  128119. declare module BABYLON {
  128120. /**
  128121. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  128122. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  128123. * As an example, all you have to do is to create the post-process:
  128124. * var mb = new BABYLON.MotionBlurPostProcess(
  128125. * 'mb', // The name of the effect.
  128126. * scene, // The scene containing the objects to blur according to their velocity.
  128127. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  128128. * camera // The camera to apply the render pass to.
  128129. * );
  128130. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  128131. */
  128132. export class MotionBlurPostProcess extends PostProcess {
  128133. /**
  128134. * Defines how much the image is blurred by the movement. Default value is equal to 1
  128135. */
  128136. motionStrength: number;
  128137. /**
  128138. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  128139. */
  128140. /**
  128141. * Sets the number of iterations to be used for motion blur quality
  128142. */
  128143. motionBlurSamples: number;
  128144. private _motionBlurSamples;
  128145. private _geometryBufferRenderer;
  128146. /**
  128147. * Creates a new instance MotionBlurPostProcess
  128148. * @param name The name of the effect.
  128149. * @param scene The scene containing the objects to blur according to their velocity.
  128150. * @param options The required width/height ratio to downsize to before computing the render pass.
  128151. * @param camera The camera to apply the render pass to.
  128152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128153. * @param engine The engine which the post process will be applied. (default: current engine)
  128154. * @param reusable If the post process can be reused on the same frame. (default: false)
  128155. * @param textureType Type of textures used when performing the post process. (default: 0)
  128156. * @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)
  128157. */
  128158. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128159. /**
  128160. * Excludes the given skinned mesh from computing bones velocities.
  128161. * 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.
  128162. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  128163. */
  128164. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128165. /**
  128166. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  128167. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  128168. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  128169. */
  128170. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  128171. /**
  128172. * Disposes the post process.
  128173. * @param camera The camera to dispose the post process on.
  128174. */
  128175. dispose(camera?: Camera): void;
  128176. }
  128177. }
  128178. declare module BABYLON {
  128179. /** @hidden */
  128180. export var refractionPixelShader: {
  128181. name: string;
  128182. shader: string;
  128183. };
  128184. }
  128185. declare module BABYLON {
  128186. /**
  128187. * Post process which applies a refractin texture
  128188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128189. */
  128190. export class RefractionPostProcess extends PostProcess {
  128191. /** the base color of the refraction (used to taint the rendering) */
  128192. color: Color3;
  128193. /** simulated refraction depth */
  128194. depth: number;
  128195. /** the coefficient of the base color (0 to remove base color tainting) */
  128196. colorLevel: number;
  128197. private _refTexture;
  128198. private _ownRefractionTexture;
  128199. /**
  128200. * Gets or sets the refraction texture
  128201. * Please note that you are responsible for disposing the texture if you set it manually
  128202. */
  128203. refractionTexture: Texture;
  128204. /**
  128205. * Initializes the RefractionPostProcess
  128206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  128207. * @param name The name of the effect.
  128208. * @param refractionTextureUrl Url of the refraction texture to use
  128209. * @param color the base color of the refraction (used to taint the rendering)
  128210. * @param depth simulated refraction depth
  128211. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  128212. * @param camera The camera to apply the render pass to.
  128213. * @param options The required width/height ratio to downsize to before computing the render pass.
  128214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128215. * @param engine The engine which the post process will be applied. (default: current engine)
  128216. * @param reusable If the post process can be reused on the same frame. (default: false)
  128217. */
  128218. constructor(name: string, refractionTextureUrl: string,
  128219. /** the base color of the refraction (used to taint the rendering) */
  128220. color: Color3,
  128221. /** simulated refraction depth */
  128222. depth: number,
  128223. /** the coefficient of the base color (0 to remove base color tainting) */
  128224. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128225. /**
  128226. * Disposes of the post process
  128227. * @param camera Camera to dispose post process on
  128228. */
  128229. dispose(camera: Camera): void;
  128230. }
  128231. }
  128232. declare module BABYLON {
  128233. /** @hidden */
  128234. export var sharpenPixelShader: {
  128235. name: string;
  128236. shader: string;
  128237. };
  128238. }
  128239. declare module BABYLON {
  128240. /**
  128241. * The SharpenPostProcess applies a sharpen kernel to every pixel
  128242. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128243. */
  128244. export class SharpenPostProcess extends PostProcess {
  128245. /**
  128246. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  128247. */
  128248. colorAmount: number;
  128249. /**
  128250. * How much sharpness should be applied (default: 0.3)
  128251. */
  128252. edgeAmount: number;
  128253. /**
  128254. * Creates a new instance ConvolutionPostProcess
  128255. * @param name The name of the effect.
  128256. * @param options The required width/height ratio to downsize to before computing the render pass.
  128257. * @param camera The camera to apply the render pass to.
  128258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128259. * @param engine The engine which the post process will be applied. (default: current engine)
  128260. * @param reusable If the post process can be reused on the same frame. (default: false)
  128261. * @param textureType Type of textures used when performing the post process. (default: 0)
  128262. * @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)
  128263. */
  128264. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128265. }
  128266. }
  128267. declare module BABYLON {
  128268. /**
  128269. * PostProcessRenderPipeline
  128270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128271. */
  128272. export class PostProcessRenderPipeline {
  128273. private engine;
  128274. private _renderEffects;
  128275. private _renderEffectsForIsolatedPass;
  128276. /**
  128277. * List of inspectable custom properties (used by the Inspector)
  128278. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  128279. */
  128280. inspectableCustomProperties: IInspectable[];
  128281. /**
  128282. * @hidden
  128283. */
  128284. protected _cameras: Camera[];
  128285. /** @hidden */
  128286. _name: string;
  128287. /**
  128288. * Gets pipeline name
  128289. */
  128290. readonly name: string;
  128291. /**
  128292. * Initializes a PostProcessRenderPipeline
  128293. * @param engine engine to add the pipeline to
  128294. * @param name name of the pipeline
  128295. */
  128296. constructor(engine: Engine, name: string);
  128297. /**
  128298. * Gets the class name
  128299. * @returns "PostProcessRenderPipeline"
  128300. */
  128301. getClassName(): string;
  128302. /**
  128303. * If all the render effects in the pipeline are supported
  128304. */
  128305. readonly isSupported: boolean;
  128306. /**
  128307. * Adds an effect to the pipeline
  128308. * @param renderEffect the effect to add
  128309. */
  128310. addEffect(renderEffect: PostProcessRenderEffect): void;
  128311. /** @hidden */
  128312. _rebuild(): void;
  128313. /** @hidden */
  128314. _enableEffect(renderEffectName: string, cameras: Camera): void;
  128315. /** @hidden */
  128316. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  128317. /** @hidden */
  128318. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  128319. /** @hidden */
  128320. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  128321. /** @hidden */
  128322. _attachCameras(cameras: Camera, unique: boolean): void;
  128323. /** @hidden */
  128324. _attachCameras(cameras: Camera[], unique: boolean): void;
  128325. /** @hidden */
  128326. _detachCameras(cameras: Camera): void;
  128327. /** @hidden */
  128328. _detachCameras(cameras: Nullable<Camera[]>): void;
  128329. /** @hidden */
  128330. _update(): void;
  128331. /** @hidden */
  128332. _reset(): void;
  128333. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  128334. /**
  128335. * Disposes of the pipeline
  128336. */
  128337. dispose(): void;
  128338. }
  128339. }
  128340. declare module BABYLON {
  128341. /**
  128342. * PostProcessRenderPipelineManager class
  128343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128344. */
  128345. export class PostProcessRenderPipelineManager {
  128346. private _renderPipelines;
  128347. /**
  128348. * Initializes a PostProcessRenderPipelineManager
  128349. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128350. */
  128351. constructor();
  128352. /**
  128353. * Gets the list of supported render pipelines
  128354. */
  128355. readonly supportedPipelines: PostProcessRenderPipeline[];
  128356. /**
  128357. * Adds a pipeline to the manager
  128358. * @param renderPipeline The pipeline to add
  128359. */
  128360. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  128361. /**
  128362. * Attaches a camera to the pipeline
  128363. * @param renderPipelineName The name of the pipeline to attach to
  128364. * @param cameras the camera to attach
  128365. * @param unique if the camera can be attached multiple times to the pipeline
  128366. */
  128367. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  128368. /**
  128369. * Detaches a camera from the pipeline
  128370. * @param renderPipelineName The name of the pipeline to detach from
  128371. * @param cameras the camera to detach
  128372. */
  128373. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  128374. /**
  128375. * Enables an effect by name on a pipeline
  128376. * @param renderPipelineName the name of the pipeline to enable the effect in
  128377. * @param renderEffectName the name of the effect to enable
  128378. * @param cameras the cameras that the effect should be enabled on
  128379. */
  128380. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128381. /**
  128382. * Disables an effect by name on a pipeline
  128383. * @param renderPipelineName the name of the pipeline to disable the effect in
  128384. * @param renderEffectName the name of the effect to disable
  128385. * @param cameras the cameras that the effect should be disabled on
  128386. */
  128387. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  128388. /**
  128389. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  128390. */
  128391. update(): void;
  128392. /** @hidden */
  128393. _rebuild(): void;
  128394. /**
  128395. * Disposes of the manager and pipelines
  128396. */
  128397. dispose(): void;
  128398. }
  128399. }
  128400. declare module BABYLON {
  128401. interface Scene {
  128402. /** @hidden (Backing field) */
  128403. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128404. /**
  128405. * Gets the postprocess render pipeline manager
  128406. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128407. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128408. */
  128409. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  128410. }
  128411. /**
  128412. * Defines the Render Pipeline scene component responsible to rendering pipelines
  128413. */
  128414. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  128415. /**
  128416. * The component name helpfull to identify the component in the list of scene components.
  128417. */
  128418. readonly name: string;
  128419. /**
  128420. * The scene the component belongs to.
  128421. */
  128422. scene: Scene;
  128423. /**
  128424. * Creates a new instance of the component for the given scene
  128425. * @param scene Defines the scene to register the component in
  128426. */
  128427. constructor(scene: Scene);
  128428. /**
  128429. * Registers the component in a given scene
  128430. */
  128431. register(): void;
  128432. /**
  128433. * Rebuilds the elements related to this component in case of
  128434. * context lost for instance.
  128435. */
  128436. rebuild(): void;
  128437. /**
  128438. * Disposes the component and the associated ressources
  128439. */
  128440. dispose(): void;
  128441. private _gatherRenderTargets;
  128442. }
  128443. }
  128444. declare module BABYLON {
  128445. /**
  128446. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  128447. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  128448. */
  128449. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  128450. private _scene;
  128451. private _camerasToBeAttached;
  128452. /**
  128453. * ID of the sharpen post process,
  128454. */
  128455. private readonly SharpenPostProcessId;
  128456. /**
  128457. * @ignore
  128458. * ID of the image processing post process;
  128459. */
  128460. readonly ImageProcessingPostProcessId: string;
  128461. /**
  128462. * @ignore
  128463. * ID of the Fast Approximate Anti-Aliasing post process;
  128464. */
  128465. readonly FxaaPostProcessId: string;
  128466. /**
  128467. * ID of the chromatic aberration post process,
  128468. */
  128469. private readonly ChromaticAberrationPostProcessId;
  128470. /**
  128471. * ID of the grain post process
  128472. */
  128473. private readonly GrainPostProcessId;
  128474. /**
  128475. * Sharpen post process which will apply a sharpen convolution to enhance edges
  128476. */
  128477. sharpen: SharpenPostProcess;
  128478. private _sharpenEffect;
  128479. private bloom;
  128480. /**
  128481. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  128482. */
  128483. depthOfField: DepthOfFieldEffect;
  128484. /**
  128485. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  128486. */
  128487. fxaa: FxaaPostProcess;
  128488. /**
  128489. * Image post processing pass used to perform operations such as tone mapping or color grading.
  128490. */
  128491. imageProcessing: ImageProcessingPostProcess;
  128492. /**
  128493. * Chromatic aberration post process which will shift rgb colors in the image
  128494. */
  128495. chromaticAberration: ChromaticAberrationPostProcess;
  128496. private _chromaticAberrationEffect;
  128497. /**
  128498. * Grain post process which add noise to the image
  128499. */
  128500. grain: GrainPostProcess;
  128501. private _grainEffect;
  128502. /**
  128503. * Glow post process which adds a glow to emissive areas of the image
  128504. */
  128505. private _glowLayer;
  128506. /**
  128507. * Animations which can be used to tweak settings over a period of time
  128508. */
  128509. animations: Animation[];
  128510. private _imageProcessingConfigurationObserver;
  128511. private _sharpenEnabled;
  128512. private _bloomEnabled;
  128513. private _depthOfFieldEnabled;
  128514. private _depthOfFieldBlurLevel;
  128515. private _fxaaEnabled;
  128516. private _imageProcessingEnabled;
  128517. private _defaultPipelineTextureType;
  128518. private _bloomScale;
  128519. private _chromaticAberrationEnabled;
  128520. private _grainEnabled;
  128521. private _buildAllowed;
  128522. /**
  128523. * Gets active scene
  128524. */
  128525. readonly scene: Scene;
  128526. /**
  128527. * Enable or disable the sharpen process from the pipeline
  128528. */
  128529. sharpenEnabled: boolean;
  128530. private _resizeObserver;
  128531. private _hardwareScaleLevel;
  128532. private _bloomKernel;
  128533. /**
  128534. * Specifies the size of the bloom blur kernel, relative to the final output size
  128535. */
  128536. bloomKernel: number;
  128537. /**
  128538. * Specifies the weight of the bloom in the final rendering
  128539. */
  128540. private _bloomWeight;
  128541. /**
  128542. * Specifies the luma threshold for the area that will be blurred by the bloom
  128543. */
  128544. private _bloomThreshold;
  128545. private _hdr;
  128546. /**
  128547. * The strength of the bloom.
  128548. */
  128549. bloomWeight: number;
  128550. /**
  128551. * The strength of the bloom.
  128552. */
  128553. bloomThreshold: number;
  128554. /**
  128555. * The scale of the bloom, lower value will provide better performance.
  128556. */
  128557. bloomScale: number;
  128558. /**
  128559. * Enable or disable the bloom from the pipeline
  128560. */
  128561. bloomEnabled: boolean;
  128562. private _rebuildBloom;
  128563. /**
  128564. * If the depth of field is enabled.
  128565. */
  128566. depthOfFieldEnabled: boolean;
  128567. /**
  128568. * Blur level of the depth of field effect. (Higher blur will effect performance)
  128569. */
  128570. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  128571. /**
  128572. * If the anti aliasing is enabled.
  128573. */
  128574. fxaaEnabled: boolean;
  128575. private _samples;
  128576. /**
  128577. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  128578. */
  128579. samples: number;
  128580. /**
  128581. * If image processing is enabled.
  128582. */
  128583. imageProcessingEnabled: boolean;
  128584. /**
  128585. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  128586. */
  128587. glowLayerEnabled: boolean;
  128588. /**
  128589. * Gets the glow layer (or null if not defined)
  128590. */
  128591. readonly glowLayer: Nullable<GlowLayer>;
  128592. /**
  128593. * Enable or disable the chromaticAberration process from the pipeline
  128594. */
  128595. chromaticAberrationEnabled: boolean;
  128596. /**
  128597. * Enable or disable the grain process from the pipeline
  128598. */
  128599. grainEnabled: boolean;
  128600. /**
  128601. * @constructor
  128602. * @param name - The rendering pipeline name (default: "")
  128603. * @param hdr - If high dynamic range textures should be used (default: true)
  128604. * @param scene - The scene linked to this pipeline (default: the last created scene)
  128605. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  128606. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  128607. */
  128608. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  128609. /**
  128610. * Get the class name
  128611. * @returns "DefaultRenderingPipeline"
  128612. */
  128613. getClassName(): string;
  128614. /**
  128615. * Force the compilation of the entire pipeline.
  128616. */
  128617. prepare(): void;
  128618. private _hasCleared;
  128619. private _prevPostProcess;
  128620. private _prevPrevPostProcess;
  128621. private _setAutoClearAndTextureSharing;
  128622. private _depthOfFieldSceneObserver;
  128623. private _buildPipeline;
  128624. private _disposePostProcesses;
  128625. /**
  128626. * Adds a camera to the pipeline
  128627. * @param camera the camera to be added
  128628. */
  128629. addCamera(camera: Camera): void;
  128630. /**
  128631. * Removes a camera from the pipeline
  128632. * @param camera the camera to remove
  128633. */
  128634. removeCamera(camera: Camera): void;
  128635. /**
  128636. * Dispose of the pipeline and stop all post processes
  128637. */
  128638. dispose(): void;
  128639. /**
  128640. * Serialize the rendering pipeline (Used when exporting)
  128641. * @returns the serialized object
  128642. */
  128643. serialize(): any;
  128644. /**
  128645. * Parse the serialized pipeline
  128646. * @param source Source pipeline.
  128647. * @param scene The scene to load the pipeline to.
  128648. * @param rootUrl The URL of the serialized pipeline.
  128649. * @returns An instantiated pipeline from the serialized object.
  128650. */
  128651. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  128652. }
  128653. }
  128654. declare module BABYLON {
  128655. /** @hidden */
  128656. export var lensHighlightsPixelShader: {
  128657. name: string;
  128658. shader: string;
  128659. };
  128660. }
  128661. declare module BABYLON {
  128662. /** @hidden */
  128663. export var depthOfFieldPixelShader: {
  128664. name: string;
  128665. shader: string;
  128666. };
  128667. }
  128668. declare module BABYLON {
  128669. /**
  128670. * BABYLON.JS Chromatic Aberration GLSL Shader
  128671. * Author: Olivier Guyot
  128672. * Separates very slightly R, G and B colors on the edges of the screen
  128673. * Inspired by Francois Tarlier & Martins Upitis
  128674. */
  128675. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  128676. /**
  128677. * @ignore
  128678. * The chromatic aberration PostProcess id in the pipeline
  128679. */
  128680. LensChromaticAberrationEffect: string;
  128681. /**
  128682. * @ignore
  128683. * The highlights enhancing PostProcess id in the pipeline
  128684. */
  128685. HighlightsEnhancingEffect: string;
  128686. /**
  128687. * @ignore
  128688. * The depth-of-field PostProcess id in the pipeline
  128689. */
  128690. LensDepthOfFieldEffect: string;
  128691. private _scene;
  128692. private _depthTexture;
  128693. private _grainTexture;
  128694. private _chromaticAberrationPostProcess;
  128695. private _highlightsPostProcess;
  128696. private _depthOfFieldPostProcess;
  128697. private _edgeBlur;
  128698. private _grainAmount;
  128699. private _chromaticAberration;
  128700. private _distortion;
  128701. private _highlightsGain;
  128702. private _highlightsThreshold;
  128703. private _dofDistance;
  128704. private _dofAperture;
  128705. private _dofDarken;
  128706. private _dofPentagon;
  128707. private _blurNoise;
  128708. /**
  128709. * @constructor
  128710. *
  128711. * Effect parameters are as follow:
  128712. * {
  128713. * chromatic_aberration: number; // from 0 to x (1 for realism)
  128714. * edge_blur: number; // from 0 to x (1 for realism)
  128715. * distortion: number; // from 0 to x (1 for realism)
  128716. * grain_amount: number; // from 0 to 1
  128717. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  128718. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  128719. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  128720. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  128721. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  128722. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  128723. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  128724. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  128725. * }
  128726. * Note: if an effect parameter is unset, effect is disabled
  128727. *
  128728. * @param name The rendering pipeline name
  128729. * @param parameters - An object containing all parameters (see above)
  128730. * @param scene The scene linked to this pipeline
  128731. * @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)
  128732. * @param cameras The array of cameras that the rendering pipeline will be attached to
  128733. */
  128734. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  128735. /**
  128736. * Get the class name
  128737. * @returns "LensRenderingPipeline"
  128738. */
  128739. getClassName(): string;
  128740. /**
  128741. * Gets associated scene
  128742. */
  128743. readonly scene: Scene;
  128744. /**
  128745. * Gets or sets the edge blur
  128746. */
  128747. edgeBlur: number;
  128748. /**
  128749. * Gets or sets the grain amount
  128750. */
  128751. grainAmount: number;
  128752. /**
  128753. * Gets or sets the chromatic aberration amount
  128754. */
  128755. chromaticAberration: number;
  128756. /**
  128757. * Gets or sets the depth of field aperture
  128758. */
  128759. dofAperture: number;
  128760. /**
  128761. * Gets or sets the edge distortion
  128762. */
  128763. edgeDistortion: number;
  128764. /**
  128765. * Gets or sets the depth of field distortion
  128766. */
  128767. dofDistortion: number;
  128768. /**
  128769. * Gets or sets the darken out of focus amount
  128770. */
  128771. darkenOutOfFocus: number;
  128772. /**
  128773. * Gets or sets a boolean indicating if blur noise is enabled
  128774. */
  128775. blurNoise: boolean;
  128776. /**
  128777. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  128778. */
  128779. pentagonBokeh: boolean;
  128780. /**
  128781. * Gets or sets the highlight grain amount
  128782. */
  128783. highlightsGain: number;
  128784. /**
  128785. * Gets or sets the highlight threshold
  128786. */
  128787. highlightsThreshold: number;
  128788. /**
  128789. * Sets the amount of blur at the edges
  128790. * @param amount blur amount
  128791. */
  128792. setEdgeBlur(amount: number): void;
  128793. /**
  128794. * Sets edge blur to 0
  128795. */
  128796. disableEdgeBlur(): void;
  128797. /**
  128798. * Sets the amout of grain
  128799. * @param amount Amount of grain
  128800. */
  128801. setGrainAmount(amount: number): void;
  128802. /**
  128803. * Set grain amount to 0
  128804. */
  128805. disableGrain(): void;
  128806. /**
  128807. * Sets the chromatic aberration amount
  128808. * @param amount amount of chromatic aberration
  128809. */
  128810. setChromaticAberration(amount: number): void;
  128811. /**
  128812. * Sets chromatic aberration amount to 0
  128813. */
  128814. disableChromaticAberration(): void;
  128815. /**
  128816. * Sets the EdgeDistortion amount
  128817. * @param amount amount of EdgeDistortion
  128818. */
  128819. setEdgeDistortion(amount: number): void;
  128820. /**
  128821. * Sets edge distortion to 0
  128822. */
  128823. disableEdgeDistortion(): void;
  128824. /**
  128825. * Sets the FocusDistance amount
  128826. * @param amount amount of FocusDistance
  128827. */
  128828. setFocusDistance(amount: number): void;
  128829. /**
  128830. * Disables depth of field
  128831. */
  128832. disableDepthOfField(): void;
  128833. /**
  128834. * Sets the Aperture amount
  128835. * @param amount amount of Aperture
  128836. */
  128837. setAperture(amount: number): void;
  128838. /**
  128839. * Sets the DarkenOutOfFocus amount
  128840. * @param amount amount of DarkenOutOfFocus
  128841. */
  128842. setDarkenOutOfFocus(amount: number): void;
  128843. private _pentagonBokehIsEnabled;
  128844. /**
  128845. * Creates a pentagon bokeh effect
  128846. */
  128847. enablePentagonBokeh(): void;
  128848. /**
  128849. * Disables the pentagon bokeh effect
  128850. */
  128851. disablePentagonBokeh(): void;
  128852. /**
  128853. * Enables noise blur
  128854. */
  128855. enableNoiseBlur(): void;
  128856. /**
  128857. * Disables noise blur
  128858. */
  128859. disableNoiseBlur(): void;
  128860. /**
  128861. * Sets the HighlightsGain amount
  128862. * @param amount amount of HighlightsGain
  128863. */
  128864. setHighlightsGain(amount: number): void;
  128865. /**
  128866. * Sets the HighlightsThreshold amount
  128867. * @param amount amount of HighlightsThreshold
  128868. */
  128869. setHighlightsThreshold(amount: number): void;
  128870. /**
  128871. * Disables highlights
  128872. */
  128873. disableHighlights(): void;
  128874. /**
  128875. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  128876. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  128877. */
  128878. dispose(disableDepthRender?: boolean): void;
  128879. private _createChromaticAberrationPostProcess;
  128880. private _createHighlightsPostProcess;
  128881. private _createDepthOfFieldPostProcess;
  128882. private _createGrainTexture;
  128883. }
  128884. }
  128885. declare module BABYLON {
  128886. /** @hidden */
  128887. export var ssao2PixelShader: {
  128888. name: string;
  128889. shader: string;
  128890. };
  128891. }
  128892. declare module BABYLON {
  128893. /** @hidden */
  128894. export var ssaoCombinePixelShader: {
  128895. name: string;
  128896. shader: string;
  128897. };
  128898. }
  128899. declare module BABYLON {
  128900. /**
  128901. * Render pipeline to produce ssao effect
  128902. */
  128903. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  128904. /**
  128905. * @ignore
  128906. * The PassPostProcess id in the pipeline that contains the original scene color
  128907. */
  128908. SSAOOriginalSceneColorEffect: string;
  128909. /**
  128910. * @ignore
  128911. * The SSAO PostProcess id in the pipeline
  128912. */
  128913. SSAORenderEffect: string;
  128914. /**
  128915. * @ignore
  128916. * The horizontal blur PostProcess id in the pipeline
  128917. */
  128918. SSAOBlurHRenderEffect: string;
  128919. /**
  128920. * @ignore
  128921. * The vertical blur PostProcess id in the pipeline
  128922. */
  128923. SSAOBlurVRenderEffect: string;
  128924. /**
  128925. * @ignore
  128926. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  128927. */
  128928. SSAOCombineRenderEffect: string;
  128929. /**
  128930. * The output strength of the SSAO post-process. Default value is 1.0.
  128931. */
  128932. totalStrength: number;
  128933. /**
  128934. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  128935. */
  128936. maxZ: number;
  128937. /**
  128938. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  128939. */
  128940. minZAspect: number;
  128941. private _samples;
  128942. /**
  128943. * Number of samples used for the SSAO calculations. Default value is 8
  128944. */
  128945. samples: number;
  128946. private _textureSamples;
  128947. /**
  128948. * Number of samples to use for antialiasing
  128949. */
  128950. textureSamples: number;
  128951. /**
  128952. * Ratio object used for SSAO ratio and blur ratio
  128953. */
  128954. private _ratio;
  128955. /**
  128956. * Dynamically generated sphere sampler.
  128957. */
  128958. private _sampleSphere;
  128959. /**
  128960. * Blur filter offsets
  128961. */
  128962. private _samplerOffsets;
  128963. private _expensiveBlur;
  128964. /**
  128965. * If bilateral blur should be used
  128966. */
  128967. expensiveBlur: boolean;
  128968. /**
  128969. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  128970. */
  128971. radius: number;
  128972. /**
  128973. * The base color of the SSAO post-process
  128974. * The final result is "base + ssao" between [0, 1]
  128975. */
  128976. base: number;
  128977. /**
  128978. * Support test.
  128979. */
  128980. static readonly IsSupported: boolean;
  128981. private _scene;
  128982. private _depthTexture;
  128983. private _normalTexture;
  128984. private _randomTexture;
  128985. private _originalColorPostProcess;
  128986. private _ssaoPostProcess;
  128987. private _blurHPostProcess;
  128988. private _blurVPostProcess;
  128989. private _ssaoCombinePostProcess;
  128990. private _firstUpdate;
  128991. /**
  128992. * Gets active scene
  128993. */
  128994. readonly scene: Scene;
  128995. /**
  128996. * @constructor
  128997. * @param name The rendering pipeline name
  128998. * @param scene The scene linked to this pipeline
  128999. * @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 }
  129000. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129001. */
  129002. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129003. /**
  129004. * Get the class name
  129005. * @returns "SSAO2RenderingPipeline"
  129006. */
  129007. getClassName(): string;
  129008. /**
  129009. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129010. */
  129011. dispose(disableGeometryBufferRenderer?: boolean): void;
  129012. private _createBlurPostProcess;
  129013. /** @hidden */
  129014. _rebuild(): void;
  129015. private _bits;
  129016. private _radicalInverse_VdC;
  129017. private _hammersley;
  129018. private _hemisphereSample_uniform;
  129019. private _generateHemisphere;
  129020. private _createSSAOPostProcess;
  129021. private _createSSAOCombinePostProcess;
  129022. private _createRandomTexture;
  129023. /**
  129024. * Serialize the rendering pipeline (Used when exporting)
  129025. * @returns the serialized object
  129026. */
  129027. serialize(): any;
  129028. /**
  129029. * Parse the serialized pipeline
  129030. * @param source Source pipeline.
  129031. * @param scene The scene to load the pipeline to.
  129032. * @param rootUrl The URL of the serialized pipeline.
  129033. * @returns An instantiated pipeline from the serialized object.
  129034. */
  129035. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  129036. }
  129037. }
  129038. declare module BABYLON {
  129039. /** @hidden */
  129040. export var ssaoPixelShader: {
  129041. name: string;
  129042. shader: string;
  129043. };
  129044. }
  129045. declare module BABYLON {
  129046. /**
  129047. * Render pipeline to produce ssao effect
  129048. */
  129049. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  129050. /**
  129051. * @ignore
  129052. * The PassPostProcess id in the pipeline that contains the original scene color
  129053. */
  129054. SSAOOriginalSceneColorEffect: string;
  129055. /**
  129056. * @ignore
  129057. * The SSAO PostProcess id in the pipeline
  129058. */
  129059. SSAORenderEffect: string;
  129060. /**
  129061. * @ignore
  129062. * The horizontal blur PostProcess id in the pipeline
  129063. */
  129064. SSAOBlurHRenderEffect: string;
  129065. /**
  129066. * @ignore
  129067. * The vertical blur PostProcess id in the pipeline
  129068. */
  129069. SSAOBlurVRenderEffect: string;
  129070. /**
  129071. * @ignore
  129072. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  129073. */
  129074. SSAOCombineRenderEffect: string;
  129075. /**
  129076. * The output strength of the SSAO post-process. Default value is 1.0.
  129077. */
  129078. totalStrength: number;
  129079. /**
  129080. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  129081. */
  129082. radius: number;
  129083. /**
  129084. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  129085. * Must not be equal to fallOff and superior to fallOff.
  129086. * Default value is 0.0075
  129087. */
  129088. area: number;
  129089. /**
  129090. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  129091. * Must not be equal to area and inferior to area.
  129092. * Default value is 0.000001
  129093. */
  129094. fallOff: number;
  129095. /**
  129096. * The base color of the SSAO post-process
  129097. * The final result is "base + ssao" between [0, 1]
  129098. */
  129099. base: number;
  129100. private _scene;
  129101. private _depthTexture;
  129102. private _randomTexture;
  129103. private _originalColorPostProcess;
  129104. private _ssaoPostProcess;
  129105. private _blurHPostProcess;
  129106. private _blurVPostProcess;
  129107. private _ssaoCombinePostProcess;
  129108. private _firstUpdate;
  129109. /**
  129110. * Gets active scene
  129111. */
  129112. readonly scene: Scene;
  129113. /**
  129114. * @constructor
  129115. * @param name - The rendering pipeline name
  129116. * @param scene - The scene linked to this pipeline
  129117. * @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 }
  129118. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  129119. */
  129120. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  129121. /**
  129122. * Get the class name
  129123. * @returns "SSAORenderingPipeline"
  129124. */
  129125. getClassName(): string;
  129126. /**
  129127. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  129128. */
  129129. dispose(disableDepthRender?: boolean): void;
  129130. private _createBlurPostProcess;
  129131. /** @hidden */
  129132. _rebuild(): void;
  129133. private _createSSAOPostProcess;
  129134. private _createSSAOCombinePostProcess;
  129135. private _createRandomTexture;
  129136. }
  129137. }
  129138. declare module BABYLON {
  129139. /** @hidden */
  129140. export var standardPixelShader: {
  129141. name: string;
  129142. shader: string;
  129143. };
  129144. }
  129145. declare module BABYLON {
  129146. /**
  129147. * Standard rendering pipeline
  129148. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129149. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  129150. */
  129151. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129152. /**
  129153. * Public members
  129154. */
  129155. /**
  129156. * Post-process which contains the original scene color before the pipeline applies all the effects
  129157. */
  129158. originalPostProcess: Nullable<PostProcess>;
  129159. /**
  129160. * Post-process used to down scale an image x4
  129161. */
  129162. downSampleX4PostProcess: Nullable<PostProcess>;
  129163. /**
  129164. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  129165. */
  129166. brightPassPostProcess: Nullable<PostProcess>;
  129167. /**
  129168. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  129169. */
  129170. blurHPostProcesses: PostProcess[];
  129171. /**
  129172. * Post-process array storing all the vertical blur post-processes used by the pipeline
  129173. */
  129174. blurVPostProcesses: PostProcess[];
  129175. /**
  129176. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  129177. */
  129178. textureAdderPostProcess: Nullable<PostProcess>;
  129179. /**
  129180. * Post-process used to create volumetric lighting effect
  129181. */
  129182. volumetricLightPostProcess: Nullable<PostProcess>;
  129183. /**
  129184. * Post-process used to smooth the previous volumetric light post-process on the X axis
  129185. */
  129186. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  129187. /**
  129188. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  129189. */
  129190. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  129191. /**
  129192. * Post-process used to merge the volumetric light effect and the real scene color
  129193. */
  129194. volumetricLightMergePostProces: Nullable<PostProcess>;
  129195. /**
  129196. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  129197. */
  129198. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  129199. /**
  129200. * Base post-process used to calculate the average luminance of the final image for HDR
  129201. */
  129202. luminancePostProcess: Nullable<PostProcess>;
  129203. /**
  129204. * Post-processes used to create down sample post-processes in order to get
  129205. * the average luminance of the final image for HDR
  129206. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  129207. */
  129208. luminanceDownSamplePostProcesses: PostProcess[];
  129209. /**
  129210. * Post-process used to create a HDR effect (light adaptation)
  129211. */
  129212. hdrPostProcess: Nullable<PostProcess>;
  129213. /**
  129214. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  129215. */
  129216. textureAdderFinalPostProcess: Nullable<PostProcess>;
  129217. /**
  129218. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  129219. */
  129220. lensFlareFinalPostProcess: Nullable<PostProcess>;
  129221. /**
  129222. * Post-process used to merge the final HDR post-process and the real scene color
  129223. */
  129224. hdrFinalPostProcess: Nullable<PostProcess>;
  129225. /**
  129226. * Post-process used to create a lens flare effect
  129227. */
  129228. lensFlarePostProcess: Nullable<PostProcess>;
  129229. /**
  129230. * Post-process that merges the result of the lens flare post-process and the real scene color
  129231. */
  129232. lensFlareComposePostProcess: Nullable<PostProcess>;
  129233. /**
  129234. * Post-process used to create a motion blur effect
  129235. */
  129236. motionBlurPostProcess: Nullable<PostProcess>;
  129237. /**
  129238. * Post-process used to create a depth of field effect
  129239. */
  129240. depthOfFieldPostProcess: Nullable<PostProcess>;
  129241. /**
  129242. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129243. */
  129244. fxaaPostProcess: Nullable<FxaaPostProcess>;
  129245. /**
  129246. * Represents the brightness threshold in order to configure the illuminated surfaces
  129247. */
  129248. brightThreshold: number;
  129249. /**
  129250. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  129251. */
  129252. blurWidth: number;
  129253. /**
  129254. * Sets if the blur for highlighted surfaces must be only horizontal
  129255. */
  129256. horizontalBlur: boolean;
  129257. /**
  129258. * Gets the overall exposure used by the pipeline
  129259. */
  129260. /**
  129261. * Sets the overall exposure used by the pipeline
  129262. */
  129263. exposure: number;
  129264. /**
  129265. * Texture used typically to simulate "dirty" on camera lens
  129266. */
  129267. lensTexture: Nullable<Texture>;
  129268. /**
  129269. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  129270. */
  129271. volumetricLightCoefficient: number;
  129272. /**
  129273. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  129274. */
  129275. volumetricLightPower: number;
  129276. /**
  129277. * Used the set the blur intensity to smooth the volumetric lights
  129278. */
  129279. volumetricLightBlurScale: number;
  129280. /**
  129281. * Light (spot or directional) used to generate the volumetric lights rays
  129282. * The source light must have a shadow generate so the pipeline can get its
  129283. * depth map
  129284. */
  129285. sourceLight: Nullable<SpotLight | DirectionalLight>;
  129286. /**
  129287. * For eye adaptation, represents the minimum luminance the eye can see
  129288. */
  129289. hdrMinimumLuminance: number;
  129290. /**
  129291. * For eye adaptation, represents the decrease luminance speed
  129292. */
  129293. hdrDecreaseRate: number;
  129294. /**
  129295. * For eye adaptation, represents the increase luminance speed
  129296. */
  129297. hdrIncreaseRate: number;
  129298. /**
  129299. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129300. */
  129301. /**
  129302. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  129303. */
  129304. hdrAutoExposure: boolean;
  129305. /**
  129306. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  129307. */
  129308. lensColorTexture: Nullable<Texture>;
  129309. /**
  129310. * The overall strengh for the lens flare effect
  129311. */
  129312. lensFlareStrength: number;
  129313. /**
  129314. * Dispersion coefficient for lens flare ghosts
  129315. */
  129316. lensFlareGhostDispersal: number;
  129317. /**
  129318. * Main lens flare halo width
  129319. */
  129320. lensFlareHaloWidth: number;
  129321. /**
  129322. * Based on the lens distortion effect, defines how much the lens flare result
  129323. * is distorted
  129324. */
  129325. lensFlareDistortionStrength: number;
  129326. /**
  129327. * Configures the blur intensity used for for lens flare (halo)
  129328. */
  129329. lensFlareBlurWidth: number;
  129330. /**
  129331. * Lens star texture must be used to simulate rays on the flares and is available
  129332. * in the documentation
  129333. */
  129334. lensStarTexture: Nullable<Texture>;
  129335. /**
  129336. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  129337. * flare effect by taking account of the dirt texture
  129338. */
  129339. lensFlareDirtTexture: Nullable<Texture>;
  129340. /**
  129341. * Represents the focal length for the depth of field effect
  129342. */
  129343. depthOfFieldDistance: number;
  129344. /**
  129345. * Represents the blur intensity for the blurred part of the depth of field effect
  129346. */
  129347. depthOfFieldBlurWidth: number;
  129348. /**
  129349. * Gets how much the image is blurred by the movement while using the motion blur post-process
  129350. */
  129351. /**
  129352. * Sets how much the image is blurred by the movement while using the motion blur post-process
  129353. */
  129354. motionStrength: number;
  129355. /**
  129356. * Gets wether or not the motion blur post-process is object based or screen based.
  129357. */
  129358. /**
  129359. * Sets wether or not the motion blur post-process should be object based or screen based
  129360. */
  129361. objectBasedMotionBlur: boolean;
  129362. /**
  129363. * List of animations for the pipeline (IAnimatable implementation)
  129364. */
  129365. animations: Animation[];
  129366. /**
  129367. * Private members
  129368. */
  129369. private _scene;
  129370. private _currentDepthOfFieldSource;
  129371. private _basePostProcess;
  129372. private _fixedExposure;
  129373. private _currentExposure;
  129374. private _hdrAutoExposure;
  129375. private _hdrCurrentLuminance;
  129376. private _motionStrength;
  129377. private _isObjectBasedMotionBlur;
  129378. private _floatTextureType;
  129379. private _camerasToBeAttached;
  129380. private _ratio;
  129381. private _bloomEnabled;
  129382. private _depthOfFieldEnabled;
  129383. private _vlsEnabled;
  129384. private _lensFlareEnabled;
  129385. private _hdrEnabled;
  129386. private _motionBlurEnabled;
  129387. private _fxaaEnabled;
  129388. private _motionBlurSamples;
  129389. private _volumetricLightStepsCount;
  129390. private _samples;
  129391. /**
  129392. * @ignore
  129393. * Specifies if the bloom pipeline is enabled
  129394. */
  129395. BloomEnabled: boolean;
  129396. /**
  129397. * @ignore
  129398. * Specifies if the depth of field pipeline is enabed
  129399. */
  129400. DepthOfFieldEnabled: boolean;
  129401. /**
  129402. * @ignore
  129403. * Specifies if the lens flare pipeline is enabed
  129404. */
  129405. LensFlareEnabled: boolean;
  129406. /**
  129407. * @ignore
  129408. * Specifies if the HDR pipeline is enabled
  129409. */
  129410. HDREnabled: boolean;
  129411. /**
  129412. * @ignore
  129413. * Specifies if the volumetric lights scattering effect is enabled
  129414. */
  129415. VLSEnabled: boolean;
  129416. /**
  129417. * @ignore
  129418. * Specifies if the motion blur effect is enabled
  129419. */
  129420. MotionBlurEnabled: boolean;
  129421. /**
  129422. * Specifies if anti-aliasing is enabled
  129423. */
  129424. fxaaEnabled: boolean;
  129425. /**
  129426. * Specifies the number of steps used to calculate the volumetric lights
  129427. * Typically in interval [50, 200]
  129428. */
  129429. volumetricLightStepsCount: number;
  129430. /**
  129431. * Specifies the number of samples used for the motion blur effect
  129432. * Typically in interval [16, 64]
  129433. */
  129434. motionBlurSamples: number;
  129435. /**
  129436. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129437. */
  129438. samples: number;
  129439. /**
  129440. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  129441. * @constructor
  129442. * @param name The rendering pipeline name
  129443. * @param scene The scene linked to this pipeline
  129444. * @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)
  129445. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  129446. * @param cameras The array of cameras that the rendering pipeline will be attached to
  129447. */
  129448. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  129449. private _buildPipeline;
  129450. private _createDownSampleX4PostProcess;
  129451. private _createBrightPassPostProcess;
  129452. private _createBlurPostProcesses;
  129453. private _createTextureAdderPostProcess;
  129454. private _createVolumetricLightPostProcess;
  129455. private _createLuminancePostProcesses;
  129456. private _createHdrPostProcess;
  129457. private _createLensFlarePostProcess;
  129458. private _createDepthOfFieldPostProcess;
  129459. private _createMotionBlurPostProcess;
  129460. private _getDepthTexture;
  129461. private _disposePostProcesses;
  129462. /**
  129463. * Dispose of the pipeline and stop all post processes
  129464. */
  129465. dispose(): void;
  129466. /**
  129467. * Serialize the rendering pipeline (Used when exporting)
  129468. * @returns the serialized object
  129469. */
  129470. serialize(): any;
  129471. /**
  129472. * Parse the serialized pipeline
  129473. * @param source Source pipeline.
  129474. * @param scene The scene to load the pipeline to.
  129475. * @param rootUrl The URL of the serialized pipeline.
  129476. * @returns An instantiated pipeline from the serialized object.
  129477. */
  129478. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  129479. /**
  129480. * Luminance steps
  129481. */
  129482. static LuminanceSteps: number;
  129483. }
  129484. }
  129485. declare module BABYLON {
  129486. /** @hidden */
  129487. export var tonemapPixelShader: {
  129488. name: string;
  129489. shader: string;
  129490. };
  129491. }
  129492. declare module BABYLON {
  129493. /** Defines operator used for tonemapping */
  129494. export enum TonemappingOperator {
  129495. /** Hable */
  129496. Hable = 0,
  129497. /** Reinhard */
  129498. Reinhard = 1,
  129499. /** HejiDawson */
  129500. HejiDawson = 2,
  129501. /** Photographic */
  129502. Photographic = 3
  129503. }
  129504. /**
  129505. * Defines a post process to apply tone mapping
  129506. */
  129507. export class TonemapPostProcess extends PostProcess {
  129508. private _operator;
  129509. /** Defines the required exposure adjustement */
  129510. exposureAdjustment: number;
  129511. /**
  129512. * Creates a new TonemapPostProcess
  129513. * @param name defines the name of the postprocess
  129514. * @param _operator defines the operator to use
  129515. * @param exposureAdjustment defines the required exposure adjustement
  129516. * @param camera defines the camera to use (can be null)
  129517. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  129518. * @param engine defines the hosting engine (can be ignore if camera is set)
  129519. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129520. */
  129521. constructor(name: string, _operator: TonemappingOperator,
  129522. /** Defines the required exposure adjustement */
  129523. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  129524. }
  129525. }
  129526. declare module BABYLON {
  129527. /** @hidden */
  129528. export var depthVertexShader: {
  129529. name: string;
  129530. shader: string;
  129531. };
  129532. }
  129533. declare module BABYLON {
  129534. /** @hidden */
  129535. export var volumetricLightScatteringPixelShader: {
  129536. name: string;
  129537. shader: string;
  129538. };
  129539. }
  129540. declare module BABYLON {
  129541. /** @hidden */
  129542. export var volumetricLightScatteringPassVertexShader: {
  129543. name: string;
  129544. shader: string;
  129545. };
  129546. }
  129547. declare module BABYLON {
  129548. /** @hidden */
  129549. export var volumetricLightScatteringPassPixelShader: {
  129550. name: string;
  129551. shader: string;
  129552. };
  129553. }
  129554. declare module BABYLON {
  129555. /**
  129556. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  129557. */
  129558. export class VolumetricLightScatteringPostProcess extends PostProcess {
  129559. private _volumetricLightScatteringPass;
  129560. private _volumetricLightScatteringRTT;
  129561. private _viewPort;
  129562. private _screenCoordinates;
  129563. private _cachedDefines;
  129564. /**
  129565. * If not undefined, the mesh position is computed from the attached node position
  129566. */
  129567. attachedNode: {
  129568. position: Vector3;
  129569. };
  129570. /**
  129571. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  129572. */
  129573. customMeshPosition: Vector3;
  129574. /**
  129575. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  129576. */
  129577. useCustomMeshPosition: boolean;
  129578. /**
  129579. * If the post-process should inverse the light scattering direction
  129580. */
  129581. invert: boolean;
  129582. /**
  129583. * The internal mesh used by the post-process
  129584. */
  129585. mesh: Mesh;
  129586. /**
  129587. * @hidden
  129588. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  129589. */
  129590. useDiffuseColor: boolean;
  129591. /**
  129592. * Array containing the excluded meshes not rendered in the internal pass
  129593. */
  129594. excludedMeshes: AbstractMesh[];
  129595. /**
  129596. * Controls the overall intensity of the post-process
  129597. */
  129598. exposure: number;
  129599. /**
  129600. * Dissipates each sample's contribution in range [0, 1]
  129601. */
  129602. decay: number;
  129603. /**
  129604. * Controls the overall intensity of each sample
  129605. */
  129606. weight: number;
  129607. /**
  129608. * Controls the density of each sample
  129609. */
  129610. density: number;
  129611. /**
  129612. * @constructor
  129613. * @param name The post-process name
  129614. * @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)
  129615. * @param camera The camera that the post-process will be attached to
  129616. * @param mesh The mesh used to create the light scattering
  129617. * @param samples The post-process quality, default 100
  129618. * @param samplingModeThe post-process filtering mode
  129619. * @param engine The babylon engine
  129620. * @param reusable If the post-process is reusable
  129621. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  129622. */
  129623. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  129624. /**
  129625. * Returns the string "VolumetricLightScatteringPostProcess"
  129626. * @returns "VolumetricLightScatteringPostProcess"
  129627. */
  129628. getClassName(): string;
  129629. private _isReady;
  129630. /**
  129631. * Sets the new light position for light scattering effect
  129632. * @param position The new custom light position
  129633. */
  129634. setCustomMeshPosition(position: Vector3): void;
  129635. /**
  129636. * Returns the light position for light scattering effect
  129637. * @return Vector3 The custom light position
  129638. */
  129639. getCustomMeshPosition(): Vector3;
  129640. /**
  129641. * Disposes the internal assets and detaches the post-process from the camera
  129642. */
  129643. dispose(camera: Camera): void;
  129644. /**
  129645. * Returns the render target texture used by the post-process
  129646. * @return the render target texture used by the post-process
  129647. */
  129648. getPass(): RenderTargetTexture;
  129649. private _meshExcluded;
  129650. private _createPass;
  129651. private _updateMeshScreenCoordinates;
  129652. /**
  129653. * Creates a default mesh for the Volumeric Light Scattering post-process
  129654. * @param name The mesh name
  129655. * @param scene The scene where to create the mesh
  129656. * @return the default mesh
  129657. */
  129658. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  129659. }
  129660. }
  129661. declare module BABYLON {
  129662. interface Scene {
  129663. /** @hidden (Backing field) */
  129664. _boundingBoxRenderer: BoundingBoxRenderer;
  129665. /** @hidden (Backing field) */
  129666. _forceShowBoundingBoxes: boolean;
  129667. /**
  129668. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  129669. */
  129670. forceShowBoundingBoxes: boolean;
  129671. /**
  129672. * Gets the bounding box renderer associated with the scene
  129673. * @returns a BoundingBoxRenderer
  129674. */
  129675. getBoundingBoxRenderer(): BoundingBoxRenderer;
  129676. }
  129677. interface AbstractMesh {
  129678. /** @hidden (Backing field) */
  129679. _showBoundingBox: boolean;
  129680. /**
  129681. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  129682. */
  129683. showBoundingBox: boolean;
  129684. }
  129685. /**
  129686. * Component responsible of rendering the bounding box of the meshes in a scene.
  129687. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  129688. */
  129689. export class BoundingBoxRenderer implements ISceneComponent {
  129690. /**
  129691. * The component name helpfull to identify the component in the list of scene components.
  129692. */
  129693. readonly name: string;
  129694. /**
  129695. * The scene the component belongs to.
  129696. */
  129697. scene: Scene;
  129698. /**
  129699. * Color of the bounding box lines placed in front of an object
  129700. */
  129701. frontColor: Color3;
  129702. /**
  129703. * Color of the bounding box lines placed behind an object
  129704. */
  129705. backColor: Color3;
  129706. /**
  129707. * Defines if the renderer should show the back lines or not
  129708. */
  129709. showBackLines: boolean;
  129710. /**
  129711. * @hidden
  129712. */
  129713. renderList: SmartArray<BoundingBox>;
  129714. private _colorShader;
  129715. private _vertexBuffers;
  129716. private _indexBuffer;
  129717. private _fillIndexBuffer;
  129718. private _fillIndexData;
  129719. /**
  129720. * Instantiates a new bounding box renderer in a scene.
  129721. * @param scene the scene the renderer renders in
  129722. */
  129723. constructor(scene: Scene);
  129724. /**
  129725. * Registers the component in a given scene
  129726. */
  129727. register(): void;
  129728. private _evaluateSubMesh;
  129729. private _activeMesh;
  129730. private _prepareRessources;
  129731. private _createIndexBuffer;
  129732. /**
  129733. * Rebuilds the elements related to this component in case of
  129734. * context lost for instance.
  129735. */
  129736. rebuild(): void;
  129737. /**
  129738. * @hidden
  129739. */
  129740. reset(): void;
  129741. /**
  129742. * Render the bounding boxes of a specific rendering group
  129743. * @param renderingGroupId defines the rendering group to render
  129744. */
  129745. render(renderingGroupId: number): void;
  129746. /**
  129747. * In case of occlusion queries, we can render the occlusion bounding box through this method
  129748. * @param mesh Define the mesh to render the occlusion bounding box for
  129749. */
  129750. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  129751. /**
  129752. * Dispose and release the resources attached to this renderer.
  129753. */
  129754. dispose(): void;
  129755. }
  129756. }
  129757. declare module BABYLON {
  129758. /** @hidden */
  129759. export var depthPixelShader: {
  129760. name: string;
  129761. shader: string;
  129762. };
  129763. }
  129764. declare module BABYLON {
  129765. /**
  129766. * This represents a depth renderer in Babylon.
  129767. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  129768. */
  129769. export class DepthRenderer {
  129770. private _scene;
  129771. private _depthMap;
  129772. private _effect;
  129773. private readonly _storeNonLinearDepth;
  129774. private readonly _clearColor;
  129775. /** Get if the depth renderer is using packed depth or not */
  129776. readonly isPacked: boolean;
  129777. private _cachedDefines;
  129778. private _camera;
  129779. /**
  129780. * Specifiess that the depth renderer will only be used within
  129781. * the camera it is created for.
  129782. * This can help forcing its rendering during the camera processing.
  129783. */
  129784. useOnlyInActiveCamera: boolean;
  129785. /** @hidden */
  129786. static _SceneComponentInitialization: (scene: Scene) => void;
  129787. /**
  129788. * Instantiates a depth renderer
  129789. * @param scene The scene the renderer belongs to
  129790. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  129791. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  129792. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129793. */
  129794. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  129795. /**
  129796. * Creates the depth rendering effect and checks if the effect is ready.
  129797. * @param subMesh The submesh to be used to render the depth map of
  129798. * @param useInstances If multiple world instances should be used
  129799. * @returns if the depth renderer is ready to render the depth map
  129800. */
  129801. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129802. /**
  129803. * Gets the texture which the depth map will be written to.
  129804. * @returns The depth map texture
  129805. */
  129806. getDepthMap(): RenderTargetTexture;
  129807. /**
  129808. * Disposes of the depth renderer.
  129809. */
  129810. dispose(): void;
  129811. }
  129812. }
  129813. declare module BABYLON {
  129814. interface Scene {
  129815. /** @hidden (Backing field) */
  129816. _depthRenderer: {
  129817. [id: string]: DepthRenderer;
  129818. };
  129819. /**
  129820. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  129821. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  129822. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  129823. * @returns the created depth renderer
  129824. */
  129825. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  129826. /**
  129827. * Disables a depth renderer for a given camera
  129828. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  129829. */
  129830. disableDepthRenderer(camera?: Nullable<Camera>): void;
  129831. }
  129832. /**
  129833. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  129834. * in several rendering techniques.
  129835. */
  129836. export class DepthRendererSceneComponent implements ISceneComponent {
  129837. /**
  129838. * The component name helpfull to identify the component in the list of scene components.
  129839. */
  129840. readonly name: string;
  129841. /**
  129842. * The scene the component belongs to.
  129843. */
  129844. scene: Scene;
  129845. /**
  129846. * Creates a new instance of the component for the given scene
  129847. * @param scene Defines the scene to register the component in
  129848. */
  129849. constructor(scene: Scene);
  129850. /**
  129851. * Registers the component in a given scene
  129852. */
  129853. register(): void;
  129854. /**
  129855. * Rebuilds the elements related to this component in case of
  129856. * context lost for instance.
  129857. */
  129858. rebuild(): void;
  129859. /**
  129860. * Disposes the component and the associated ressources
  129861. */
  129862. dispose(): void;
  129863. private _gatherRenderTargets;
  129864. private _gatherActiveCameraRenderTargets;
  129865. }
  129866. }
  129867. declare module BABYLON {
  129868. /** @hidden */
  129869. export var outlinePixelShader: {
  129870. name: string;
  129871. shader: string;
  129872. };
  129873. }
  129874. declare module BABYLON {
  129875. /** @hidden */
  129876. export var outlineVertexShader: {
  129877. name: string;
  129878. shader: string;
  129879. };
  129880. }
  129881. declare module BABYLON {
  129882. interface Scene {
  129883. /** @hidden */
  129884. _outlineRenderer: OutlineRenderer;
  129885. /**
  129886. * Gets the outline renderer associated with the scene
  129887. * @returns a OutlineRenderer
  129888. */
  129889. getOutlineRenderer(): OutlineRenderer;
  129890. }
  129891. interface AbstractMesh {
  129892. /** @hidden (Backing field) */
  129893. _renderOutline: boolean;
  129894. /**
  129895. * Gets or sets a boolean indicating if the outline must be rendered as well
  129896. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  129897. */
  129898. renderOutline: boolean;
  129899. /** @hidden (Backing field) */
  129900. _renderOverlay: boolean;
  129901. /**
  129902. * Gets or sets a boolean indicating if the overlay must be rendered as well
  129903. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  129904. */
  129905. renderOverlay: boolean;
  129906. }
  129907. /**
  129908. * This class is responsible to draw bothe outline/overlay of meshes.
  129909. * It should not be used directly but through the available method on mesh.
  129910. */
  129911. export class OutlineRenderer implements ISceneComponent {
  129912. /**
  129913. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  129914. */
  129915. private static _StencilReference;
  129916. /**
  129917. * The name of the component. Each component must have a unique name.
  129918. */
  129919. name: string;
  129920. /**
  129921. * The scene the component belongs to.
  129922. */
  129923. scene: Scene;
  129924. /**
  129925. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  129926. */
  129927. zOffset: number;
  129928. private _engine;
  129929. private _effect;
  129930. private _cachedDefines;
  129931. private _savedDepthWrite;
  129932. /**
  129933. * Instantiates a new outline renderer. (There could be only one per scene).
  129934. * @param scene Defines the scene it belongs to
  129935. */
  129936. constructor(scene: Scene);
  129937. /**
  129938. * Register the component to one instance of a scene.
  129939. */
  129940. register(): void;
  129941. /**
  129942. * Rebuilds the elements related to this component in case of
  129943. * context lost for instance.
  129944. */
  129945. rebuild(): void;
  129946. /**
  129947. * Disposes the component and the associated ressources.
  129948. */
  129949. dispose(): void;
  129950. /**
  129951. * Renders the outline in the canvas.
  129952. * @param subMesh Defines the sumesh to render
  129953. * @param batch Defines the batch of meshes in case of instances
  129954. * @param useOverlay Defines if the rendering is for the overlay or the outline
  129955. */
  129956. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  129957. /**
  129958. * Returns whether or not the outline renderer is ready for a given submesh.
  129959. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  129960. * @param subMesh Defines the submesh to check readyness for
  129961. * @param useInstances Defines wheter wee are trying to render instances or not
  129962. * @returns true if ready otherwise false
  129963. */
  129964. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129965. private _beforeRenderingMesh;
  129966. private _afterRenderingMesh;
  129967. }
  129968. }
  129969. declare module BABYLON {
  129970. /**
  129971. * Class used to manage multiple sprites of different sizes on the same spritesheet
  129972. * @see http://doc.babylonjs.com/babylon101/sprites
  129973. */
  129974. export class SpritePackedManager extends SpriteManager {
  129975. /** defines the packed manager's name */
  129976. name: string;
  129977. /**
  129978. * Creates a new sprite manager from a packed sprite sheet
  129979. * @param name defines the manager's name
  129980. * @param imgUrl defines the sprite sheet url
  129981. * @param capacity defines the maximum allowed number of sprites
  129982. * @param scene defines the hosting scene
  129983. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  129984. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  129985. * @param samplingMode defines the smapling mode to use with spritesheet
  129986. * @param fromPacked set to true; do not alter
  129987. */
  129988. constructor(
  129989. /** defines the packed manager's name */
  129990. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  129991. }
  129992. }
  129993. declare module BABYLON {
  129994. /**
  129995. * Defines the list of states available for a task inside a AssetsManager
  129996. */
  129997. export enum AssetTaskState {
  129998. /**
  129999. * Initialization
  130000. */
  130001. INIT = 0,
  130002. /**
  130003. * Running
  130004. */
  130005. RUNNING = 1,
  130006. /**
  130007. * Done
  130008. */
  130009. DONE = 2,
  130010. /**
  130011. * Error
  130012. */
  130013. ERROR = 3
  130014. }
  130015. /**
  130016. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  130017. */
  130018. export abstract class AbstractAssetTask {
  130019. /**
  130020. * Task name
  130021. */ name: string;
  130022. /**
  130023. * Callback called when the task is successful
  130024. */
  130025. onSuccess: (task: any) => void;
  130026. /**
  130027. * Callback called when the task is not successful
  130028. */
  130029. onError: (task: any, message?: string, exception?: any) => void;
  130030. /**
  130031. * Creates a new AssetsManager
  130032. * @param name defines the name of the task
  130033. */
  130034. constructor(
  130035. /**
  130036. * Task name
  130037. */ name: string);
  130038. private _isCompleted;
  130039. private _taskState;
  130040. private _errorObject;
  130041. /**
  130042. * Get if the task is completed
  130043. */
  130044. readonly isCompleted: boolean;
  130045. /**
  130046. * Gets the current state of the task
  130047. */
  130048. readonly taskState: AssetTaskState;
  130049. /**
  130050. * Gets the current error object (if task is in error)
  130051. */
  130052. readonly errorObject: {
  130053. message?: string;
  130054. exception?: any;
  130055. };
  130056. /**
  130057. * Internal only
  130058. * @hidden
  130059. */
  130060. _setErrorObject(message?: string, exception?: any): void;
  130061. /**
  130062. * Execute the current task
  130063. * @param scene defines the scene where you want your assets to be loaded
  130064. * @param onSuccess is a callback called when the task is successfully executed
  130065. * @param onError is a callback called if an error occurs
  130066. */
  130067. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130068. /**
  130069. * Execute the current task
  130070. * @param scene defines the scene where you want your assets to be loaded
  130071. * @param onSuccess is a callback called when the task is successfully executed
  130072. * @param onError is a callback called if an error occurs
  130073. */
  130074. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130075. /**
  130076. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  130077. * This can be used with failed tasks that have the reason for failure fixed.
  130078. */
  130079. reset(): void;
  130080. private onErrorCallback;
  130081. private onDoneCallback;
  130082. }
  130083. /**
  130084. * Define the interface used by progress events raised during assets loading
  130085. */
  130086. export interface IAssetsProgressEvent {
  130087. /**
  130088. * Defines the number of remaining tasks to process
  130089. */
  130090. remainingCount: number;
  130091. /**
  130092. * Defines the total number of tasks
  130093. */
  130094. totalCount: number;
  130095. /**
  130096. * Defines the task that was just processed
  130097. */
  130098. task: AbstractAssetTask;
  130099. }
  130100. /**
  130101. * Class used to share progress information about assets loading
  130102. */
  130103. export class AssetsProgressEvent implements IAssetsProgressEvent {
  130104. /**
  130105. * Defines the number of remaining tasks to process
  130106. */
  130107. remainingCount: number;
  130108. /**
  130109. * Defines the total number of tasks
  130110. */
  130111. totalCount: number;
  130112. /**
  130113. * Defines the task that was just processed
  130114. */
  130115. task: AbstractAssetTask;
  130116. /**
  130117. * Creates a AssetsProgressEvent
  130118. * @param remainingCount defines the number of remaining tasks to process
  130119. * @param totalCount defines the total number of tasks
  130120. * @param task defines the task that was just processed
  130121. */
  130122. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  130123. }
  130124. /**
  130125. * Define a task used by AssetsManager to load meshes
  130126. */
  130127. export class MeshAssetTask extends AbstractAssetTask {
  130128. /**
  130129. * Defines the name of the task
  130130. */
  130131. name: string;
  130132. /**
  130133. * Defines the list of mesh's names you want to load
  130134. */
  130135. meshesNames: any;
  130136. /**
  130137. * Defines the root url to use as a base to load your meshes and associated resources
  130138. */
  130139. rootUrl: string;
  130140. /**
  130141. * Defines the filename of the scene to load from
  130142. */
  130143. sceneFilename: string;
  130144. /**
  130145. * Gets the list of loaded meshes
  130146. */
  130147. loadedMeshes: Array<AbstractMesh>;
  130148. /**
  130149. * Gets the list of loaded particle systems
  130150. */
  130151. loadedParticleSystems: Array<IParticleSystem>;
  130152. /**
  130153. * Gets the list of loaded skeletons
  130154. */
  130155. loadedSkeletons: Array<Skeleton>;
  130156. /**
  130157. * Gets the list of loaded animation groups
  130158. */
  130159. loadedAnimationGroups: Array<AnimationGroup>;
  130160. /**
  130161. * Callback called when the task is successful
  130162. */
  130163. onSuccess: (task: MeshAssetTask) => void;
  130164. /**
  130165. * Callback called when the task is successful
  130166. */
  130167. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  130168. /**
  130169. * Creates a new MeshAssetTask
  130170. * @param name defines the name of the task
  130171. * @param meshesNames defines the list of mesh's names you want to load
  130172. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  130173. * @param sceneFilename defines the filename of the scene to load from
  130174. */
  130175. constructor(
  130176. /**
  130177. * Defines the name of the task
  130178. */
  130179. name: string,
  130180. /**
  130181. * Defines the list of mesh's names you want to load
  130182. */
  130183. meshesNames: any,
  130184. /**
  130185. * Defines the root url to use as a base to load your meshes and associated resources
  130186. */
  130187. rootUrl: string,
  130188. /**
  130189. * Defines the filename of the scene to load from
  130190. */
  130191. sceneFilename: string);
  130192. /**
  130193. * Execute the current task
  130194. * @param scene defines the scene where you want your assets to be loaded
  130195. * @param onSuccess is a callback called when the task is successfully executed
  130196. * @param onError is a callback called if an error occurs
  130197. */
  130198. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130199. }
  130200. /**
  130201. * Define a task used by AssetsManager to load text content
  130202. */
  130203. export class TextFileAssetTask extends AbstractAssetTask {
  130204. /**
  130205. * Defines the name of the task
  130206. */
  130207. name: string;
  130208. /**
  130209. * Defines the location of the file to load
  130210. */
  130211. url: string;
  130212. /**
  130213. * Gets the loaded text string
  130214. */
  130215. text: string;
  130216. /**
  130217. * Callback called when the task is successful
  130218. */
  130219. onSuccess: (task: TextFileAssetTask) => void;
  130220. /**
  130221. * Callback called when the task is successful
  130222. */
  130223. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  130224. /**
  130225. * Creates a new TextFileAssetTask object
  130226. * @param name defines the name of the task
  130227. * @param url defines the location of the file to load
  130228. */
  130229. constructor(
  130230. /**
  130231. * Defines the name of the task
  130232. */
  130233. name: string,
  130234. /**
  130235. * Defines the location of the file to load
  130236. */
  130237. url: string);
  130238. /**
  130239. * Execute the current task
  130240. * @param scene defines the scene where you want your assets to be loaded
  130241. * @param onSuccess is a callback called when the task is successfully executed
  130242. * @param onError is a callback called if an error occurs
  130243. */
  130244. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130245. }
  130246. /**
  130247. * Define a task used by AssetsManager to load binary data
  130248. */
  130249. export class BinaryFileAssetTask extends AbstractAssetTask {
  130250. /**
  130251. * Defines the name of the task
  130252. */
  130253. name: string;
  130254. /**
  130255. * Defines the location of the file to load
  130256. */
  130257. url: string;
  130258. /**
  130259. * Gets the lodaded data (as an array buffer)
  130260. */
  130261. data: ArrayBuffer;
  130262. /**
  130263. * Callback called when the task is successful
  130264. */
  130265. onSuccess: (task: BinaryFileAssetTask) => void;
  130266. /**
  130267. * Callback called when the task is successful
  130268. */
  130269. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  130270. /**
  130271. * Creates a new BinaryFileAssetTask object
  130272. * @param name defines the name of the new task
  130273. * @param url defines the location of the file to load
  130274. */
  130275. constructor(
  130276. /**
  130277. * Defines the name of the task
  130278. */
  130279. name: string,
  130280. /**
  130281. * Defines the location of the file to load
  130282. */
  130283. url: string);
  130284. /**
  130285. * Execute the current task
  130286. * @param scene defines the scene where you want your assets to be loaded
  130287. * @param onSuccess is a callback called when the task is successfully executed
  130288. * @param onError is a callback called if an error occurs
  130289. */
  130290. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130291. }
  130292. /**
  130293. * Define a task used by AssetsManager to load images
  130294. */
  130295. export class ImageAssetTask extends AbstractAssetTask {
  130296. /**
  130297. * Defines the name of the task
  130298. */
  130299. name: string;
  130300. /**
  130301. * Defines the location of the image to load
  130302. */
  130303. url: string;
  130304. /**
  130305. * Gets the loaded images
  130306. */
  130307. image: HTMLImageElement;
  130308. /**
  130309. * Callback called when the task is successful
  130310. */
  130311. onSuccess: (task: ImageAssetTask) => void;
  130312. /**
  130313. * Callback called when the task is successful
  130314. */
  130315. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  130316. /**
  130317. * Creates a new ImageAssetTask
  130318. * @param name defines the name of the task
  130319. * @param url defines the location of the image to load
  130320. */
  130321. constructor(
  130322. /**
  130323. * Defines the name of the task
  130324. */
  130325. name: string,
  130326. /**
  130327. * Defines the location of the image to load
  130328. */
  130329. url: string);
  130330. /**
  130331. * Execute the current task
  130332. * @param scene defines the scene where you want your assets to be loaded
  130333. * @param onSuccess is a callback called when the task is successfully executed
  130334. * @param onError is a callback called if an error occurs
  130335. */
  130336. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130337. }
  130338. /**
  130339. * Defines the interface used by texture loading tasks
  130340. */
  130341. export interface ITextureAssetTask<TEX extends BaseTexture> {
  130342. /**
  130343. * Gets the loaded texture
  130344. */
  130345. texture: TEX;
  130346. }
  130347. /**
  130348. * Define a task used by AssetsManager to load 2D textures
  130349. */
  130350. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  130351. /**
  130352. * Defines the name of the task
  130353. */
  130354. name: string;
  130355. /**
  130356. * Defines the location of the file to load
  130357. */
  130358. url: string;
  130359. /**
  130360. * Defines if mipmap should not be generated (default is false)
  130361. */
  130362. noMipmap?: boolean | undefined;
  130363. /**
  130364. * Defines if texture must be inverted on Y axis (default is false)
  130365. */
  130366. invertY?: boolean | undefined;
  130367. /**
  130368. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130369. */
  130370. samplingMode: number;
  130371. /**
  130372. * Gets the loaded texture
  130373. */
  130374. texture: Texture;
  130375. /**
  130376. * Callback called when the task is successful
  130377. */
  130378. onSuccess: (task: TextureAssetTask) => void;
  130379. /**
  130380. * Callback called when the task is successful
  130381. */
  130382. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  130383. /**
  130384. * Creates a new TextureAssetTask object
  130385. * @param name defines the name of the task
  130386. * @param url defines the location of the file to load
  130387. * @param noMipmap defines if mipmap should not be generated (default is false)
  130388. * @param invertY defines if texture must be inverted on Y axis (default is false)
  130389. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130390. */
  130391. constructor(
  130392. /**
  130393. * Defines the name of the task
  130394. */
  130395. name: string,
  130396. /**
  130397. * Defines the location of the file to load
  130398. */
  130399. url: string,
  130400. /**
  130401. * Defines if mipmap should not be generated (default is false)
  130402. */
  130403. noMipmap?: boolean | undefined,
  130404. /**
  130405. * Defines if texture must be inverted on Y axis (default is false)
  130406. */
  130407. invertY?: boolean | undefined,
  130408. /**
  130409. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  130410. */
  130411. samplingMode?: number);
  130412. /**
  130413. * Execute the current task
  130414. * @param scene defines the scene where you want your assets to be loaded
  130415. * @param onSuccess is a callback called when the task is successfully executed
  130416. * @param onError is a callback called if an error occurs
  130417. */
  130418. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130419. }
  130420. /**
  130421. * Define a task used by AssetsManager to load cube textures
  130422. */
  130423. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  130424. /**
  130425. * Defines the name of the task
  130426. */
  130427. name: string;
  130428. /**
  130429. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130430. */
  130431. url: string;
  130432. /**
  130433. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130434. */
  130435. extensions?: string[] | undefined;
  130436. /**
  130437. * Defines if mipmaps should not be generated (default is false)
  130438. */
  130439. noMipmap?: boolean | undefined;
  130440. /**
  130441. * Defines the explicit list of files (undefined by default)
  130442. */
  130443. files?: string[] | undefined;
  130444. /**
  130445. * Gets the loaded texture
  130446. */
  130447. texture: CubeTexture;
  130448. /**
  130449. * Callback called when the task is successful
  130450. */
  130451. onSuccess: (task: CubeTextureAssetTask) => void;
  130452. /**
  130453. * Callback called when the task is successful
  130454. */
  130455. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  130456. /**
  130457. * Creates a new CubeTextureAssetTask
  130458. * @param name defines the name of the task
  130459. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130460. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130461. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130462. * @param files defines the explicit list of files (undefined by default)
  130463. */
  130464. constructor(
  130465. /**
  130466. * Defines the name of the task
  130467. */
  130468. name: string,
  130469. /**
  130470. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  130471. */
  130472. url: string,
  130473. /**
  130474. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  130475. */
  130476. extensions?: string[] | undefined,
  130477. /**
  130478. * Defines if mipmaps should not be generated (default is false)
  130479. */
  130480. noMipmap?: boolean | undefined,
  130481. /**
  130482. * Defines the explicit list of files (undefined by default)
  130483. */
  130484. files?: string[] | undefined);
  130485. /**
  130486. * Execute the current task
  130487. * @param scene defines the scene where you want your assets to be loaded
  130488. * @param onSuccess is a callback called when the task is successfully executed
  130489. * @param onError is a callback called if an error occurs
  130490. */
  130491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130492. }
  130493. /**
  130494. * Define a task used by AssetsManager to load HDR cube textures
  130495. */
  130496. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  130497. /**
  130498. * Defines the name of the task
  130499. */
  130500. name: string;
  130501. /**
  130502. * Defines the location of the file to load
  130503. */
  130504. url: string;
  130505. /**
  130506. * Defines the desired size (the more it increases the longer the generation will be)
  130507. */
  130508. size: number;
  130509. /**
  130510. * Defines if mipmaps should not be generated (default is false)
  130511. */
  130512. noMipmap: boolean;
  130513. /**
  130514. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130515. */
  130516. generateHarmonics: boolean;
  130517. /**
  130518. * 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)
  130519. */
  130520. gammaSpace: boolean;
  130521. /**
  130522. * Internal Use Only
  130523. */
  130524. reserved: boolean;
  130525. /**
  130526. * Gets the loaded texture
  130527. */
  130528. texture: HDRCubeTexture;
  130529. /**
  130530. * Callback called when the task is successful
  130531. */
  130532. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  130533. /**
  130534. * Callback called when the task is successful
  130535. */
  130536. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  130537. /**
  130538. * Creates a new HDRCubeTextureAssetTask object
  130539. * @param name defines the name of the task
  130540. * @param url defines the location of the file to load
  130541. * @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.
  130542. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130543. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130544. * @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)
  130545. * @param reserved Internal use only
  130546. */
  130547. constructor(
  130548. /**
  130549. * Defines the name of the task
  130550. */
  130551. name: string,
  130552. /**
  130553. * Defines the location of the file to load
  130554. */
  130555. url: string,
  130556. /**
  130557. * Defines the desired size (the more it increases the longer the generation will be)
  130558. */
  130559. size: number,
  130560. /**
  130561. * Defines if mipmaps should not be generated (default is false)
  130562. */
  130563. noMipmap?: boolean,
  130564. /**
  130565. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  130566. */
  130567. generateHarmonics?: boolean,
  130568. /**
  130569. * 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)
  130570. */
  130571. gammaSpace?: boolean,
  130572. /**
  130573. * Internal Use Only
  130574. */
  130575. reserved?: boolean);
  130576. /**
  130577. * Execute the current task
  130578. * @param scene defines the scene where you want your assets to be loaded
  130579. * @param onSuccess is a callback called when the task is successfully executed
  130580. * @param onError is a callback called if an error occurs
  130581. */
  130582. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130583. }
  130584. /**
  130585. * Define a task used by AssetsManager to load Equirectangular cube textures
  130586. */
  130587. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  130588. /**
  130589. * Defines the name of the task
  130590. */
  130591. name: string;
  130592. /**
  130593. * Defines the location of the file to load
  130594. */
  130595. url: string;
  130596. /**
  130597. * Defines the desired size (the more it increases the longer the generation will be)
  130598. */
  130599. size: number;
  130600. /**
  130601. * Defines if mipmaps should not be generated (default is false)
  130602. */
  130603. noMipmap: boolean;
  130604. /**
  130605. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130606. * but the standard material would require them in Gamma space) (default is true)
  130607. */
  130608. gammaSpace: boolean;
  130609. /**
  130610. * Gets the loaded texture
  130611. */
  130612. texture: EquiRectangularCubeTexture;
  130613. /**
  130614. * Callback called when the task is successful
  130615. */
  130616. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  130617. /**
  130618. * Callback called when the task is successful
  130619. */
  130620. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  130621. /**
  130622. * Creates a new EquiRectangularCubeTextureAssetTask object
  130623. * @param name defines the name of the task
  130624. * @param url defines the location of the file to load
  130625. * @param size defines the desired size (the more it increases the longer the generation will be)
  130626. * If the size is omitted this implies you are using a preprocessed cubemap.
  130627. * @param noMipmap defines if mipmaps should not be generated (default is false)
  130628. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  130629. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  130630. * (default is true)
  130631. */
  130632. constructor(
  130633. /**
  130634. * Defines the name of the task
  130635. */
  130636. name: string,
  130637. /**
  130638. * Defines the location of the file to load
  130639. */
  130640. url: string,
  130641. /**
  130642. * Defines the desired size (the more it increases the longer the generation will be)
  130643. */
  130644. size: number,
  130645. /**
  130646. * Defines if mipmaps should not be generated (default is false)
  130647. */
  130648. noMipmap?: boolean,
  130649. /**
  130650. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  130651. * but the standard material would require them in Gamma space) (default is true)
  130652. */
  130653. gammaSpace?: boolean);
  130654. /**
  130655. * Execute the current task
  130656. * @param scene defines the scene where you want your assets to be loaded
  130657. * @param onSuccess is a callback called when the task is successfully executed
  130658. * @param onError is a callback called if an error occurs
  130659. */
  130660. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  130661. }
  130662. /**
  130663. * This class can be used to easily import assets into a scene
  130664. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  130665. */
  130666. export class AssetsManager {
  130667. private _scene;
  130668. private _isLoading;
  130669. protected _tasks: AbstractAssetTask[];
  130670. protected _waitingTasksCount: number;
  130671. protected _totalTasksCount: number;
  130672. /**
  130673. * Callback called when all tasks are processed
  130674. */
  130675. onFinish: (tasks: AbstractAssetTask[]) => void;
  130676. /**
  130677. * Callback called when a task is successful
  130678. */
  130679. onTaskSuccess: (task: AbstractAssetTask) => void;
  130680. /**
  130681. * Callback called when a task had an error
  130682. */
  130683. onTaskError: (task: AbstractAssetTask) => void;
  130684. /**
  130685. * Callback called when a task is done (whatever the result is)
  130686. */
  130687. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  130688. /**
  130689. * Observable called when all tasks are processed
  130690. */
  130691. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  130692. /**
  130693. * Observable called when a task had an error
  130694. */
  130695. onTaskErrorObservable: Observable<AbstractAssetTask>;
  130696. /**
  130697. * Observable called when all tasks were executed
  130698. */
  130699. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  130700. /**
  130701. * Observable called when a task is done (whatever the result is)
  130702. */
  130703. onProgressObservable: Observable<IAssetsProgressEvent>;
  130704. /**
  130705. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  130706. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  130707. */
  130708. useDefaultLoadingScreen: boolean;
  130709. /**
  130710. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  130711. * when all assets have been downloaded.
  130712. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  130713. */
  130714. autoHideLoadingUI: boolean;
  130715. /**
  130716. * Creates a new AssetsManager
  130717. * @param scene defines the scene to work on
  130718. */
  130719. constructor(scene: Scene);
  130720. /**
  130721. * Add a MeshAssetTask to the list of active tasks
  130722. * @param taskName defines the name of the new task
  130723. * @param meshesNames defines the name of meshes to load
  130724. * @param rootUrl defines the root url to use to locate files
  130725. * @param sceneFilename defines the filename of the scene file
  130726. * @returns a new MeshAssetTask object
  130727. */
  130728. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  130729. /**
  130730. * Add a TextFileAssetTask to the list of active tasks
  130731. * @param taskName defines the name of the new task
  130732. * @param url defines the url of the file to load
  130733. * @returns a new TextFileAssetTask object
  130734. */
  130735. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  130736. /**
  130737. * Add a BinaryFileAssetTask to the list of active tasks
  130738. * @param taskName defines the name of the new task
  130739. * @param url defines the url of the file to load
  130740. * @returns a new BinaryFileAssetTask object
  130741. */
  130742. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  130743. /**
  130744. * Add a ImageAssetTask to the list of active tasks
  130745. * @param taskName defines the name of the new task
  130746. * @param url defines the url of the file to load
  130747. * @returns a new ImageAssetTask object
  130748. */
  130749. addImageTask(taskName: string, url: string): ImageAssetTask;
  130750. /**
  130751. * Add a TextureAssetTask to the list of active tasks
  130752. * @param taskName defines the name of the new task
  130753. * @param url defines the url of the file to load
  130754. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130755. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  130756. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130757. * @returns a new TextureAssetTask object
  130758. */
  130759. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  130760. /**
  130761. * Add a CubeTextureAssetTask to the list of active tasks
  130762. * @param taskName defines the name of the new task
  130763. * @param url defines the url of the file to load
  130764. * @param extensions defines the extension to use to load the cube map (can be null)
  130765. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130766. * @param files defines the list of files to load (can be null)
  130767. * @returns a new CubeTextureAssetTask object
  130768. */
  130769. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  130770. /**
  130771. *
  130772. * Add a HDRCubeTextureAssetTask to the list of active tasks
  130773. * @param taskName defines the name of the new task
  130774. * @param url defines the url of the file to load
  130775. * @param size defines the size you want for the cubemap (can be null)
  130776. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130777. * @param generateHarmonics defines if you want to automatically generate (true by default)
  130778. * @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)
  130779. * @param reserved Internal use only
  130780. * @returns a new HDRCubeTextureAssetTask object
  130781. */
  130782. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  130783. /**
  130784. *
  130785. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  130786. * @param taskName defines the name of the new task
  130787. * @param url defines the url of the file to load
  130788. * @param size defines the size you want for the cubemap (can be null)
  130789. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  130790. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130791. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130792. * @returns a new EquiRectangularCubeTextureAssetTask object
  130793. */
  130794. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  130795. /**
  130796. * Remove a task from the assets manager.
  130797. * @param task the task to remove
  130798. */
  130799. removeTask(task: AbstractAssetTask): void;
  130800. private _decreaseWaitingTasksCount;
  130801. private _runTask;
  130802. /**
  130803. * Reset the AssetsManager and remove all tasks
  130804. * @return the current instance of the AssetsManager
  130805. */
  130806. reset(): AssetsManager;
  130807. /**
  130808. * Start the loading process
  130809. * @return the current instance of the AssetsManager
  130810. */
  130811. load(): AssetsManager;
  130812. /**
  130813. * Start the loading process as an async operation
  130814. * @return a promise returning the list of failed tasks
  130815. */
  130816. loadAsync(): Promise<void>;
  130817. }
  130818. }
  130819. declare module BABYLON {
  130820. /**
  130821. * Wrapper class for promise with external resolve and reject.
  130822. */
  130823. export class Deferred<T> {
  130824. /**
  130825. * The promise associated with this deferred object.
  130826. */
  130827. readonly promise: Promise<T>;
  130828. private _resolve;
  130829. private _reject;
  130830. /**
  130831. * The resolve method of the promise associated with this deferred object.
  130832. */
  130833. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  130834. /**
  130835. * The reject method of the promise associated with this deferred object.
  130836. */
  130837. readonly reject: (reason?: any) => void;
  130838. /**
  130839. * Constructor for this deferred object.
  130840. */
  130841. constructor();
  130842. }
  130843. }
  130844. declare module BABYLON {
  130845. /**
  130846. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  130847. */
  130848. export class MeshExploder {
  130849. private _centerMesh;
  130850. private _meshes;
  130851. private _meshesOrigins;
  130852. private _toCenterVectors;
  130853. private _scaledDirection;
  130854. private _newPosition;
  130855. private _centerPosition;
  130856. /**
  130857. * Explodes meshes from a center mesh.
  130858. * @param meshes The meshes to explode.
  130859. * @param centerMesh The mesh to be center of explosion.
  130860. */
  130861. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  130862. private _setCenterMesh;
  130863. /**
  130864. * Get class name
  130865. * @returns "MeshExploder"
  130866. */
  130867. getClassName(): string;
  130868. /**
  130869. * "Exploded meshes"
  130870. * @returns Array of meshes with the centerMesh at index 0.
  130871. */
  130872. getMeshes(): Array<Mesh>;
  130873. /**
  130874. * Explodes meshes giving a specific direction
  130875. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  130876. */
  130877. explode(direction?: number): void;
  130878. }
  130879. }
  130880. declare module BABYLON {
  130881. /**
  130882. * Class used to help managing file picking and drag'n'drop
  130883. */
  130884. export class FilesInput {
  130885. /**
  130886. * List of files ready to be loaded
  130887. */
  130888. static readonly FilesToLoad: {
  130889. [key: string]: File;
  130890. };
  130891. /**
  130892. * Callback called when a file is processed
  130893. */
  130894. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  130895. private _engine;
  130896. private _currentScene;
  130897. private _sceneLoadedCallback;
  130898. private _progressCallback;
  130899. private _additionalRenderLoopLogicCallback;
  130900. private _textureLoadingCallback;
  130901. private _startingProcessingFilesCallback;
  130902. private _onReloadCallback;
  130903. private _errorCallback;
  130904. private _elementToMonitor;
  130905. private _sceneFileToLoad;
  130906. private _filesToLoad;
  130907. /**
  130908. * Creates a new FilesInput
  130909. * @param engine defines the rendering engine
  130910. * @param scene defines the hosting scene
  130911. * @param sceneLoadedCallback callback called when scene is loaded
  130912. * @param progressCallback callback called to track progress
  130913. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  130914. * @param textureLoadingCallback callback called when a texture is loading
  130915. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  130916. * @param onReloadCallback callback called when a reload is requested
  130917. * @param errorCallback callback call if an error occurs
  130918. */
  130919. 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);
  130920. private _dragEnterHandler;
  130921. private _dragOverHandler;
  130922. private _dropHandler;
  130923. /**
  130924. * Calls this function to listen to drag'n'drop events on a specific DOM element
  130925. * @param elementToMonitor defines the DOM element to track
  130926. */
  130927. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  130928. /**
  130929. * Release all associated resources
  130930. */
  130931. dispose(): void;
  130932. private renderFunction;
  130933. private drag;
  130934. private drop;
  130935. private _traverseFolder;
  130936. private _processFiles;
  130937. /**
  130938. * Load files from a drop event
  130939. * @param event defines the drop event to use as source
  130940. */
  130941. loadFiles(event: any): void;
  130942. private _processReload;
  130943. /**
  130944. * Reload the current scene from the loaded files
  130945. */
  130946. reload(): void;
  130947. }
  130948. }
  130949. declare module BABYLON {
  130950. /**
  130951. * Defines the root class used to create scene optimization to use with SceneOptimizer
  130952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130953. */
  130954. export class SceneOptimization {
  130955. /**
  130956. * Defines the priority of this optimization (0 by default which means first in the list)
  130957. */
  130958. priority: number;
  130959. /**
  130960. * Gets a string describing the action executed by the current optimization
  130961. * @returns description string
  130962. */
  130963. getDescription(): string;
  130964. /**
  130965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  130966. * @param scene defines the current scene where to apply this optimization
  130967. * @param optimizer defines the current optimizer
  130968. * @returns true if everything that can be done was applied
  130969. */
  130970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  130971. /**
  130972. * Creates the SceneOptimization object
  130973. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  130974. * @param desc defines the description associated with the optimization
  130975. */
  130976. constructor(
  130977. /**
  130978. * Defines the priority of this optimization (0 by default which means first in the list)
  130979. */
  130980. priority?: number);
  130981. }
  130982. /**
  130983. * Defines an optimization used to reduce the size of render target textures
  130984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  130985. */
  130986. export class TextureOptimization extends SceneOptimization {
  130987. /**
  130988. * Defines the priority of this optimization (0 by default which means first in the list)
  130989. */
  130990. priority: number;
  130991. /**
  130992. * 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
  130993. */
  130994. maximumSize: number;
  130995. /**
  130996. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  130997. */
  130998. step: number;
  130999. /**
  131000. * Gets a string describing the action executed by the current optimization
  131001. * @returns description string
  131002. */
  131003. getDescription(): string;
  131004. /**
  131005. * Creates the TextureOptimization object
  131006. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131007. * @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
  131008. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131009. */
  131010. constructor(
  131011. /**
  131012. * Defines the priority of this optimization (0 by default which means first in the list)
  131013. */
  131014. priority?: number,
  131015. /**
  131016. * 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
  131017. */
  131018. maximumSize?: number,
  131019. /**
  131020. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  131021. */
  131022. step?: number);
  131023. /**
  131024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131025. * @param scene defines the current scene where to apply this optimization
  131026. * @param optimizer defines the current optimizer
  131027. * @returns true if everything that can be done was applied
  131028. */
  131029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131030. }
  131031. /**
  131032. * Defines an optimization used to increase or decrease the rendering resolution
  131033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131034. */
  131035. export class HardwareScalingOptimization extends SceneOptimization {
  131036. /**
  131037. * Defines the priority of this optimization (0 by default which means first in the list)
  131038. */
  131039. priority: number;
  131040. /**
  131041. * Defines the maximum scale to use (2 by default)
  131042. */
  131043. maximumScale: number;
  131044. /**
  131045. * Defines the step to use between two passes (0.5 by default)
  131046. */
  131047. step: number;
  131048. private _currentScale;
  131049. private _directionOffset;
  131050. /**
  131051. * Gets a string describing the action executed by the current optimization
  131052. * @return description string
  131053. */
  131054. getDescription(): string;
  131055. /**
  131056. * Creates the HardwareScalingOptimization object
  131057. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131058. * @param maximumScale defines the maximum scale to use (2 by default)
  131059. * @param step defines the step to use between two passes (0.5 by default)
  131060. */
  131061. constructor(
  131062. /**
  131063. * Defines the priority of this optimization (0 by default which means first in the list)
  131064. */
  131065. priority?: number,
  131066. /**
  131067. * Defines the maximum scale to use (2 by default)
  131068. */
  131069. maximumScale?: number,
  131070. /**
  131071. * Defines the step to use between two passes (0.5 by default)
  131072. */
  131073. step?: number);
  131074. /**
  131075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131076. * @param scene defines the current scene where to apply this optimization
  131077. * @param optimizer defines the current optimizer
  131078. * @returns true if everything that can be done was applied
  131079. */
  131080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131081. }
  131082. /**
  131083. * Defines an optimization used to remove shadows
  131084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131085. */
  131086. export class ShadowsOptimization extends SceneOptimization {
  131087. /**
  131088. * Gets a string describing the action executed by the current optimization
  131089. * @return description string
  131090. */
  131091. getDescription(): string;
  131092. /**
  131093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131094. * @param scene defines the current scene where to apply this optimization
  131095. * @param optimizer defines the current optimizer
  131096. * @returns true if everything that can be done was applied
  131097. */
  131098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131099. }
  131100. /**
  131101. * Defines an optimization used to turn post-processes off
  131102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131103. */
  131104. export class PostProcessesOptimization extends SceneOptimization {
  131105. /**
  131106. * Gets a string describing the action executed by the current optimization
  131107. * @return description string
  131108. */
  131109. getDescription(): string;
  131110. /**
  131111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131112. * @param scene defines the current scene where to apply this optimization
  131113. * @param optimizer defines the current optimizer
  131114. * @returns true if everything that can be done was applied
  131115. */
  131116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131117. }
  131118. /**
  131119. * Defines an optimization used to turn lens flares off
  131120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131121. */
  131122. export class LensFlaresOptimization extends SceneOptimization {
  131123. /**
  131124. * Gets a string describing the action executed by the current optimization
  131125. * @return description string
  131126. */
  131127. getDescription(): string;
  131128. /**
  131129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131130. * @param scene defines the current scene where to apply this optimization
  131131. * @param optimizer defines the current optimizer
  131132. * @returns true if everything that can be done was applied
  131133. */
  131134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131135. }
  131136. /**
  131137. * Defines an optimization based on user defined callback.
  131138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131139. */
  131140. export class CustomOptimization extends SceneOptimization {
  131141. /**
  131142. * Callback called to apply the custom optimization.
  131143. */
  131144. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  131145. /**
  131146. * Callback called to get custom description
  131147. */
  131148. onGetDescription: () => string;
  131149. /**
  131150. * Gets a string describing the action executed by the current optimization
  131151. * @returns description string
  131152. */
  131153. getDescription(): string;
  131154. /**
  131155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131156. * @param scene defines the current scene where to apply this optimization
  131157. * @param optimizer defines the current optimizer
  131158. * @returns true if everything that can be done was applied
  131159. */
  131160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131161. }
  131162. /**
  131163. * Defines an optimization used to turn particles off
  131164. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131165. */
  131166. export class ParticlesOptimization extends SceneOptimization {
  131167. /**
  131168. * Gets a string describing the action executed by the current optimization
  131169. * @return description string
  131170. */
  131171. getDescription(): string;
  131172. /**
  131173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131174. * @param scene defines the current scene where to apply this optimization
  131175. * @param optimizer defines the current optimizer
  131176. * @returns true if everything that can be done was applied
  131177. */
  131178. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131179. }
  131180. /**
  131181. * Defines an optimization used to turn render targets off
  131182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131183. */
  131184. export class RenderTargetsOptimization extends SceneOptimization {
  131185. /**
  131186. * Gets a string describing the action executed by the current optimization
  131187. * @return description string
  131188. */
  131189. getDescription(): string;
  131190. /**
  131191. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131192. * @param scene defines the current scene where to apply this optimization
  131193. * @param optimizer defines the current optimizer
  131194. * @returns true if everything that can be done was applied
  131195. */
  131196. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  131197. }
  131198. /**
  131199. * Defines an optimization used to merge meshes with compatible materials
  131200. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131201. */
  131202. export class MergeMeshesOptimization extends SceneOptimization {
  131203. private static _UpdateSelectionTree;
  131204. /**
  131205. * Gets or sets a boolean which defines if optimization octree has to be updated
  131206. */
  131207. /**
  131208. * Gets or sets a boolean which defines if optimization octree has to be updated
  131209. */
  131210. static UpdateSelectionTree: boolean;
  131211. /**
  131212. * Gets a string describing the action executed by the current optimization
  131213. * @return description string
  131214. */
  131215. getDescription(): string;
  131216. private _canBeMerged;
  131217. /**
  131218. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  131219. * @param scene defines the current scene where to apply this optimization
  131220. * @param optimizer defines the current optimizer
  131221. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  131222. * @returns true if everything that can be done was applied
  131223. */
  131224. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  131225. }
  131226. /**
  131227. * Defines a list of options used by SceneOptimizer
  131228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131229. */
  131230. export class SceneOptimizerOptions {
  131231. /**
  131232. * Defines the target frame rate to reach (60 by default)
  131233. */
  131234. targetFrameRate: number;
  131235. /**
  131236. * Defines the interval between two checkes (2000ms by default)
  131237. */
  131238. trackerDuration: number;
  131239. /**
  131240. * Gets the list of optimizations to apply
  131241. */
  131242. optimizations: SceneOptimization[];
  131243. /**
  131244. * Creates a new list of options used by SceneOptimizer
  131245. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  131246. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  131247. */
  131248. constructor(
  131249. /**
  131250. * Defines the target frame rate to reach (60 by default)
  131251. */
  131252. targetFrameRate?: number,
  131253. /**
  131254. * Defines the interval between two checkes (2000ms by default)
  131255. */
  131256. trackerDuration?: number);
  131257. /**
  131258. * Add a new optimization
  131259. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  131260. * @returns the current SceneOptimizerOptions
  131261. */
  131262. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  131263. /**
  131264. * Add a new custom optimization
  131265. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  131266. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  131267. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  131268. * @returns the current SceneOptimizerOptions
  131269. */
  131270. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  131271. /**
  131272. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  131273. * @param targetFrameRate defines the target frame rate (60 by default)
  131274. * @returns a SceneOptimizerOptions object
  131275. */
  131276. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131277. /**
  131278. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  131279. * @param targetFrameRate defines the target frame rate (60 by default)
  131280. * @returns a SceneOptimizerOptions object
  131281. */
  131282. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131283. /**
  131284. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  131285. * @param targetFrameRate defines the target frame rate (60 by default)
  131286. * @returns a SceneOptimizerOptions object
  131287. */
  131288. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  131289. }
  131290. /**
  131291. * Class used to run optimizations in order to reach a target frame rate
  131292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  131293. */
  131294. export class SceneOptimizer implements IDisposable {
  131295. private _isRunning;
  131296. private _options;
  131297. private _scene;
  131298. private _currentPriorityLevel;
  131299. private _targetFrameRate;
  131300. private _trackerDuration;
  131301. private _currentFrameRate;
  131302. private _sceneDisposeObserver;
  131303. private _improvementMode;
  131304. /**
  131305. * Defines an observable called when the optimizer reaches the target frame rate
  131306. */
  131307. onSuccessObservable: Observable<SceneOptimizer>;
  131308. /**
  131309. * Defines an observable called when the optimizer enables an optimization
  131310. */
  131311. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  131312. /**
  131313. * Defines an observable called when the optimizer is not able to reach the target frame rate
  131314. */
  131315. onFailureObservable: Observable<SceneOptimizer>;
  131316. /**
  131317. * Gets a boolean indicating if the optimizer is in improvement mode
  131318. */
  131319. readonly isInImprovementMode: boolean;
  131320. /**
  131321. * Gets the current priority level (0 at start)
  131322. */
  131323. readonly currentPriorityLevel: number;
  131324. /**
  131325. * Gets the current frame rate checked by the SceneOptimizer
  131326. */
  131327. readonly currentFrameRate: number;
  131328. /**
  131329. * Gets or sets the current target frame rate (60 by default)
  131330. */
  131331. /**
  131332. * Gets or sets the current target frame rate (60 by default)
  131333. */
  131334. targetFrameRate: number;
  131335. /**
  131336. * Gets or sets the current interval between two checks (every 2000ms by default)
  131337. */
  131338. /**
  131339. * Gets or sets the current interval between two checks (every 2000ms by default)
  131340. */
  131341. trackerDuration: number;
  131342. /**
  131343. * Gets the list of active optimizations
  131344. */
  131345. readonly optimizations: SceneOptimization[];
  131346. /**
  131347. * Creates a new SceneOptimizer
  131348. * @param scene defines the scene to work on
  131349. * @param options defines the options to use with the SceneOptimizer
  131350. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  131351. * @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)
  131352. */
  131353. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  131354. /**
  131355. * Stops the current optimizer
  131356. */
  131357. stop(): void;
  131358. /**
  131359. * Reset the optimizer to initial step (current priority level = 0)
  131360. */
  131361. reset(): void;
  131362. /**
  131363. * Start the optimizer. By default it will try to reach a specific framerate
  131364. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  131365. */
  131366. start(): void;
  131367. private _checkCurrentState;
  131368. /**
  131369. * Release all resources
  131370. */
  131371. dispose(): void;
  131372. /**
  131373. * Helper function to create a SceneOptimizer with one single line of code
  131374. * @param scene defines the scene to work on
  131375. * @param options defines the options to use with the SceneOptimizer
  131376. * @param onSuccess defines a callback to call on success
  131377. * @param onFailure defines a callback to call on failure
  131378. * @returns the new SceneOptimizer object
  131379. */
  131380. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  131381. }
  131382. }
  131383. declare module BABYLON {
  131384. /**
  131385. * Class used to serialize a scene into a string
  131386. */
  131387. export class SceneSerializer {
  131388. /**
  131389. * Clear cache used by a previous serialization
  131390. */
  131391. static ClearCache(): void;
  131392. /**
  131393. * Serialize a scene into a JSON compatible object
  131394. * @param scene defines the scene to serialize
  131395. * @returns a JSON compatible object
  131396. */
  131397. static Serialize(scene: Scene): any;
  131398. /**
  131399. * Serialize a mesh into a JSON compatible object
  131400. * @param toSerialize defines the mesh to serialize
  131401. * @param withParents defines if parents must be serialized as well
  131402. * @param withChildren defines if children must be serialized as well
  131403. * @returns a JSON compatible object
  131404. */
  131405. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  131406. }
  131407. }
  131408. declare module BABYLON {
  131409. /**
  131410. * Class used to host texture specific utilities
  131411. */
  131412. export class TextureTools {
  131413. /**
  131414. * Uses the GPU to create a copy texture rescaled at a given size
  131415. * @param texture Texture to copy from
  131416. * @param width defines the desired width
  131417. * @param height defines the desired height
  131418. * @param useBilinearMode defines if bilinear mode has to be used
  131419. * @return the generated texture
  131420. */
  131421. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  131422. }
  131423. }
  131424. declare module BABYLON {
  131425. /**
  131426. * This represents the different options available for the video capture.
  131427. */
  131428. export interface VideoRecorderOptions {
  131429. /** Defines the mime type of the video. */
  131430. mimeType: string;
  131431. /** Defines the FPS the video should be recorded at. */
  131432. fps: number;
  131433. /** Defines the chunk size for the recording data. */
  131434. recordChunckSize: number;
  131435. /** The audio tracks to attach to the recording. */
  131436. audioTracks?: MediaStreamTrack[];
  131437. }
  131438. /**
  131439. * This can help with recording videos from BabylonJS.
  131440. * This is based on the available WebRTC functionalities of the browser.
  131441. *
  131442. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  131443. */
  131444. export class VideoRecorder {
  131445. private static readonly _defaultOptions;
  131446. /**
  131447. * Returns whether or not the VideoRecorder is available in your browser.
  131448. * @param engine Defines the Babylon Engine.
  131449. * @returns true if supported otherwise false.
  131450. */
  131451. static IsSupported(engine: Engine): boolean;
  131452. private readonly _options;
  131453. private _canvas;
  131454. private _mediaRecorder;
  131455. private _recordedChunks;
  131456. private _fileName;
  131457. private _resolve;
  131458. private _reject;
  131459. /**
  131460. * True when a recording is already in progress.
  131461. */
  131462. readonly isRecording: boolean;
  131463. /**
  131464. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  131465. * @param engine Defines the BabylonJS Engine you wish to record.
  131466. * @param options Defines options that can be used to customize the capture.
  131467. */
  131468. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  131469. /**
  131470. * Stops the current recording before the default capture timeout passed in the startRecording function.
  131471. */
  131472. stopRecording(): void;
  131473. /**
  131474. * Starts recording the canvas for a max duration specified in parameters.
  131475. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  131476. * If null no automatic download will start and you can rely on the promise to get the data back.
  131477. * @param maxDuration Defines the maximum recording time in seconds.
  131478. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  131479. * @return A promise callback at the end of the recording with the video data in Blob.
  131480. */
  131481. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  131482. /**
  131483. * Releases internal resources used during the recording.
  131484. */
  131485. dispose(): void;
  131486. private _handleDataAvailable;
  131487. private _handleError;
  131488. private _handleStop;
  131489. }
  131490. }
  131491. declare module BABYLON {
  131492. /**
  131493. * Class containing a set of static utilities functions for screenshots
  131494. */
  131495. export class ScreenshotTools {
  131496. /**
  131497. * Captures a screenshot of the current rendering
  131498. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131499. * @param engine defines the rendering engine
  131500. * @param camera defines the source camera
  131501. * @param size This parameter can be set to a single number or to an object with the
  131502. * following (optional) properties: precision, width, height. If a single number is passed,
  131503. * it will be used for both width and height. If an object is passed, the screenshot size
  131504. * will be derived from the parameters. The precision property is a multiplier allowing
  131505. * rendering at a higher or lower resolution
  131506. * @param successCallback defines the callback receives a single parameter which contains the
  131507. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131508. * src parameter of an <img> to display it
  131509. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131510. * Check your browser for supported MIME types
  131511. */
  131512. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  131513. /**
  131514. * Captures a screenshot of the current rendering
  131515. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131516. * @param engine defines the rendering engine
  131517. * @param camera defines the source camera
  131518. * @param size This parameter can be set to a single number or to an object with the
  131519. * following (optional) properties: precision, width, height. If a single number is passed,
  131520. * it will be used for both width and height. If an object is passed, the screenshot size
  131521. * will be derived from the parameters. The precision property is a multiplier allowing
  131522. * rendering at a higher or lower resolution
  131523. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  131524. * Check your browser for supported MIME types
  131525. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131526. * to the src parameter of an <img> to display it
  131527. */
  131528. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  131529. /**
  131530. * Generates an image screenshot from the specified camera.
  131531. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131532. * @param engine The engine to use for rendering
  131533. * @param camera The camera to use for rendering
  131534. * @param size This parameter can be set to a single number or to an object with the
  131535. * following (optional) properties: precision, width, height. If a single number is passed,
  131536. * it will be used for both width and height. If an object is passed, the screenshot size
  131537. * will be derived from the parameters. The precision property is a multiplier allowing
  131538. * rendering at a higher or lower resolution
  131539. * @param successCallback The callback receives a single parameter which contains the
  131540. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  131541. * src parameter of an <img> to display it
  131542. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131543. * Check your browser for supported MIME types
  131544. * @param samples Texture samples (default: 1)
  131545. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131546. * @param fileName A name for for the downloaded file.
  131547. */
  131548. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  131549. /**
  131550. * Generates an image screenshot from the specified camera.
  131551. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  131552. * @param engine The engine to use for rendering
  131553. * @param camera The camera to use for rendering
  131554. * @param size This parameter can be set to a single number or to an object with the
  131555. * following (optional) properties: precision, width, height. If a single number is passed,
  131556. * it will be used for both width and height. If an object is passed, the screenshot size
  131557. * will be derived from the parameters. The precision property is a multiplier allowing
  131558. * rendering at a higher or lower resolution
  131559. * @param mimeType The MIME type of the screenshot image (default: image/png).
  131560. * Check your browser for supported MIME types
  131561. * @param samples Texture samples (default: 1)
  131562. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  131563. * @param fileName A name for for the downloaded file.
  131564. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  131565. * to the src parameter of an <img> to display it
  131566. */
  131567. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  131568. /**
  131569. * Gets height and width for screenshot size
  131570. * @private
  131571. */
  131572. private static _getScreenshotSize;
  131573. }
  131574. }
  131575. declare module BABYLON {
  131576. /**
  131577. * Interface for a data buffer
  131578. */
  131579. export interface IDataBuffer {
  131580. /**
  131581. * Reads bytes from the data buffer.
  131582. * @param byteOffset The byte offset to read
  131583. * @param byteLength The byte length to read
  131584. * @returns A promise that resolves when the bytes are read
  131585. */
  131586. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  131587. /**
  131588. * The byte length of the buffer.
  131589. */
  131590. readonly byteLength: number;
  131591. }
  131592. /**
  131593. * Utility class for reading from a data buffer
  131594. */
  131595. export class DataReader {
  131596. /**
  131597. * The data buffer associated with this data reader.
  131598. */
  131599. readonly buffer: IDataBuffer;
  131600. /**
  131601. * The current byte offset from the beginning of the data buffer.
  131602. */
  131603. byteOffset: number;
  131604. private _dataView;
  131605. private _dataByteOffset;
  131606. /**
  131607. * Constructor
  131608. * @param buffer The buffer to read
  131609. */
  131610. constructor(buffer: IDataBuffer);
  131611. /**
  131612. * Loads the given byte length.
  131613. * @param byteLength The byte length to load
  131614. * @returns A promise that resolves when the load is complete
  131615. */
  131616. loadAsync(byteLength: number): Promise<void>;
  131617. /**
  131618. * Read a unsigned 32-bit integer from the currently loaded data range.
  131619. * @returns The 32-bit integer read
  131620. */
  131621. readUint32(): number;
  131622. /**
  131623. * Read a byte array from the currently loaded data range.
  131624. * @param byteLength The byte length to read
  131625. * @returns The byte array read
  131626. */
  131627. readUint8Array(byteLength: number): Uint8Array;
  131628. /**
  131629. * Read a string from the currently loaded data range.
  131630. * @param byteLength The byte length to read
  131631. * @returns The string read
  131632. */
  131633. readString(byteLength: number): string;
  131634. /**
  131635. * Skips the given byte length the currently loaded data range.
  131636. * @param byteLength The byte length to skip
  131637. */
  131638. skipBytes(byteLength: number): void;
  131639. }
  131640. }
  131641. declare module BABYLON {
  131642. /**
  131643. * A cursor which tracks a point on a path
  131644. */
  131645. export class PathCursor {
  131646. private path;
  131647. /**
  131648. * Stores path cursor callbacks for when an onchange event is triggered
  131649. */
  131650. private _onchange;
  131651. /**
  131652. * The value of the path cursor
  131653. */
  131654. value: number;
  131655. /**
  131656. * The animation array of the path cursor
  131657. */
  131658. animations: Animation[];
  131659. /**
  131660. * Initializes the path cursor
  131661. * @param path The path to track
  131662. */
  131663. constructor(path: Path2);
  131664. /**
  131665. * Gets the cursor point on the path
  131666. * @returns A point on the path cursor at the cursor location
  131667. */
  131668. getPoint(): Vector3;
  131669. /**
  131670. * Moves the cursor ahead by the step amount
  131671. * @param step The amount to move the cursor forward
  131672. * @returns This path cursor
  131673. */
  131674. moveAhead(step?: number): PathCursor;
  131675. /**
  131676. * Moves the cursor behind by the step amount
  131677. * @param step The amount to move the cursor back
  131678. * @returns This path cursor
  131679. */
  131680. moveBack(step?: number): PathCursor;
  131681. /**
  131682. * Moves the cursor by the step amount
  131683. * If the step amount is greater than one, an exception is thrown
  131684. * @param step The amount to move the cursor
  131685. * @returns This path cursor
  131686. */
  131687. move(step: number): PathCursor;
  131688. /**
  131689. * Ensures that the value is limited between zero and one
  131690. * @returns This path cursor
  131691. */
  131692. private ensureLimits;
  131693. /**
  131694. * Runs onchange callbacks on change (used by the animation engine)
  131695. * @returns This path cursor
  131696. */
  131697. private raiseOnChange;
  131698. /**
  131699. * Executes a function on change
  131700. * @param f A path cursor onchange callback
  131701. * @returns This path cursor
  131702. */
  131703. onchange(f: (cursor: PathCursor) => void): PathCursor;
  131704. }
  131705. }
  131706. declare module BABYLON {
  131707. /** @hidden */
  131708. export var blurPixelShader: {
  131709. name: string;
  131710. shader: string;
  131711. };
  131712. }
  131713. declare module BABYLON {
  131714. /** @hidden */
  131715. export var pointCloudVertexDeclaration: {
  131716. name: string;
  131717. shader: string;
  131718. };
  131719. }
  131720. // Mixins
  131721. interface Window {
  131722. mozIndexedDB: IDBFactory;
  131723. webkitIndexedDB: IDBFactory;
  131724. msIndexedDB: IDBFactory;
  131725. webkitURL: typeof URL;
  131726. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  131727. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  131728. WebGLRenderingContext: WebGLRenderingContext;
  131729. MSGesture: MSGesture;
  131730. CANNON: any;
  131731. AudioContext: AudioContext;
  131732. webkitAudioContext: AudioContext;
  131733. PointerEvent: any;
  131734. Math: Math;
  131735. Uint8Array: Uint8ArrayConstructor;
  131736. Float32Array: Float32ArrayConstructor;
  131737. mozURL: typeof URL;
  131738. msURL: typeof URL;
  131739. VRFrameData: any; // WebVR, from specs 1.1
  131740. DracoDecoderModule: any;
  131741. setImmediate(handler: (...args: any[]) => void): number;
  131742. }
  131743. interface HTMLCanvasElement {
  131744. requestPointerLock(): void;
  131745. msRequestPointerLock?(): void;
  131746. mozRequestPointerLock?(): void;
  131747. webkitRequestPointerLock?(): void;
  131748. /** Track wether a record is in progress */
  131749. isRecording: boolean;
  131750. /** Capture Stream method defined by some browsers */
  131751. captureStream(fps?: number): MediaStream;
  131752. }
  131753. interface CanvasRenderingContext2D {
  131754. msImageSmoothingEnabled: boolean;
  131755. }
  131756. interface MouseEvent {
  131757. mozMovementX: number;
  131758. mozMovementY: number;
  131759. webkitMovementX: number;
  131760. webkitMovementY: number;
  131761. msMovementX: number;
  131762. msMovementY: number;
  131763. }
  131764. interface Navigator {
  131765. mozGetVRDevices: (any: any) => any;
  131766. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131767. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131768. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  131769. webkitGetGamepads(): Gamepad[];
  131770. msGetGamepads(): Gamepad[];
  131771. webkitGamepads(): Gamepad[];
  131772. }
  131773. interface HTMLVideoElement {
  131774. mozSrcObject: any;
  131775. }
  131776. interface Math {
  131777. fround(x: number): number;
  131778. imul(a: number, b: number): number;
  131779. }
  131780. interface WebGLRenderingContext {
  131781. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  131782. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  131783. vertexAttribDivisor(index: number, divisor: number): void;
  131784. createVertexArray(): any;
  131785. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  131786. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  131787. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  131788. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  131789. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  131790. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  131791. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  131792. // Queries
  131793. createQuery(): WebGLQuery;
  131794. deleteQuery(query: WebGLQuery): void;
  131795. beginQuery(target: number, query: WebGLQuery): void;
  131796. endQuery(target: number): void;
  131797. getQueryParameter(query: WebGLQuery, pname: number): any;
  131798. getQuery(target: number, pname: number): any;
  131799. MAX_SAMPLES: number;
  131800. RGBA8: number;
  131801. READ_FRAMEBUFFER: number;
  131802. DRAW_FRAMEBUFFER: number;
  131803. UNIFORM_BUFFER: number;
  131804. HALF_FLOAT_OES: number;
  131805. RGBA16F: number;
  131806. RGBA32F: number;
  131807. R32F: number;
  131808. RG32F: number;
  131809. RGB32F: number;
  131810. R16F: number;
  131811. RG16F: number;
  131812. RGB16F: number;
  131813. RED: number;
  131814. RG: number;
  131815. R8: number;
  131816. RG8: number;
  131817. UNSIGNED_INT_24_8: number;
  131818. DEPTH24_STENCIL8: number;
  131819. MIN: number;
  131820. MAX: number;
  131821. /* Multiple Render Targets */
  131822. drawBuffers(buffers: number[]): void;
  131823. readBuffer(src: number): void;
  131824. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  131825. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  131826. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  131827. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  131828. // Occlusion Query
  131829. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  131830. ANY_SAMPLES_PASSED: number;
  131831. QUERY_RESULT_AVAILABLE: number;
  131832. QUERY_RESULT: number;
  131833. }
  131834. interface WebGLProgram {
  131835. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  131836. }
  131837. interface EXT_disjoint_timer_query {
  131838. QUERY_COUNTER_BITS_EXT: number;
  131839. TIME_ELAPSED_EXT: number;
  131840. TIMESTAMP_EXT: number;
  131841. GPU_DISJOINT_EXT: number;
  131842. QUERY_RESULT_EXT: number;
  131843. QUERY_RESULT_AVAILABLE_EXT: number;
  131844. queryCounterEXT(query: WebGLQuery, target: number): void;
  131845. createQueryEXT(): WebGLQuery;
  131846. beginQueryEXT(target: number, query: WebGLQuery): void;
  131847. endQueryEXT(target: number): void;
  131848. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  131849. deleteQueryEXT(query: WebGLQuery): void;
  131850. }
  131851. interface WebGLUniformLocation {
  131852. _currentState: any;
  131853. }
  131854. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  131855. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  131856. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  131857. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131858. interface WebGLRenderingContext {
  131859. readonly RASTERIZER_DISCARD: number;
  131860. readonly DEPTH_COMPONENT24: number;
  131861. readonly TEXTURE_3D: number;
  131862. readonly TEXTURE_2D_ARRAY: number;
  131863. readonly TEXTURE_COMPARE_FUNC: number;
  131864. readonly TEXTURE_COMPARE_MODE: number;
  131865. readonly COMPARE_REF_TO_TEXTURE: number;
  131866. readonly TEXTURE_WRAP_R: number;
  131867. readonly HALF_FLOAT: number;
  131868. readonly RGB8: number;
  131869. readonly RED_INTEGER: number;
  131870. readonly RG_INTEGER: number;
  131871. readonly RGB_INTEGER: number;
  131872. readonly RGBA_INTEGER: number;
  131873. readonly R8_SNORM: number;
  131874. readonly RG8_SNORM: number;
  131875. readonly RGB8_SNORM: number;
  131876. readonly RGBA8_SNORM: number;
  131877. readonly R8I: number;
  131878. readonly RG8I: number;
  131879. readonly RGB8I: number;
  131880. readonly RGBA8I: number;
  131881. readonly R8UI: number;
  131882. readonly RG8UI: number;
  131883. readonly RGB8UI: number;
  131884. readonly RGBA8UI: number;
  131885. readonly R16I: number;
  131886. readonly RG16I: number;
  131887. readonly RGB16I: number;
  131888. readonly RGBA16I: number;
  131889. readonly R16UI: number;
  131890. readonly RG16UI: number;
  131891. readonly RGB16UI: number;
  131892. readonly RGBA16UI: number;
  131893. readonly R32I: number;
  131894. readonly RG32I: number;
  131895. readonly RGB32I: number;
  131896. readonly RGBA32I: number;
  131897. readonly R32UI: number;
  131898. readonly RG32UI: number;
  131899. readonly RGB32UI: number;
  131900. readonly RGBA32UI: number;
  131901. readonly RGB10_A2UI: number;
  131902. readonly R11F_G11F_B10F: number;
  131903. readonly RGB9_E5: number;
  131904. readonly RGB10_A2: number;
  131905. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  131906. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  131907. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  131908. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  131909. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  131910. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  131911. 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;
  131912. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  131913. readonly TRANSFORM_FEEDBACK: number;
  131914. readonly INTERLEAVED_ATTRIBS: number;
  131915. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  131916. createTransformFeedback(): WebGLTransformFeedback;
  131917. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  131918. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  131919. beginTransformFeedback(primitiveMode: number): void;
  131920. endTransformFeedback(): void;
  131921. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  131922. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131923. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131924. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  131925. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  131926. }
  131927. interface ImageBitmap {
  131928. readonly width: number;
  131929. readonly height: number;
  131930. close(): void;
  131931. }
  131932. interface WebGLQuery extends WebGLObject {
  131933. }
  131934. declare var WebGLQuery: {
  131935. prototype: WebGLQuery;
  131936. new(): WebGLQuery;
  131937. };
  131938. interface WebGLSampler extends WebGLObject {
  131939. }
  131940. declare var WebGLSampler: {
  131941. prototype: WebGLSampler;
  131942. new(): WebGLSampler;
  131943. };
  131944. interface WebGLSync extends WebGLObject {
  131945. }
  131946. declare var WebGLSync: {
  131947. prototype: WebGLSync;
  131948. new(): WebGLSync;
  131949. };
  131950. interface WebGLTransformFeedback extends WebGLObject {
  131951. }
  131952. declare var WebGLTransformFeedback: {
  131953. prototype: WebGLTransformFeedback;
  131954. new(): WebGLTransformFeedback;
  131955. };
  131956. interface WebGLVertexArrayObject extends WebGLObject {
  131957. }
  131958. declare var WebGLVertexArrayObject: {
  131959. prototype: WebGLVertexArrayObject;
  131960. new(): WebGLVertexArrayObject;
  131961. };
  131962. // Type definitions for WebVR API
  131963. // Project: https://w3c.github.io/webvr/
  131964. // Definitions by: six a <https://github.com/lostfictions>
  131965. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  131966. interface VRDisplay extends EventTarget {
  131967. /**
  131968. * Dictionary of capabilities describing the VRDisplay.
  131969. */
  131970. readonly capabilities: VRDisplayCapabilities;
  131971. /**
  131972. * z-depth defining the far plane of the eye view frustum
  131973. * enables mapping of values in the render target depth
  131974. * attachment to scene coordinates. Initially set to 10000.0.
  131975. */
  131976. depthFar: number;
  131977. /**
  131978. * z-depth defining the near plane of the eye view frustum
  131979. * enables mapping of values in the render target depth
  131980. * attachment to scene coordinates. Initially set to 0.01.
  131981. */
  131982. depthNear: number;
  131983. /**
  131984. * An identifier for this distinct VRDisplay. Used as an
  131985. * association point in the Gamepad API.
  131986. */
  131987. readonly displayId: number;
  131988. /**
  131989. * A display name, a user-readable name identifying it.
  131990. */
  131991. readonly displayName: string;
  131992. readonly isConnected: boolean;
  131993. readonly isPresenting: boolean;
  131994. /**
  131995. * If this VRDisplay supports room-scale experiences, the optional
  131996. * stage attribute contains details on the room-scale parameters.
  131997. */
  131998. readonly stageParameters: VRStageParameters | null;
  131999. /**
  132000. * Passing the value returned by `requestAnimationFrame` to
  132001. * `cancelAnimationFrame` will unregister the callback.
  132002. * @param handle Define the hanle of the request to cancel
  132003. */
  132004. cancelAnimationFrame(handle: number): void;
  132005. /**
  132006. * Stops presenting to the VRDisplay.
  132007. * @returns a promise to know when it stopped
  132008. */
  132009. exitPresent(): Promise<void>;
  132010. /**
  132011. * Return the current VREyeParameters for the given eye.
  132012. * @param whichEye Define the eye we want the parameter for
  132013. * @returns the eye parameters
  132014. */
  132015. getEyeParameters(whichEye: string): VREyeParameters;
  132016. /**
  132017. * Populates the passed VRFrameData with the information required to render
  132018. * the current frame.
  132019. * @param frameData Define the data structure to populate
  132020. * @returns true if ok otherwise false
  132021. */
  132022. getFrameData(frameData: VRFrameData): boolean;
  132023. /**
  132024. * Get the layers currently being presented.
  132025. * @returns the list of VR layers
  132026. */
  132027. getLayers(): VRLayer[];
  132028. /**
  132029. * Return a VRPose containing the future predicted pose of the VRDisplay
  132030. * when the current frame will be presented. The value returned will not
  132031. * change until JavaScript has returned control to the browser.
  132032. *
  132033. * The VRPose will contain the position, orientation, velocity,
  132034. * and acceleration of each of these properties.
  132035. * @returns the pose object
  132036. */
  132037. getPose(): VRPose;
  132038. /**
  132039. * Return the current instantaneous pose of the VRDisplay, with no
  132040. * prediction applied.
  132041. * @returns the current instantaneous pose
  132042. */
  132043. getImmediatePose(): VRPose;
  132044. /**
  132045. * The callback passed to `requestAnimationFrame` will be called
  132046. * any time a new frame should be rendered. When the VRDisplay is
  132047. * presenting the callback will be called at the native refresh
  132048. * rate of the HMD. When not presenting this function acts
  132049. * identically to how window.requestAnimationFrame acts. Content should
  132050. * make no assumptions of frame rate or vsync behavior as the HMD runs
  132051. * asynchronously from other displays and at differing refresh rates.
  132052. * @param callback Define the eaction to run next frame
  132053. * @returns the request handle it
  132054. */
  132055. requestAnimationFrame(callback: FrameRequestCallback): number;
  132056. /**
  132057. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  132058. * Repeat calls while already presenting will update the VRLayers being displayed.
  132059. * @param layers Define the list of layer to present
  132060. * @returns a promise to know when the request has been fulfilled
  132061. */
  132062. requestPresent(layers: VRLayer[]): Promise<void>;
  132063. /**
  132064. * Reset the pose for this display, treating its current position and
  132065. * orientation as the "origin/zero" values. VRPose.position,
  132066. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  132067. * updated when calling resetPose(). This should be called in only
  132068. * sitting-space experiences.
  132069. */
  132070. resetPose(): void;
  132071. /**
  132072. * The VRLayer provided to the VRDisplay will be captured and presented
  132073. * in the HMD. Calling this function has the same effect on the source
  132074. * canvas as any other operation that uses its source image, and canvases
  132075. * created without preserveDrawingBuffer set to true will be cleared.
  132076. * @param pose Define the pose to submit
  132077. */
  132078. submitFrame(pose?: VRPose): void;
  132079. }
  132080. declare var VRDisplay: {
  132081. prototype: VRDisplay;
  132082. new(): VRDisplay;
  132083. };
  132084. interface VRLayer {
  132085. leftBounds?: number[] | Float32Array | null;
  132086. rightBounds?: number[] | Float32Array | null;
  132087. source?: HTMLCanvasElement | null;
  132088. }
  132089. interface VRDisplayCapabilities {
  132090. readonly canPresent: boolean;
  132091. readonly hasExternalDisplay: boolean;
  132092. readonly hasOrientation: boolean;
  132093. readonly hasPosition: boolean;
  132094. readonly maxLayers: number;
  132095. }
  132096. interface VREyeParameters {
  132097. /** @deprecated */
  132098. readonly fieldOfView: VRFieldOfView;
  132099. readonly offset: Float32Array;
  132100. readonly renderHeight: number;
  132101. readonly renderWidth: number;
  132102. }
  132103. interface VRFieldOfView {
  132104. readonly downDegrees: number;
  132105. readonly leftDegrees: number;
  132106. readonly rightDegrees: number;
  132107. readonly upDegrees: number;
  132108. }
  132109. interface VRFrameData {
  132110. readonly leftProjectionMatrix: Float32Array;
  132111. readonly leftViewMatrix: Float32Array;
  132112. readonly pose: VRPose;
  132113. readonly rightProjectionMatrix: Float32Array;
  132114. readonly rightViewMatrix: Float32Array;
  132115. readonly timestamp: number;
  132116. }
  132117. interface VRPose {
  132118. readonly angularAcceleration: Float32Array | null;
  132119. readonly angularVelocity: Float32Array | null;
  132120. readonly linearAcceleration: Float32Array | null;
  132121. readonly linearVelocity: Float32Array | null;
  132122. readonly orientation: Float32Array | null;
  132123. readonly position: Float32Array | null;
  132124. readonly timestamp: number;
  132125. }
  132126. interface VRStageParameters {
  132127. sittingToStandingTransform?: Float32Array;
  132128. sizeX?: number;
  132129. sizeY?: number;
  132130. }
  132131. interface Navigator {
  132132. getVRDisplays(): Promise<VRDisplay[]>;
  132133. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  132134. }
  132135. interface Window {
  132136. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  132137. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  132138. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  132139. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132140. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  132141. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  132142. }
  132143. interface Gamepad {
  132144. readonly displayId: number;
  132145. }
  132146. type XRSessionMode =
  132147. | "inline"
  132148. | "immersive-vr"
  132149. | "immersive-ar";
  132150. type XRReferenceSpaceType =
  132151. | "viewer"
  132152. | "local"
  132153. | "local-floor"
  132154. | "bounded-floor"
  132155. | "unbounded";
  132156. type XREnvironmentBlendMode =
  132157. | "opaque"
  132158. | "additive"
  132159. | "alpha-blend";
  132160. type XRVisibilityState =
  132161. | "visible"
  132162. | "visible-blurred"
  132163. | "hidden";
  132164. type XRHandedness =
  132165. | "none"
  132166. | "left"
  132167. | "right";
  132168. type XRTargetRayMode =
  132169. | "gaze"
  132170. | "tracked-pointer"
  132171. | "screen";
  132172. type XREye =
  132173. | "none"
  132174. | "left"
  132175. | "right";
  132176. interface XRSpace extends EventTarget {
  132177. }
  132178. interface XRRenderState {
  132179. depthNear?: number;
  132180. depthFar?: number;
  132181. inlineVerticalFieldOfView?: number;
  132182. baseLayer?: XRWebGLLayer;
  132183. }
  132184. interface XRInputSource {
  132185. handedness: XRHandedness;
  132186. targetRayMode: XRTargetRayMode;
  132187. targetRaySpace: XRSpace;
  132188. gripSpace: XRSpace | undefined;
  132189. gamepad: Gamepad | undefined;
  132190. profiles: Array<string>;
  132191. }
  132192. interface XRSession {
  132193. addEventListener: Function;
  132194. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132195. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  132196. requestAnimationFrame: Function;
  132197. end(): Promise<void>;
  132198. renderState: XRRenderState;
  132199. inputSources: Array<XRInputSource>;
  132200. }
  132201. interface XRReferenceSpace extends XRSpace {
  132202. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  132203. onreset: any;
  132204. }
  132205. interface XRFrame {
  132206. session: XRSession;
  132207. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  132208. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  132209. }
  132210. interface XRViewerPose extends XRPose {
  132211. views: Array<XRView>;
  132212. }
  132213. interface XRPose {
  132214. transform: XRRigidTransform;
  132215. emulatedPosition: boolean;
  132216. }
  132217. declare var XRWebGLLayer: {
  132218. prototype: XRWebGLLayer;
  132219. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  132220. };
  132221. interface XRWebGLLayer {
  132222. framebuffer: WebGLFramebuffer;
  132223. framebufferWidth: number;
  132224. framebufferHeight: number;
  132225. getViewport: Function;
  132226. }
  132227. interface XRRigidTransform {
  132228. position: DOMPointReadOnly;
  132229. orientation: DOMPointReadOnly;
  132230. matrix: Float32Array;
  132231. inverse: XRRigidTransform;
  132232. }
  132233. interface XRView {
  132234. eye: XREye;
  132235. projectionMatrix: Float32Array;
  132236. transform: XRRigidTransform;
  132237. }
  132238. interface XRInputSourceChangeEvent {
  132239. session: XRSession;
  132240. removed: Array<XRInputSource>;
  132241. added: Array<XRInputSource>;
  132242. }